import lmfitimport numpy as npdef gaussian2d(x, y, amplitude=1., centerx=0., centery=0., sigmax=1., sigmay=1., rotation=0, A0=0.):"""Return a two dimensional lorentzian. The maximum of the peak occurs at ``centerx`` and ``centery`` with widths ``sigmax`` and ``sigmay`` in the x and y directions respectively. The peak can be rotated by choosing the value of ``rotation`` in radians. """ xp = (x - centerx)*np.cos(rotation) - (y - centery)*np.sin(rotation) yp = (x - centerx)*np.sin(rotation) + (y - centery)*np.cos(rotation) R = (xp/sigmax)**2+ (yp/sigmay)**2return A0 + amplitude * np.exp(-R/2)model = lmfit.Model(gaussian2d, independent_vars=['x', 'y'])# params = model.make_params(amplitude=10, centerx=x[np.argmax(z)], centery=y[np.argmax(z)])
%%R# Fit a linear model to the log-transformed datalm_fit <- lm(j0_norm_log ~ L_mn_norm_log, data = all_events_l1)# Extract the coefficientsintercept <- coef(lm_fit)[1]slope <- coef(lm_fit)[2]# Create a scatter plot with the log-log transformationp <- ggplot(all_events_l1, aes(x = L_mn_norm_log, y = j0_norm_log)) + geom_point() +# Add the scatter points geom_abline(intercept = intercept, slope = slope, color ='blue', size =1) +# Add the fitted line facet_wrap(~ sat, scales ="free") +# Facet by 'sat' labs(x ="Log10(L_mn_norm)", y ="Log10(j0_norm)") # Label axesprint(p)