ZernikeVector¶
- class mmtwfs.zernike.ZernikeVector(coeffs=[], modestart=2, normalized=False, zmap=None, units=Unit('nm'), errorbars=None, **kwargs)[source] [edit on github]¶
Bases:
collections.abc.MutableMappingClass to wrap and visualize a vector of Zernike polynomial coefficients. We build upon a
MutableMappingclass to provide a way to access/modify coefficients in a dict-like way.- Attributes
- modestartint
Noll mode number of the first included mode.
- normalizedbool
If True, coefficients are normalized to unit variance. If False, coefficients reflect the phase amplitude of the mode.
- coeffsdict
Contains the Zernike coefficients with keys of form “Z%02d”
- ignoreddict
Used to store coefficients that are temporarily ignored. Managed via
self.ignore()andself.restore().
- Parameters
- coeffslist-like (default: [])
Vector of coefficients starting from modestart.
- modestartint (default: 2)
Noll mode number of the first included mode.
- normalizedbool (default: False)
If True, coefficients are normalized to unit variance (Noll coefficients). If False, coefficients reflect the phase amplitude of the mode (fringe coefficients).
- zmapdict
When loading coefficients from an array this maps the coefficient keys to array indices.
- units
IrreducibleUnitorPrefixUnit(default:u.nm- nanometers) Units of the coefficients.
- errorbars = dict (default: None)
Uncertainties for each coefficient.
- **kwargskwargs
Keyword arguments for setting terms individually, e.g. Z09=10.0.
Attributes Summary
Return coefficients in the form of a 1D np.ndarray.
Return coefficients in the form of a 1D np.ndarray with each coefficient normalized to unit variance for its mode.
Return the peak-to-valley amplitude of the Zernike set.
Return the RMS phase displacement of the Zernike set.
Return the coefficient units currently being used.
Methods Summary
bar_chart([residual, total, max_c, title, ...])Plot a bar chart of the coefficients and, optionally, a residual amount not included in the coefficients.
copy()Make a new ZernikeVector with the same configuration and coefficients
Restore normalized coefficients to fringe coefficients.
frac_error([key])Calculate fractional size of the error bar for mode, key.
fringe_bar_chart([total, max_c, title, ...])Plot a bar chart of the fringe amplitudes of the coefficients
from_array(coeffs[, zmap, modestart, ...])Load coefficients from a provided list/array starting from modestart.
ignore(key)Set coefficient, key, aside for later recall if needed.
label(key)If defined, return the descriptive label for mode, 'key'
load([filename])Load ZernikeVector data from JSON format.
load_lmfit(fit_report)Load information from a lmfit.minimizer.MinimizerResult that is output from a wavefront fit.
Normalize coefficients to unit variance for each mode.
phase_map([n])Calculate a 2D polar map of total phase displacements with sampling of n points along rho and phi vectors.
plot_map()Plot 2D map of total phase displacement.
Plot total phase displacement as a 3D surface along with 2D contour map.
pretty_print([last])Overload __repr__ to print out coefficients in a nice way including units and descriptive labels.
restore(key)Restore coefficient, key, back into set of coefficients.
rotate([angle])Rotate the ZernikeVector by an angle.
save([filename])Save Zernike vector to JSON format to retain units and normalization info.
shortlabel(key)If defined, return the short label for mode, 'key'
total_phase(rho, phi)Calculate total phase displacement at polar coordinates (rho, phi).
Attributes Documentation
- array¶
Return coefficients in the form of a 1D np.ndarray.
- norm_array¶
Return coefficients in the form of a 1D np.ndarray with each coefficient normalized to unit variance for its mode.
- peak2valley¶
Return the peak-to-valley amplitude of the Zernike set.
- rms¶
Return the RMS phase displacement of the Zernike set.
- units¶
Return the coefficient units currently being used.
Methods Documentation
- bar_chart(residual=None, total=True, max_c=<Quantity 500. nm>, title=None, last_mode=None)[source] [edit on github]¶
Plot a bar chart of the coefficients and, optionally, a residual amount not included in the coefficients.
- copy()[source] [edit on github]¶
Make a new ZernikeVector with the same configuration and coefficients
- denormalize()[source] [edit on github]¶
Restore normalized coefficients to fringe coefficients.
- frac_error(key=None)[source] [edit on github]¶
Calculate fractional size of the error bar for mode, key.
- fringe_bar_chart(total=True, max_c=<Quantity 2000. nm>, title=None, last_mode=None)[source] [edit on github]¶
Plot a bar chart of the fringe amplitudes of the coefficients
- from_array(coeffs, zmap=None, modestart=None, errorbars=None, normalized=False)[source] [edit on github]¶
Load coefficients from a provided list/array starting from modestart. Array is assumed to start from self.modestart if modestart is not provided.
- ignore(key)[source] [edit on github]¶
Set coefficient, key, aside for later recall if needed.
- label(key)[source] [edit on github]¶
If defined, return the descriptive label for mode, ‘key’
- load(filename='zernike.json')[source] [edit on github]¶
Load ZernikeVector data from JSON format.
- load_lmfit(fit_report)[source] [edit on github]¶
Load information from a lmfit.minimizer.MinimizerResult that is output from a wavefront fit. If there are reported errorbars, populate those, too.
- normalize()[source] [edit on github]¶
Normalize coefficients to unit variance for each mode.
- phase_map(n=400)[source] [edit on github]¶
Calculate a 2D polar map of total phase displacements with sampling of n points along rho and phi vectors.
- plot_map()[source] [edit on github]¶
Plot 2D map of total phase displacement.
- plot_surface()[source] [edit on github]¶
Plot total phase displacement as a 3D surface along with 2D contour map.
- pretty_print(last=22)[source] [edit on github]¶
Overload __repr__ to print out coefficients in a nice way including units and descriptive labels.
- restore(key)[source] [edit on github]¶
Restore coefficient, key, back into set of coefficients.
- rotate(angle=<Quantity 0. deg>)[source] [edit on github]¶
Rotate the ZernikeVector by an angle. Rotation matrix algorithm taken from https://arxiv.org/pdf/1302.7106.pdf.
- save(filename='zernike.json')[source] [edit on github]¶
Save Zernike vector to JSON format to retain units and normalization info.
- shortlabel(key)[source] [edit on github]¶
If defined, return the short label for mode, ‘key’
- total_phase(rho, phi)[source] [edit on github]¶
Calculate total phase displacement at polar coordinates (rho, phi).