IterativeGaussian.fit

giant.point_spread_functions.gaussians:

classmethod IterativeGaussian.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)}\]

The estimation in this function is performed iteratively. First, a transformed fit is performed using the Gaussian.fit() method. This initial fit is then refined using iterative non-linear least squares to remove biases that can be introduced in the transformed 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:

IterativeGaussian