mtf.huygens_fresnel
Huygens Modulation Transfer Function (HuygensMTF) Module.
This module provides the ScalarHuygensMTF, VectorialHuygensMTF (via factory), and HuygensMTF factory class for computing the MTF of an optical system using a Point Spread Function (PSF) derived from the Huygens-Fresnel principle.
Kramer Harrison, 2025
Classes
|
Factory class for generating either a Vectorial or Scalar Huygens MTF. |
|
Scalar Huygens Modulation Transfer Function class. |
|
Vectorial Huygens Modulation Transfer Function class. |
- class HuygensMTF(optic, fields: str | list = 'all', wavelength: str | float = 'primary', num_rays=128, image_size=128, max_freq='cutoff')[source]
Factory class for generating either a Vectorial or Scalar Huygens MTF.
This class inspects the optical system’s polarization state to determine which Huygens MTF implementation to instantiate. If polarization is enabled, it returns a
VectorialHuygensMTF. Otherwise, it returns aScalarHuygensMTF.- Parameters:
optic (Optic) – The optical system object.
fields (str or list, optional) – The field coordinates for which to calculate the MTF. Defaults to ‘all’.
wavelength (str or float, optional) – The wavelength of light to use. Defaults to ‘primary’.
num_rays (int, optional) – The number of rays to use for the PSF calculation. Defaults to 128.
image_size (int, optional) – The size of the image grid for PSF calculation and subsequent MTF. Defaults to 128.
max_freq (str or float, optional) – The maximum frequency for the MTF calculation in cycles/mm. Defaults to ‘cutoff’.
- class ScalarHuygensMTF(optic, fields: str | list = 'all', wavelength: str | float = 'primary', num_rays=128, image_size=128, max_freq='cutoff')[source]
Scalar Huygens Modulation Transfer Function class.
This class calculates and visualizes the Modulation Transfer Function (MTF) of an optic using a Point Spread Function (PSF) derived from the Huygens-Fresnel principle. It is intended for use with unpolarized optical systems. Use the
HuygensMTFfactory to automatically select between scalar and vectorial implementations based on the optic’s polarization state.Supports both the NumPy and PyTorch backends. The underlying Huygens-Fresnel summation uses Numba (NumPy) or batched tensor operations (PyTorch) transparently via the strategy pattern in
ScalarHuygensPSF.- Parameters:
optic (Optic) – The optic for which to calculate the MTF.
fields (str or list, optional) – The field coordinates for which to calculate the MTF. Defaults to ‘all’.
wavelength (str or float, optional) – The wavelength of light to use for the MTF calculation. Defaults to ‘primary’.
num_rays (int, optional) – The number of rays to use for the HuygensPSF calculation along one dimension of the pupil grid. Defaults to 128.
image_size (int, optional) – The size of the image grid for PSF calculation and subsequent MTF. Defaults to 128.
max_freq (str or float, optional) – The maximum frequency for the MTF calculation in cycles/mm. If ‘cutoff’, it’s determined by the diffraction limit (1 / (lambda * FNO)). Defaults to ‘cutoff’.
- num_rays
The number of rays used for the PSF calculation.
- Type:
int
- image_size
The size of the grid used for the PSF/MTF calculation.
- Type:
int
- max_freq
The maximum frequency for the MTF calculation (cycles/mm).
- Type:
float
- FNO
The F-number of the optic.
- Type:
float
- psf_data
List of 2D PSF data arrays for each field.
- Type:
list
- psf_instances
List of PSF instances for each field.
- Type:
list
- mtf
List of MTF data ([tangential, sagittal]) for each field.
- Type:
list
- freq
Array of frequency points for the MTF curve (cycles/mm).
- Type:
be.ndarray
- view(fig_to_plot_on: Figure | None = None, figsize: tuple[float, float] = (12, 4), add_reference: bool = False) tuple[Figure, Axes]
Visualizes the Modulation Transfer Function (MTF).
This method sets up the plot and iterates through field data, calling _plot_field_mtf for each field’s specific plotting.
Subclasses must ensure self.mtf, self.freq, and self.max_freq are populated before calling this method. self.resolved_fields (from __init__) is also used.
- Parameters:
fig_to_plot_on (plt.Figure, optional) – The figure to plot on. If None, a new figure will be created. Defaults to None.
figsize (tuple, optional) – The size of the figure. Defaults to (12, 4).
add_reference (bool, optional) – Whether to overlay the theoretical diffraction-limited MTF curve for a clear circular aperture. The reference is computed using the on-axis working F/# and the resolved wavelength. Defaults to False.
- Returns:
A tuple containing the figure and axes objects.
- Return type:
tuple
- class VectorialHuygensMTF(optic, fields: str | list = 'all', wavelength: str | float = 'primary', num_rays=128, image_size=128, max_freq='cutoff')[source]
Vectorial Huygens Modulation Transfer Function class.
This class calculates the MTF of an optical system using the vectorial Huygens-Fresnel method. It accounts for the full 3D electric field at the exit pupil and is intended for use with polarized optical systems. Use the
HuygensMTFfactory to automatically select between scalar and vectorial implementations based on the optic’s polarization state.Inherits all constructor arguments and attributes from
ScalarHuygensMTF.- view(fig_to_plot_on: Figure | None = None, figsize: tuple[float, float] = (12, 4), add_reference: bool = False) tuple[Figure, Axes]
Visualizes the Modulation Transfer Function (MTF).
This method sets up the plot and iterates through field data, calling _plot_field_mtf for each field’s specific plotting.
Subclasses must ensure self.mtf, self.freq, and self.max_freq are populated before calling this method. self.resolved_fields (from __init__) is also used.
- Parameters:
fig_to_plot_on (plt.Figure, optional) – The figure to plot on. If None, a new figure will be created. Defaults to None.
figsize (tuple, optional) – The size of the figure. Defaults to (12, 4).
add_reference (bool, optional) – Whether to overlay the theoretical diffraction-limited MTF curve for a clear circular aperture. The reference is computed using the on-axis working F/# and the resolved wavelength. Defaults to False.
- Returns:
A tuple containing the figure and axes objects.
- Return type:
tuple