Exemple #1
0
def test_donut_simulator():
    """
    import os
    import aos
    import numpy as np
    from aos.telescope import BendingTelescope
    from aos.simulator import DonutSimulator
    import matplotlib.pyplot as plt

    tel = BendingTelescope.nominal()
    sim = DonutSimulator()
    fieldx, fieldy = (0, 0)
    donut = sim.simulateDonut(tel.intra, fieldx, fieldy)
    array = np.array(donut.array)
    np.save(os.path.join(aos.testDir, 'nominal_donut_0_0.npy'), array)
    """
    tel = BendingTelescope.nominal()
    sim = DonutSimulator()
    fieldx, fieldy = (0, 0)
    donut = sim.simulateDonut(tel.intra, fieldx, fieldy)
    array = np.array(donut.array)

    ref = np.load(os.path.join(aos.testDir, 'nominal_donut_0_0.npy'))

    err = np.sum(np.abs(array - ref))
    poisson_err = np.sum(np.sqrt(ref))

    assert err < 2 * poisson_err
    np.testing.assert_array_equal(array.shape, [192, 192])
Exemple #2
0
def test_nominal():
    btel = BendingTelescope.nominal()
    bOutRadius = btel.optic.itemDict['LSST.M1'].outRadius

    ztel = ZernikeTelescope.nominal()
    zOutRadius = ztel.optic.itemDict['LSST.M1'].outRadius

    assert bOutRadius == 4.18
    assert zOutRadius == 4.18
Exemple #3
0
def test_m2rx():
    state = BendingState()
    state['m2rx'] = np.deg2rad(1e-3)
    tel = BendingTelescope.nominal()
    tel.update(state)

    m2rx = tel.optic.itemDict['LSST.M2'].coordSys.rot
    ref = batoid.RotX(state['m2rx'])

    np.testing.assert_allclose(m2rx, ref)
Exemple #4
0
def test_bending_mode_update():
    state = BendingState()
    state['m2rx'] = np.deg2rad(1e-3)
    state['m2b3'] = 1e-6
    tel = BendingTelescope.nominal()
    tel.update(state)

    m2rx = tel.optic.itemDict['LSST.M2'].coordSys.rot
    ref = batoid.RotX(state['m2rx'])
    np.testing.assert_allclose(m2rx, ref)

    pert = tel.optic.itemDict['LSST.M2'].surface.surfaces[1]
    np.testing.assert_allclose(pert.zs, tel.m2res.surfResidual)
Exemple #5
0
def test_camx():
    bstate = BendingState()
    bstate['camx'] = 1e-6
    btel = BendingTelescope.nominal()
    btel.update(bstate)
    bcamx = btel.optic.itemDict['LSST.LSSTCamera'].coordSys.origin[0]

    assert bcamx == bstate['camx']

    zstate = ZernikeState()
    zstate['camx'] = 1e-6
    ztel = ZernikeTelescope.nominal()
    ztel.update(zstate)
    zcamx = ztel.optic.itemDict['LSST.LSSTCamera'].coordSys.origin[0]

    assert zcamx == zstate['camx']
Exemple #6
0
def test_wavefront_simulator():
    """
    import os
    import aos
    import numpy as np
    from aos.telescope import BendingTelescope
    from aos.simulator import WavefrontSimulator

    np.random.seed(0)
    tel = BendingTelescope.nominal()
    sim = WavefrontSimulator()
    fieldx, fieldy = (0, 0)
    wavefront = sim.simulateWavefront(tel.optic, fieldx, fieldy)
    ref = np.save(os.path.join(aos.testDir, 'nominal_wavefront_0_0.npy'), wavefront)
    """
    np.random.seed(0)
    tel = BendingTelescope.nominal()
    sim = WavefrontSimulator()
    fieldx, fieldy = (0, 0)
    wavefront = sim.simulateWavefront(tel.optic, fieldx, fieldy)
    ref = np.load(os.path.join(aos.testDir, 'nominal_wavefront_0_0.npy'))

    np.testing.assert_allclose(wavefront, ref)
    np.testing.assert_array_equal(wavefront.shape, [255, 255])
Exemple #7
0
def test_integration():
    telescope = BendingTelescope.nominal(band='g')
    simulator = WavefrontSimulator()
    estimator = WavefrontEstimator()
    solver = SensitivitySolver()
    metric = SumOfSquares()
    controller = GainController(metric, gain=0.3)
    fieldx, fieldy = 0, 0

    x = BendingState()
    # add 1 micron of the third bending mode to M2.
    x['m2b3'] = 1e-6
    telescope.update(x)
    wavefront = simulator.simulateWavefront(telescope.optic, fieldx, fieldy)
    yest = estimator.estimate(wavefront)
    xest = solver.solve(yest)
    xprime, xdelta = controller.nextState(xest)

    # start second iteration
    telescope.update(xdelta)
    wavefront = simulator.simulateWavefront(telescope.optic, fieldx, fieldy)
    yest = estimator.estimate(wavefront)
    xest = solver.solve(yest)
    xprime, xdelta = controller.nextState(xest)