prysm.interferogram¶
tools to analyze interferometric data.
-
prysm.interferogram.
fit_plane
(x, y, z)¶ Fit a plane to data.
- Parameters
x (numpy.ndarray) – 1D array of x (axis 1) values
y (numpy.ndarray) – 1D array of y (axis 0) values
z (numpy.ndarray) – 2D array of z values
- Returns
array representation of plane
- Return type
numpy.ndarray
-
prysm.interferogram.
fit_sphere
(z)¶ Fit a sphere to data.
- Parameters
z (numpy.ndarray) – 2D array of data
- Returns
sphere data
- Return type
numpy.ndarray
-
prysm.interferogram.
make_window
(signal, sample_spacing, which=None, alpha=4)¶ Generate a window function to be used in PSD analysis.
- Parameters
signal (numpy.ndarray) – signal or phase data
sample_spacing (float) – spacing of samples in the input data
which (str, {‘welch’, ‘hann’, None}, optional) – which window to produce. If auto, attempts to guess the appropriate window based on the input signal
alpha (float, optional) – alpha value for welch window
Notes
For 2D welch, see: Power Spectral Density Specification and Analysis of Large Optical Surfaces E. Sidick, JPL
- Returns
window array
- Return type
numpy.ndarray
-
prysm.interferogram.
psd
(height, sample_spacing, window=None)¶ Compute the power spectral density of a signal.
- Parameters
height (numpy.ndarray) – height or phase data
sample_spacing (float) – spacing of samples in the input data
window ({'welch', 'hann'} or ndarray, optional) –
- Returns
x (numpy.ndarray) – ordinate x frequency axis
y (numpy.ndarray) – ordinate y frequency axis
psd (numpy.ndarray) – power spectral density
Notes
See GH_FFT for a rigorous treatment of FFT scalings https://holometer.fnal.gov/GH_FFT.pdf
-
prysm.interferogram.
bandlimited_rms
(ux, uy, psd, wllow=None, wlhigh=None, flow=None, fhigh=None)¶ Calculate the bandlimited RMS of a signal from its PSD.
- Parameters
ux (numpy.ndarray) – x spatial frequencies
uy (numpy.ndarray) – y spatial frequencies
psd (numpy.ndarray) – power spectral density
wllow (float) – short spatial scale
wlhigh (float) – long spatial scale
flow (float) – low frequency
fhigh (float) – high frequency
- Returns
band-limited RMS value.
- Return type
float
-
prysm.interferogram.
window_2d_welch
(x, y, alpha=8)¶ Return a 2D welch window for a given alpha.
- Parameters
x (numpy.ndarray) – x values, 1D array
y (numpy.ndarray) – y values, 1D array
alpha (float) – alpha (edge roll) parameter
- Returns
window
- Return type
numpy.ndarray
-
prysm.interferogram.
abc_psd
(nu, a, b, c)¶ Lorentzian model of a Power Spectral Density.
- Parameters
nu (numpy.ndarray or float) – spatial frequency
a (float) – a coefficient
b (float) – b coefficient
c (float) – c coefficient
- Returns
value of PSD model
- Return type
numpy.ndarray
-
prysm.interferogram.
ab_psd
(nu, a, b)¶ Inverse power model of a Power Spectral Density.
- Parameters
nu (numpy.ndarray or float) – spatial frequency
a (float) – a coefficient
b (float) – b coefficient
- Returns
value of PSD model
- Return type
numpy.ndarray
-
prysm.interferogram.
synthesize_surface_from_psd
(psd, nu_x, nu_y)¶ Synthesize a surface height map from PSD data.
- Parameters
psd (numpy.ndarray) – PSD data, units nm²/(cy/mm)²
nu_x (numpy.ndarray) – x spatial frequency, cy/mm
nu_y (numpy.ndarray) – y spatial frequency, cy_mm
-
prysm.interferogram.
render_synthetic_surface
(size, samples, rms=None, mask='circle', psd_fcn=<function abc_psd>, **psd_fcn_kwargs)¶ Render a synthetic surface with a given RMS value given a PSD function.
- Parameters
size (float) – diameter of the output surface, mm
samples (int) – number of samples across the output surface
rms (float) – desired RMS value of the output, if rms=None, no normalization is done
mask (str, optional) – mask defining the clear aperture
psd_fcn (callable) – function used to generate the PSD
**psd_fcn_kwargs –
keyword arguments passed to psd_fcn in addition to nu if psd_fcn == abc_psd, kwargs are a, b, c elif psd_Fcn == ab_psd kwargs are a, b
kwargs will be user-defined for user PSD functions
- Returns
x (numpy.ndarray) – x coordinates, mm
y (numpy.ndarray) – y coordinates, mm
z (numpy.ndarray) – height data, nm
-
prysm.interferogram.
fit_psd
(f, psd, callable=<function abc_psd>, guess=None, return_='coefficients')¶ Fit parameters to a PSD curve.
- Parameters
f (numpy.ndarray) – spatial frequency, cy/length
psd (numpy.ndarray) – 1D PSD, units of height^2 / (cy/length)^2
callable (callable, optional) – a callable object that takes parameters of (frequency, *); all other parameters will be fit
return (str, optional, {‘coefficients’, ‘optres’}) – what to return; either return the coefficients (optres.x) or the optimization result (optres)
- Returns
optres – scipy.optimization.OptimizationResult
coefficients – numpy.ndarray of coefficients
-
class
prysm.interferogram.
Interferogram
(phase, intensity=None, x=None, y=None, scale='px', phase_unit='nm', meta=None)¶ Bases:
prysm._phase.OpticalPhase
Class containing logic and data for working with interferometric data.
-
dropout_percentage
¶ Percentage of pixels in the data that are invalid (NaN).
-
pvr
¶ Peak-to-Valley residual.
Notes
See: C. Evans, “Robust Estimation of PV for Optical Surface Specification and Testing” in Optical Fabrication and Testing, OSA Technical Digest (CD) (Optical Society of America, 2008), paper OWA4. http://www.opticsinfobase.org/abstract.cfm?URI=OFT-2008-OWA4
-
fit_zernikes
(terms, map_='noll', norm=True, residual=False)¶ Fit Zernikes to the interferometric data.
- Parameters
terms (int) – number of terms to fit
map (str, {‘noll’, ‘fringe’}, optional) – which set (“map”) of Zernikes to fit to
norm (bool, optional) – whether to orthonormalize the terms to unit RMS value
residual (bool) – if true, return two values (coefficients, residual), else return only coefficients
- Returns
coefs (numpy.ndarray) – Zernike coefficients, same units as self.phase_unit
residual (float) – RMS residual of the fit, same units as self.phase_unit
-
fill
(_with=0)¶ Fill invalid (NaN) values.
- Parameters
_with (float, optional) – value to fill with
- Returns
self
- Return type
Interferogram
-
crop
()¶ Crop data to rectangle bounding non-NaN region.
-
recenter
()¶ Adjust the x and y coordinates so the data is centered on 0,0.
-
remove_piston
()¶ Remove piston from the data by subtracting the mean value.
-
remove_tiptilt
()¶ Remove tip/tilt from the data by least squares fitting and subtracting a plane.
-
remove_power
()¶ Remove power from the data by least squares fitting.
-
remove_piston_tiptilt
()¶ Remove piston/tip/tilt from the data, see remove_tiptilt and remove_piston.
-
remove_piston_tiptilt_power
()¶ Remove piston/tip/tilt/power from the data.
-
mask
(shape_or_mask, diameter=None)¶ Mask the signal.
The mask will be inscribed in the axis with fewer pixels. I.e., for a interferogram with 1280x1000 pixels, the mask will be 1000x1000 at largest.
- Parameters
shape_or_mask (str or numpy.ndarray) – valid shape from prysm.geometry or array containing mask
diameter (float) – diameter of the mask, in self.spatial_units
mask (numpy.ndarray) – user-provided mask
- Returns
modified Interferogram instance.
- Return type
self
-
filter
(critical_frequency=None, critical_period=None, kind='bessel', type_=None, order=1, filtkwargs={})¶ Apply a frequency-domain filter to the phase data.
- Parameters
critical_frequency (float or length-2 tuple) – critical (“cutoff”) frequency/frequencies of the filter. Units of cy/self.spatial_unit
critical_period (float or length-2 tuple) – critical (“cutoff”) period/s of the filter. Units of self.spatial_unit. Will clobber critical_frequency if both given
kind (str, optional) – filter type – see scipy.signal for filter types and possible extra arguments. Examples are: - bessel - butter - ellip - cheby2
type (str, optional, {‘lowpass’, ‘highpass’, ‘bandpass’, ‘bandreject’}) – filter type – lowpass, highpass, bandpass, or bandreject defaults to lowpass if single freq/period given or bandpass if two given
order (int, optional) – order of the filter
filtkwargs (dict, optional) – kwargs passed to the filter constructor
- Returns
self
- Return type
Interferogram
Notes
These filters are implemented using scipy.signal and are a rigorous treatment that defaults to use of higher order filters with strong out-of-band rejection. This choices is not in accord with the one in made by some software shipping with commercial interferometers.
-
latcal
(plate_scale, unit='mm')¶ Perform lateral calibration.
This probably won’t do what you want if your data already has spatial units of anything but pixels (px).
- Parameters
plate_scale (float) – center-to-center sample spacing of pixels, in (unit)s.
unit (str, optional) – unit associated with the plate scale.
- Returns
modified Interferogram instance.
- Return type
self
-
pad
(value, unit='spatial')¶ Pad the interferogram.
- Parameters
value (float) – how much to pad the interferogram
unit (str, {‘spatial’, ‘px’}, optional) – what unit to use for padding, spatial units (self.spatial_unit), or pixels
- Returns
self
- Return type
Interferogram
-
spike_clip
(nsigma=3)¶ Clip points in the data that exceed a certain multiple of the standard deviation.
- Parameters
nsigma (float) – number of standard deviations to keep
- Returns
this Interferogram instance.
- Return type
self
-
psd
()¶ Power spectral density of the data., units (self.phase_unit^2)/((cy/self.spatial_unit)^2).
- Returns
x (numpy.ndarray) – ordinate x frequency axis
y (numpy.ndarray) – ordinate y frequency axis
psd (numpy.ndarray) – power spectral density
-
psd_slices
(x=True, y=True, azavg=True, azmin=False, azmax=False)¶ Power spectral density of the data., units (self.phase_unit^2)/((cy/self.spatial_unit)^2).
- Returns
with keys x, y, avg. Each containing a tuple of (unit, psd)
- Return type
dict
-
bandlimited_rms
(wllow=None, wlhigh=None, flow=None, fhigh=None)¶ Calculate the bandlimited RMS of a signal from its PSD.
- Parameters
wllow (float) – short spatial scale
wlhigh (float) – long spatial scale
flow (float) – low frequency
fhigh (float) – high frequency
- Returns
band-limited RMS value.
- Return type
float
-
total_integrated_scatter
(wavelength, incident_angle=0)¶ Calculate the total integrated scatter (TIS) for an angle or angles.
- Parameters
wavelength (float) – wavelength of light in microns.
incident_angle (float or numpy.ndarray) – incident angle(s) of light.
- Returns
TIS value.
- Return type
float or numpy.ndarray
-
plot_psd2d
(axlim=None, clim=(1e-09, 100.0), cmap='Greys_r', interp_method='lanczos', fig=None, ax=None)¶ Plot the two dimensional PSD.
- Parameters
axlim (float, optional) – symmetrical axis limit
clim (tuple, optional) – lower, upper limits on color scale
cmap (str, optional) – colormap
interp_method (str, optional) – method used to interpolate the image, passed directly to matplotlib imshow
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_psd_slices
(x=True, y=True, azavg=True, azmin=False, azmax=False, a=None, b=None, c=None, mode='freq', alpha=1, legend=True, lw=3, zorder=3, xlim=None, ylim=None, fig=None, ax=None)¶ Plot the x, y, and average PSD on a linear x axis.
- Parameters
x (bool, optional) – whether to plot the “x” PSD
y (bool, optional) – whether to plot the “y” PSD
azavg (bool, optional) – whether to plot the azimuthally averaged PSD
azmin (bool, optional) – whether to plot the azimuthal minimum PSD
azmax (bool, optional) – whether to plot the azimuthal maximum PSD
a (float, optional) – a coefficient of Lorentzian PSD model plotted alongside data
b (float, optional) – b coefficient of Lorentzian PSD model plotted alongside data
c (float, optional) – c coefficient of Lorentzian PSD model plotted alongside data
mode (str, {‘freq’, ‘period’}) – x-axis mode, either frequency or period
alpha (float, optional) – alpha value for the line(s), passed directly to matplotlib
legend (bool, optional) – if True, display the legend
lw (float, optional) – linewidth provided directly to matplotlib
zorder (int, optional) – zorder provided directly to matplotlib
xlim (tuple, optional) – len 2 tuple of low, high x axis limits
ylim (tuple, optional) – len 2 tuple of low, high y axis limits
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
Notes
if a, b given but not c, an AB / inverse power model will be used for the PSD. If a, b, c are given the Lorentzian model will be used.
-
save_zygo_ascii
(file, high_phase_res=True)¶ Save the interferogram to a Zygo ASCII file.
- Parameters
file (Path_like, str, or File_like) – where to save to.
-
static
from_zygo_dat
(path, multi_intensity_action='first', scale='mm')¶ Create a new interferogram from a zygo dat file.
- Parameters
path (path_like) – path to a zygo dat file
multi_intensity_action (str, optional) – see io.read_zygo_dat
scale (str, optional, {‘um’, ‘mm’}) – what xy scale to label the data with, microns or mm
- Returns
new Interferogram instance
- Return type
Interferogram
-
static
render_from_psd
(size, samples, rms=None, mask='circle', phase_unit='nm', psd_fcn=<function abc_psd>, **psd_fcn_kwargs)¶ Render a synthetic surface with a given RMS value given a PSD function.
- Parameters
size (float) – diameter of the output surface, mm
samples (int) – number of samples across the output surface
rms (float) – desired RMS value of the output, if rms=None, no normalization is done
mask (str, optional) – mask defining the clear aperture
psd_fcn (callable) – function used to generate the PSD
**psd_fcn_kwargs –
keyword arguments passed to psd_fcn in addition to nu if psd_fcn == abc_psd, kwargs are a, b, c elif psd_Fcn == ab_psd kwargs are a, b
kwargs will be user-defined for user PSD functions
- Returns
new interferogram instance
- Return type
Interferogram
-
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.
-
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
-
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.
-