regularizepsf.transform#

Tools to transform from one PSF to another.

Classes#

ArrayPSFTransform

Representation of a transformation from a source to a target PSF that can be applied to images.

Module Contents#

class regularizepsf.transform.ArrayPSFTransform(transfer_kernel: regularizepsf.util.IndexedCube)#

Representation of a transformation from a source to a target PSF that can be applied to images.

Initialize a PSFTransform.

Parameters:

transfer_kernel (TransferKernel) – the transfer kernel required by this ArrayPSFTransform

_transfer_kernel#
property psf_shape: tuple[int, int]#

Retrieve the shape of the individual PSFs for this transform.

property coordinates: list[tuple[int, int]]#

Retrieve the coordinates of the individual PSFs for this transform.

__len__() int#

Retrieve the number of coordinates used to represent this transform.

classmethod construct(source: regularizepsf.psf.ArrayPSF, target: regularizepsf.psf.ArrayPSF, alpha: float, epsilon: float) ArrayPSFTransform#

Construct an ArrayPSFTransform from a source to a target PSF.

Parameters:
  • source (ArrayPSF) – source point spread function

  • target (ArrayPSF) – target point spread function

  • alpha (float) – controls the “hardness” of the transition from amplification to attenuation

  • epsilon (float) – controls the maximum of the amplification

Returns:

corresponding ArrayPSFTransform instance

Return type:

ArrayPSFTransform

apply(image: numpy.ndarray, workers: int | None = None, pad_mode: str = 'symmetric') numpy.ndarray#

Apply the PSFTransform to an image.

Parameters:
  • image (np.ndarray) – image to apply the transform to

  • 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.

  • pad_mode (str) – how to pad the image when computing ffts, see np.pad for more details.

Returns:

image with psf transformed

Return type:

np.ndarray

visualize(fig: matplotlib.figure.Figure | None = None, fig_scale: int = 1, all_patches: bool = False, imshow_args: dict | None = None) None#

Visualize the transfer kernels.

save(path: pathlib.Path) None#

Save a PSFTransform to a file. Supports h5 and FITS.

Parameters:

path (pathlib.Path) – where to save the PSFTransform

Return type:

None

classmethod load(path: pathlib.Path) ArrayPSFTransform#

Load a PSFTransform object. Supports h5 and FITS.

Parameters:

path (pathlib.Path) – file to load the PSFTransform from

Return type:

PSFTransform

__eq__(other: ArrayPSFTransform) bool#

Test equality between two transforms.