prysm.zernike

Zernike functions.

prysm.zernike.piston(rho, phi)

Zernike Piston.

prysm.zernike.tip(rho, phi)

Zernike Tilt-Y.

prysm.zernike.tilt(rho, phi)

Zernike Tilt-X.

prysm.zernike.defocus(rho, phi)

Zernike defocus.

prysm.zernike.primary_astigmatism_00(rho, phi)

Zernike primary astigmatism 0°.

prysm.zernike.primary_astigmatism_45(rho, phi)

Zernike primary astigmatism 45°.

prysm.zernike.primary_coma_y(rho, phi)

Zernike primary coma Y.

prysm.zernike.primary_coma_x(rho, phi)

Zernike primary coma X.

prysm.zernike.primary_spherical(rho, phi)

Zernike primary Spherical.

prysm.zernike.primary_trefoil_y(rho, phi)

Zernike primary trefoil Y.

prysm.zernike.primary_trefoil_x(rho, phi)

Zernike primary trefoil X.

prysm.zernike.secondary_astigmatism_00(rho, phi)

Zernike secondary astigmatism 0°.

prysm.zernike.secondary_astigmatism_45(rho, phi)

Zernike secondary astigmatism 45°.

prysm.zernike.secondary_coma_y(rho, phi)

Zernike secondary coma Y.

prysm.zernike.secondary_coma_x(rho, phi)

Zernike secondary coma X.

prysm.zernike.secondary_spherical(rho, phi)

Zernike secondary spherical.

prysm.zernike.primary_tetrafoil_y(rho, phi)

Zernike primary tetrafoil Y.

prysm.zernike.primary_tetrafoil_x(rho, phi)

Zernike primary tetrafoil X.

prysm.zernike.secondary_trefoil_y(rho, phi)

Zernike secondary trefoil Y.

prysm.zernike.secondary_trefoil_x(rho, phi)

Zernike secondary trefoil X.

prysm.zernike.tertiary_astigmatism_00(rho, phi)

Zernike tertiary astigmatism 0°.

prysm.zernike.tertiary_astigmatism_45(rho, phi)

Zernike tertiary astigmatism 45°.

prysm.zernike.tertiary_coma_y(rho, phi)

Zernike tertiary coma Y.

prysm.zernike.tertiary_coma_x(rho, phi)

Zernike tertiary coma X.

prysm.zernike.tertiary_spherical(rho, phi)

Zernike tertiary spherical.

prysm.zernike.primary_pentafoil_y(rho, phi)

Zernike primary pentafoil Y.

prysm.zernike.primary_pentafoil_x(rho, phi)

Zernike primary pentafoil X.

prysm.zernike.secondary_tetrafoil_y(rho, phi)

Zernike secondary tetrafoil Y.

prysm.zernike.secondary_tetrafoil_x(rho, phi)

Zernike secondary tetrafoil X.

prysm.zernike.tertiary_trefoil_y(rho, phi)

Zernike tertiary trefoil Y.

prysm.zernike.tertiary_trefoil_x(rho, phi)

Zernike tertiary trefoil X.

prysm.zernike.quaternary_astigmatism_00(rho, phi)

Zernike quaternary astigmatism 0°.

prysm.zernike.quaternary_astigmatism_45(rho, phi)

Zernike quaternary astigmatism 45°.

prysm.zernike.quaternary_coma_y(rho, phi)

Zernike quaternary coma Y.

prysm.zernike.quaternary_coma_x(rho, phi)

Zernike quaternary coma X.

prysm.zernike.quaternary_spherical(rho, phi)

Zernike quaternary spherical.

prysm.zernike.primary_hexafoil_y(rho, phi)

Zernike primary hexafoil Y.

prysm.zernike.primary_hexafoil_x(rho, phi)

Zernike primary hexafoil X.

prysm.zernike.secondary_pentafoil_y(rho, phi)

Zernike secondary pentafoil Y.

prysm.zernike.secondary_pentafoil_x(rho, phi)

Zernike secondary pentafoil X.

prysm.zernike.tertiary_tetrafoil_y(rho, phi)

Zernike tertiary tetrafoil Y.

prysm.zernike.tertiary_tetrafoil_x(rho, phi)

Zernike tertiary tetrafoil X.

prysm.zernike.quaternary_trefoil_y(rho, phi)

Zernike quaternary trefoil Y.

prysm.zernike.quaternary_trefoil_x(rho, phi)

Zernike quaternary trefoil X.

prysm.zernike.quinternary_astigmatism_00(rho, phi)

Zernike quinternary astigmatism 0°.

prysm.zernike.quinternary_astigmatism_45(rho, phi)

Zernike quinternary astigmatism 45°.

prysm.zernike.quinternary_coma_y(rho, phi)

Zernike quinternary coma Y.

prysm.zernike.quinternary_coma_x(rho, phi)

Zernike quinternary coma X.

prysm.zernike.quinternary_spherical(rho, phi)

Zernike quinternary spherical.

prysm.zernike.primary_septafoil_y(rho, phi)

Zernike primary septafoil.

prysm.zernike.primary_septafoil_x(rho, phi)

Zernike primary septafoil.

prysm.zernike.compfunc(rho, phi)

Zernike primary septafoil.

prysm.zernike.change_backend(to)

Change the backend between cuda/cupy and CPU.

prysm.zernike.zernikename(idx, base, map_)

Return the name of a Fringe Zernike with the given index and base.

prysm.zernike.zernikes_to_magnitude_angle(coefs, namer)

Convert Fringe Zernike polynomial set to a magnitude and phase representation.

class prysm.zernike.ZCache

Bases: object

Cache of Zernike terms evaluated over the unit circle.

get_zernike(number, norm, samples)

Get an array of phase values for a given index, norm, and number of samples.

clear(*args)

Empty the cache.

class prysm.zernike.BaseZernike(*args, **kwargs)

Bases: prysm.pupil.Pupil

Basic class implementing Zernike features.

build()

Use the wavefront coefficients stored in this class instance to build a wavefront model.

Returns

  • self.phase (numpy.ndarray) – arrays containing the phase associated with the pupil

  • self.fcn (numpy.ndarray) – array containing the wavefunction of the pupil plane

top_n(n=5)

Identify the top n terms in the wavefront.

Parameters

n (int, optional) – identify the top n terms.

Returns

list of tuples (magnitude, index, term)

Return type

list

magnitudes

Return the magnitude and angles of the zernike components in this wavefront.

names

Names of the terms in self.

barplot(orientation='h', buffer=1, zorder=3, number=True, offset=0, width=0.8, fig=None, ax=None)

Create a barplot of coefficients and their names.

Parameters
  • orientation (str, {‘h’, ‘v’, ‘horizontal’, ‘vertical’}) – orientation of the plot

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • number (bool, optional) – if True, plot numbers along the y=0 line showing indices

  • offset (float, optional) – offset to apply to bars, useful for before/after Zernike breakdowns

  • width (float, optional) – width of bars, useful for before/after Zernike breakdowns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

barplot_magnitudes(orientation='h', sort=False, buffer=1, zorder=3, offset=0, width=0.8, fig=None, ax=None)

Create a barplot of magnitudes of coefficient pairs and their names.

E.g., astigmatism will get one bar.

Parameters
  • orientation (str, {‘h’, ‘v’, ‘horizontal’, ‘vertical’}) – orientation of the plot

  • sort (bool, optional) – whether to sort the zernikes in descending order

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • offset (float, optional) – offset to apply to bars, useful for before/after Zernike breakdowns

  • width (float, optional) – width of bars, useful for before/after Zernike breakdowns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

barplot_topn(n=5, orientation='h', buffer=1, zorder=3, fig=None, ax=None)

Plot the top n terms in the wavefront.

Parameters
  • n (int, optional) – plot the top n terms.

  • orientation (str, {‘h’, ‘v’, ‘horizontal’, ‘vertical’}) – orientation of the plot

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

truncate(n)

Truncate the wavefront to the first n terms.

Parameters

n (int) – number of terms to keep.

Returns

modified FringeZernike instance.

Return type

self

truncate_topn(n)

Truncate the pupil to only the top n terms.

Parameters

n (int) – number of parameters to keep

Returns

modified FringeZernike instance.

Return type

self

Sa

Sa phase error. DIN/ISO Sa.

center_x

Center “pixel” in x.

center_y

Center “pixel” in y.

change_phase_unit(to, inplace=True)

Change the units used to describe the phase.

Parameters
  • to (str) – new unit, a member of OpticalPhase.units.keys()

  • inplace (bool, optional) – whether to change self.phase, if False, returns updated phase, if True, returns self.

Returns

  • `new_phase` (np.ndarray) – new phase data

  • OR

  • `self` (OpticalPhase) – self

change_spatial_unit(to, inplace=True)

Change the units used to describe the spatial dimensions.

Parameters
  • to (str) – new unit, a member of OpticalPhase.units.keys()

  • inplace (bool, optional) – whether to change self.x and self.y. If False, returns updated phase, if True, returns self

Returns

  • `new_ux` (np.ndarray) – new ordinate x axis

  • `new_uy` (np.ndarray) – new ordinate y axis

  • OR

  • `self` (OpticalPhase) – self

copy()

Return a (deep) copy of this instance.

diameter

Greater of (self.diameter_x, self.diameter_y).

diameter_x

Diameter of the data in x.

diameter_y

Diameter of the data in y.

fcn

Complex wavefunction associated with the pupil.

static from_interferogram(interferogram, wvl=None)

Create a new Pupil instance from an interferogram.

Parameters
  • interferogram (Interferogram) – an interferogram object

  • wvl (float, optional) – wavelength of light, in micrometers, if not present in interferogram.meta

Returns

new Pupil instance

Return type

Pupil

Raises

ValueError – wavelength not present

interferogram(visibility=1, passes=2, interp_method='lanczos', fig=None, ax=None)

Create an interferogram of the Pupil.

Parameters
  • visibility (float) – Visibility of the interferogram

  • passes (float) – Number of passes (double-pass, quadra-pass, etc.)

  • interp_method (str, optional) – interpolation method, passed directly to matplotlib

  • fig (matplotlib.figure.Figure, optional) – Figure to draw plot in

  • ax (matplotlib.axes.Axis) – Axis to draw plot in

Returns

  • fig (matplotlib.figure.Figure, optional) – Figure containing the plot

  • ax (matplotlib.axes.Axis, optional:) – Axis containing the plot

mask(mask, target, nanify=True)

Apply a mask to the pupil.

Used to implement vignetting, chief ray angles, etc.

Parameters
  • mask (str or numpy.ndarray) – if a string, uses geometry.mcache for high speed access to a mask with a given shape, e.g. mask=’circle’ or mask=’hexagon’. If an ndarray, directly use the mask.

  • target (str, {‘phase’, ‘fcn’, ‘both’}) – which array to mask

  • nanify (bool, optional) – if True, make (target) equal to NaN where the mask is zero.

Returns

self, the pupil instance

Return type

Pupil

phase_unit

Unit used to describe the optical phase.

plot2d(cmap='inferno', clim=(None, None), interp_method='lanczos', show_colorbar=True, fig=None, ax=None)

Plot the phase in 2D.

Parameters
  • cmap (str) – colormap to use, passed directly to matplotlib

  • interp_method (str, optional) – interpolation method to use, passed directly to matplotlib

  • show_colorbar (bool, optional) – whether to draw the colorbar

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

plot_slice_xy(lw=3, zorder=3, fig=None, ax=None)

Create a plot of slices through the X and Y axes of the Pupil.

Parameters
  • lw (float, optional) – line width

  • zorder (int, optional) – zorder

  • fig (matplotlib.figure.Figure, optional) – Figure to draw plot in

  • ax (matplotlib.axes.Axis) – Axis to draw plot in

Returns

  • fig (matplotlib.figure.Figure, optional) – Figure containing the plot

  • ax (matplotlib.axes.Axis, optional:) – Axis containing the plot

pv

Peak-to-Valley phase error. DIN/ISO St.

rms

RMS phase error. DIN/ISO Sq.

sample_spacing

center-to-center sample spacing.

samples_x

Number of samples in the x dimension.

samples_y

Number of samples in the y dimension.

semidiameter

Half of self.diameter.

shape

Proxy to phase or data shape.

size

Proxy to phase or data size.

slice_x

Retrieve a slice through the X axis of the phase.

Returns

  • self.unit (numpy.ndarray) – ordinate axis

  • slice of self.phase or self.data (numpy.ndarray)

slice_y

Retrieve a slice through the Y axis of the phase.

Returns

  • self.unit (numpy.ndarray) – ordinate axis

  • slice of self.phase or self.data (numpy.ndarray)

spatial_unit

Unit used to describe the spatial phase.

std

Standard deviation of phase error.

strehl

Strehl ratio of the pupil.

class prysm.zernike.FringeZernike(*args, **kwargs)

Bases: prysm.zernike.BaseZernike

Fringe Zernike description of an optical pupil.

Sa

Sa phase error. DIN/ISO Sa.

barplot(orientation='h', buffer=1, zorder=3, number=True, offset=0, width=0.8, fig=None, ax=None)

Create a barplot of coefficients and their names.

Parameters
  • orientation (str, {‘h’, ‘v’, ‘horizontal’, ‘vertical’}) – orientation of the plot

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • number (bool, optional) – if True, plot numbers along the y=0 line showing indices

  • offset (float, optional) – offset to apply to bars, useful for before/after Zernike breakdowns

  • width (float, optional) – width of bars, useful for before/after Zernike breakdowns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

barplot_magnitudes(orientation='h', sort=False, buffer=1, zorder=3, offset=0, width=0.8, fig=None, ax=None)

Create a barplot of magnitudes of coefficient pairs and their names.

E.g., astigmatism will get one bar.

Parameters
  • orientation (str, {‘h’, ‘v’, ‘horizontal’, ‘vertical’}) – orientation of the plot

  • sort (bool, optional) – whether to sort the zernikes in descending order

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • offset (float, optional) – offset to apply to bars, useful for before/after Zernike breakdowns

  • width (float, optional) – width of bars, useful for before/after Zernike breakdowns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

barplot_topn(n=5, orientation='h', buffer=1, zorder=3, fig=None, ax=None)

Plot the top n terms in the wavefront.

Parameters
  • n (int, optional) – plot the top n terms.

  • orientation (str, {‘h’, ‘v’, ‘horizontal’, ‘vertical’}) – orientation of the plot

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

build()

Use the wavefront coefficients stored in this class instance to build a wavefront model.

Returns

  • self.phase (numpy.ndarray) – arrays containing the phase associated with the pupil

  • self.fcn (numpy.ndarray) – array containing the wavefunction of the pupil plane

center_x

Center “pixel” in x.

center_y

Center “pixel” in y.

change_phase_unit(to, inplace=True)

Change the units used to describe the phase.

Parameters
  • to (str) – new unit, a member of OpticalPhase.units.keys()

  • inplace (bool, optional) – whether to change self.phase, if False, returns updated phase, if True, returns self.

Returns

  • `new_phase` (np.ndarray) – new phase data

  • OR

  • `self` (OpticalPhase) – self

change_spatial_unit(to, inplace=True)

Change the units used to describe the spatial dimensions.

Parameters
  • to (str) – new unit, a member of OpticalPhase.units.keys()

  • inplace (bool, optional) – whether to change self.x and self.y. If False, returns updated phase, if True, returns self

Returns

  • `new_ux` (np.ndarray) – new ordinate x axis

  • `new_uy` (np.ndarray) – new ordinate y axis

  • OR

  • `self` (OpticalPhase) – self

copy()

Return a (deep) copy of this instance.

diameter

Greater of (self.diameter_x, self.diameter_y).

diameter_x

Diameter of the data in x.

diameter_y

Diameter of the data in y.

fcn

Complex wavefunction associated with the pupil.

static from_interferogram(interferogram, wvl=None)

Create a new Pupil instance from an interferogram.

Parameters
  • interferogram (Interferogram) – an interferogram object

  • wvl (float, optional) – wavelength of light, in micrometers, if not present in interferogram.meta

Returns

new Pupil instance

Return type

Pupil

Raises

ValueError – wavelength not present

interferogram(visibility=1, passes=2, interp_method='lanczos', fig=None, ax=None)

Create an interferogram of the Pupil.

Parameters
  • visibility (float) – Visibility of the interferogram

  • passes (float) – Number of passes (double-pass, quadra-pass, etc.)

  • interp_method (str, optional) – interpolation method, passed directly to matplotlib

  • fig (matplotlib.figure.Figure, optional) – Figure to draw plot in

  • ax (matplotlib.axes.Axis) – Axis to draw plot in

Returns

  • fig (matplotlib.figure.Figure, optional) – Figure containing the plot

  • ax (matplotlib.axes.Axis, optional:) – Axis containing the plot

magnitudes

Return the magnitude and angles of the zernike components in this wavefront.

mask(mask, target, nanify=True)

Apply a mask to the pupil.

Used to implement vignetting, chief ray angles, etc.

Parameters
  • mask (str or numpy.ndarray) – if a string, uses geometry.mcache for high speed access to a mask with a given shape, e.g. mask=’circle’ or mask=’hexagon’. If an ndarray, directly use the mask.

  • target (str, {‘phase’, ‘fcn’, ‘both’}) – which array to mask

  • nanify (bool, optional) – if True, make (target) equal to NaN where the mask is zero.

Returns

self, the pupil instance

Return type

Pupil

names

Names of the terms in self.

phase_unit

Unit used to describe the optical phase.

plot2d(cmap='inferno', clim=(None, None), interp_method='lanczos', show_colorbar=True, fig=None, ax=None)

Plot the phase in 2D.

Parameters
  • cmap (str) – colormap to use, passed directly to matplotlib

  • interp_method (str, optional) – interpolation method to use, passed directly to matplotlib

  • show_colorbar (bool, optional) – whether to draw the colorbar

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

plot_slice_xy(lw=3, zorder=3, fig=None, ax=None)

Create a plot of slices through the X and Y axes of the Pupil.

Parameters
  • lw (float, optional) – line width

  • zorder (int, optional) – zorder

  • fig (matplotlib.figure.Figure, optional) – Figure to draw plot in

  • ax (matplotlib.axes.Axis) – Axis to draw plot in

Returns

  • fig (matplotlib.figure.Figure, optional) – Figure containing the plot

  • ax (matplotlib.axes.Axis, optional:) – Axis containing the plot

pv

Peak-to-Valley phase error. DIN/ISO St.

rms

RMS phase error. DIN/ISO Sq.

sample_spacing

center-to-center sample spacing.

samples_x

Number of samples in the x dimension.

samples_y

Number of samples in the y dimension.

semidiameter

Half of self.diameter.

shape

Proxy to phase or data shape.

size

Proxy to phase or data size.

slice_x

Retrieve a slice through the X axis of the phase.

Returns

  • self.unit (numpy.ndarray) – ordinate axis

  • slice of self.phase or self.data (numpy.ndarray)

slice_y

Retrieve a slice through the Y axis of the phase.

Returns

  • self.unit (numpy.ndarray) – ordinate axis

  • slice of self.phase or self.data (numpy.ndarray)

spatial_unit

Unit used to describe the spatial phase.

std

Standard deviation of phase error.

strehl

Strehl ratio of the pupil.

top_n(n=5)

Identify the top n terms in the wavefront.

Parameters

n (int, optional) – identify the top n terms.

Returns

list of tuples (magnitude, index, term)

Return type

list

truncate(n)

Truncate the wavefront to the first n terms.

Parameters

n (int) – number of terms to keep.

Returns

modified FringeZernike instance.

Return type

self

truncate_topn(n)

Truncate the pupil to only the top n terms.

Parameters

n (int) – number of parameters to keep

Returns

modified FringeZernike instance.

Return type

self

class prysm.zernike.NollZernike(*args, **kwargs)

Bases: prysm.zernike.BaseZernike

Noll Zernike deswcription of an optical pupil.

Sa

Sa phase error. DIN/ISO Sa.

barplot(orientation='h', buffer=1, zorder=3, number=True, offset=0, width=0.8, fig=None, ax=None)

Create a barplot of coefficients and their names.

Parameters
  • orientation (str, {‘h’, ‘v’, ‘horizontal’, ‘vertical’}) – orientation of the plot

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • number (bool, optional) – if True, plot numbers along the y=0 line showing indices

  • offset (float, optional) – offset to apply to bars, useful for before/after Zernike breakdowns

  • width (float, optional) – width of bars, useful for before/after Zernike breakdowns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

barplot_magnitudes(orientation='h', sort=False, buffer=1, zorder=3, offset=0, width=0.8, fig=None, ax=None)

Create a barplot of magnitudes of coefficient pairs and their names.

E.g., astigmatism will get one bar.

Parameters
  • orientation (str, {‘h’, ‘v’, ‘horizontal’, ‘vertical’}) – orientation of the plot

  • sort (bool, optional) – whether to sort the zernikes in descending order

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • offset (float, optional) – offset to apply to bars, useful for before/after Zernike breakdowns

  • width (float, optional) – width of bars, useful for before/after Zernike breakdowns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

barplot_topn(n=5, orientation='h', buffer=1, zorder=3, fig=None, ax=None)

Plot the top n terms in the wavefront.

Parameters
  • n (int, optional) – plot the top n terms.

  • orientation (str, {‘h’, ‘v’, ‘horizontal’, ‘vertical’}) – orientation of the plot

  • buffer (float, optional) – buffer to use around the left and right (or top and bottom) bars

  • zorder (int, optional) – zorder of the bars. Use zorder > 3 to put bars in front of gridlines

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

build()

Use the wavefront coefficients stored in this class instance to build a wavefront model.

Returns

  • self.phase (numpy.ndarray) – arrays containing the phase associated with the pupil

  • self.fcn (numpy.ndarray) – array containing the wavefunction of the pupil plane

center_x

Center “pixel” in x.

center_y

Center “pixel” in y.

change_phase_unit(to, inplace=True)

Change the units used to describe the phase.

Parameters
  • to (str) – new unit, a member of OpticalPhase.units.keys()

  • inplace (bool, optional) – whether to change self.phase, if False, returns updated phase, if True, returns self.

Returns

  • `new_phase` (np.ndarray) – new phase data

  • OR

  • `self` (OpticalPhase) – self

change_spatial_unit(to, inplace=True)

Change the units used to describe the spatial dimensions.

Parameters
  • to (str) – new unit, a member of OpticalPhase.units.keys()

  • inplace (bool, optional) – whether to change self.x and self.y. If False, returns updated phase, if True, returns self

Returns

  • `new_ux` (np.ndarray) – new ordinate x axis

  • `new_uy` (np.ndarray) – new ordinate y axis

  • OR

  • `self` (OpticalPhase) – self

copy()

Return a (deep) copy of this instance.

diameter

Greater of (self.diameter_x, self.diameter_y).

diameter_x

Diameter of the data in x.

diameter_y

Diameter of the data in y.

fcn

Complex wavefunction associated with the pupil.

static from_interferogram(interferogram, wvl=None)

Create a new Pupil instance from an interferogram.

Parameters
  • interferogram (Interferogram) – an interferogram object

  • wvl (float, optional) – wavelength of light, in micrometers, if not present in interferogram.meta

Returns

new Pupil instance

Return type

Pupil

Raises

ValueError – wavelength not present

interferogram(visibility=1, passes=2, interp_method='lanczos', fig=None, ax=None)

Create an interferogram of the Pupil.

Parameters
  • visibility (float) – Visibility of the interferogram

  • passes (float) – Number of passes (double-pass, quadra-pass, etc.)

  • interp_method (str, optional) – interpolation method, passed directly to matplotlib

  • fig (matplotlib.figure.Figure, optional) – Figure to draw plot in

  • ax (matplotlib.axes.Axis) – Axis to draw plot in

Returns

  • fig (matplotlib.figure.Figure, optional) – Figure containing the plot

  • ax (matplotlib.axes.Axis, optional:) – Axis containing the plot

magnitudes

Return the magnitude and angles of the zernike components in this wavefront.

mask(mask, target, nanify=True)

Apply a mask to the pupil.

Used to implement vignetting, chief ray angles, etc.

Parameters
  • mask (str or numpy.ndarray) – if a string, uses geometry.mcache for high speed access to a mask with a given shape, e.g. mask=’circle’ or mask=’hexagon’. If an ndarray, directly use the mask.

  • target (str, {‘phase’, ‘fcn’, ‘both’}) – which array to mask

  • nanify (bool, optional) – if True, make (target) equal to NaN where the mask is zero.

Returns

self, the pupil instance

Return type

Pupil

names

Names of the terms in self.

phase_unit

Unit used to describe the optical phase.

plot2d(cmap='inferno', clim=(None, None), interp_method='lanczos', show_colorbar=True, fig=None, ax=None)

Plot the phase in 2D.

Parameters
  • cmap (str) – colormap to use, passed directly to matplotlib

  • interp_method (str, optional) – interpolation method to use, passed directly to matplotlib

  • show_colorbar (bool, optional) – whether to draw the colorbar

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

Returns

  • fig (matplotlib.figure.Figure) – Figure containing the plot

  • ax (matplotlib.axes.Axis) – Axis containing the plot

plot_slice_xy(lw=3, zorder=3, fig=None, ax=None)

Create a plot of slices through the X and Y axes of the Pupil.

Parameters
  • lw (float, optional) – line width

  • zorder (int, optional) – zorder

  • fig (matplotlib.figure.Figure, optional) – Figure to draw plot in

  • ax (matplotlib.axes.Axis) – Axis to draw plot in

Returns

  • fig (matplotlib.figure.Figure, optional) – Figure containing the plot

  • ax (matplotlib.axes.Axis, optional:) – Axis containing the plot

pv

Peak-to-Valley phase error. DIN/ISO St.

rms

RMS phase error. DIN/ISO Sq.

sample_spacing

center-to-center sample spacing.

samples_x

Number of samples in the x dimension.

samples_y

Number of samples in the y dimension.

semidiameter

Half of self.diameter.

shape

Proxy to phase or data shape.

size

Proxy to phase or data size.

slice_x

Retrieve a slice through the X axis of the phase.

Returns

  • self.unit (numpy.ndarray) – ordinate axis

  • slice of self.phase or self.data (numpy.ndarray)

slice_y

Retrieve a slice through the Y axis of the phase.

Returns

  • self.unit (numpy.ndarray) – ordinate axis

  • slice of self.phase or self.data (numpy.ndarray)

spatial_unit

Unit used to describe the spatial phase.

std

Standard deviation of phase error.

strehl

Strehl ratio of the pupil.

top_n(n=5)

Identify the top n terms in the wavefront.

Parameters

n (int, optional) – identify the top n terms.

Returns

list of tuples (magnitude, index, term)

Return type

list

truncate(n)

Truncate the wavefront to the first n terms.

Parameters

n (int) – number of terms to keep.

Returns

modified FringeZernike instance.

Return type

self

truncate_topn(n)

Truncate the pupil to only the top n terms.

Parameters

n (int) – number of parameters to keep

Returns

modified FringeZernike instance.

Return type

self

prysm.zernike.func(rho, phi)

Zernike primary septafoil.

prysm.zernike.zernikefit(data, x=None, y=None, rho=None, phi=None, terms=16, norm=False, residual=False, round_at=6, map_='fringe')

Fits a number of Zernike coefficients to provided data.

Works by minimizing the mean square error between each coefficient and the given data. The data should be uniformly sampled in an x,y grid.

Parameters
  • data (numpy.ndarray) – data to fit to.

  • x (numpy.ndarray, optional) – x coordinates, same shape as data

  • y (numpy.ndarray, optional) – y coordinates, same shape as data

  • rho (numpy.ndarray, optional) – radial coordinates, same shape as data

  • phi (numpy.ndarray, optional) – azimuthal coordinates, same shape as data

  • terms (int, optional) – number of terms to fit, fits terms 0~terms

  • norm (bool, optional) – if True, normalize coefficients to unit RMS value

  • residual (bool, optional) – if True, return a tuple of (coefficients, residual)

  • round_at (int, optional) – decimal place to round values at.

  • map (str, optional, {‘fringe’, ‘noll’}) – which ordering of Zernikes to use

Returns

  • coefficients (numpy.ndarray) – an array of coefficients matching the input data.

  • residual (float) – RMS error between the input data and the fit.

Raises

ValueError – too many terms requested.