giant.point_spread_functions.psf_meta

Provides abstract base classes for the construction of Point Spread Function classes for GIANT.

In this module there are a number of abstract base classes (ABCs) that define the interface for and provide some common functionality for point spread functions (PSFs) in GIANT. In general, most users will not interact with these directly, and will instead use a predefined implementation of a PSF, however, if you wish to define a new PSF for GIANT to use then you will likely benefit from what is available in this module.

To define a new PSF you will most likely want to subclass at least one of the ABCs defined in this module, which will help you to be sure you’ve defined all the interfaces GIANT expects and possibly add some shared functionality so that you don’t need to reinvent the wheel. However, this is not strictly necessary. While type checkers will complain if you don’t at least inherit from PointSpreadFunction, GIANT will not actually error so long as you have defined all the appropriate interfaces (so called duck typing).

Use

To implement a fully function custom PSF for GIANT you must at minimum implement the following methods and attributes

Method/Attribute

Use

save_residuals

A class attribute which determines whether to save information about the residuals from attempting to fit the PSF to data. If True then you should save the residual statistics and formal fit covariance.

__call__()

The built in call method for the class. This method should apply the defined PSF in the current instance to a 2D image, returning the image after the PSF has been applied.

apply_1d()

An analogous method to __call__() but for applying the PSF to (a) 1D scan line(s) instead of a 2D image.

generate_kernel()

A method that generates a square unit kernel (sums to 1) of the current instance of the PSF.

evaluate()

A method that evaluates the current instance of the PSF at provided x and y locations

fit()

A class method which fits an instance of the PSF to supplied data and returns and initialized version of the PSF with the fit parameters.

centroid

A property which returns the location of the peak of the PSF as a as a length 2 numpy array.

residual_rss

A property which returns the root sum of squares of the rss of the fit of the PSF iff the current instance was made by a call to fit() and save_residuals is True. If either of these are not True then returns None.

residual_std

A property which returns the standard deviation of the rss of the fit of the PSF iff the current instance was made by a call to fit() and save_residuals is True. If either of these are not True then returns None.

covariance

A property which returns the formal covariance of the fit of the PSF iff the current instance was made by a call to fit() and save_residuals is True. If either of these are not True then returns None.

volume

A method which computes the total volume under the PSF (integral from \(-\inf\) to \(\inf\))

Implementing these, plus whatever else is needed internally for the functionality of the PSF, will result in a PSF class that can be used throughout GIANT.

For examples of how this is done, refer to the pre-defined PSFs in gaussians.

Classes

PointSpreadFunction

This abstract base class serves as the template for implementing a point spread function in GIANT.

SizedPSF

This ABC adds common functionality for a PSF where the required size can be determine algorithmically.

KernelBasedCallPSF

This ABC adds concrete common functionality for applying the initialized PSF to 2D images to PointSpreadFunction.

KernelBasedApply1DPSF

This ABC adds concrete common functionality for applying the initialized PSF to 1D scan lines to PointSpreadFunction.

IterativeNonlinearLSTSQPSF

This ABC defines common attributes, properties, and methods for Iterative Non-linear least squares estimation of a Point Spread function.

IterativeNonlinearLSTSQwBackground

This class provides support for estimating the superposition of the PSF and a linear background gradient.

InitialGuessIterativeNonlinearLSTSQPSF

This class provides a fit class method which generates the initial guess from a subclass and then converges to a better solution using iterative Nonlinear LSTSQ.

InitialGuessIterativeNonlinearLSTSQPSFwBackground

This class provides a fit class method which generates the initial guess from a subclass and then converges to a better solution using iterative Nonlinear LSTSQ including a background gradient.