analysis.through_focus_spot_diagram

Through Focus Spot Diagram Analysis

This module provides a class for performing through-focus spot diagram analysis, calculating the spot diagram at various focal planes.

Kramer Harrison, 2025

Classes

ThroughFocusSpotDiagram(optic[, ...])

Performs spot diagram analysis over a range of focal planes.

class ThroughFocusSpotDiagram(optic: Optic, delta_focus: float = 0.1, num_steps: int = 5, fields='all', wavelengths='all', num_rings: int = 6, distribution: DistributionType = 'hexapolar', coordinates: Literal['global', 'local'] = 'local')[source]

Performs spot diagram analysis over a range of focal planes.

This class extends ThroughFocusAnalysis to specifically calculate and report RMS spot radii from spot diagrams at various focal positions. It utilizes the SpotDiagram class for the core calculations at each focal plane.

optic

The optical system being analyzed.

Type:

optiland.optic.Optic

delta_focus

The focal shift increment in mm.

Type:

float

num_steps

Number of focal planes analyzed before and after the nominal focus.

Type:

int

fields

Resolved list of field coordinates for analysis.

Type:

list

wavelengths

Resolved list of wavelengths for analysis.

Type:

list

num_rings

Number of rings for pupil sampling in the SpotDiagram calculation.

Type:

int

distribution

Pupil sampling distribution type (e.g., ‘hexapolar’, ‘random’) for SpotDiagram.

Type:

str

coordinates

Coordinate system used for spot data generation within SpotDiagram.

Type:

Literal[“global”, “local”]

results

A list where each item is a dictionary. Each dictionary corresponds to a single focal plane and maps the delta focus (float, in mm) to a list of RMS spot radii (list of floats, in mm). Each RMS spot radius in the list corresponds to a field defined in self.fields, calculated at the primary wavelength.

Type:

list[dict[float, list[float]]]

MAX_STEPS = 7
MIN_STEPS = 1
view(fig_to_plot_on: Figure | None = None, figsize_per_plot: tuple[float, float] = (3, 3), buffer: float = 1.05, *, show: bool = True) tuple[Figure, list[Axes]] | None[source]

Visualizes the through-focus spot diagrams, either in a new window or on a provided GUI figure.

Parameters:
  • fig_to_plot_on – A matplotlib figure to plot on. If None, a new figure will be created.

  • figsize_per_plot – Size of each subplot

  • inches (in) – (width, height). Defaults to (3, 3).

  • buffer – Scaling buffer applied to the maximum radius for axis limits. Defaults to 1.05.

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

Returns:

A tuple containing the figure and a list of axes used for plotting. Or None

if updating the GUI.