poke package
Submodules
poke.beamlets module
Experimental module for beamlet decomposition
- poke.beamlets.beamlet_decomposition_field(xData, yData, zData, lData, mData, nData, opd, dPx, dPy, dHx, dHy, dcoords, dnorm, wavelength=1.65e-06, nloops=32, use_centroid=True, vignetting=None)
computes the coherent beamlet decomposition field from ray data
- Parameters:
xData (numpy.ndarray) – the x position coordinates of the rays at the final field of evaluation
yData (numpy.ndarray) – the y position coordinates of the rays at the final field of evaluation
zData (numpy.ndarray) – the z position coordinates of the rays at the final field of evaluation
mData (numpy.ndarray) – the l position coordinates of the rays at the final field of evaluation
lData (numpy.ndarray) – the m position coordinates of the rays at the final field of evaluation
nData (numpy.ndarray) – the n position coordinates of the rays at the final field of evaluation
opd (numpy.ndarray) – the OPD of the rays at the final field of evaluation
dPx (float) – The ray differential in position used to compute the ABCD matrix
dPy (float) – The ray differential in position used to compute the ABCD matrix
dHx (float) – The ray differential in direction cosine used to compute the ABCD matrix
dHy (float) – The ray differential in direction cosine used to compute the ABCD matrix
dcoords (N x 3 numpy.ndarray) – coordinates of detector on final field of evaluation
dnorm (N x 3 numpy.ndarray or, a single vector) – surface normal of detector on final field of evaluation
- poke.beamlets.center_transversal_plane(r_pixels, r_ray, O)
Centers the coordinate system on the transversal plane
- Returns:
coordinates of distances from the center of the transversal plane to the pixels
- Return type:
r
- poke.beamlets.determine_misalingment_vectors(central_ray_r_start, central_ray_r_end, central_ray_k_start, central_ray_k_end, optical_axis_r=array([0., 0.]), optical_axis_k=array([0., 0.]))
computes the misalignment vectors of an optical system
- Parameters:
central_ray_r (numpy.ndarray) – array of shape raysets x surfaces x coordinates x dimensions containing the ray positions through the optical system
central_ray_k (numpy.ndarray) – array of shape raysets x surfaces x coordinates x dimensions containing the ray directions through the optical system
optical_axis_r (_type_, optional) – _description_, by default np.array([0.,0.])
optical_axis_k (_type_, optional) – _description_, by default np.array([0.,0.])
- Returns:
_description_
- Return type:
_type_
- poke.beamlets.differential_matrix_calculation(central_u, central_v, diff_uu, diff_uv, diff_vu, diff_vv, du, dv)
computes a sub-matrix of the ray transfer tensor
diff_ij means a differential ray with initial differential in dimension i, evaluated in j diff_xy means the differential ray with an initial dX in the x dimension on the source plane, and these are the coordinates of that ray in the y-axis on the detector plane
- Parameters:
central_u (numpy.ndarray) – array describing the central rays position or angle in x or l
central_v (numpy.ndarray) – array describing the central rays position or angle in y or m
diff_uu (numpy.ndarray) – array describing the differential rays position or angle in x or l
diff_uv (numpy.ndarray) – array describing the differential rays position or angle in y or m
diff_vu (numpy.ndarray) – array describing the differential rays position or angle in y or m
diff_vv (numpy.ndarray) – array describing the differential rays position or angle in y or m
du (float) – differential on sourc plane in position or angle in x or l
dv (float) – differential on sourc plane in position or angle in y or m
- Returns:
sub-matrix of the ray transfer tensor
- Return type:
numpy.ndarray
- poke.beamlets.differential_matrix_calculation_misaligned(central_u, central_v, diff_uu, diff_uv, diff_vu, diff_vv, du, dv)
computes a sub-matrix of the ray transfer tensor
diff_ij means a differential ray with initial differential in dimension i, evaluated in j diff_xy means the differential ray with an initial dX in the x dimension on the source plane, and these are the coordinates of that ray in the y-axis on the detector plane
- Parameters:
central_u (numpy.ndarray) – array describing the central rays position or angle in x or l
central_v (numpy.ndarray) – array describing the central rays position or angle in y or m
diff_uu (numpy.ndarray) – array describing the differential rays position or angle in x or l
diff_uv (numpy.ndarray) – array describing the differential rays position or angle in y or m
diff_vu (numpy.ndarray) – array describing the differential rays position or angle in y or m
diff_vv (numpy.ndarray) – array describing the differential rays position or angle in y or m
du (float) – differential on sourc plane in position or angle in x or l
dv (float) – differential on sourc plane in position or angle in y or m
- Returns:
sub-matrix of the ray transfer tensor
- Return type:
numpy.ndarray
- poke.beamlets.disp_array(array, cmap='viridis')
- poke.beamlets.distance_to_transversal(r_pixel, r_ray, k_ray)
- poke.beamlets.extra_factors(rho_1m, rho_2, B, A)
compute the extra phase factor from ray data
- Returns:
phase factors from tilt/decenter
- Return type:
numpy.ndarray
- poke.beamlets.guoy_phase(Qpinv)
compute the guoy phase of a complex curvature matrix
- Parameters:
Qpinv (numpy.ndarray) – N x 2 x 2 complex curvature matrix
- Returns:
guoy phase of the complex curvature matrix
- Return type:
numpy.ndarray
- poke.beamlets.misaligned_beamlet_field(xData, yData, zData, lData, mData, nData, opd, dPx, dPy, dHx, dHy, dcoords, dnorm, wavelength=1.65e-06, nloops=1, use_centroid=True, vignetting=None)
computes the coherent beamlet decomposition field from ray data. This is an experimental function that is intented to skip the overhead of beamlet_decomposition_field, reducing the complexity by a factor of Npix. It’s based on the work by Weber https://www.tandfonline.com/doi/full/10.1080/09500340600842237
We perform an additional step where we subtract the aberrations of second-order (focus, astigmatism) by virtue of a Zernike decomposition. This because ray transfer matrices actually describe the behavior of an astigmatic system, so supplying the information for focus and astigmatism is redundant.
- Parameters:
xData (numpy.ndarray) – the x position coordinates of the rays at the final field of evaluation
yData (numpy.ndarray) – the y position coordinates of the rays at the final field of evaluation
zData (numpy.ndarray) – the z position coordinates of the rays at the final field of evaluation
mData (numpy.ndarray) – the l position coordinates of the rays at the final field of evaluation
lData (numpy.ndarray) – the m position coordinates of the rays at the final field of evaluation
nData (numpy.ndarray) – the n position coordinates of the rays at the final field of evaluation
opd (numpy.ndarray) – the OPD of the rays at the final field of evaluation
dPx (float) – The ray differential in position used to compute the ABCD matrix
dPy (float) – The ray differential in position used to compute the ABCD matrix
dHx (float) – The ray differential in direction cosine used to compute the ABCD matrix
dHy (float) – The ray differential in direction cosine used to compute the ABCD matrix
dcoords (N x 3 numpy.ndarray) – coordinates of detector on final field of evaluation
dnorm (N x 3 numpy.ndarray or, a single vector) – surface normal of detector on final field of evaluation
- poke.beamlets.misalignment_phase(rho_1m, the_1m, rho_2m, the_2m)
- poke.beamlets.optical_path_and_delta(OPD, Delta)
compute the total optical path experienced by a beamlet
- Parameters:
OPD (numpy.ndarray) – optical path difference from raytracing code
Delta (numpy.ndarray) – optical path propagation from evaluation plane to transversal plane
- Returns:
the total optical path experienced by a ray
- Return type:
numpy.ndarray
- poke.beamlets.orthogonal_transformation_matrix(n, normal)
generates the orthogonal transformation to the transversal plane
- Parameters:
n (N x 3 vector, typically k_ray[0]) – vector normal to the transversal plane, typically the central ray of a beamlet
normal (N x 3 vector, typically (0,0,1)) – local surface normal of the detector plane
- Returns:
O – orthogonal transformation matrix
- Return type:
Nx3x3 ndarray
- poke.beamlets.prop_complex_curvature(Qinv, A, B, C, D)
propagate a complex curvature matrix Qinv
- Parameters:
Qinv (numpy.ndarray) – N x 2 x 2 complex curvature matrix
A (numpy.ndarray) – N x 2 x 2 sub matrix of the ray transfer tensor
B (numpy.ndarray) – N x 2 x 2 sub matrix of the ray transfer tensor
C (numpy.ndarray) – N x 2 x 2 sub matrix of the ray transfer tensor
D (numpy.ndarray) – N x 2 x 2 sub matrix of the ray transfer tensor
- Returns:
propagated complex curvature matrices
- Return type:
numpy.ndarray
- poke.beamlets.propagate_rays_and_transform(r_ray, k_ray, Delta, O)
propagate rays in free space
- Parameters:
r_rays (ndarray) – position vectors
k_rays (ndarray) – direction cosine vectors
Delta (_type_) – distances to propagate along k_rays
- Returns:
broadcasted r and k rays after propagating
- Return type:
r_rays,k_rays
- poke.beamlets.transversal_phase(Qpinv, r)
compute the transverse gaussian phase of a gaussian beam
- Parameters:
Qpinv (numpy.ndarray) – N x 2 x 2 complex curvature matrix
r (numpy.ndarray) – N x 2 radial coordinate vector
- Returns:
phase of the gaussian profile
- Return type:
numpy.ndarray
poke.interfaces module
interfaces with POPPY, HCIPy
- poke.interfaces.jones_pupil_to_hcipy_wavefront(jones_pupil, pupil_grid, input_stokes_vector=[1, 0, 0, 0], shape=None)
converts a poke jones pupil to an HCIPy partially polarized wavefront, only works on square jones pupils
- Parameters:
jones_pupil (numpy.ndarray) – poke jones pupil, typically Rayfront.jones_pupil
pupil_grid (hcipy.PupilGrid) – Pupil grid from hcipy that the jones pupil is defined on
input_stokes_vector (list, optional) – stokes vector of the wavefront, by default [1,0,0,0]
shape (int, optional) – dimension on the side of the square jones pupil, by default None
- Returns:
hcipy.Wavefront containing the Jones pupil data
- Return type:
wavefront
- poke.interfaces.jones_pupil_to_poppy_wavefronts(jones_pupil, wavelength=1e-06, shape=None)
converts a Poke jones pupil to a POPPY wavefront list
- Parameters:
jones_pupil (numpy.ndarray) – poke jones pupil, typically Rayfront.jones_pupil
wavelength (float, optional) – wavelength in meters, by default 1e-6
shape (int, optional) – dimension on the side of the square jones pupil, by default None
- Returns:
list of poppy.Wavefronts
- Return type:
wflist
- poke.interfaces.rayfront_to_hcipy_wavefront(rayfront, npix, pupil_grid, nmodes=11, input_stokes_vector=[1, 0, 0, 0], which=-1)
convert rayfront to an hcipy wavefront using zernike decomposition
- Parameters:
rayfront (poke.Rayfront) – rayfront which contains the jones pupils to perform the decomposition on
npix (int) – number of pixels along the side of the jones pupils this function returns
pupil_grid (hcipy pupil grid) – HCIPy pupil grid to define the Wavefront on
nmodes (int, optional) – number of Zernike modes to use in the decomposition, by default 11
input_stokes_vector (list, optional) – stokes vector that defines the polarization of the wavefront, by default [1,0,0,0]
which (int, optional) – which jones pupil in the Rayfront.jones_pupil list to use, by default -1
- Returns:
hcipy partially polarized Wavefront defined with the Jones pupil
- Return type:
hcipy.Wavefront
- poke.interfaces.regularly_space_jones(rayfront, nmodes, npix, which=-1, return_residuals=False)
converts a jones pupil from a rayfront to a regularly-spaced array with zernike decomposition
- Parameters:
rayfront (poke.Rayfront) – Rayfront that holds the jones pupil
nmodes (int) – number of modes to use in the decomposition
npix (int) – number of samples along the side of the output array
which (int, optional) – which jones pupil in the rf.jones_pupil list to use, by default -1
return_residuals (bool, optional) – Whether to return the full np.linalg.lstsq residuals, by default False
- Returns:
npix x npix x 2 x 2 array containing the jones pupil data
- Return type:
numpy.ndarray
- poke.interfaces.zernike(rho, phi, J)
Generates an array containing Zernike polynomials contributed by Emory Jenkins with edits made by Jaren Ashcraft
- Parameters:
rho (numpy.ndarray) – radial coordinate
phi (numpy.ndarray) – azimuthal coordinate
J (int) – maximum number of modes to use, Noll indexed
- Returns:
values – array containing the Zernike modes
- Return type:
numpy.ndarray
poke.plotting module
- poke.plotting.jones_pupil(raybundle, which=-1, coordinates='polar')
plot the jones pupil
- Parameters:
raybundle (poke.Rayfront) – Rayfront that holds the jones pupil you wish to plot
which (int, optional) – Which index of the jones pupil list to plot, by default -1
coordinates (str, optional) – The expression of the complex variable. ‘polar’ plots magnitude and phase. ‘cartesian’ plots real and imaginary
- poke.plotting.mueller_pupil(M)
- poke.plotting.point_spread_matrix(PSM)
- poke.plotting.prt_pupil(raybundle, which=-1, coordinates='polar')
plot the 3x3 PRT pupil
- Parameters:
raybundle (poke.Rayfront) – Rayfront that holds the PRT pupil you wish to plot
which (int, optional) – Which index of the PRT pupil list to plot, by default -1
coordinates (str, optional) – The expression of the complex variable. ‘polar’ plots magnitude and phase. ‘cartesian’ plots real and imaginary
- poke.plotting.ray_opd(raybundle, which=-1)
plot the OPD of the ray trace
- Parameters:
raybundle (poke.Rayfront) – the Rayfront that holds the data you wish to plot
which (int, optional) – Which index of the jones pupil list to plot, by default -1
poke.poke_core module
- class poke.poke_core.Rayfront(nrays, wavelength, pupil_radius, max_fov, normalized_pupil_radius=1, fov=[0.0, 0.0], waist_pad=None, circle=True, grid='even')
Bases:
object- Attributes:
- surfaces
Methods
optional constructor to init the rayfront for GBD, comes with additional args
as_polarized(surfaces)optional constructor to init the rayfront for PRT, comes with additional args
beamlet_decomposition_field(dcoords[, ...])computes the coherent field by decomposing the entrance pupil into gaussian beams and propagating them to the final surface
compute_arm([pad, circle, is_square])Computes the amplitude response matrix from the Jones Pupil, requires a square array
compute_jones_pupil([ambient_index, aloc, ...])compute jones pupil from ray data using the double pole coordinate system
compute_psm([cut, stokes])We regrettably need to loop over this because we use numpy.kron()
convert_data_sourcemodule([new_backend])This is a bit cursed, but in the case where data is initialized in numpy, but we want to use it in Jax/Cupy, then we have to convert it and vice versa
trace_rayset(pth[, wave, surfaces, ...])- as_gaussianbeamlets(wo)
optional constructor to init the rayfront for GBD, comes with additional args
- Parameters:
wo (float) – The gaussian beam waist used to decompose the field. Coupled to nrays and OF
- as_polarized(surfaces)
optional constructor to init the rayfront for PRT, comes with additional args
- Parameters:
surfaces (list of dicts) –
- list of dictionaries that contain {
‘surf’ : surface number in raytrace code ‘coating’ : complex float or list ‘mode’ : ‘reflect’ or ‘refract’ }
- beamlet_decomposition_field(dcoords, dnorms=array([0., 0., 1.]), memory_avail=4, misaligned=True, vignette=True)
computes the coherent field by decomposing the entrance pupil into gaussian beams and propagating them to the final surface
- Parameters:
dcoords (Nx3 numpy.ndarray) – coordinates of detector pixels
dnorms (Nx3 numpy.ndarray) – coordinates of detector pixel surface normals. Nominally useful for tilted or curved detectors. Defaults to pointing along the local z-axis of the detector surface
memory_avail (int) – amount of memory in GB to use for field calculation
- compute_arm(pad=2, circle=True, is_square=True)
Computes the amplitude response matrix from the Jones Pupil, requires a square array
- compute_jones_pupil(ambient_index=1, aloc=array([0., 0., 1.]), entrance_x=array([1., 0., 0.]), exit_x=array([1., 0., 0.]), proper_retardance=False, coordinates='double', collimated_object=True)
compute jones pupil from ray data using the double pole coordinate system
- Parameters:
ambient_index (float, optional) – refractive index the system is immersed in, by default 1
aloc (numpy.ndarray, optional) – direction of the double antipole - typically use the optical axis ray direction cosines, by default np.array([0.,0.,1.])
entrance_x (numpy.ndarray, optional) – input local x-axis in global coordinates, by default np.array([1.,0.,0.])
exit_x (numpy.ndarray, optional) – output local x-axis in global coordinates, by default np.array([1.,0.,0.])
proper_retardance (bool, optional) – whether to use the “proper” retardance calculation, by default False
coordinates (string) – type of local coordinate transformation to use. Options are “double” for the double-pole coordinate system, and “dipole” for the dipole coordinate system.
collimated_object (bool) – If object space is collimated or not. If true, applies same basis vectors to all input rays, otherwise, it computes them on a curved surface.
- compute_psm(cut=128, stokes=array([1., 0., 0., 0.]))
We regrettably need to loop over this because we use numpy.kron()
- convert_data_sourcemodule(new_backend='numpy')
This is a bit cursed, but in the case where data is initialized in numpy, but we want to use it in Jax/Cupy, then we have to convert it and vice versa
- property surfaces
- trace_rayset(pth, wave=1, surfaces=None, ref_surf=1, _experimental=True)
- Parameters:
pth (str) – path to the lens file you want to run the ray trace on
wave (int) – wavelength number in the lens data editor to run ray trace for, Defaults to 1
surfaces (list of dictionaries) – List of surface dictionaries to guide the raytrace. Optional, if None uses self.surflist
ref_surf (int) – Global coordinate reference surface, defaults to 1
_experimental (boolean) – If True, default to the faster code v ray trace
poke.poke_math module
- class poke.poke_math.BackendShim(src)
Bases:
objectA shim that allows a backend to be swapped at runtime. Taken from prysm.mathops with permission from Brandon Dube
- poke.poke_math.broadcast_kron(a, b)
broadcasted kronecker product of two N,M,…,2,2 arrays. Used for jones -> mueller conversion In the unbroadcasted case, this output looks like
- out = [a[0,0]*b,a[0,1]*b]
[a[1,0]*b,a[1,1]*b]
where out is a N,M,…,4,4 array. I wrote this to work for generally shaped kronecker products where the matrix is contained in the last two axes, but it’s only tested for the Nx2x2 case
- Parameters:
a (numpy.ndarray) – N,M,…,2,2 array used to scale b in kronecker product
b (numpy.ndarray) – N,M,…,2,2 array used to form block matrices in kronecker product
- Returns:
N,M,…,4,4 array
- Return type:
out
- poke.poke_math.det_2x2(array)
compute determinant of 2x2 matrix, broadcasted
- Parameters:
array (numpy.ndarray) – array containing 2x2 matrices in last dimension. Returns determinant array of shape array.shape[:-2]
- Returns:
determinant array
- Return type:
det
- poke.poke_math.eigenvalues_2x2(array)
Computes the eigenvalues of a 2x2 matrix using a trick
- Parameters:
array (numpy.ndarray) – a N x 2 x 2 array that we are computing the eigenvalues of
- Returns:
e1, e2 – The eigenvalues of the array
- Return type:
floats of shape N
- poke.poke_math.mat_inv_2x2(array)
compute inverse of 2x2 matrix, broadcasted
- Parameters:
array (numpy.ndarray) – array containing 2x2 matrices in last dimension. Returns inverse array of shape array.shape
- Returns:
matrix inverse array
- Return type:
matinv
- poke.poke_math.mat_inv_3x3(array)
compute inverse of 3x3 matrix, broadcasted
- Parameters:
array (numpy.ndarray) – array containing 3x3 matrices in last dimension. Returns inverse array of shape array.shape
- Returns:
matrix inverse array
- Return type:
matinv
- poke.poke_math.pauli_spin_matrix(i)
Returns the pauli spin matrix of index i
- Parameters:
i (int) – pauli spin matrix index. Can be 0, 1, 2, or 3
- Returns:
Pauli spin matrix of the corresponding index
- Return type:
ndarray
- poke.poke_math.rotation3D(angle, axis)
Rotation matrix about an axis by an angle
- Parameters:
angle (float) – rotation angle in radians
axis (ndarray) – shape 3 vector in cartesian coordinates to rotate about
- Returns:
mat – rotation matrix
- Return type:
ndarray
- poke.poke_math.rotation_3d(angle, axis)
Rotation matrix about an axis by an angle
- Parameters:
angle (float) – rotation angle in radians
axis (ndarray) – shape 3 vector in cartesian coordinates to rotate about
- Returns:
mat – rotation matrix
- Return type:
ndarray
- poke.poke_math.set_backend_to_cupy()
Convenience method to automatically configure poke’s backend to cupy.
- poke.poke_math.set_backend_to_jax()
Convenience method to automatically configure poke’s backend to cupy.
- poke.poke_math.set_backend_to_numpy()
Convenience method to automatically configure poke’s backend to cupy.
- poke.poke_math.vectorAngle(u, v)
computes the vector angle between two vectors
- Parameters:
u (ndarray) – shape 3 vector
v (ndarray) – shape 3 vector
- Returns:
vector of angle between u and v in x, y, z in radians
- Return type:
ndarray
- poke.poke_math.vector_angle(u, v)
computes the vector angle between two vectors
- Parameters:
u (ndarray) – shape 3 vector
v (ndarray) – shape 3 vector
- Returns:
vector of angle between u and v in x, y, z in radians
- Return type:
ndarray
- poke.poke_math.vector_norm(vector)
computes the magnitude of a vector
- Parameters:
vector (numpy.ndarray) – N x 3 array containing a 3-vector
- Returns:
magnitude of the vector
- Return type:
numpy.ndarray
poke.polarization module
- poke.polarization.brewsters_angle(n1, n2)
computes Brewster’s angle, or the angle of a dielectric surface such that no p-polarized light is reflected.
- Parameters:
n1 (float) – refractive index of incident medium, or the medium the light is entering from. Typically n1 > n2.
n2 (float) – refractive index of exiting medium, or the medium the light is entering. Typically, n2 < n1
- Returns:
brewster’s angle in radians
- Return type:
float
- poke.polarization.critical_angle(n1, n2)
- poke.polarization.fresnel_coefficients(aoi, n1, n2, mode='reflect')
Computes Fresnel Coefficients for a single surface interaction
- Parameters:
aoi (float or array of floats) – angle of incidence in radians on the interface
n1 (float) – complex refractive index of the incident media
n2 (float) – complex refractive index of the exitant media
- Returns:
fs, fp – the Fresnel s- and p- coefficients of the surface interaction
- Return type:
complex floats
- poke.polarization.global_to_local_coordinates(P, kin, k, a, xin, exit_x, Q=None, coordinates='double', collimated_object=True)
Use the double pole basis to compute the local coordinate system of the Jones pupil. Vectorized to perform on arrays of arbitrary shape, assuming the PRT matrix is in the last two dimensions. Chipman, Lam, Young, from Ch 11 : The Jones Pupil
- Parameters:
Pmat (ndarray) – Pmat is the polarization ray tracing matrix
kin (ndarray) – incident direction cosine vector at the entrance pupil. Generally an ND array where the vector is in the last dimension.
kout (ndarray) – exiting direction cosine vector at the exit pupil. Generally an ND array where the vector is in the last dimension.
a (ndarray) – vector in global coordinates describing the antipole direction
xin (ndarray) – vector in global coordinates describing the input local x direction
exit_x (ndarray) – vector in global coordinates describing the direction that should be the “local x” direction
Q (Parallel Transport matrix) – the non-polarizing PRT matrix, used to account for geometric transformations
coordinates (string) – type of local coordinate transformation to use. Options are “double” for the double-pole coordinate system, and “dipole” for the dipole coordinate system.
- Returns:
J – shape 3 x 3 ndarray containing the Jones pupil of the optical system. The elements Jtot[0,2], Jtot[1,2], Jtot[2,0], Jtot[2,1] should be zero. Jtot[-1,-1] should be 1
- Return type:
ndarray
- poke.polarization.jones_to_mueller(Jones)
Converts a Jones matrix to a Mueller matrix
- Parameters:
Jones (2x2 ndarray) – Jones matrix to convert to a mueller matrix
- Returns:
Mueller matrix from Jones matrix
- Return type:
M
- poke.polarization.jones_to_mueller_broadcast(jones)
- poke.polarization.mueller_to_jones(M)
Converts Mueller matrix to a relative Jones matrix. Phase aberration is relative to the Pxx component.
- Returns:
J – Jones matrix from Mueller matrix calculation
- Return type:
2x2 ndarray
- poke.polarization.orthogonal_transofrmation_matrices(kin, kout, normal)
compute the orthogonal transformation matrices that rotate into and out of the local coordinates of a surface
- Parameters:
kin (numpy.ndarray) – array containing the incident ray vectors
kout (numpy.ndarray) – array containing the exitant ray vectors
normal (numpy.ndarray) – array containing the surface normal vectors
- Returns:
Oinv,Oout – orthogonal transformation matrices
- Return type:
numpy.ndarray
- poke.polarization.prt_matrix(kin, kout, normal, aoi, surfdict, wavelength, ambient_index)
prt matrix for a single surface
- Parameters:
aoi (numpy.ndarray) – array describing the ray angles of incidence on a surface
kin (numpy.ndarray) – array containing the incident ray vectors
kout (numpy.ndarray) – array containing the exitant ray vectors
norm (numpy.ndarray) – array containing the surface normal vectors
surfdict (dict) – dictionary describing the surface interaction
wavelength (float) – wavelength of light the computation is done at
ambient_index (float) – refractive index of material in the exiting space
- Returns:
PRT, Jones, and parallel transport matrices for a given surface
- Return type:
Pmat,J,Qmat
- poke.polarization.system_prt_matrices(aoi, kin, kout, norm, surfaces, wavelength, ambient_index)
computes the PRT matrices for each surface in the optical system
- Parameters:
aoi (numpy.ndarray) – array describing the ray angles of incidence on a surface
kin (numpy.ndarray) – array containing the incident ray vectors
kout (numpy.ndarray) – array containing the exitant ray vectors
norm (numpy.ndarray) – array containing the surface normal vectors
surfaces (list) – list of dictionaries describing the surface interaction
wavelength (float) – wavelength of light the computation is done at
ambient_index (float) – refractive index that the optical system is immersed in
- Returns:
lists of the PRT matrices, Jones matrices, and parallel transport matrices
- Return type:
P,J,Q
- poke.polarization.total_prt_matrix(P, Q)
computes the total PRT matrix for the optical system
- Parameters:
P (list) – prt matrices computed per surface
Q (list) – unpolarized prt matrices computed per surface. Largely for berry phase calculations
- Returns:
the total PRT and Parallel transport matrices
- Return type:
numpy.ndarrays
poke.raytrace module
- poke.raytrace.convert_ray_data_to_prt_data(LData, MData, NData, L2Data, M2Data, N2Data, surflist, ambient_index, aoi_computed)
Function that computes the PRT-relevant data from ray and material data Mathematics principally from Polarized Light and Optical Systems by Chipman, Lam, Young 2018
- Parameters:
LData (ndarray) – Direction cosine in the x direction indexed by 0 = rayset 1 = surface 2 = coordinate
NData (ndarray) – Direction cosine in the y direction indexed by 0 = rayset 1 = surface 2 = coordinate
NData – Direction cosine in the z direction indexed by 0 = rayset 1 = surface 2 = coordinate
L2Data (ndarray) – Surface normal direction cosine in the x direction indexed by 0 = rayset 1 = surface 2 = coordinate
N2Data (ndarray) – Surface normal direction cosine in the y direction indexed by 0 = rayset 1 = surface 2 = coordinate
N2Data – Surface normal direction cosine in the z direction indexed by 0 = rayset 1 = surface 2 = coordinate
surflist (list of dicts) – list of dictionaries that describe surfaces. Including surface number in raytrace, interaction mode, coating, etc.
ambient_index (float) – complex refractive index of the medium the optical system exists in.
aoi_computed (bool) – Wether the angle of incidence was computed by the raytrace
Notes
CODE V direction cosines are multiplied by the refractive index of the medium
- poke.raytrace.trace_through_cv(raysets, pth, surflist, nrays, wavelength, global_coords, global_coord_reference=1, extension='.seq')
trace raysets through a sequential code v optical system
- Parameters:
raysets (numpy.ndarray) – arrays of shape Nrays x 4 that contain the normalized pupil + field data [Px,Py,Hx,Hy]
pth (str) – path to .seq or .len file to trace the rays through
surflist (list of dictionaries) – list of surfaces to trace the rays to
nrays (int) – number of rays to trace
wavelength (float) – wavelength to trace, keep consistent with what is specified in the System Data. CODE V tends to default to nanometers.
global_coords (boolean) – whether to trace rays using global or local coordinates.
global_coord_reference (str, optional) – surface number to use as the global coordinate reference, by default ‘1’
extension (str, optional) – extension of the raytrace file, by default “.seq”
- Returns:
position, direction, surface normal, and OPD data
- Return type:
positions,directions,normals,opd
- poke.raytrace.trace_through_zos(raysets, pth, surflist, nrays, wave, global_coords)
Traces initialized rays through a zemax opticstudio file
- Parameters:
raysets (np.ndarray) – 4 x Nrays array containing normalized pupil coordinates and field coordinates. Structure is like [x1,x2,…,xN] [y1,y2,…,yN] [l1,l2,…,lN] [m1,m2,…,mN]
pth (str) – path to Zemax opticstudio file. Supports .zmx extension, .zos is untested but should work
surflist (list of ints) – list of surface numbers to trace to and record the position of. The rays will hit every surface in the optical system, this just tells the Raybundle if the information at that point should be saved
wave (int, optional) – wavelength number in ZOS file, by default 1
global_coords (bool, optional) – whether to use global coordinates or local coordinates. Defaults to global coordinates. PRT uses global coordinates GBD uses local coordinates
- Returns:
positions (list of ndarrays) – list containing [xData,yData,zData]. Each array contains positions indexed by 0 = rayset 1 = surface 2 = coordinate
directions (list) – list containing [lData,mData,nData]. Each array contains direction cosines indexed by 0 = rayset 1 = surface 2 = coordinate
normals (list) – list containing [l2Data,m2Data,n2Data]. Each array contains surface normals indexed by 0 = rayset 1 = surface 2 = coordinate
opd (ndarray) – Array containing the total optical path of a ray indexed by 0 = rayset 1 = surface 2 = coordinate
poke.thinfilms module
- poke.thinfilms.compute_thin_films_broadcasted(stack, aoi, wavelength, ambient_index=None, substrate_index=1.5, polarization='s')
compute fresnel coefficients for a multilayer stack using the BYU Optics Book method
- Parameters:
stack (list of tuples containing raveled ndarrays, eg. [(n1,d1),(n2,d2),....]) – The reciple that defines the multilayer stack. where n1.shape,d2.shape = aoi.shape
aoi (numpy.ndarray) – angle of incidence on the thin film in radians
wavelength (float) – wavelegnth of the light incident on the thin film stack. Should be in same units as thin film distances.
ambient_index (float, optional) – index optical system is immersed in, by default None, which assumes 1
substrate_index (float, optional) – index of substrate thin film is deposited on, by default 1.5
polarization (str, optional) – polarization state to compute values for, can be ‘s’ or ‘p’, by default ‘s’
- Returns:
fresnel coefficients for the polarization specified
- Return type:
rf,tf
- poke.thinfilms.compute_thin_films_macleod(stack, aoi, wavelength, ambient_index=1, substrate_index=1.5, polarization='s')
compute fresnel coefficients for a multilayer stack using the Macleod 1969 method
- Parameters:
stack (list of tuples containing raveled ndarrays, eg. [(n1,d1),(n2,d2),....]) – The reciple that defines the multilayer stack. where n1.shape,d2.shape = aoi.shape
aoi (numpy.ndarray) – angle of incidence on the thin film in radians
wavelength (float) – wavelegnth of the light incident on the thin film stack. Should be in same units as thin film distances.
ambient_index (float, optional) – index optical system is immersed in, by default 1
substrate_index (float, optional) – index of substrate thin film is deposited on, by default 1.5
polarization (str, optional) – polarization state to compute values for, can be ‘s’ or ‘p’, by default ‘s’
- Returns:
fresnel coefficients for the polarization specified
- Return type:
rf,tf
poke.writing module
- class poke.writing.MsgpackTrickerEmpty
Bases:
objectdummy class to trick msgpack
- poke.writing.deserialize(buf)
deserializes a class using msgpack written by Brandon Dube, docstring by Jaren Ashcraft
- Parameters:
buf (serdat) – serial data coorresponding to class
- Returns:
deserialized class, typically a rayfront
- Return type:
class
- poke.writing.jones_to_fits(rayfront, filename, realimag=True, which=-1, nmodes=11, npix=128)
Write a N x N x 2 x 2 x 2 Jones Pupil to a FITS file
- Parameters:
rayfront (poke.Rayfront) – Jones pupil data generated by poke. Generally the first two dimensions are square, and correspond to the exit pupil coordinate. The remainder are matrix row, column, and then real/imag
filename (str) – name of file to save the jones pupil as
realimag (bool) – whether to save in real/imaginary parts. Defaults to True. If False, saves as absolute value and phase.
which (int) – Which index of the poke.Rayfront.jones_pupil list to save, by default -1 or the most recent
nmodes (int) – Number of Noll-ordered Zernike polynomials to use in the decomposition, by default 11
npix (int) – Number of samples along one dimension of the square jones pupil, by default 128
- poke.writing.read_serial_to_rayfront(filename)
reads serial data containing Rayfront into a Rayfront object
- Parameters:
filename (str) – name of the file to read serial data from
- Returns:
the saved poke.Rayfront object
- Return type:
poke.Rayfront
- poke.writing.serialize(T)
serializes a class using msgpack written by Brandon Dube, docstring by Jaren Ashcraft
- Parameters:
T (class) – class to convert to hex code. Used for rayfronts
- Returns:
serial data corresponding to class T
- Return type:
serdat
- poke.writing.write_rayfront_to_serial(rayfront, filename)
writes rayfront to serial file using msgpack
- Parameters:
rayfront (poke.Rayfront) – Rayfront object to serialize
filename (str) – name of the file to save serial data to. The .msgpack extension will be added to this string
Module contents
poke base file