analysis.spot_diagram#

Spot Diagram Analysis Package

This package provides spot diagram analysis for optical systems, including configurable reference centering strategies.

class SpotData(x: array, y: array, intensity: array)[source]#

Stores the x, y coordinates and intensity of a spot.

Variables:
  • x (optiland.backend.numpy_backend.creation.CreationMixin.array) – Array of x-coordinates.

  • y (optiland.backend.numpy_backend.creation.CreationMixin.array) – Array of y-coordinates.

  • intensity (optiland.backend.numpy_backend.creation.CreationMixin.array) – Array of intensity values.

intensity: array#
x: array#
y: array#
class SpotDiagram(optic, fields: str | list = 'all', wavelengths: str | list = 'all', num_rings: int = 6, distribution: DistributionType = 'hexapolar', coordinates: Literal['global', 'local'] = 'local', reference: str | SpotReferenceType = SpotReferenceType.CHIEF_RAY)[source]#

Generates and plots real ray intersection data on the image surface.

This class creates spot diagrams, which are purely geometric plots that give an indication of the blur produced by aberrations in an optical system.

Variables:
  • optic – Instance of the optic object to be assessed.

  • fields – Fields at which data is generated.

  • wavelengths – Wavelengths at which data is generated.

  • num_rings – Number of rings in the pupil distribution for ray tracing.

  • distribution – The pupil distribution type for ray tracing.

  • data – Contains spot data in a nested list, ordered by field, then wavelength.

  • coordinates – The coordinate system (‘global’ or ‘local’) for data and plotting.

  • reference – The reference point type used for centering spots.

airy_disc_x_y(wavelength: float) tuple[list[float], list[float]][source]#

Generates the Airy disk radii for the x and y axes for each field.

Parameters:

wavelength – The wavelength for the calculation.

Returns:

x-axis radii and y-axis radii per field.

Return type:

A tuple of two lists

airy_radius(n_w: float, wavelength: float) float[source]#

Calculates the Airy disk radius.

Parameters:
  • n_w – The physical F-number.

  • wavelength – The wavelength of light in micrometers.

Returns:

The Airy disk radius.

angle_from_cosine(a: BEArray, b: BEArray) float[source]#

Calculates the angle in radians between two direction cosine vectors.

Parameters:
  • a – The first direction cosine vector.

  • b – The second direction cosine vector.

Returns:

The angle between the vectors in radians.

centroid() list[tuple[BEArray, BEArray]][source]#

Calculates the geometric centroid of each spot for the reference wavelength.

Returns:

A list of (x, y) centroid coordinates for each field.

f_number(n: float, theta: float) float[source]#

Calculates the physical F-number.

Parameters:
  • n – The refractive index of the medium.

  • theta – The half-angle of the cone of light in radians.

Returns:

The calculated physical F-number.

generate_chief_rays_centers(wavelength: float) BEArray[source]#

Generates the (x, y) intersection points for the chief ray of each field.

Parameters:

wavelength – The wavelength for the rays.

Returns:

An array of shape (num_fields, 2) with (x, y) coordinates.

generate_chief_rays_cosines(wavelength: float) BEArray[source]#

Generates direction cosines for the chief ray of each field.

Parameters:

wavelength – The wavelength for the rays.

Returns:

An array of shape (num_fields, 3) containing the direction cosines.

generate_marginal_rays(H_x: float, H_y: float, wavelength: float) tuple[source]#

Generates marginal rays at the four cardinal points of the pupil.

Parameters:
  • H_x – The x-field coordinate.

  • H_y – The y-field coordinate.

  • wavelength – The wavelength for the rays.

Returns:

A tuple containing the traced rays for north, south, east, and west pupil points.

generate_marginal_rays_cosines(H_x: float, H_y: float, wavelength: float) tuple[source]#

Generates direction cosines for each marginal ray of a given field.

Parameters:
  • H_x – The x-field coordinate.

  • H_y – The y-field coordinate.

  • wavelength – The wavelength for the rays.

Returns:

A tuple of direction cosine vectors for north, south, east, and west rays.

geometric_spot_radius() list[list[BEArray]][source]#

Calculates the maximum geometric spot radius for each spot.

Returns:

A nested list of maximum radii for each field and wavelength.

rms_spot_radius() list[list[BEArray]][source]#

Calculates the root-mean-square (RMS) spot radius for each spot.

Returns:

A nested list of RMS radii for each field and wavelength.

view(fig_to_plot_on: Figure | None = None, figsize: tuple[float, float] = (12, 4), add_airy_disk: bool = False, *, show: bool = True) tuple[Figure, list[Axes]][source]#

Displays the spot diagram plot.

Parameters:
  • fig_to_plot_on – An existing Matplotlib figure to plot on. If None, a new figure is created. Defaults to None.

  • figsize – The figure size for the output window, applied per row. Defaults to (12, 4).

  • add_airy_disk – If True, adds the Airy disk visualization to the plots. Defaults to False.

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

Returns:

A tuple containing the Matplotlib figure and a list of its axes.

class SpotReferenceType(*values)[source]#

Defines the available reference point types for spot centering.

CENTROID = 'centroid'#
CHIEF_RAY = 'chief_ray'#