analysis.chromatic_focal_shift#

Chromatic Focal Shift Analysis

This module provides a chromatic focal shift analysis for optical systems: the paraxial focus position as a function of wavelength, relative to the focus at the primary wavelength.

Javier Ruiz, 2026

Classes

ChromaticFocalShift(optic[, ...])

Chromatic focal shift: paraxial focus position versus wavelength.

class ChromaticFocalShift(optic: Optic, wavelength_range: tuple[float, float] | None = None, num_points: int = 128)[source]#

Chromatic focal shift: paraxial focus position versus wavelength.

For each sampled wavelength, a paraxial marginal ray (Hy = 0, Py = 1) is traced. Its axial focus, measured from the image surface, is dz = -y / u at the image surface. The focal shift is dz minus its value at the primary wavelength.

Parameters:
  • optic (Optic) – The optic object to analyze.

  • wavelength_range (tuple[float, float], optional) – The minimum and maximum wavelengths in µm. If None, the minimum and maximum of the optic’s defined wavelengths are used. Defaults to None.

  • num_points (int, optional) – The number of wavelengths sampled across the range. Defaults to 128.

Variables:
  • optic (Optic) – The optic object being analyzed.

  • wavelength_range (tuple[float, float]) – The sampled wavelength range in µm.

  • num_points (int) – The number of sampled wavelengths.

  • data (dict) – The generated data, with keys "wavelengths" (µm), "focal_shift" (lens units), and the same two quantities at the optic’s defined wavelengths, "defined_wavelengths" and "defined_focal_shift".

Raises:

ValueError – If the wavelength range is empty.

max_focal_shift() → float[source]#

Returns the range of the focal shift over the sampled wavelengths.

Returns:

The maximum minus the minimum focal shift, in lens units.

Return type:

float

view(fig_to_plot_on: Figure | None = None, figsize: tuple[float, float] = (8, 5.5), *, show: bool = True) → tuple[Figure, Axes][source]#

Displays a plot of the chromatic focal shift.

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[float, float], optional) – The size of the figure. Defaults to (8, 5.5).

  • show (bool) – If True (default), calls plt.show(). Set False for headless use.

Returns:

The current figure and its axes.

Return type:

tuple