regularizepsf.psf#
Representations of point spread functions.
Classes#
Model for a simple PSF. |
|
Model for a PSF that varies over the field of view. |
|
A PSF represented as a set of arrays. |
Functions#
|
Decorate a SimpleFunctionalPSF. |
|
|
|
Decorate to create a VariedFunctionalPSF. |
Module Contents#
- class regularizepsf.psf.SimpleFunctionalPSF(function: collections.abc.Callable)[source]#
Model for a simple PSF.
Create a PSF object.
- Parameters:
function –
- Python function representing the PSF,
first two parameters must be x and y and must return an numpy array
- _f: collections.abc.Callable#
- _signature: inspect.Signature#
- _parameters: set[str]#
- __call__(row: numbers.Real | numpy.ndarray, col: numbers.Real | numpy.ndarray, **kwargs: dict[str, Any]) numbers.Real | numpy.ndarray[source]#
Get the PSF value at (row, col).
- property parameters: set[str]#
Get the parameters of this PSF.
- as_array_psf(coordinates: list[tuple[int, int]], size: int, **kwargs) ArrayPSF[source]#
Convert FunctionalPSF to an ArrayPSF.
- property f: collections.abc.Callable#
Retrieve the PSF functional form for calling.
- regularizepsf.psf.simple_functional_psf(arg: Any = None) SimpleFunctionalPSF[source]#
Decorate a SimpleFunctionalPSF.
- class regularizepsf.psf.VariedFunctionalPSF(vary_function: collections.abc.Callable, base_psf: SimpleFunctionalPSF, validate_at_call: bool = True)[source]#
Model for a PSF that varies over the field of view.
Create a VariedFunctionalPSF object.
- Parameters:
vary_function (Callable) – function used to vary the parameters of the base_psf
base_psf (Callable) – base form of the PSF
validate_at_call (bool) – whether to check if parameters are valid at each call, turning off may be faster but is risky
- _vary_function#
- _base_psf#
- validate_at_call = True#
- parameterization_signature#
- _origin_parameters: set[str]#
- __call__(row: numbers.Real | numpy.ndarray, col: numbers.Real | numpy.ndarray) numbers.Real | numpy.ndarray[source]#
Get the PSF value at (row, col).
- property parameters: set[str]#
Get the parameters of this PSF.
- simplify(row: int, col: int) SimpleFunctionalPSF[source]#
Simplify this VariedFunctionalPSF to a SimpleFunctionalPSF by evaluating at (row, col).
- regularizepsf.psf._varied_functional_psf(base_psf: SimpleFunctionalPSF) VariedFunctionalPSF[source]#
- regularizepsf.psf.varied_functional_psf(base_psf: SimpleFunctionalPSF = None) VariedFunctionalPSF[source]#
Decorate to create a VariedFunctionalPSF.
- class regularizepsf.psf.ArrayPSF(values_cube: regularizepsf.util.IndexedCube, fft_cube: regularizepsf.util.IndexedCube | None = None, workers: int | None = None)[source]#
A PSF represented as a set of arrays.
Initialize an ArrayPSF model.
- Parameters:
values_cube (IndexedCube) – PSF model where keys are upper left coordinates of array patches in the image
fft_cube (IndexedCube) – fft of the model
workers (int | None) – Maximum number of workers to use for parallel computation of FFT. If negative, the value wraps around from os.cpu_count(). See scipy.fft.fft for more details. Only used if fft_cube is None.
- _values_cube#
- _fft_cube = None#
- _workers = None#
- property coordinates: list[tuple[int, int]]#
Get the keys of the PSF model, i.e., where it is evaluated as an array.
- property values: numpy.ndarray#
Get the model values.
- property fft_evaluations: numpy.ndarray#
Get the model values.
- __getitem__(coord: tuple[int, int]) numpy.ndarray[source]#
Evaluate the PSF model at specific coordinates.
- save(path: pathlib.Path) None[source]#
Save the PSF model to a file. Supports h5 and FITS.
- Parameters:
path (pathlib.Path) – where to save the PSF model
- Return type:
None
- classmethod load(path: pathlib.Path) ArrayPSF[source]#
Load the PSF model from a file. Supports h5 and FITS.
- Parameters:
path (pathlib.Path) – where to load the PSF model from
- Returns:
loaded model
- Return type:
- visualize_psfs(fig: matplotlib.figure.Figure | None = None, fig_scale: int = 1, edge_trim: int = 1, patch_stride: int = 1, imshow_args: dict | None = None) None[source]#
Visualize the PSFs.
- Parameters:
fig (mp.figure.Figure) – the figure to plot in
fig_scale (int) – increasing this will make the figure higher resolution
edge_trim (int) – how many pixels to drop on each side of the PSF for plotting
patch_stride (int) – multiple of how many patches to skip when plotting, 1 means no skipping, 2 plots every other, 3 every third
imshow_args (dict) – additional arguments for imshow
- Return type:
None
- visualize_ffts(fig: matplotlib.figure.Figure | None = None, fig_scale: int = 1, edge_trim: int = 1, patch_stride: int = 1, imshow_args: dict | None = None) None[source]#
Visualize the FFT kernels.
- Parameters:
fig (mp.figure.Figure) – the figure to plot in
fig_scale (int) – increasing this will make the figure higher resolution
edge_trim (int) – how many pixels to drop on each side of the PSF for plotting
patch_stride (int) – multiple of how many patches to skip when plotting, 1 means no skipping, 2 plots every other, 3 every third
imshow_args (dict) – additional arguments for imshow
- Return type:
None
- property sample_shape: tuple[int, int]#
Get the sample shape for this PSF model.