IterativeGeneralizedGaussian.fit

giant.point_spread_functions.gaussians:

classmethod IterativeGeneralizedGaussian.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[a(x-x_0)^2 + 2b (x-x_0)(y-y_0) + c (y-y_0)^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 data the gaussian surface is to be fit to

  • y (Sequence | ndarray) – The y values underlying the data the gaussian surface is to be fit to

  • z (Sequence | ndarray) – The z or “height” values for the gaussian surface

Returns:

The initialized PSF with values according to the fit

Return type:

IterativeGeneralizedGaussian