Exemplo n.º 1
0
def test_precomputed_angular_spectrum_functions():
    data = np.random.rand(2, 2)
    wf = propagation.Wavefront(cmplx_field=data, dx=1, wavelength=.6328)
    tf = propagation.angular_spectrum_transfer_function(
        2, wf.wavelength, wf.dx, 1)
    wf2 = wf.free_space(tf=tf)
    assert wf2
Exemplo n.º 2
0
def test_can_mul_wavefronts():
    data = np.random.rand(2, 2).astype(np.complex128)
    x = np.array([1, 2])
    y = np.array([1, 2])
    wf = propagation.Wavefront(x=x, y=y, fcn=data, wavelength=.6328)
    wf2 = wf * 2
    assert wf2
Exemplo n.º 3
0
def test_obj_oriented_wavefront_focusing_reverses():
    x = y = np.arange(128, dtype=np.float32)
    z = np.random.rand(128, 128)
    wf = propagation.Wavefront(x=x, y=y, fcn=z, wavelength=HeNe)
    wf2 = wf.focus(1, 1).unfocus(
        1, 1
    )  # first is efl, meaningless.  second is Q, we neglect padding at the moment
    assert np.allclose(wf.fcn, wf2.fcn)
Exemplo n.º 4
0
def test_obj_oriented_wavefront_focusing_reverses():
    z = np.random.rand(128, 128)
    dx = 1
    wf = propagation.Wavefront(dx=dx, cmplx_field=z, wavelength=HeNe)
    wf2 = wf.focus(1, 1).unfocus(
        1,
        1)  # first is efl, meaningless.  second is Q, we neglect padding here
    assert np.allclose(wf.data, wf2.data)
Exemplo n.º 5
0
def test_frespace_functions():
    dx = 1
    z = np.random.rand(SAMPLES, SAMPLES)
    wf = propagation.Wavefront(dx=dx,
                               cmplx_field=z,
                               wavelength=HeNe,
                               space='pupil')
    wf = wf.free_space(1, 1)
    assert wf
Exemplo n.º 6
0
def test_focus_fft_mdft_equivalent_Wavefront():
    x = y = np.linspace(-1, 1, SAMPLES)
    z = np.random.rand(SAMPLES, SAMPLES)
    wf = propagation.Wavefront(x=x, y=y, fcn=z, wavelength=HeNe, space='pupil')
    unfocus_fft = wf.focus(Q=2, efl=1)
    unfocus_mdft = wf.focus_fixed_sampling(
        efl=1,
        sample_spacing=unfocus_fft.sample_spacing,
        samples=unfocus_fft.samples_x)

    assert np.allclose(unfocus_fft.data, unfocus_mdft.data)
Exemplo n.º 7
0
def test_focus_fft_mdft_equivalent_Wavefront():
    dx = 1
    z = np.random.rand(SAMPLES, SAMPLES)
    wf = propagation.Wavefront(dx=dx,
                               cmplx_field=z,
                               wavelength=HeNe,
                               space='pupil')
    unfocus_fft = wf.focus(Q=2, efl=1)
    unfocus_mdft = wf.focus_fixed_sampling(efl=1,
                                           dx=unfocus_fft.dx,
                                           samples=unfocus_fft.data.shape[1])

    assert np.allclose(unfocus_fft.data, unfocus_mdft.data)
Exemplo n.º 8
0
def test_unfocus_fft_mdft_equivalent_Wavefront():
    x = y = np.linspace(-1, 1, SAMPLES)
    z = np.random.rand(SAMPLES, SAMPLES)
    wf = propagation.Wavefront(x=x, y=y, fcn=z, wavelength=HeNe, space='psf')
    unfocus_fft = wf.unfocus(Q=2, efl=1)
    # magic number 4 - a bit unclear, but accounts for non-energy
    # conserving fft; sf is to satisfy parseval's theorem
    sf = fttools.mdft._norm(wf.data, 2, unfocus_fft.samples_x) * 4
    unfocus_mdft = wf.unfocus_fixed_sampling(
        efl=1,
        sample_spacing=unfocus_fft.sample_spacing,
        samples=unfocus_fft.samples_x)

    assert np.allclose(unfocus_fft.data, unfocus_mdft.data/sf)
Exemplo n.º 9
0
def test_unfocus_fft_mdft_equivalent_Wavefront():
    z = np.random.rand(128, 128)
    dx = 1
    wf = propagation.Wavefront(dx=dx,
                               cmplx_field=z,
                               wavelength=HeNe,
                               space='psf')
    unfocus_fft = wf.unfocus(Q=2, efl=1)
    # magic number 4 - a bit unclear, but accounts for non-energy
    # conserving fft; sf is to satisfy parseval's theorem
    unfocus_mdft = wf.unfocus_fixed_sampling(efl=1,
                                             dx=unfocus_fft.dx,
                                             samples=unfocus_fft.data.shape[1])

    assert np.allclose(unfocus_fft.data, unfocus_mdft.data)
Exemplo n.º 10
0
def test_frespace_functions():
    x = y = np.linspace(-1, 1, SAMPLES)
    z = np.random.rand(SAMPLES, SAMPLES)
    wf = propagation.Wavefront(x=x, y=y, fcn=z, wavelength=HeNe, space='pupil')
    wf = wf.free_space(1, 1)
    assert wf
Exemplo n.º 11
0
def test_can_div_wavefronts():
    data = np.random.rand(2, 2).astype(np.complex128)
    wf = propagation.Wavefront(cmplx_field=data, dx=1, wavelength=.6328)
    wf2 = wf / 2
    assert wf2