psfsim.aberration_models

Aberration models.

Attributes

fratio

Functions

aberration_gradients([use_filter, nn, ...])

Build a table of the derivatives of the wavefront error with respect to each surface mode.

aberration_transfer_matrix([use_filter, nn, ...])

Computes the transfer matrix from surface distortion modes to Zernikes.

aberration_transfer_matrix_svd([use_filter, nn, n_zernike])

Computes the SVD of the transfer matrix from surface distortion modes to Zernikes.

extract_basis_coefs(infile, use_filter[, nn, smin, ...])

Computes basis coefficients from a Zernike file.

display_aberration_gradients(outfile)

Save aberration gradients as a FITS file.

Module Contents

fratio = 8.0[source]
aberration_gradients(use_filter='W', nn=128, subtract_offset=False, mask=False)[source]

Build a table of the derivatives of the wavefront error with respect to each surface mode.

Parameters:
  • use_filter (str, optional) – Which filter to use.

  • nn (int, optional) – What size pupil array to use.

  • subtract_offset (bool, optional) – Whether to subtract the Z1 mode (which has no effect on the PSF).

  • mask (bool, optional) – Whether to null out masked regions.

Returns:

A table of sensitivities of OPD to each surface error mode. The shape is (number of field points, nn, nn, number of basis modes).

Reminder that this can be huge!

Return type:

np.ndarray

aberration_transfer_matrix(use_filter='W', nn=128, n_zernike=22, outdiagnostic=None)[source]

Computes the transfer matrix from surface distortion modes to Zernikes.

Parameters:
  • use_filter (str, optional) – Which filter to use.

  • nn (int, optional) – What size pupil array to use.

  • n_zernike (int, optional) – How many Zernikes to use?

  • outdiagnostic (str, optional) – Output FITS file for diagnostics (for debugging only).

Returns:

  • transfer (np.ndarray) – The transfer matrix, shape (number of field points, n_zernike, number of basis modes).

  • s_decomp (np.ndarray) – The decomposition of the ray-traced design wavefront, shape (number of field points, n_zernike). The return value is in Poppy OPD sign convention (negative of the path length difference).

aberration_transfer_matrix_svd(use_filter='W', nn=128, n_zernike=22)[source]

Computes the SVD of the transfer matrix from surface distortion modes to Zernikes.

Parameters:
  • use_filter (str, optional) – Which filter to use.

  • nn (int, optional) – What size pupil array to use.

  • n_zernike (int, optional) – How many Zernikes to use?

  • outdiagnostic (str, optional) – Output FITS file for diagnostics (for debugging only).

Returns:

U, S, Vh – The SVD of the transfer matrix:

  • U has dimension (number of field points * n_zernike, nbasis)

  • S has length nbasis

  • Vh has dimension (nbasis, nbasis)

The transfer matrix is U @ diag(S) @ Vh.

Return type:

np.ndarray

extract_basis_coefs(infile, use_filter, nn=128, smin=0.01, pars_input=None, flip_y=True, nmin=None, nmax=None, c=3, verbose=True, return_coefs=False)[source]

Computes basis coefficients from a Zernike file.

Parameters:
  • infile (str) – The input Zernike file to read. This should be a .csv file.

  • use_filter (str) – The filter to use (1-character string).

  • nn (int, optional) – Grid size to use for the Zernikes.

  • smin (float, optional) – The minimum singular value to invert.

  • pars_input (np.ndarray, optional) – If provided, take this set of instrument parameters as an initial condition; default is all 0’s.

  • flip_y (bool, optional) – Whether to flip the Y-axis of the input Zernikes (useful for WFI-local vs FPA coordinates).

  • nmin (int, optional) – Minimum and maximum coefficient indices to fit (otherwise starts from pars_input).

  • nmax (int, optional) – Minimum and maximum coefficient indices to fit (otherwise starts from pars_input).

  • c (int, optional) – Number of Zernike modes to exclude from the fit. This is usually either 3 (default, skip piston and tip+tilt) or 1 (skip piston but include tip+tilt).

  • verbose (bool, optional) – Whether to talk a lot to the output.

  • return_coefs (bool, optional) – If set to True, returns the matrix of coefficients for the difference between the astrometric model computed by PSFSim and the table provided by the Project.

Returns:

If return_coefs is False (default), this is a 1D array of the inferred basis coefficients.

If return_coefs is True, this is a 2D array of shape (3, 3) for the residual of the FPA positions:

[tabulated - predicted] = coefs[:2, :] @ [predicted] + coefs[-1, :]

where the 2nd axis has order x, y, focus.

Return type:

np.ndarray

display_aberration_gradients(outfile)[source]

Save aberration gradients as a FITS file.

Parameters:

outfile (str) – Where to write.