prysm.psf#
Evaluation routines for point spread functions.
- prysm.psf.estimate_size(data, metric, dx=None, x=None, y=None, criteria='last')#
Calculate the “size” of the function in data based on a metric.
- Parameters
data (numpy.ndarray) – f(x,y), 2D
metric (str or float, {'fwhm', '1/e', '1/e^2', float()}) – what metric to apply
dx (float) – inter-sample spacing, if x and y != None, they supercede this parameter
x (numpy.ndarray) – x coordinates, 2D
y (numpy.ndarray) – y coordinates, 2D
criteria (str, optional, {'first', 'last'}) – whether to use the first or last occurence of <metric>
- Returns
the radial coordinate at which on average the function reaches <metric>
- Return type
float
- Raises
ValueError – metric not in (‘fwhm’, ‘1/e’, ‘1/e^2’, numbers.Number())
- prysm.psf.fwhm(data, dx=None, x=None, y=None, criteria='last')#
Calculate the FWHM of (data).
- Parameters
data (numpy.ndarray) – f(x,y), 2D
dx (float) – inter-sample spacing, if x and y != None, they supercede this parameter
x (numpy.ndarray) – x coordinates, 2D
y (numpy.ndarray) – y coordinates, 2D
criteria (str, optional, {'first', 'last'}) – whether to use the first or last occurence of <metric>
- Returns
the FWHM
- Return type
float
- prysm.psf.one_over_e(data, dx=None, x=None, y=None, criteria='last')#
Calculate the 1/e diameter of data.
- Parameters
data (numpy.ndarray) – f(x,y), 2D
dx (float) – inter-sample spacing, if x and y != None, they supercede this parameter
x (numpy.ndarray) – x coordinates, 2D
y (numpy.ndarray) – y coordinates, 2D
criteria (str, optional, {'first', 'last'}) – whether to use the first or last occurence of <metric>
- Returns
the FWHM
- Return type
float
- prysm.psf.one_over_e_sq(data, dx=None, x=None, y=None, criteria='last')#
Calculate the 1/e^2 diameter of data.
- Parameters
data (numpy.ndarray) – f(x,y), 2D
dx (float) – inter-sample spacing, if x and y != None, they supercede this parameter
x (numpy.ndarray) – x coordinates, 2D
y (numpy.ndarray) – y coordinates, 2D
criteria (str, optional, {'first', 'last'}) – whether to use the first or last occurence of <metric>
- Returns
the FWHM
- Return type
float
- prysm.psf.centroid(data, dx=None, unit='spatial')#
Calculate the centroid of the PSF.
- Parameters
data (numpy.ndarray) – data to centroid
dx (float) – sample spacing, may be None if unit != spatial
unit (str, {'spatial', 'pixels'}) – unit to return the centroid in. If pixels, corner indexed. If spatial, center indexed.
- Returns
int, int – if unit == pixels, indices into the array
float, float – if unit == spatial, referenced to the origin
- prysm.psf.autocrop(data, px)#
Crop to a rectangular window around the centroid.
- Parameters
data (numpy.ndarray) – data to crop into
px (int) – window full width, samples
- Returns
cropped data
- Return type
numpy.ndarray
- prysm.psf.airydisk(unit_r, fno, wavelength)#
Compute the airy disk function over a given spatial distancnp.
- Parameters
unit_r (numpy.ndarray) – ndarray with units of um
fno (float) – F/# of the system
wavelength (float) – wavelength of light, um
- Returns
ndarray containing the airy pattern
- Return type
numpy.ndarray
- prysm.psf.airydisk_ft(r, fno, wavelength)#
Compute the Fourier transform of the airy disk.
- Parameters
r (numpy.ndarray) – radial spatial frequency, if wvl has units of um, then r has units of 1/um
fno (float) – f number of the system, dimensionless
wavelength (float) – wavelength of light, notionally units of um
- Returns
ndarray of same shape as r
- Return type
numpy.ndarray
- prysm.psf.encircled_energy(psf, dx, radius)#
Compute the encircled energy of the PSF.
- Parameters
psf (numpy.ndarray) – 2D array containing PSF data
dx (float) – sample spacing of psf
radius (float or iterable) – radius or radii to evaluate encircled energy at
- Returns
if radius is a float, returns a float, else returns a list.
- Return type
encircled energy
Notes
implementation of “Simplified Method for Calculating Encircled Energy,” Baliga, J. V. and Cohn, B. D., doi: 10.1117/12.944334