Base Classes

class prysm._richdata.RichData(x, y, data, labels, xy_unit=None, z_unit=None, wavelength=None)

Bases: object

Abstract base class holding some data properties.

shape

Proxy to phase or data shape.

size

Proxy to phase or data size.

samples_x

Number of samples in the x dimension.

samples_y

Number of samples in the y dimension.

sample_spacing

center-to-center sample spacing.

center_x

Center “pixel” in x.

center_y

Center “pixel” in y.

copy()

Return a (deep) copy of this instance.

astype(other_type)

Change this instance of one type into another.

Useful to access methods of the other class.

Parameters

other_type (object) – the name of the other type to “cast” to, e.g. Interferogram. Not a string.

Returns

type-converted to the other type.

Return type

self

change_xy_unit(to, inplace=True)

Change the x/y unit to a new one, scaling the data in the process.

Parameters
  • to (astropy.unit or str) – if not an astropy unit, a string that is a valid attribute of astropy.units.

  • inplace (bool, optional) – if True, returns self. Otherwise returns the modified data.

Returns

  • RichData – self, if inplace=True

  • numpy.ndarray, numpy.ndarray – x, y from self, if inplace=False

change_z_unit(to, inplace=True)

Change the z unit to a new one, scaling the data in the process.

Parameters
  • to (astropy.unit or str) – if not an astropy unit, a string that is a valid attribute of astropy.units.

  • inplace (bool, optional) – if True, returns self. Otherwise returns the modified data.

Returns

  • RichData – self, if inplace=True

  • numpy.ndarray – data from self, if inplace=False

slices(twosided=None)

Create a Slices instance from this instance.

Parameters

twosided (bool, optional) – if None, copied from self._default_twosided

Returns

a Slices object

Return type

Slices

exact_polar(rho, phi=None)

Retrieve data at the specified radial coordinates pairs.

Parameters
  • r (iterable) – radial coordinate(s) to sample

  • phi (iterable) – azimuthal coordinate(s) to sample

Returns

data at the given points

Return type

numpy.ndarray

exact_xy(x, y=None)

Retrieve data at the specified X-Y frequency pairs.

Parameters
  • x (iterable) – X coordinate(s) to retrieve

  • y (iterable) – Y coordinate(s) to retrieve

Returns

data at the given points

Return type

numpy.ndarray

exact_x(x)

Return data at an exact x coordinate along the y=0 axis.

Parameters

x (number or numpy.ndarray) – x coordinate(s) to return

Returns

ndarray of values

Return type

numpy.ndarray

exact_y(y)

Return data at an exact y coordinate along the x=0 axis.

Parameters

y (number or numpy.ndarray) – y coordinate(s) to return

Returns

ndarray of values

Return type

numpy.ndarray

plot2d(xlim=None, ylim=None, clim=None, cmap=None, log=False, power=1, interpolation=None, show_colorbar=True, show_axlabels=True, fig=None, ax=None)

Plot the data in 2D.

Parameters
  • xlim (float or iterable, optional) – x axis limits. If not iterable, symmetric version of the single value

  • ylim (float or iterable, optional) – y axis limits. If None and xlim is not None, copied from xlim. If not iterable, symmetric version of the single value.

  • clim (iterable, optional) – clim passed directly to matplotlib. If None, looked up on self._default_clim.

  • cmap (str, optional) – colormap to use, passed directly to matplotlib if not None. If None, looks up the default cmap for self._data_type on config

  • log (bool, optional) – if True, plot on a log color scale

  • power (float, optional) – if not 1, plot on a power stretched color scale

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

  • show_colorbar (bool, optional) – if True, draws the colorbar

  • show_axlabels (bool, optional) – if True, draws the axis labels

  • 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

class prysm._richdata.Slices(data, x, y, x_unit, z_unit, labels, xscale, yscale, twosided=True)

Bases: object

Slices of data.

check_polar_calculated()

Ensure that the polar representation of the source data has been calculated.

x

Slice through the Y=0 axis of the data, i.e. along the X axis.

Returns

  • x (numpy.ndarray) – coordinates

  • slice (numpy.ndarray) – values of the data array at these coordinates

y

Slice through the X=0 axis of the data, i.e., along the Y axis.

Returns

  • y (numpy.ndarray) – coordinates

  • slice (numpy.ndarray) – values of the data array at these coordinates

azavg

Azimuthal average of the data.

Returns

  • rho (numpy.ndarray) – coordinates

  • slice (numpy.ndarray) – values of the data array at these coordinates

azmedian

Azimuthal median of the data.

Returns

  • rho (numpy.ndarray) – coordinates

  • slice (numpy.ndarray) – values of the data array at these coordinates

azmin

Azimuthal minimum of the data.

Returns

  • rho (numpy.ndarray) – coordinates

  • slice (numpy.ndarray) – values of the data array at these coordinates

azmax

Azimuthal maximum of the data.

Returns

  • rho (numpy.ndarray) – coordinates

  • slice (numpy.ndarray) – values of the data array at these coordinates

azpv

Azimuthal PV of the data.

Returns

  • rho (numpy.ndarray) – coordinates

  • slice (numpy.ndarray) – values of the data array at these coordinates

azvar

Azimuthal variance of the data.

Returns

  • rho (numpy.ndarray) – coordinates

  • slice (numpy.ndarray) – values of the data array at these coordinates

azstd

Azimuthal standard deviation of the data.

Returns

  • rho (numpy.ndarray) – coordinates

  • slice (numpy.ndarray) – values of the data array at these coordinates

plot(slices, lw=None, alpha=None, zorder=None, invert_x=False, xlim=(None, None), xscale=None, ylim=(None, None), yscale=None, show_legend=True, show_axlabels=True, fig=None, ax=None)

Plot slice(s).

Parameters
  • slices (str or Iterable) – if a string, plots a single slice. Else, plots several slices.

  • lw (float or Iterable, optional) – line width to use for the slice(s). If a single value, used for all slice(s). If iterable, used pairwise with the slices

  • alpha (float or Iterable, optional) – alpha (transparency) to use for the slice(s). If a single value, used for all slice(s). If iterable, used pairwise with the slices

  • zorder (int or Iterable, optional) – zorder (stack height) to use for the slice(s). If a single value, used for all slice(s). If iterable, used pairwise with the slices

  • invert_x (bool, optional) – if True, flip x (i.e., Freq => Period or vice-versa)

  • xlim (tuple, optional) – x axis limits

  • xscale (str, {‘linear’, ‘log’}, optional) – scale used for the x axis

  • ylim (tuple, optional) – y axis limits

  • yscale (str, {‘linear’, ‘log’}, optional) – scale used for the y axis

  • show_legend (bool, optional) – if True, show the legend

  • show_axlabels (bool, optional) – if True, show the axis labels

  • 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

class prysm._phase.OpticalPhase(x, y, phase, labels, xy_unit=None, z_unit=None, wavelength=None)

Bases: prysm._richdata.RichData

Phase of an optical field.

pv

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

rms

RMS phase error. DIN/ISO Sq.

Sa

Sa phase error. DIN/ISO Sa.

std

Standard deviation of phase error.

diameter_x

Diameter of the data in x.

diameter_y

Diameter of the data in y.

diameter

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

semidiameter

Half of self.diameter.

phase

Phase is the Z (“height” or “opd”) data.

astype(other_type)

Change this instance of one type into another.

Useful to access methods of the other class.

Parameters

other_type (object) – the name of the other type to “cast” to, e.g. Interferogram. Not a string.

Returns

type-converted to the other type.

Return type

self

center_x

Center “pixel” in x.

center_y

Center “pixel” in y.

change_xy_unit(to, inplace=True)

Change the x/y unit to a new one, scaling the data in the process.

Parameters
  • to (astropy.unit or str) – if not an astropy unit, a string that is a valid attribute of astropy.units.

  • inplace (bool, optional) – if True, returns self. Otherwise returns the modified data.

Returns

  • RichData – self, if inplace=True

  • numpy.ndarray, numpy.ndarray – x, y from self, if inplace=False

change_z_unit(to, inplace=True)

Change the z unit to a new one, scaling the data in the process.

Parameters
  • to (astropy.unit or str) – if not an astropy unit, a string that is a valid attribute of astropy.units.

  • inplace (bool, optional) – if True, returns self. Otherwise returns the modified data.

Returns

  • RichData – self, if inplace=True

  • numpy.ndarray – data from self, if inplace=False

copy()

Return a (deep) copy of this instance.

exact_polar(rho, phi=None)

Retrieve data at the specified radial coordinates pairs.

Parameters
  • r (iterable) – radial coordinate(s) to sample

  • phi (iterable) – azimuthal coordinate(s) to sample

Returns

data at the given points

Return type

numpy.ndarray

exact_x(x)

Return data at an exact x coordinate along the y=0 axis.

Parameters

x (number or numpy.ndarray) – x coordinate(s) to return

Returns

ndarray of values

Return type

numpy.ndarray

exact_xy(x, y=None)

Retrieve data at the specified X-Y frequency pairs.

Parameters
  • x (iterable) – X coordinate(s) to retrieve

  • y (iterable) – Y coordinate(s) to retrieve

Returns

data at the given points

Return type

numpy.ndarray

exact_y(y)

Return data at an exact y coordinate along the x=0 axis.

Parameters

y (number or numpy.ndarray) – y coordinate(s) to return

Returns

ndarray of values

Return type

numpy.ndarray

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

Create a picture of fringes.

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

plot2d(xlim=None, ylim=None, clim=None, cmap=None, log=False, power=1, interpolation=None, show_colorbar=True, show_axlabels=True, fig=None, ax=None)

Plot the data in 2D.

Parameters
  • xlim (float or iterable, optional) – x axis limits. If not iterable, symmetric version of the single value

  • ylim (float or iterable, optional) – y axis limits. If None and xlim is not None, copied from xlim. If not iterable, symmetric version of the single value.

  • clim (iterable, optional) – clim passed directly to matplotlib. If None, looked up on self._default_clim.

  • cmap (str, optional) – colormap to use, passed directly to matplotlib if not None. If None, looks up the default cmap for self._data_type on config

  • log (bool, optional) – if True, plot on a log color scale

  • power (float, optional) – if not 1, plot on a power stretched color scale

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

  • show_colorbar (bool, optional) – if True, draws the colorbar

  • show_axlabels (bool, optional) – if True, draws the axis labels

  • 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

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.

shape

Proxy to phase or data shape.

size

Proxy to phase or data size.

slices(twosided=None)

Create a Slices instance from this instance.

Parameters

twosided (bool, optional) – if None, copied from self._default_twosided

Returns

a Slices object

Return type

Slices