示例#1
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)
示例#2
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)
示例#3
0
def prep_data(sys_parameters, truth_df):
    """Extract data needed for optimization from the system parameters and truth data.

    Parameters
    ----------
    sys_parameters : `prysm.macros.SetupParameters`
        a setupparameters namedtuple
    truth_df : `pandas.DataFrame`
        a pandas DF with columns Field, Focus, Azimuth, MTF

    Returns
    -------
    `OptSetup`
        optimization setup namedtuple with focus diversity, t and s truth data, and diffraction data

    """
    focus_diversity, ax_t, ax_s = grab_axial_data(sys_parameters, truth_df)

    # casting ndarray to list makes it a list of arrays where the first index
    # is the focal plane and the second frequency.
    t_true, s_true = list(ax_t), list(ax_s)

    # now compute diffraction for the setup and use it as a normailzation
    diffraction = diffraction_limited_mtf(sys_parameters.fno, sys_parameters.wvl, frequencies=sys_parameters.freqs)

    return OptSetup(
        focus_diversity=focus_diversity,
        t_true=t_true,
        s_true=s_true,
        diffraction=diffraction)
示例#4
0
def test_diffprop_matches_analyticmtf(efl, epd, wvl):
    fno = efl / epd
    x, y = make_xy_grid(128, diameter=epd)
    r, t = cart_to_polar(x, y)
    amp = circle(epd/2, r)
    wf = Wavefront.from_amp_and_phase(amp, None, wvl, x[0, 1] - x[0, 0])
    psf = wf.focus(efl, Q=3).intensity
    mtf = mtf_from_psf(psf.data, psf.dx)
    s = mtf.slices()
    u_, sx = s.x
    u_, sy = 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, sx, atol=PRECISION)
    assert np.allclose(analytic_2, sy, atol=PRECISION)