wf_psf.psf_models.psf_models

PSF_Models.

A module which provides general utility methods to manage the parameters of the psf model.

Authors:

Tobias Liaudat <tobiasliaudat@gmail.com> and Jennifer Pollack <jennifer.pollack@cea.fr>

Functions

build_PSF_model(model_inst[, optimizer, ...])

Define the model-compilation parameters.

generate_zernike_maps_3d(n_zernikes, pupil_diam)

Generate 3D Zernike Maps.

get_psf_model(*psf_model_params)

Get PSF Model Class Instance.

get_psf_model_weights_filepath(weights_filepath)

Get PSF model weights filepath.

register_psfclass(psf_factory_class)

Register PSF Factory Class.

set_psf_model(model_name)

Set PSF Model Class.

simPSF(model_params)

Instantiate and configure a Simulated PSF model.

tf_obscurations(pupil_diam[, N_filter, ...])

Tensor Flow Obscurations.

Classes

PSFModelBaseFactory()

Base factory class for PSF models.

Exceptions

PSFModelError([message])

PSF Model Parameter Error exception class.

class wf_psf.psf_models.psf_models.PSFModelBaseFactory[source]

Bases: object

Base factory class for PSF models.

This class serves as the base factory for instantiating PSF (Point Spread Function) models. Subclasses should implement the get_model_instance method to provide specific PSF model instances.

None
get_model_instance(model_params, training_params, data=None, coeff_matrix=None)[source]

Instantiates a PSF model with the provided parameters.

Notes

Subclasses of PSFModelBaseFactory should override the get_model_instance method to provide implementation-specific logic for instantiating PSF model instances.

Methods

get_model_instance(model_params, training_params)

Instantiate a PSF model instance.

get_model_instance(model_params, training_params, data=None, coeff_matrix=None)[source]

Instantiate a PSF model instance.

Parameters:
  • model_params (Recursive Namespace) – A Recursive Namespace object containing parameters for this PSF model class.

  • training_params (Recursive Namespace) – A Recursive Namespace object containing training hyperparameters for this PSF model class.

  • data (DataConfigHandler) – A DataConfigHandler object that provides access to training and test datasets, as well as prior knowledge like Zernike coefficients.

  • coeff_mat (Tensor or None, optional) – Coefficient matrix defining the parametric PSF field model.

Returns:

An instance of the PSF model.

Return type:

PSF model instance

exception wf_psf.psf_models.psf_models.PSFModelError(message='An error with your PSF model parameter settings occurred.')[source]

Bases: Exception

PSF Model Parameter Error exception class.

This exception class is used to handle errors related to PSF (Point Spread Function) model parameters.

Parameters:

message (str, optional) – Error message to be raised. Defaults to “An error with your PSF model parameter settings occurred.”

wf_psf.psf_models.psf_models.build_PSF_model(model_inst, optimizer=None, loss=None, metrics=None)[source]

Define the model-compilation parameters.

Specially the loss function, the optimizer and the metrics.

wf_psf.psf_models.psf_models.generate_zernike_maps_3d(n_zernikes, pupil_diam)[source]

Generate 3D Zernike Maps.

This function generates Zernike maps on a three-dimensional tensor.

Parameters:
  • n_zernikes (int) – The number of Zernike polynomials.

  • pupil_diam (float) – The diameter of the pupil.

Returns:

A TensorFlow EagerTensor containing the Zernike map tensor.

Return type:

tf.Tensor

Notes

The Zernike maps are generated using the specified number of Zernike polynomials and the size of the pupil diameter. The resulting tensor contains the Zernike maps in a three-dimensional format.

wf_psf.psf_models.psf_models.get_psf_model(*psf_model_params)[source]

Get PSF Model Class Instance.

A function to instantiate a PSF model class.

Parameters:

*psf_model_params (tuple) – Positional arguments representing the parameters required to instantiate the PSF model.

Returns:

An instance of the PSF model class based on the provided parameters.

Return type:

PSF model class instance

wf_psf.psf_models.psf_models.get_psf_model_weights_filepath(weights_filepath)[source]

Get PSF model weights filepath.

A function to return the basename of the user-specified psf model weights path.

Parameters:

weights_filepath (str) – Basename of the psf model weights to be loaded.

Returns:

The absolute path concatenated to the basename of the psf model weights to be loaded.

Return type:

str

wf_psf.psf_models.psf_models.register_psfclass(psf_factory_class)[source]

Register PSF Factory Class.

A function to register a PSF factory class in a dictionary.

Parameters:

factory_class (type) – PSF Factory Class

wf_psf.psf_models.psf_models.set_psf_model(model_name)[source]

Set PSF Model Class.

A function to select a class of the PSF model from a dictionary.

Parameters:

model_name (str) – Name of PSF model

Returns:

psf_class – Name of PSF model class

Return type:

class

wf_psf.psf_models.psf_models.simPSF(model_params)[source]

Instantiate and configure a Simulated PSF model.

This function creates a PSFSimulator instance with the given model parameters, generates random Zernike coefficients, normalizes them, and produces a monochromatic PSF.

Parameters:

model_params (Recursive Namespace) – A recursive namespace object storing model parameters

Returns:

A configured PSFSimulator instance with the specified model parameters.

Return type:

PSFSimulator

wf_psf.psf_models.psf_models.tf_obscurations(pupil_diam, N_filter=2, rotation_angle=0)[source]

Tensor Flow Obscurations.

A function to generate obscurations as a tensor.

Parameters:
  • pupil_diam (float) – Size of the pupil diameter

  • N_filters (int) – Number of filters

  • rotation_angle (int) – Rotation angle in degrees to apply to the obscuration pattern. It only supports 90 degree rotations. The rotation will be counterclockwise.

Returns:

TensorFlow EagerTensor type

Return type:

Obscurations tensor