prysm.propagation¶
Numerical optical propagation.
-
prysm.propagation.
focus
(wavefunction, Q, incoherent=True, norm=None)¶ Propagate a pupil plane to a PSF plane.
- Parameters
wavefunction (numpy.ndarray) – the pupil wavefunction
Q (float) – oversampling / padding factor
incoherent (bool, optional) – whether to return the incoherent (real valued) PSF, or the coherent (complex-valued) PSF. Incoherent = |coherent|^2
norm (str, {None, ‘ortho’}) – normalization parameter passed directly to numpy/cupy fft
- Returns
psf – point spread function
- Return type
numpy.ndarray
-
prysm.propagation.
unfocus
(wavefunction, Q, norm=None)¶ Propagate a PSF plane to a pupil plane.
- Parameters
wavefunction (numpy.ndarray) – the pupil wavefunction
Q (float) – oversampling / padding factor
norm (str, {None, ‘ortho’}) – normalization parameter passed directly to numpy/cupy fft
- Returns
pupil – field in the pupil plane
- Return type
numpy.ndarray
-
prysm.propagation.
focus_fixed_sampling
(wavefunction, input_sample_spacing, prop_dist, wavelength, output_sample_spacing, output_samples, coherent=False, norm=True)¶ Propagate a pupil function to the PSF plane with fixed sampling.
- Parameters
wavefunction (numpy.ndarray) – the pupil wavefunction
input_sample_spacing (float) – spacing between samples in the pupil plane, millimeters
prop_dist (float) – propagation distance along the z distance
wavelength (float) – wavelength of light
output_sample_spacing (float) – sample spacing in the output plane, microns
output_samples (int) – number of samples in the square output array
coherent (bool) – if True, returns the complex array. Else returns its magnitude squared.
- Returns
data – 2D array of data
- Return type
numpy.ndarray
-
prysm.propagation.
unfocus_fixed_sampling
(wavefunction, input_sample_spacing, prop_dist, wavelength, output_sample_spacing, output_samples, norm=True)¶ Propagate an image plane field to the pupil plane with fixed sampling.
- Parameters
wavefunction (numpy.ndarray) – the image plane wavefunction
input_sample_spacing (float) – spacing between samples in the pupil plane, millimeters
prop_dist (float) – propagation distance along the z distance
wavelength (float) – wavelength of light
output_sample_spacing (float) – sample spacing in the output plane, microns
output_samples (int) – number of samples in the square output array
- Returns
x (numpy.ndarray) – x axis unit, 1D ndarray
y (numpy.ndarray) – y axis unit, 1D ndarray
data (numpy.ndarray) – 2D array of data
-
prysm.propagation.
Q_for_sampling
(input_diameter, prop_dist, wavelength, output_sample_spacing)¶ Value of Q for a given output sampling, given input sampling.
- Parameters
input_diameter (float) – diameter of the input array in millimeters
prop_dist (float) – propagation distance along the z distance
wavelength (float) – wavelength of light
output_sample_spacing (float) – sampling in the output plane, microns
- Returns
requesite Q
- Return type
float
-
prysm.propagation.
focus_units
(wavefunction, input_sample_spacing, efl, wavelength, Q)¶ Compute the ordinate axes for a pupil plane to PSF plane propagation.
- Parameters
wavefunction (numpy.ndarray) – the pupil wavefunction
input_sample_spacing (float) – spacing between samples in the pupil plane
efl (float) – propagation distance along the z distance
wavelength (float) – wavelength of light
Q (float) – oversampling / padding factor
- Returns
x (numpy.ndarray) – x axis unit, 1D ndarray
y (numpy.ndarray) – y axis unit, 1D ndarray
-
prysm.propagation.
unfocus_units
(wavefunction, input_sample_spacing, efl, wavelength, Q)¶ Compute the ordinate axes for a PSF plane to pupil plane propagation.
- Parameters
wavefunction (numpy.ndarray) – the pupil wavefunction
input_sample_spacing (float) – spacing between samples in the PSF plane
efl (float) – propagation distance along the z distance
wavelength (float) – wavelength of light
Q (float) – oversampling / padding factor
- Returns
x (numpy.ndarray) – x axis unit, 1D ndarray
y (numpy.ndarray) – y axis unit, 1D ndarray
-
prysm.propagation.
pupil_sample_to_psf_sample
(pupil_sample, samples, wavelength, efl)¶ Convert pupil sample spacing to PSF sample spacing. fλ/D or Q.
- Parameters
pupil_sample (float) – sample spacing in the pupil plane
samples (int) – number of samples present in both planes (must be equal)
wavelength (float) – wavelength of light, in microns
efl (float) – effective focal length of the optical system in mm
- Returns
the sample spacing in the PSF plane
- Return type
float
-
prysm.propagation.
psf_sample_to_pupil_sample
(psf_sample, samples, wavelength, efl)¶ Convert PSF sample spacing to pupil sample spacing.
- Parameters
psf_sample (float) – sample spacing in the PSF plane
samples (int) – number of samples present in both planes (must be equal)
wavelength (float) – wavelength of light, in microns
efl (float) – effective focal length of the optical system in mm
- Returns
the sample spacing in the pupil plane
- Return type
float
-
prysm.propagation.
fresnel_number
(a, L, lambda_)¶ Compute the Fresnel number.
Notes
if the fresnel number is << 1, paraxial assumptions hold for propagation
- Parameters
a (float) – characteristic size (“radius”) of an aperture
L (float) – distance of observation
lambda (float) – wavelength of light, same units as a
- Returns
the fresnel number for these parameters
- Return type
float
-
prysm.propagation.
talbot_distance
(a, lambda_)¶ Compute the talbot distance.
- Parameters
a (float) – period of the grating, units of microns
lambda (float) – wavleength of light, units of microns
- Returns
talbot distance, units of microns
- Return type
float
-
prysm.propagation.
angular_spectrum
(field, wvl, sample_spacing, z, Q=2)¶ Propagate a field via the angular spectrum method.
- Parameters
field (numpy.ndarray) – 2D array of complex electric field values
wvl (float) – wavelength of light, microns
z (float) – propagation distance, units of millimeters
sample_spacing (float) – cartesian sample spacing, units of millimeters
Q (float) – sampling factor used. Q>=2 for Nyquist sampling of incoherent fields
- Returns
2D ndarray of the output field, complex
- Return type
numpy.ndarray
-
class
prysm.propagation.
Wavefront
(x, y, fcn, wavelength, space='pupil')¶ Bases:
prysm._richdata.RichData
(Complex) representation of a wavefront.
-
fcn
¶ Complex field / wavefunction.
-
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.
-
intensity
¶ Intensity, abs(w)^2.
-
phase
¶ Phase, angle(w). Possibly wrapped for large OPD.
-
free_space
(dz, Q=2)¶ Perform a plane-to-plane free space propagation.
Uses angular spectrum and the free space kernel.
- Parameters
dz (float) – inter-plane distance, millimeters
Q (float) – padding factor. Q=1 does no padding, Q=2 pads 1024 to 2048.
- Returns
the wavefront at the new plane
- Return type
Wavefront
-
focus
(efl, Q=2)¶ Perform a “pupil” to “psf” plane propgation.
Uses an FFT with no quadratic phase.
- Parameters
efl (float) – focusing distance, millimeters
Q (float) – padding factor. Q=1 does no padding, Q=2 pads 1024 to 2048. To avoid aliasng, the array must be padded such that Q is at least 2 this may happen organically if your data does not span the array.
- Returns
the wavefront at the focal plane
- Return type
Wavefront
-
unfocus
(efl, Q=2)¶ Perform a “psf” to “pupil” plane propagation.
uses an FFT with no quadratic phase.
- Parameters
efl (float) – un-focusing distance, millimeters
Q (float) – padding factor. Q=1 does no padding, Q=2 pads 1024 to 2048. To avoid aliasng, the array must be padded such that Q is at least 2 this may happen organically if your data does not span the array.
- Returns
the wavefront at the pupil plane
- Return type
Wavefront
-
focus_fixed_sampling
(efl, sample_spacing, samples)¶ Perform a “pupil” to “psf” propagation with fixed output sampling.
Uses matrix triple product DFTs to specify the grid directly.
- Parameters
efl (float) – focusing distance, millimeters
sample_spacing (float) – output sample spacing, microns
samples (int) – number of samples in the output plane. If int, interpreted as square else interpreted as (x,y), which is the reverse of numpy’s (y, x) row major ordering
- Returns
the wavefront at the psf plane
- Return type
Wavefront
-
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
rho (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
-
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
-
unfocus_fixed_sampling
(efl, sample_spacing, samples)¶ Perform a “psf” to “pupil” propagation with fixed output sampling.
Uses matrix triple product DFTs to specify the grid directly.
- Parameters
efl (float) – un-focusing distance, millimeters
sample_spacing (float) – output sample spacing, millimeters
samples (int) – number of samples in the output plane. If int, interpreted as square else interpreted as (x,y), which is the reverse of numpy’s (y, x) row major ordering
- Returns
wavefront at the pupil plane
- Return type
Wavefront
-