Esempio n. 1
0
def test_polychromatic_functions():
    from prysm import Pupil
    p1 = Pupil(wavelength=0.55)
    p2 = Pupil(wavelength=0.5)
    p3 = Pupil(wavelength=0.6)

    psfs = [psf.PSF.from_pupil(p, 1) for p in [p1, p2, p3]]
    poly = psf.PSF.polychromatic(psfs)
    assert isinstance(poly, psf.PSF)
Esempio n. 2
0
def test_doesnt_recalculate_when_psf_caches_mtf():
    from prysm import Pupil, PSF
    pu = Pupil()
    ps = PSF.from_pupil(pu, 2)
    mt = otf.MTF.from_psf(ps)
    ps._mtf = mt
    mt2 = otf.MTF.from_psf(ps)
    assert id(mt) == id(mt2)
Esempio n. 3
0
def test_polychromatic_functions():
    from prysm import Pupil
    from prysm.wavelengths import HeNe, Cu, XeF
    pupils = [Pupil(wavelength=wvl) for wvl in (HeNe, Cu, XeF)]

    psfs = [psf.PSF.from_pupil(p, 1) for p in pupils]
    poly = psf.PSF.polychromatic(psfs)
    assert isinstance(poly, psf.PSF)
Esempio n. 4
0
def test_diffprop_matches_airydisk(efl, epd, wvl):
    fno = efl / epd

    p = Pupil(wavelength=wvl, epd=epd)
    psf = PSF.from_pupil(p, efl)
    u, sx = psf.slice_x
    u, sy = psf.slice_y
    analytic = airydisk(u, fno, wvl)
    assert np.allclose(sx, analytic, rtol=PRECISION, atol=PRECISION)
    assert np.allclose(sy, analytic, rtol=PRECISION, atol=PRECISION)
Esempio n. 5
0
def test_diffprop_matches_airydisk(efl, epd, wvl):
    fno = efl / epd

    p = Pupil(wavelength=wvl, epd=epd)
    psf = PSF.from_pupil(p, efl, Q=3)  # use Q=3 not Q=4 for improved accuracy
    u, sx = psf.slice_x
    u, sy = psf.slice_y
    analytic = _airydisk(u, fno, wvl)
    assert np.allclose(sx, analytic, atol=PRECISION)
    assert np.allclose(sy, analytic, atol=PRECISION)
Esempio n. 6
0
def test_diffprop_matches_airydisk(efl, epd, wvl):
    fno = efl / epd

    p = Pupil(dia=epd, xy_unit=u.mm, z_unit=u.nm, wavelength=mkwvl(wvl, u.um))
    psf = PSF.from_pupil(p, efl, Q=3)  # use Q=3 not Q=4 for improved accuracy
    s = psf.slices()
    u_, sx = s.x
    u_, sy = s.y
    analytic = airydisk(u_, fno, wvl)
    assert np.allclose(sx, analytic, atol=PRECISION)
    assert np.allclose(sy, analytic, atol=PRECISION)
Esempio n. 7
0
def test_pupil_passes_valid_params():
    parameters = {
        'samples': 16,
        'epd': 128.2,
        'wavelength': 0.6328,
        'opd_unit': 'nm'}
    p = Pupil(**parameters)
    assert p.samples == parameters['samples']
    assert p.epd == parameters['epd']
    assert p.wavelength == parameters['wavelength']
    assert p._opd_str == parameters['opd_unit']
    assert p._opd_unit == 'nanometers'  # make sure this is updated if the test is changed to a different unit
Esempio n. 8
0
def test_pupil_passes_valid_params():
    parameters = {
        'samples': 16,
        'dia': 128.2,
        'wavelength': 0.6328,
        'opd_unit': 'nm'
    }
    p = Pupil(**parameters)
    assert p.samples == parameters['samples']
    assert p.dia == parameters['dia']
    assert p.wavelength == parameters['wavelength']
    assert p.phase_unit == 'nm'
Esempio n. 9
0
def test_diffprop_matches_analyticmtf(efl, epd, wvl):
    fno = efl / epd
    p = Pupil(wavelength=wvl, epd=epd)
    psf = PSF.from_pupil(p, efl)
    mtf = MTF.from_psf(psf)
    u, t = mtf.tan
    uu, s = mtf.sag

    analytic_1 = diffraction_limited_mtf(fno, wvl, frequencies=u)
    analytic_2 = diffraction_limited_mtf(fno, wvl, frequencies=uu)
    assert np.allclose(analytic_1, t, rtol=PRECISION, atol=PRECISION)
    assert np.allclose(analytic_2, s, rtol=PRECISION, atol=PRECISION)
Esempio n. 10
0
def test_diffprop_matches_analyticmtf(efl, epd, wvl):
    fno = efl / epd
    p = Pupil(dia=epd, xy_unit=u.mm, z_unit=u.nm, wavelength=mkwvl(wvl, u.um))
    psf = PSF.from_pupil(p, efl)
    mtf = MTF.from_psf(psf)
    s = mtf.slices()
    u_, x = s.x
    u__, y = s.y

    analytic_1 = diffraction_limited_mtf(fno, wvl, frequencies=u_)
    analytic_2 = diffraction_limited_mtf(fno, wvl, frequencies=u__)
    assert np.allclose(analytic_1, x, atol=PRECISION)
    assert np.allclose(analytic_2, y, atol=PRECISION)
Esempio n. 11
0
def test_create_pupil():
    p = Pupil()
    assert hasattr(p, 'wavelength')
    assert hasattr(p, 'epd')
    assert hasattr(p, 'sample_spacing')
    assert hasattr(p, 'samples')
    assert hasattr(p, 'opd_unit')
    assert hasattr(p, '_opd_unit')
    assert hasattr(p, '_opd_str')
    assert hasattr(p, 'phase')
    assert hasattr(p, 'fcn')
    assert hasattr(p, 'unit')
    assert hasattr(p, 'rho')
    assert hasattr(p, 'phi')
    assert hasattr(p, 'center')
Esempio n. 12
0
def test_create_pupil():
    p = Pupil()
    assert hasattr(p, 'wavelength')
    assert hasattr(p, 'diameter')
    assert hasattr(p, 'sample_spacing')
    assert hasattr(p, 'samples')
    assert hasattr(p, 'phase_unit')
    assert hasattr(p, 'spatial_unit')
    assert hasattr(p, 'phase')
    assert hasattr(p, 'fcn')
    assert hasattr(p, 'unit_x')
    assert hasattr(p, 'unit_y')
    assert hasattr(p, 'rho')
    assert hasattr(p, 'phi')
    assert hasattr(p, 'center_x')
    assert hasattr(p, 'center_y')
Esempio n. 13
0
def test_passed_phase_is_not_ignored():
    phase = np.random.rand(32, 32)
    x = y = np.linspace(-1, 1, 128)
    p = Pupil(x=x, y=y, phase=phase)
    assert np.all(p.phase == phase)
    assert p.samples_y == 32
Esempio n. 14
0
def p():
    return Pupil()
Esempio n. 15
0
def test_OTF_from_pupil_functions():
    from prysm import Pupil
    pu = Pupil()
    ot = otf.OTF.from_pupil(pu, 2)
    assert ot
Esempio n. 16
0
def test_from_pupil_functions():
    from prysm import Pupil
    pu = Pupil()
    mt = otf.MTF.from_pupil(pu, 2)
    assert mt
Esempio n. 17
0
def test_pupil_passes_valid_params():
    parameters = {'samples': 16, 'dia': 128.2}
    p = Pupil(**parameters)
    assert p.samples == parameters['samples']
    assert p.diameter == parameters['dia']
Esempio n. 18
0
def test_coherent_propagation_is_used_in_object_oriented_api():
    p = Pupil()
    ps = psf.PSF.from_pupil(p, 1, incoherent=False)
    assert ps.data.dtype == np.complex128
Esempio n. 19
0
def test_pupil_rejects_bad_opd_unit():
    with pytest.raises(ValueError):
        Pupil(opd_unit='foo')
Esempio n. 20
0
def sample_psf():
    p = Pupil()
    return PSF.from_pupil(p, 10)
Esempio n. 21
0
def test_pupil_from_interferogram_does_not_error():
    i = Interferogram.from_zygo_dat(sample_files('dat'))
    pu = Pupil.from_interferogram(i)
    assert pu
Esempio n. 22
0
def sample_psf_bigger():
    p = Pupil()
    return PSF.from_pupil(p, 20)