regularizepsf.corrector#
Classes#
A version of the PSF corrector that stores the model as a set of functions. |
|
A PSF corrector that is evaluated as array patches. |
Functions#
|
Determines the grid of overlapping neighborhood patches. |
Module Contents#
- class regularizepsf.corrector.CorrectorABC#
- abstract save(path: str | pathlib.Path) None#
Save the model to a file.
- Parameters:
path (str or pathlib.Path) – where to save the model, suggested extension is “.psf”
- Return type:
None
- classmethod load(path: str | pathlib.Path) CorrectorABC#
- Abstractmethod:
Loads a model from the path.
- Parameters:
path (str or pathlib.Path) – where to load the model from, suggested extension is “.psf”
- abstract correct_image(image: numpy.ndarray, size: int, alpha: float = 0.5, epsilon: float = 0.05) numpy.ndarray#
PSF correct an image according to the model.
- Parameters:
image (2D float np.ndarray) – image to be corrected
size (int) – how big to make the patches when correcting an image, only used for FunctionalCorrector
alpha (float) – controls the “hardness” of the transition from amplification to attenuation, see notes
epsilon (float) – controls the maximum of the amplification, see notes
- Returns:
a image that has been PSF corrected
- Return type:
np.ndarray
- abstract simulate_observation(image: numpy.ndarray) numpy.ndarray#
Simulates on a star field what an observation using this PSF looks like.
- Parameters:
image (2D float np.ndarray) – image of point source stars to simluate PSF for
- Returns:
an image with the PSF applied
- Return type:
np.ndarray
- class regularizepsf.corrector.FunctionalCorrector(psf: regularizepsf.psf.PointSpreadFunctionABC, target_model: regularizepsf.psf.PointSpreadFunctionABC | None)#
Bases:
CorrectorABCA version of the PSF corrector that stores the model as a set of functions. For the actual correction, the functions must first be evaluated to an ArrayCorrector.
Initialize a FunctionalCorrector.
- Parameters:
- _variable: bool#
- _target_model: regularizepsf.psf.SimplePSF#
- property is_variable: bool#
- returns: True if the PSF model is varied (changes across the field-of-view)
and False otherwise
- Return type:
bool
- evaluate_to_array_form(x: numpy.ndarray, y: numpy.ndarray, size: int) ArrayCorrector#
Evaluates a FunctionalCorrector to an ArrayCorrector.
- Parameters:
x (np.ndarray) – the first dimension coordinates to evaluate over
y (np.ndarray) – the second dimension coordinates to evaluate over
size (int) – how large the patches in the PSF correction model shouuld be
- Returns:
an array evaluated form of this PSF corrector
- Return type:
- correct_image(image: numpy.ndarray, size: int, alpha: float = 0.5, epsilon: float = 0.05) numpy.ndarray#
PSF correct an image according to the model.
- Parameters:
image (2D float np.ndarray) – image to be corrected
size (int) – how big to make the patches when correcting an image, only used for FunctionalCorrector
alpha (float) – controls the “hardness” of the transition from amplification to attenuation, see notes
epsilon (float) – controls the maximum of the amplification, see notes
- Returns:
a image that has been PSF corrected
- Return type:
np.ndarray
- save(path: str) None#
Save the model to a file.
- Parameters:
path (str or pathlib.Path) – where to save the model, suggested extension is “.psf”
- Return type:
None
- classmethod load(path: str) FunctionalCorrector#
Loads a model from the path.
- Parameters:
path (str or pathlib.Path) – where to load the model from, suggested extension is “.psf”
- simulate_observation(image: numpy.ndarray, size: int) numpy.ndarray#
Simulates on a star field what an observation using this PSF looks like.
- Parameters:
image (2D float np.ndarray) – image of point source stars to simluate PSF for
size (int) – the PSF will be evaluated to size x size pixels box
- Returns:
an image with the PSF applied
- Return type:
np.ndarray
- class regularizepsf.corrector.ArrayCorrector(evaluations: dict[Any, numpy.ndarray], target_evaluations: numpy.ndarray | dict[Any, numpy.ndarray])#
Bases:
CorrectorABCA PSF corrector that is evaluated as array patches.
Initialize an ArrayCorrector.
- Parameters:
evaluations (dict) –
- evaluated version of the PSF as they vary over the image,
keys should be (x, y) of the lower left pixel of each patch. values should be the np.ndarray that corresponds to that patch
target_evaluations (np.ndarray) – evaluated version of the target PSF
- _evaluation_points: list[Any]#
- _size#
- _evaluations: dict[Any, numpy.ndarray]#
- _target_evaluations#
- psf_i_fft#
- target_fft#
- property evaluations: dict[Any, numpy.ndarray]#
- property evaluation_points: list#
- correct_image(image: numpy.ndarray, size: int | None = None, alpha: float = 0.5, epsilon: float = 0.05) numpy.ndarray#
PSF correct an image according to the model.
- Parameters:
image (2D float np.ndarray) – image to be corrected
size (int) – how big to make the patches when correcting an image, only used for FunctionalCorrector
alpha (float) – controls the “hardness” of the transition from amplification to attenuation, see notes
epsilon (float) – controls the maximum of the amplification, see notes
- Returns:
a image that has been PSF corrected
- Return type:
np.ndarray
- __getitem__(xy: tuple[int, int]) numpy.ndarray#
- save(path: str) None#
Save the model to a file.
- Parameters:
path (str or pathlib.Path) – where to save the model, suggested extension is “.psf”
- Return type:
None
- classmethod load(path: str) ArrayCorrector#
Loads a model from the path.
- Parameters:
path (str or pathlib.Path) – where to load the model from, suggested extension is “.psf”
- simulate_observation(image: numpy.ndarray) numpy.ndarray#
Simulates on a star field what an observation using this PSF looks like.
- Parameters:
image (2D float np.ndarray) – image of point source stars to simluate PSF for
- Returns:
an image with the PSF applied
- Return type:
np.ndarray
- regularizepsf.corrector.calculate_covering(image_shape: tuple[int, int], size: int) numpy.ndarray#
Determines the grid of overlapping neighborhood patches.
- Parameters:
image_shape (tuple of 2 ints) – shape of the image we plan to correct
size (int) – size of the square patches we want to create
- Returns:
an array of shape Nx2 where return[:, 0] are the x coordinate and return[:, 1] are the y coordinates
- Return type:
np.ndarray