opd_expand

poppy.zernike.opd_expand(opd, aperture=None, nterms=15, basis=<function zernike_basis>, **kwargs)[source]

Given a wavefront OPD map, return the list of coefficients in a given basis set (by default, Zernikes) that best fit the OPD map.

Note that this implementation of the function treats the Zernikes as an orthonormal basis, which is only true on the unobscured unit circle. See also opd_expand_nonorthonormal for an alternative approach for basis vectors that are not orthonormal, or opd_expand_segments for basis vectors defined over physically disjoint segments.

opd : 2D numpy.ndarray
The wavefront OPD map to expand in terms of the requested basis. Must be square.
aperture : 2D numpy.ndarray, optional
Aperture mask for which pixels are included within the aperture. NOTE - this is handed through to the basis function (see basis parameter) which is responsible for implementing this masking, if appropriate. All positive nonzero values are considered within the aperture; any pixels with zero, negative, or NaN values will be considered outside the aperture, and set equal to the ‘outside’ parameter value. If this parameter is not set, the aperture will be inferred from the finite (i.e. non-NaN) pixels in the OPD array.
nterms : int
Number of terms to use. (Default: 15)
basis : callable, optional
Callable (e.g. a function) that generates a sequence of basis arrays given arguments nterms, npix, and outside. Default is poppy.zernike.zernike_basis.

Additional keyword arguments to this function are passed through to the basis callable.

Note: Recovering coefficients used to generate synthetic/test data depends greatly on the sampling (as one might expect). Generating test data using zernike_basis with npix=256 and passing the result through opd_expand reproduces the input coefficients within <0.1%.

coeffs : list
List of coefficients (of length nterms) from which the input OPD map can be constructed in the given basis. (No additional unit conversions are performed. If the input wavefront is in waves, coeffs will be in waves.) Note that the first coefficient (element 0 in Python indexing) corresponds to the Z=1 Zernike piston term, and so on.