optiland.mtf.sampled

Sampled Modulation Transfer Function (MTF) Module.

This module provides the SampledMTF class for computing the MTF of an optical system based on sampled wavefront data.

Kramer Harrison, 2025

Classes

SampledMTF(optic, field, wavelength[, ...])

Sampled Modulation Transfer Function (MTF) class.

class SampledMTF(optic, field, wavelength: str | float, num_rays=128, distribution='uniform', zernike_terms=37, zernike_type='fringe')[source]

Sampled Modulation Transfer Function (MTF) class.

This class calculates the MTF of an optical system from sampled wavefront data. It utilizes Zernike polynomial fitting to represent the wavefront aberrations.

Note

This class assumes that amplitude variations between the pupil and a shifted version of the pupil can be ignored.

Parameters:
  • optic (Optic) – The optical system.

  • field (tuple) – The field point (Hx, Hy) at which to calculate the MTF.

  • wavelength (str or float) – The wavelength (in mm) at which to calculate the MTF. Can be ‘primary’ to use the optic’s primary wavelength.

  • num_rays (int, optional) – The number of rings to trace for the wavefront analysis. Defaults to 128 in each axis.

  • distribution (str, optional) – The distribution of rays in the pupil. Defaults to ‘uniform’.

  • zernike_terms (int, optional) – The number of Zernike terms to use for the wavefront fit. Defaults to 37.

  • zernike_type (str, optional) – The type of Zernike polynomials to use (‘fringe’, ‘standard’, etc.). Defaults to ‘fringe’.

optic

The optical system.

Type:

Optic

field

The field point (Hx, Hy).

Type:

tuple

wavelength

The wavelength (in mm) used for calculation.

Type:

float

num_rays

The number of rays used for wavefront analysis.

Type:

int

distribution

The ray distribution in the pupil.

Type:

str

zernike_terms

The number of Zernike terms for the fit.

Type:

int

zernike_type

The type of Zernike polynomials used.

Type:

str

x_norm

Normalized x-coordinates of pupil samples.

Type:

be.ndarray

y_norm

Normalized y-coordinates of pupil samples.

Type:

be.ndarray

opd_waves

Optical Path Difference (OPD) in waves.

Type:

be.ndarray

intensity

Intensity at each pupil sample point.

Type:

be.ndarray

zernike_fit

The Zernike fit object.

Type:

ZernikeFit

P1

The complex pupil function.

Type:

be.ndarray

otf_at_zero

The value of the Optical Transfer Function (OTF) at zero frequency, equivalent to the sum of intensities.

Type:

float

calculate_mtf(frequencies)[source]

Calculates the Modulation Transfer Function (MTF) for given spatial frequencies.

The method computes the MTF by determining the Optical Transfer Function (OTF) from the overlap integral of the pupil function with a shifted version of itself. The shift corresponds to the spatial frequency being evaluated. The MTF is the absolute value of the normalized OTF.

Parameters:

frequencies (list[tuple[float, float]] or be.ndarray) – A list or array of tuples, where each tuple (fx, fy) represents a spatial frequency pair in cycles per mm for which to calculate the MTF.

Returns:

A list of MTF values corresponding to each input frequency pair. The MTF values are dimensionless and range from 0 to 1.

Return type:

list[float]

Notes

The calculation involves: 1. Retrieving the exit pupil diameter (XPD). If XPD is near zero,

MTF is 0 for non-zero frequencies and 1 for zero frequency.

  1. Converting the wavelength to mm.

  2. For each frequency pair (fx, fy):
    1. Calculating physical shifts in the pupil based on wavelength and frequency.

    2. Normalizing these shifts using the XPD radius & exit pupil position.

    3. Determining the shifted normalized coordinates for pupil evaluation.

    4. Evaluating the Optical Path Difference (OPD) at these shifted coordinates using the Zernike polynomial fit of the wavefront.

    5. Masking points where the shifted evaluation falls outside the unit circle (i.e., outside the pupil).

    6. Computing the complex conjugate of the pupil function at the shifted coordinates (P2_conj).

    7. Calculating the OTF element as the product of the original complex pupil function (P1) and P2_conj.

    8. Summing the OTF elements over all pupil sample points to get the total OTF value for the given frequency.

    9. Normalizing the OTF value by otf_at_zero (the OTF at zero frequency).

    10. The MTF is the absolute value of this normalized OTF.