psf.huygens_fresnel
Huygens-Fresnel Point Spread Function (PSF) Module
This module provides functionality for simulating and analyzing the Point Spread Function (PSF) of optical systems using the Huygens-Fresnel principle. It includes capabilities for generating PSF for a given optical system. Visualization and Strehl ratio calculation are primarily handled by the base class. The PSF is normalized against the peak of an ideal diffraction-limited system calculated using the same Huygens-Fresnel principle.
The module exposes:
- ScalarHuygensPSF: scalar (intensity-only) Huygens PSF.
- HuygensPSF: factory that automatically dispatches to
VectorialHuygensPSFwhen a polarization state is set on the optic, and toScalarHuygensPSFotherwise.
Kramer Harrison, 2025
Classes
|
Factory class for generating either a Vectorial or Scalar Huygens PSF. |
- class HuygensPSF(optic, field, wavelength: str | float, num_rays=128, image_size=128, strategy='chief_ray', remove_tilt=False, oversample: float = None, pixel_pitch: float = None, normalization: float = None, **kwargs)[source]
Factory class for generating either a Vectorial or Scalar Huygens PSF.
This class inspects the optical system’s polarization state to determine which Huygens PSF implementation to instantiate. If polarization is enabled, it returns a
VectorialHuygensPSF. Otherwise, it returns aScalarHuygensPSF.- Parameters:
optic (Optic) – The optical system object.
field (tuple) – The field point.
wavelength (str | float) – The wavelength of light in micrometers.
num_rays (int, optional) – The number of rays to trace. Defaults to 128.
image_size (int, optional) – The size of the image grid. Defaults to 128.
strategy (str) – The wavefront calculation strategy. Defaults to “chief_ray”.
remove_tilt (bool) – If True, removes tilt from OPD. Defaults to False.
oversample (float, optional) – Oversampling ratio for MTF use. Defaults to None.
pixel_pitch (float, optional) – Pixel pitch in mm. Defaults to None.
**kwargs – Additional keyword arguments.
- class ScalarHuygensPSF(optic, field, wavelength: str | float, num_rays=128, image_size=128, strategy='chief_ray', remove_tilt=False, oversample: float = None, pixel_pitch: float = None, normalization: float = None, **kwargs)[source]
Huygens PSF class using Huygens-Fresnel principle (scalar formulation).
Computes PSF by integrating contributions from point sources across the exit pupil. The PSF is normalized such that the peak intensity of an equivalent diffraction-limited system (same pupil amplitude, zero phase error) would be 100.0. This makes the Strehl ratio (peak of actual PSF / 100.0, or value at PSF center / 100.0) meaningful.
Inherits from BasePSF for common initialization (Wavefront setup) and visualization methods.
- Parameters:
optic (Optic) – The optical system object, containing properties like paraxial data and surface information.
field (tuple) – The field point (e.g., (Hx, Hy) in normalized field coordinates) at which to compute the PSF.
wavelength (str | float) – The wavelength of light in micrometers. Can be ‘primary’ or a float value.
num_rays (int, optional) – The number of rays used to sample the pupil plane along one dimension. The pupil will be a grid of num_rays x num_rays. Defaults to 128.
image_size (int, optional) – The size of the image grid for PSF calculation. Defaults to 128.
strategy (str) – The calculation strategy to use. Supported options are “chief_ray”, “centroid_sphere”, and “best_fit_sphere”. Defaults to “chief_ray”.
remove_tilt (bool) – If True, removes tilt and piston from the OPD data. Defaults to False.
oversample (float, optional) – The oversampling ratio with respect to the optical cutoff. Impacts the extent of the image and is generally only used for MTF calculation. Defaults to None.
pixel_pitch (float, optional) – The pixel pitch of the image plane in mm. If provided, this will override the automatic extent calculation. Defaults to None.
**kwargs – Additional keyword arguments passed to the strategy.
- static fit_and_remove_tilt(data: WavefrontData, remove_piston: bool = False, ridge: float = 1e-12) be.ndarray
Removes piston and tilt from OPD data using weighted least squares.
- Parameters:
data (WavefrontData) – The wavefront data containing pupil coordinates and OPD.
remove_piston (bool, optional) – If True, removes piston term as well as tilt. Defaults to False.
ridge (float, optional) – Small diagonal regularization for stability. Defaults to 1e-12.
- Returns:
OPD with piston and tilt removed, shape (N,).
- Return type:
opd_detrended (be.ndarray)
- get_data(field: tuple[float, float], wl: float) WavefrontData
Retrieves precomputed wavefront data for a field and wavelength.
- Parameters:
field (tuple[float, float]) – The field coordinates, or a FieldPoint.
wl (float) – The wavelength in µm, or a WavelengthPoint.
- Returns:
A data container with the computed wavefront results.
- Return type:
- strehl_ratio()
Computes the Strehl ratio of the PSF.
The Strehl ratio is the ratio of the peak intensity of the aberrated PSF to the peak intensity of the diffraction-limited PSF. Assumes self.psf is normalized such that its peak would be 1.0 (or 100%) for a diffraction-limited system.
- Returns:
The Strehl ratio.
- Return type:
float
- Raises:
RuntimeError – If the PSF has not been computed.
- view(fig_to_plot_on: Figure | None = None, projection: str = '2d', log: bool = False, figsize: tuple = (7, 5.5), threshold: float = 0.05, num_points: int = 128) tuple[Figure, Axes]
Visualizes the PSF.
- Parameters:
projection (str, optional) – The projection type. Can be ‘2d’ or ‘3d’. Defaults to ‘2d’.
log (bool, optional) – Whether to use a logarithmic scale for the intensity. Defaults to False.
figsize (tuple, optional) – The figure size. Defaults to (7, 5.5).
threshold (float, optional) – The threshold for determining the bounds of the PSF for zoomed view. Defaults to 0.05.
num_points (int, optional) – The number of points used for interpolating the PSF for smoother visualization. Defaults to 128.
- Returns:
A tuple containing the figure and axes objects.
- Return type:
tuple
- Raises:
RunentimeError – If the PSF has not been computed.
ValueError – If the projection is not ‘2d’ or ‘3d’.
RuntimeError – If the PSF has not been computed by the subclass.