psfsim.basis

Basis functions for decomposition of the figure errors.

Attributes

basis_set

Classes

_FigureBasis

Base class for basis functions for figures.

ZernikeBasis

Zernike basis set.

LegendreBasis

Legendre basis set.

LegendreBasisMaxOrder

Legendre basis set with maximum order.

RomanBasisSet

Class to build a table of basis sets from a dictionary.

Module Contents

class _FigureBasis[source]

Base class for basis functions for figures.

Parameters:

None

N[source]

The number of basis modes.

Type:

int

basis()[source]

Function to take an array: valid(x,y), where x and y are numpy arrays, and return an array with one extra axis (at the end) giving the basis mode index. Should be replaced when you inherit.

valid()[source]

Function to take an array: valid(x,y), where x and y are numpy arrays, and return a Boolean numpy array of whether it is valid. Should be replaced when you inherit.

N = 1[source]
basis(x, y)[source]

Dummy basis function (all 1’s).

Parameters:
  • x (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

  • y (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

Returns:

Basis function array at these points; shape is np.shape(x) + (N,), where N is the number of basis functions.

Return type:

np.ndarray of float

valid(x, y)[source]

Dummy valid function (all True).

Parameters:
  • x (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

  • y (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

Returns:

True if valid, False if not; shape is the same as x.

Return type:

np.ndarray of bool

class ZernikeBasis(radius, nmax, skip=0)[source]

Bases: _FigureBasis

Zernike basis set.

Parameters:
  • radius (float) – The maximum radius.

  • nmax (int) – The maximum Zernike order.

  • skip (int, optional) – If specified, skip orders below this value (e.g., skip=1 to not use piston).

radius[source]
nmax[source]
skip = 0[source]
N[source]
basis(x, y)[source]

Zernike basis functions.

These are normalized in a circle of radius self.radius.

Parameters:
  • x (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

  • y (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

Returns:

Basis function array at these points; shape is np.shape(x) + (N,), where N is the number of basis functions.

Return type:

np.ndarray of float

valid(x, y)[source]

Valid function.

This is True for points in a circle of radius self.radius.

Parameters:
  • x (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

  • y (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

Returns:

True if valid, False if not; shape is the same as x.

Return type:

np.ndarray of bool

class LegendreBasis(bbox, nmax_x, nmax_y, skip=0)[source]

Bases: _FigureBasis

Legendre basis set.

Parameters:
  • bbox (array-like of float) – The bounding box, in the form [xmin, xmax, ymin, ymax].

  • nmax_x (int) – The maximum Legendre order on each axis.

  • nmax_y (int) – The maximum Legendre order on each axis.

  • skip (int, optional) – Skip modes below this order.

xmin[source]
xmax[source]
ymin[source]
ymax[source]
nmax_x[source]
nmax_y[source]
skip = 0[source]
N[source]
basis(x, y)[source]

The Legendre basis functions.

These are organized by order in x (outer loop) and y (inner loop), and are normalized to rms=1.

Parameters:
  • x (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

  • y (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

Returns:

Basis function array at these points; shape is np.shape(x) + (N,), where N is the number of basis functions.

Return type:

np.ndarray of float

valid(x, y)[source]

Valid function.

This is True for points in a circle of radius self.radius.

Parameters:
  • x (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

  • y (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

Returns:

True if valid, False if not; shape is the same as x.

Return type:

np.ndarray of bool

class LegendreBasisMaxOrder(bbox, nmax, skip=0)[source]

Bases: _FigureBasis

Legendre basis set with maximum order.

Parameters:
  • bbox (array-like of float) – The bounding box, in the form [xmin, xmax, ymin, ymax].

  • nmax (int) – The maximum Legendre order (total).

  • skip (int, optional) – Skip modes below this order.

xmin[source]
xmax[source]
ymin[source]
ymax[source]
nmax[source]
skip = 0[source]
N[source]
basis(x, y)[source]

The Legendre basis functions.

These are organized by order in x (outer loop) and y (inner loop), and are normalized to rms=1.

Parameters:
  • x (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

  • y (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

Returns:

Basis function array at these points; shape is np.shape(x) + (N,), where N is the number of basis functions.

Return type:

np.ndarray of float

valid(x, y)[source]

Valid function.

This is True for points in a circle of radius self.radius.

Parameters:
  • x (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

  • y (np.ndarray of float) – The x and y coordinates of the points to evaluate. These should be the same shape.

Returns:

True if valid, False if not; shape is the same as x.

Return type:

np.ndarray of bool

class RomanBasisSet(pars)[source]

Class to build a table of basis sets from a dictionary.

Parameters:

pars (dict) – The parameter dictionary. See below for parameters.

basis[source]

The basis functions (augmented with a start key for which index they start with).

Type:

_FigureBasis

N

Number of basis modes for the whole system.

Type:

int

Notes

The following parameters (nested if indicated) are allowed in pars:

  • M1 : primary mirror - ORDER : Zernike order

basis[source]
__call__()[source]

Sets up the parameter mapping.

basis_set[source]