prysm.qpoly

Tools for working with Q (Forbes) polynomials.

prysm.qpoly.qbfs_recurrence_P(n, x, Pnm1=None, Pnm2=None, recursion_coef=None)

P(m+1) from oe-18-19-19700 eq. (2.6).

Parameters
  • n (int) – polynomial order

  • x (numpy.ndarray) – x values, notionally in / orthogonal over [0, 1], to evaluate at

  • Pnm1 (numpy.ndarray, optional) – the value of this function for argument n - 1

  • Pnm2 (numpy.ndarray, optional) – the value of this function for argument n - 2

  • recursion_coef (numpy.ndarray, optional) – the coefficient to apply, if recursion_coef = C: evaluates C * Pnm1 - Pnm2

Returns

the value of the auxiliary P polynomial for given order n and point(s) x

Return type

numpy.ndarray

prysm.qpoly.qbfs_recurrence_Q(n, x, Pn=None, Pnm1=None, Pnm2=None, Qnm1=None, Qnm2=None, recursion_coef=None)

Q(m+1) from oe-18-19-19700 eq. (2.7).

Parameters
  • n (int) – polynomial order

  • x (numpy.ndarray) – x values, notionally in / orthogonal over [0, 1], to evaluate at

  • Pnm1 (numpy.ndarray, optional) – the value of qbfs_recurrence_P for argument n - 1

  • Pnm2 (numpy.ndarray, optional) – the value of qbfs_recurrence_P for argument n - 2

  • Qnm1 (numpy.ndarray, optional) – the value of this function for argument n - 1

  • Qnm2 (numpy.ndarray, optional) – the value of this function for argument n - 2

  • recursion_coef (numpy.ndarray, optional) – the coefficient to apply, if recursion_coef = C: evaluates C * Pnm1 - Pnm2

Returns

the value of the the Qbfs polynomial for given order n and point(s) x

Return type

numpy.ndarray

prysm.qpoly.g_qbfs

g(m-1) from oe-18-19-19700 eq. (A.15)

prysm.qpoly.h_qbfs

h(m-2) from oe-18-19-19700 eq. (A.14)

prysm.qpoly.f_qbfs

f(m) from oe-18-19-19700 eq. (A.16)

class prysm.qpoly.QBFSCache(gridcache=<prysm.coordinates.GridCache object>)

Bases: object

Cache of Qbfs terms evaluated over the unit circle.

get_QBFS(m, samples, rho_max=1)

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

get_PBFS(m, samples, rho_max=1)

Get an array of P values for a given index.

get_grid(samples, rho_max=1)

Get a grid of rho coordinates for a given number of samples.

make_key(m, samples, rho_max)

Generate a key into the cache dictionaries.

clear(*args)

Empty the cache.

class prysm.qpoly.QCONCache(gridcache=<prysm.coordinates.GridCache object>)

Bases: object

Cache of Qcon terms evaluated over the unit circle.

get_QCON(m, samples, rho_max=1)

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

get_PJAC(m, samples, rho_max=1)

Get an array of P_n^(0,4) values for a given index.

get_grid(samples, rho_max=1)

Get a grid of rho coordinates for a given number of samples.

make_key(m, samples, rho_max)

Generate a key into the cache dictionaries.

clear(*args)

Empty the cache.

class prysm.qpoly.QPolySag1D(*args, **kwargs)

Bases: prysm.pupil.Pupil

Base class with 1D Q polynomial logic.

build()

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

Returns

self – this QPolySag1D instance`

Return type

QPolySag1D

Sa

Sa phase error. DIN/ISO Sa.

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.

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.

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

fcn

Complex wavefunction associated with the pupil.

static from_interferogram(interferogram, wvl=None, mask_phase=True)

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, interpolation='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

phase

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

phase_unit

Unit used to describe the optical phase.

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

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.

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

spatial_unit

Unit used to describe the spatial phase.

std

Standard deviation of phase error.

strehl

Strehl ratio of the pupil.

class prysm.qpoly.QBFSSag(*args, **kwargs)

Bases: prysm.qpoly.QPolySag1D

build()

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

Returns

self – this QBFSSag instance`

Return type

QBFSSag

Sa

Sa phase error. DIN/ISO Sa.

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.

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.

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

fcn

Complex wavefunction associated with the pupil.

static from_interferogram(interferogram, wvl=None, mask_phase=True)

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, interpolation='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

phase

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

phase_unit

Unit used to describe the optical phase.

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

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.

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

spatial_unit

Unit used to describe the spatial phase.

std

Standard deviation of phase error.

strehl

Strehl ratio of the pupil.

class prysm.qpoly.QCONSag(*args, **kwargs)

Bases: prysm.qpoly.QPolySag1D

build()

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

Returns

self – this QCONSag instance`

Return type

QCONSag

Sa

Sa phase error. DIN/ISO Sa.

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.

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.

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

fcn

Complex wavefunction associated with the pupil.

static from_interferogram(interferogram, wvl=None, mask_phase=True)

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, interpolation='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

phase

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

phase_unit

Unit used to describe the optical phase.

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

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.

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

spatial_unit

Unit used to describe the spatial phase.

std

Standard deviation of phase error.

strehl

Strehl ratio of the pupil.