Factory¶
The factory module provides DonutFactory and a set of coordinate-transform
utilities for mapping between pupil and focal planes.
DonutFactory¶
Coordinate transforms¶
danish.factory.pupil_to_focal ¶
pupil_to_focal(u, v, *, Z=None, aberrations=None, R_outer=1.0, R_inner=0.0, focal_length=None, x_offset=None, y_offset=None)
Transform pupil coordinates to focal coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
array of float
|
Pupil coordinates in meters. |
required |
v
|
array of float
|
Pupil coordinates in meters. |
required |
Z
|
Zernike
|
Aberrations in meters. |
None
|
aberrations
|
array of float
|
Aberrations in meters. |
None
|
R_outer
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
R_inner
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
focal_length
|
float
|
Focal length in meters. |
None
|
x_offset
|
Zernike
|
Additional focal plane offsets (in meters) represented as Zernike series. |
None
|
y_offset
|
Zernike
|
Additional focal plane offsets (in meters) represented as Zernike series. |
None
|
Returns:
| Type | Description |
|---|---|
x, y : array of float
|
Focal coordinates in meters. |
Source code in danish/factory.py
danish.factory.focal_to_pupil ¶
focal_to_pupil(x, y, *, Z=None, aberrations=None, R_outer=1.0, R_inner=0.0, focal_length=None, x_offset=None, y_offset=None, prefit_order=F2P_PREFIT_ORDER, maxiter=F2P_MAXITER, tol=F2P_TOL, strict=F2P_STRICT)
Transform focal coordinates to pupil coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array of float
|
Focal coordinates in meters. |
required |
y
|
array of float
|
Focal coordinates in meters. |
required |
Z
|
Zernike
|
Aberrations in meters. |
None
|
aberrations
|
array of float
|
Aberrations in meters. |
None
|
R_outer
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
R_inner
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
focal_length
|
float
|
Focal length in meters. |
None
|
x_offset
|
Zernike
|
Additional focal plane offsets (in meters) represented as Zernike series. |
None
|
y_offset
|
Zernike
|
Additional focal plane offsets (in meters) represented as Zernike series. |
None
|
prefit_order
|
int
|
Order of prefit used to get good initial guesses for coordinate transformation. |
F2P_PREFIT_ORDER
|
maxiter
|
int
|
Number of Newton iterations to attempt before failing. |
F2P_MAXITER
|
tol
|
float
|
Tolerance for successful coordinate transformation. |
F2P_TOL
|
strict
|
If True, then raise a RuntimeError if any coordinates could not be mapped. If False, then return NaN for unmappable coordinates. |
F2P_STRICT
|
Returns:
| Type | Description |
|---|---|
u, v : array of float
|
Pupil coordinates in meters. |
Source code in danish/factory.py
danish.factory.pupil_focal_jacobian ¶
pupil_focal_jacobian(u, v, *, Z=None, aberrations=None, R_outer=1.0, R_inner=0.0, focal_length=None, x_offset=None, y_offset=None)
Compute Jacobian of the pupil-to-focal coordinate transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
array of float
|
Pupil coordinates in meters. |
required |
v
|
array of float
|
Pupil coordinates in meters. |
required |
Z
|
Zernike
|
Aberrations in meters. |
None
|
aberrations
|
array of float
|
Aberrations in meters. |
None
|
R_outer
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
R_inner
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
focal_length
|
float
|
Focal length in meters. |
None
|
x_offset
|
Zernike
|
Additional focal plane offsets (in meters) represented as Zernike series. |
None
|
y_offset
|
Zernike
|
Additional focal plane offsets (in meters) represented as Zernike series. |
None
|
Returns:
| Type | Description |
|---|---|
dxdu, dxdv, dydu, dydv : array of float
|
Jacobian of focal coordinates with respect to pupil coordinates. |
Source code in danish/factory.py
danish.factory.pupil_focal_coef_jacobian ¶
Derivative of projected focal position with respect to each Zernike.
pupil_to_focal evaluates the gradient of a Zernike series, and that
series is linear in its coefficients, so the projected position of a fixed
pupil point is linear in the aberrations. Its derivative is therefore a
constant matrix: independent of the aberrations, fixed by the pupil points
alone. Evaluating it once lets a fitter replace a Zernike evaluation per
model call with a single matrix product, and gives the exact
d(position)/d(coefficient) that an analytic Jacobian needs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
array of float
|
Pupil coordinates in meters. |
required |
v
|
array of float
|
Pupil coordinates in meters. |
required |
nterm
|
int
|
Number of leading Zernike coefficients to differentiate with respect
to. Only these get a column; the derivative with respect to the rest
of the series is not returned because a fitter holds them fixed. See
|
required |
R_outer
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
R_inner
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
focal_length
|
float
|
Focal length in meters. |
required |
pixel_scale
|
float
|
Pixel scale in meters. Defaults to 1.0, i.e. focal coordinates in meters rather than pixels. |
1.0
|
Returns:
| Type | Description |
|---|---|
dxdz, dydz : array of float, shape (len(u), nterm)
|
Derivative of focal x and y with respect to each Zernike coefficient.
Column 0 is zero: Noll indexing starts at 1, so |
Source code in danish/factory.py
danish.factory.pupil_to_focal_basis ¶
pupil_to_focal_basis(u, v, *, aberrations, nterm, R_outer=1.0, R_inner=0.0, focal_length, pixel_scale=1.0, x_offset=None, y_offset=None)
Split pupil_to_focal into a constant part and a linear map.
Returns the pieces needed to evaluate
x, y = x0 + dxdz @ ab[:nterm], y0 + dydz @ ab[:nterm]
for any aberration vector sharing this one's tail. A fitter varies only
the leading nterm coefficients, so x0/y0 -- which carry the fixed
remainder of the reference wavefront plus any focal-plane offsets -- stay
valid for the whole fit and the per-call work collapses to one matrix
product.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
u
|
array of float
|
Pupil coordinates in meters. |
required |
v
|
array of float
|
Pupil coordinates in meters. |
required |
aberrations
|
array of float
|
Reference aberrations in meters. May be longer than |
required |
nterm
|
int
|
Number of leading coefficients the caller intends to vary. |
required |
R_outer
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
R_inner
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
focal_length
|
float
|
Focal length in meters. |
required |
pixel_scale
|
float
|
Pixel scale in meters. Defaults to 1.0. |
1.0
|
x_offset
|
Zernike
|
Additional focal plane offsets (in meters) represented as Zernike
series. Constant in the aberrations, so they land in |
None
|
y_offset
|
Zernike
|
Additional focal plane offsets (in meters) represented as Zernike
series. Constant in the aberrations, so they land in |
None
|
Returns:
| Type | Description |
|---|---|
x0, y0 : array of float
|
Focal coordinates from the fixed part of the wavefront. |
dxdz, dydz : array of float, shape (len(u), nterm)
|
Derivative with respect to each varied coefficient, from
|
Source code in danish/factory.py
Pupil sampling¶
danish.factory.enclosed_fraction ¶
enclosed_fraction(x, y, u, v, u0, v0, radius, *, Z=None, aberrations=None, R_outer=1.0, R_inner=0.0, focal_length=None, x_offset=None, y_offset=None, pixel_scale=None)
Compute fraction of pixels enclosed by circles defined on the pupil.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array of float
|
Pixel coordinates. |
required |
y
|
array of float
|
Pixel coordinates. |
required |
u
|
array of float
|
Pupil coordinates in meters. |
required |
v
|
array of float
|
Pupil coordinates in meters. |
required |
u0
|
float
|
Pupil coordinates of circle center in meters. |
required |
v0
|
float
|
Pupil coordinates of circle center in meters. |
required |
radius
|
float
|
Circle radius in meters. |
required |
Z
|
Zernike
|
Aberrations in meters. |
None
|
aberrations
|
array of float
|
Aberrations in meters. |
None
|
R_outer
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
R_inner
|
float
|
Annulus outer and inner radii in meters. |
1.0
|
focal_length
|
float
|
Focal length in meters. |
None
|
x_offset
|
Zernike
|
Additional focal plane offsets (in meters) represented as Zernike series. |
None
|
y_offset
|
Zernike
|
Additional focal plane offsets (in meters) represented as Zernike series. |
None
|
pixel_scale
|
float
|
Pixel scale in meters. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
enclosed |
array of float, congruent to x or y
|
Each pixel's enclosed fraction between 0, 1. |