mtf.fft
Fast Fourier Transform Modulation Transfer Function (FFTMTF) Module.
This module provides the ScalarFFTMTF, VectorialFFTMTF (via factory), and FFTMTF factory class for computing the MTF of an optical system using FFT techniques.
Kramer Harrison, 2025
Classes
|
Factory class for generating either a Vectorial or Scalar FFT MTF. |
- class FFTMTF(optic, fields: str | list = 'all', wavelength: str | float = 'primary', num_rays=128, grid_size=None, max_freq='cutoff', strategy='chief_ray', remove_tilt=False, **kwargs)[source]
Factory class for generating either a Vectorial or Scalar FFT MTF.
This class inspects the optical system’s polarization state to determine which FFT MTF implementation to instantiate. If polarization is enabled, it returns a VectorialFFTMTF. Otherwise, it returns a ScalarFFTMTF.
- 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.
grid_size (int or None, optional) – The FFT grid size. Defaults to None.
max_freq (str or float, optional) – The maximum frequency for the MTF calculation. Defaults to ‘cutoff’.
strategy (str) – The wavefront calculation strategy. Defaults to “chief_ray”.
remove_tilt (bool) – If True, removes tilt from OPD. Defaults to False.
**kwargs – Additional keyword arguments passed to the strategy.
- class ScalarFFTMTF(optic, fields: str | list = 'all', wavelength: str | float = 'primary', num_rays=128, grid_size=None, max_freq='cutoff', strategy='chief_ray', remove_tilt=False, **kwargs)[source]
Scalar Fast Fourier Transform Modulation Transfer Function class.
This class calculates and visualizes the Modulation Transfer Function (MTF) of an optic using the scalar FFT method. It is intended for use with unpolarized optical systems. Use the FFTMTF factory to automatically select between scalar and vectorial implementations based on the optic’s polarization state.
- 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 PSF calculation, which is then used for MTF. Defaults to 128.
grid_size (int or None, optional) – The size of the grid used for the PSF/MTF calculation. If None, the grid size will be calculated from num_rays as documented in optiland.psf.fft.ScalarFFTPSF. Defaults to None.
max_freq (str or float, optional) – The maximum frequency for the MTF calculation. Defaults to ‘cutoff’.
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.
**kwargs – Additional keyword arguments passed to the strategy.
- num_rays
The number of rays used for the MTF calculation.
- Type:
int
- grid_size
The size of the grid used for the MTF calculation.
- Type:
int
- max_freq
The maximum frequency for the MTF calculation.
- Type:
float
- FNO
The F-number of the optic.
- Type:
float
- psf
List of PSF data 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.
- 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