IterativeGaussianWBackground.fit¶
giant.point_spread_functions.gaussians
:
- classmethod IterativeGaussianWBackground.fit(x, y, z)[source]¶
This fits a 2d gaussian function to a surface using iterative non-linear least squares estimation.
The fit assumes that z = f(x, y) where f is the gaussian function (and thus z is the “height” of the gaussian function).
The fit performed is for a 2D gaussian function of the form
\[z = f(x, y) = A e^{\left(-\left[\frac{(x-x_0)^2}{2\sigma_x^2}+\frac{(y-y_0)^2}{2\sigma_y^2}\right]\right)} +Bx+Cy+D\]The estimation in this function is performed iteratively. First, the rough background is estimated and removed. Then, a transformed fit is performed using the super class’s fit method on the data with the rough background removed. This initial fit is then refined using iterative non-linear least squares on the original data to remove biases that might have been introduced in the non-iterative fit.
If the fit is unsuccessful due to a rank deficient matrix or a fit of a hyperbolic surface the resulting data will be set to np.nan.
- Parameters:
x (Sequence | ndarray) – The x values underlying the surface the PSF is to be fit to
y (Sequence | ndarray) – The y values underlying the surface the PSF is to be fit to
z (Sequence | ndarray) – The z or “height” values of the surface the PSF is to be fit to
- Returns:
The initialized PSF with values according to the fit
- Return type: