opticks.utils.prysm_utils

Package for prysm integration utilities and helpers.

Functions

richdata_has_units(rich_data)

Checks whether RichData object has units.

richdata_with_units(rich_data[, dx_units])

Generates a deepcopy of the input RichData object with units.

Classes

Grid(shape, dx)

Create an x, y grid from -1, 1 with n number of samples.

OptPathDiff(opd)

Init with Optical Path Difference.

class Grid(shape, dx)[source]

Create an x, y grid from -1, 1 with n number of samples.

Parameters:
  • shape (int or tuple of int) – number of samples per dimension. If a scalar value, broadcast to both dimensions. Order is numpy axis convention, (row, col)

  • dx (Quantity) – inter-sample spacing

cartesian()[source]

Gets the cartesian grid with the given internal sample points.

Return type:

tuple[ndarray, ndarray]

Returns:

x, y (tuple[ndarray, ndarray]) – tuple of x and y cartesian coordinates, respectively

dx: Quantity

Inter-sample spacing.

classmethod from_size(shape, size)[source]

Generates a Grid object from the size of one side.

If sample sizes are not equal in the two dimensions, the larger sample size is taken: dx = size / max(shape)

Return type:

Grid

Parameters:
  • shape (int or tuple of int) – number of samples per dimension. If a scalar value, broadcast to both dimensions. Order is numpy axis convention, (row, col)

  • size (Quantity) – size of the grid on one side

Returns:

Grid – new Grid object

property has_units: bool

Checks whether the internal data have units or are plain float ndarrays.

polar()[source]

Gets the polar grid with the given internal sample points.

Return type:

tuple[ndarray, ndarray]

Returns:

rho, phi (tuple[ndarray, ndarray]) – tuple of radial coordinate and azimuthal coordinate, respectively

property r: ndarray

Gets the radial coordinates.

shape = None

Number of samples per dimension.

If a scalar value, broadcast to both dimensions. Order is numpy axis convention, (row, col). Type is int or tuple of int.

strip_units(units=Unit('mm'))[source]

Converts the Grid object to the default units.

Converts the internal parameters to float ndarrays and returns a deepcopy of the Grid object.

Azimuthal coordinates are in radians.

Return type:

Grid

Parameters:

units (Unit, optional) – requested unit, by default “mm”

Returns:

Grid – New Grid object with float ndarrays

property t: ndarray

Gets the azimuthal coordinates.

x: ndarray | None = None

Cartesian x coordinate.

y: ndarray | None = None

Cartesian y coordinate.

class OptPathDiff(opd)[source]

Init with Optical Path Difference.

The input data should be in a format that can be used in prysm. Therefore, it is recommended to initialise this object with from_zernike or similar methods.

Parameters:

opd (ndarray) – Optical Path Difference data (in nm)

classmethod from_zernike(wfe_rms, aperture_diameter, grid, ordering='ansi')[source]

Computes the Optical Path Difference via Zernike Polynomials.

Generates the Zernike Polynomials to the order corresponding to the number of coefficients (e.g., 9 coefficients = mode 8) sums them properly, adding the WFE RMS Zernike coefficients.

The result is the monochromatic OPD for a single location on the PSF plane.

The input coefficients may be supplied in any of the three orderings supported by prysm: ANSI/OSA (0-based), Noll (1-based), or Fringe (1-based). The selected ordering determines the (n, m) mapping used for each coefficient.

Common optical-design tool defaults:

  • Zemax OpticStudio — Fringe by default (the “Zernike Fringe” surface and Wavefront Analysis outputs). A “Zernike Standard” surface uses ANSI/OSA instead.

  • CODE V — Fringe by default (University of Arizona / Fringe convention). Noll is also available as an option.

Parameters:
  • wfe_rms (Quantity) – list of aberration coefficients (WFE RMS) (in nm), in the order specified by ordering

  • diameter (Quantity) – aperture diameter in mm

  • grid (Grid) – aperture grid (in mm and rad)

  • ordering (str, optional) – Zernike index ordering of wfe_rms. One of "ansi" (default), "noll", or "fringe". Zemax and CODE V default to "fringe".

  • aperture_diameter (Quantity)

Returns:

Return type:

OptPathDiff

property has_units: bool

Checks whether the internal data have units or are plain float ndarrays.

strip_units(units=Unit('nm'))[source]

Converts the OptPhaseDiff object to the default units.

Converts the internal parameters to float ndarrays and returns a deepcopy of the OptPhaseDiff object.

Return type:

OptPathDiff

Parameters:

units (Unit, optional) – requested unit, by default “nm”

Returns:

OptPathDiff – New OptPathDiff object with float ndarrays

richdata_has_units(rich_data)[source]

Checks whether RichData object has units.

Return type:

bool

Parameters:

rich_data (RichData)

richdata_with_units(rich_data, dx_units=Unit('mm'))[source]

Generates a deepcopy of the input RichData object with units.

Adds units to dx and wavelength (if available). The data structure is already without units by definition.

If the input rich_data has units, raises a ValueError exception.

Return type:

RichData

Parameters:
  • rich_data (RichData) – input object without units

  • dx_units (Unit) – units to be used for dx spacing parameter

Returns:

RichData – output object with units