def config_codex_params_to_pupil(config, codex, params, defocus=0): """Convert a config dictionary, codex dictionary, and parameter vector to a pupil. Parameters ---------- config : `dict` dictionary with keys efl, fno, wavelength, samples codex : `dict` dict with integer, string key value pairs, e.g. {0: 'Z1', 1: 'Z9'} params : iterable sequence of optimization parameters defocus : `float`, optional amount of defocus applied in the same units as params Returns ------- `prysm.Pupil` a pupil object """ s = config pupil_pass_zernikes = { key: value for (key, value) in zip(codex.values(), params) } pupil_pass_zernikes['Z4'] += defocus return FringeZernike(**pupil_pass_zernikes, base=1, epd=s.efl / s.fno, wavelength=s.wvl, samples=s.samples, rms_norm=s.focus_normed, mask=s.mask)
def test_array_orientation_consistency_tilt(): """The pupil array should be shaped as arr[y,x], as should the psf and MTF. A linear phase error in the pupil along y should cause a motion of the PSF in y. Specifically, for a positive-signed phase, that should cause a shift in the +y direction. """ samples = 128 p = FringeZernike(Z2=1000, base=1, samples=samples) ps = PSF.from_pupil(p, 1) idx_y, idx_x = np.unravel_index(ps.data.argmax(), ps.data.shape) # row-major y, x assert idx_x == ps.center_x assert idx_y > ps.center_y
# In[2]: import inspect import numpy as np from scipy import interpolate, optimize from prysm import NollZernike, MTF, PSF, FringeZernike from matplotlib import pyplot as plt from lentil import FocusSet from lentil.constants_utils import * # 9, 16, 25, 36 for z in range(3, 60): print(z) p = FringeZernike(**{"Z{}".format(z): 0.3}) print(z) p.plot2d() plt.show() exit() plt.style.use('bmh') if 0: dia = 10 fnos = [1, 4] opds = [.4, .1] mtfs = [] for fno, opd in zip(fnos, opds): z = NollZernike(Z11=opd, norm=True, dia=dia,
def p_tlt(): return FringeZernike(Z2=1, samples=64)