IterativeGaussian¶
- class giant.point_spread_functions.gaussians.IterativeGaussian(sigma_x=1, sigma_y=0, size=None, amplitude=None, centroid_x=0, centroid_y=0, **kwargs)[source]¶
Bases:
Gaussian
,InitialGuessIterativeNonlinearLSTSQPSF
A class for representing and fitting a standard (non-rotated) 2D Gaussian point spread function using iterative non-linear least squares.
This class only differs from the
Gaussian
class in the way thefit()
class method works. In this version, the fit is performed using iterative non-linear least squares, which is typically more accurate than using the logarithmic transformation to do linear least squares at the expense of more computation time.For more details about the model this works with, see the
Gaussian
documentation.This class can be used anywhere GIANT expects a point spread function
- Parameters:
sigma_x (float) – The Gaussian RMS width in the x direction in pixels
sigma_y (Real | None) – The Gaussian RMS Width in the y direction in pixels. If set to 0 or
None
this is set to be the same assigma_x
size (int) – The size of the kernel to use when applying this PSF in pixels. If set to 0 or
None
will be computed based on the Gaussian RSM widths.amplitude (float) – The amplitude of the gaussian kernel to use when applying this PSF. If set to 0 or
None
this will be computed so that the kernel does not increase/decrease the total signal.centroid_x (float) – The x location of the peak of the Gaussian PSF in pixels. This is not used when applying the PSF, but it is used when fitting the PSF. Typically this is not specified by the user.
centroid_y (float) – The y location of the peak of the Gaussian PSF in pixels. This is not used when applying the PSF, but it is used when fitting the PSF. Typically this is not specified by the user.
- save_residuals = False¶
This class attribute specifies whether to save the residuals when fitting the specified PSF to data.
Saving the residuals can be important for in depth analysis but can use a lot of space when many fits are being performed and stored so this defaults to off. To store the residuals simply set this to
True
either before or after initialization.
- max_iter = 20¶
An integer defining the maximum number of iterations to attempt in the iterative least squares solution.
- atol = 1e-10¶
The absolute tolerance cut-off for the iterative least squares. (The iteration will cease when the new estimate is within this tolerance for every element from the previous estimate)
- rtol = 1e-10¶
The relative tolerance cut-off for the iterative least squares. (The iteration will cease when the maximum percent change in the state vector from one iteration to the next is less than this value)
- sigma_x: float¶
The Gaussian RMS width in the x direction in pixels.
- sigma_y¶
The Gaussian RMS width in the y direction in pixels.
- amplitude: float¶
The amplitude of the Gaussian.
This specifies how much energy the Gaussian function increases or decreases the signal by.
Typically this is set so that the kernel does not increase or decrease the signal, which can be achieved by using the
normalize_amplitude()
method.
- centroid_x: float¶
The x location of the peak of the Gaussian kernel
When applying the gaussian kernel, the centroid doesn’t matter as it will always be applied as if it was centered on a pixel. In general this is just used when estimating a kernel to locate the peak of the PSF in the image.
- centroid_y: float¶
The y location of the peak of the Gaussian kernel
When applying the gaussian kernel, the centroid doesn’t matter as it will always be applied as if it was centered on a pixel. In general this is just used when estimating a kernel to locate the peak of the PSF in the image.
- property residuals: ndarray¶
A 1D array containing residuals of the fit of this Gaussian Model to data.
These are only populated when initialized by
fit()
and when the class attributesave_residuals
is set to true.
- property covariance: ndarray | None¶
The formal covariance of the PSF parameters after fitting this PSF model to data.
If this instance is not the result of a fit (
fit()
) of ifsave_residuals
isFalse
then this will return None.The order of the state vector (and thus the covariance matrix) is \([x_0, y_0, \sigma_x, \sigma_y, A]\).
- size: int¶
The size of the kernel to return on a call to
generate_kernel()
.Typically this should be an odd number to ensure that the kernel is square and centered.
- property residual_mean: float | None¶
The mean of the post-fit residuals after fitting this PSF model to data.
If this instance is not the result of a fit (
fit()
) or ifsave_residuals
isFalse
then this will return None
- property residual_std: float | None¶
The standard deviation of the post-fit residuals after fitting this PSF model to data.
If this instance is not the result of a fit (
fit()
) or ifsave_residuals
isFalse
then this will return None
- property residual_rss: float | None¶
The sum of squares of the post-fit residuals after fitting this PSF model to data.
If this instance is not the result of a fit (
fit()
) or ifsave_residuals
isFalse
then this will return None
Summary of Methods
This fits a 2d gaussian function to a surface using iterative non-linear least squares estimation. |
|
Applies the represented Gaussian PSF to a 2D array. |
|
Applies the defined PSF using the stored parameters to the 1D image scans provided. |
|
Applies the defined PSF using the stored parameters to the 1D image scans provided with a given kernel size. |
|
This method computes the Jacobian of the PSF with respect to a change in the state. |
|
Performs iterative non-linear least squares on a PSF model until convergence has been reached for a function of the form \(z=f(x, y)\) |
|
This fits a PSF to a surface using iterative non-linear least squares estimation. |
|
Sets the size for the kernel based on the width of the PSF. |
|
This method evaluates the PSF at the given x and y. |
|
Generates a square kernel centered at the centroid of the PSF normalized to have a volume (sum) of 1 for the size input or specified in the |
|
Calculate and store the amplitude that makes the volume under the gaussian surface equal to 1 |
|
Updates the current values based on the provided update vector. |