optiland.analysis.through_focus

Through-focus analysis base class

This module provides a base class for performing through-focus analysis.

Kramer Harrison, 2025

Classes

ThroughFocusAnalysis(optic[, delta_focus, ...])

Base class for through-focus analysis.

class ThroughFocusAnalysis(optic, delta_focus: float = 0.1, num_steps: int = 5, fields='all', wavelengths: str | list[float] = 'all')[source]

Base class for through-focus analysis.

This class provides the basic framework for analyses that need to be performed over a range of focal planes. It handles the iteration through different focal positions and delegates the specific analysis at each position to subclasses.

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

  • delta_focus (float, optional) – The increment of focal shift in mm. Defaults to 0.1.

  • num_steps (int, optional) – The number of focal planes to analyze before and after the nominal focus. Defaults to 5.

  • fields (list[tuple[float, float]] | str, optional) – Fields for analysis. If “all”, uses all fields from optic.fields. Otherwise, expects a list of field coordinates. Defaults to “all”.

  • wavelengths (list[float] | str, optional) – Wavelengths for analysis. If “all”, uses all wavelengths from optic.wavelengths. Otherwise, expects a list of wavelength values. Defaults to “all”.

results

A list to store the results from the analysis performed at each focal plane. The structure of each item in the list is determined by the _perform_analysis_at_focus method of the subclass.

Type:

list

MAX_STEPS = 7
MIN_STEPS = 1
abstract view(*, show: bool = True)[source]

Visualizes or prints the results of the through-focus analysis.

This abstract method must be implemented by subclasses. It defines how the collected self.results (containing analysis data from all focal planes) should be presented to the user, for example, by plotting graphs or printing a formatted table.

Parameters:

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