psfsim.opticspsf
Optics objects.
Classes
Geometric optics object. |
Functions
|
Quadratic fitting function. |
|
Helper function to do a linear fit: f = a + b*x + c*y. |
|
Computes the Jacobian for entrance --> exit pupil. |
Module Contents
- altgriddata(points, values, xi)[source]
Quadratic fitting function.
This is a substitute for
scipy.interpolate.griddatawhen we have 5 points and want to fit a quadratic, minus the x^2-y^2 term.Paramters
- pointsnp.ndarray of float
The coordinates of the 5 points where we have values; shape (5, 2).
- valuesnp.ndarray of flat
The values to interpolate; shape (5,).
- xi(float, float)
The location to interpolate to.
- returns:
The interpolated value.
- rtype:
float
- fit_linfunc(f)[source]
Helper function to do a linear fit: f = a + b*x + c*y.
Excludes nans. Here x and y start at 0.
- Parameters:
f (np.ndarray of float) – The function to fit. Should be a 2D array,
f[y, x].- Returns:
coefs – The coefficients of the fit. Length 4: a, b, c, rmserr.
- Return type:
np.ndarray of float
- compute_jacobian(u, dx=1.0, dy=1.0)[source]
Computes the Jacobian for entrance –> exit pupil.
- Parameters:
u (np.ndarray of float) – 3D array of exit pupil positions;
u[iy, ix, ic]is the orthographic direction of the outgoing ray in entrance pixel (ix, iy). The components are ic == 0 for the x-component of u and ic == 1 for the y-component of u.dx (float, optional) – The entrance pupil grid spacings.
dy (float, optional) – The entrance pupil grid spacings.
- Returns:
The Jacobian, d(u_x,u_y)_out / d(x,y)_in. Shape is (N, N, 2, 2), where the first 2 axes refer to the shape of u, and the second 2 axes are matrix axes.
- Return type:
np.ndarray of float
- class GeometricOptics(scanum, scax, scay, wavelength=0.48, use_filter='H', ulen=2048, ray_trace=True, pixelsampling=1.0, a_lanczos=3, cycle=9, mjd=None)[source]
Geometric optics object.
- Parameters:
scanum (int) – The SCA number.
scax (float) – The pixel positions on the SCA (in mm, FPA coordinates relative to the SCA center).
scay (float) – The pixel positions on the SCA (in mm, FPA coordinates relative to the SCA center).
wavelength (float, optional) – The vacuum wavelength in microns.
use_filter (str) – The filter as a 1-character string.
ulen (int, optional) – The size of array for pupil sampling.
ray_trace (bool, optional) – Whether to use ray tracing.
pixelsampling (float, optional) – Desired FFT-based output pixel sampling in microns.
cycle (int, optional) – Which cycle to use for the Zernike modes.
mjd (float, optional) – The MJD to use for the optical model.
- scax, scay
The pixel positions on the SCA (in mm, FPA coordinates relative to the SCA center).
- Type:
float
- xan, yan
The field angles in degrees.
- Type:
float
- ucen, vcen
The orthographic coordinates at the exit pupil of the center of the pupil image.
- Type:
float
- path_difference[source]
The wavefront map in microns. Shape (ulen, ulen).
- Type:
np.ndarray of float
- rb
The ray trace object.
- a_lanczos[source]
The order of Lanczos kernel apodization to use for the high-resolution pupil.
- Type:
int, optional
- compute_distortion_matrix(method='raytrace')[source]
Computes the distortion matrix.
- Parameters:
method (str, optional) – If “poly”, uses the pre-computed polynomial fit. The default (recommended) is “raytrace”.
- Returns:
The 2x2 Jacobian matrix, d(xan,yan)/d(fpax,fpay); units of mm^-1.
- Return type:
np.ndarray of float
- compute_determinant()[source]
Determinant of distortion matrix.
- Returns:
The determinant of the FPA –> field angle mapping, in mm^-2.
- Return type:
float
- load_pupil_mask(use_ray_trace=True)[source]
Loads the pupil mask.
Also sets the pupil coordinates.
- Parameters:
use_ray_trace (bool, optional) – Ray traced pupil mask (Only turn off for testing, if stpsf-data is available.)
- Returns:
The pupil mask.
- Return type:
np.ndarray of float
- path_diff(use_ray_trace=True)[source]
Path difference map. The behavior depends on the selected cycle.
The method is:
in Cycle 9, looks up the Zernike modes
in Cycle 10, uses the perturbation model
- Returns:
The path difference map; same shape as
self.u_array(). Units of microns.- Return type:
np.ndarray of float