예제 #1
0
def test_psf_to_pupil_sample_inverts_pupil_to_psf_sample(dzeta):
    samples, wvl, efl = 128, 0.55, 10
    psf_sample = propagation.pupil_sample_to_psf_sample(
        dzeta, samples, wvl, efl)
    dzeta2 = propagation.psf_sample_to_pupil_sample(psf_sample, samples, wvl,
                                                    efl)
    assert dzeta2 == dzeta
# The above specification determine a Q of:
Q = (wlen) * (fno) / pixel_pitch

# Need Q_forward >= 2 for forward model, so Q_forward = Q*(oversampling) = 2
oversampling = ceil(2 / Q)
Q_forward = round(Q * oversampling, 1)

# Intermediate higher res gives psize = pixel_pitch/oversampling
psize = pixel_pitch / oversampling

# PSF_domain_res will be output_res*oversampling
# Pupil domain samples will be (PSF_domain_res)/Q_forward
samples = ceil(output_res * oversampling / Q_forward)

# Find pupil dx from wanted psize
pup_dx = psf_sample_to_pupil_sample(psize, samples, wlen, f)

# Construct pupil grid, convert to polar, construct normalized r for phase
xi, eta = make_xy_grid(samples, dx=pup_dx)
r, theta = cart_to_polar(xi, eta)
norm_r = r / lens_R

# Construct amplitude function of pupil function
amp = circle(lens_R, r)
amp = amp / amp.sum()

# Construct phase mode
aber = zernike_nm(4, 0, norm_r, theta)  # spherical aberration
# Scale phase mode to desired opd
phase = aber * wlen / 16 * 1e3