Beispiel #1
0
def testg_initCustomShape():

    config = confParse.loadSoapyConfig(os.path.join(CONFIG_PATH,
                                                    "sh_8x8.yaml"))

    config.sim.pupilSize = 64
    config.sim.simSize = 66
    mask = aotools.circle(config.sim.pupilSize / 2., config.sim.simSize)
    wfs = WFS.ShackHartmann(config, mask=mask)
    dm = DM.KarhunenLoeve(config, n_dm=1, wfss=[wfs], mask=mask)
    customShape = dm.iMatShapes

    # saving temporary shapes
    fname = os.path.dirname(
        os.path.abspath(__file__)) + '/tmp_CustomDmShapes.fits'
    fits.writeto(fname, customShape, overwrite=True)

    # change size to ensure it tests interpolation
    config.sim.pupilSize = 100
    config.sim.simSize = 104
    mask = aotools.circle(config.sim.pupilSize / 2., config.sim.simSize)
    wfs = WFS.ShackHartmann(config, mask=mask)
    config.dms[1].dmShapesFilename = fname
    dm = DM.CustomShapes(config, n_dm=1, wfss=[wfs], mask=mask)
    # remove temporary shapes
    os.remove(fname)
Beispiel #2
0
def test_Piezo_valid_actuators():
    """
    Tests that when you set the "valid actuators", the DM doesn't use actuators marked 'invalid'
    """

    config = confParse.loadSoapyConfig(os.path.join(CONFIG_PATH, "sh_8x8.yaml"))

    mask = aotools.circle(config.sim.pupilSize / 2., config.sim.simSize)

    wfs = WFS.ShackHartmann(config, mask=mask)
    dm = DM.FastPiezo(config, n_dm=1, wfss=[wfs], mask=mask)

    act_coord1 = dm.valid_act_coords[0]
    act_coord_last = dm.valid_act_coords[-1]
    act_coord2 = dm.valid_act_coords[1]

    valid_actuators = numpy.ones(dm.n_acts, dtype=int)
    valid_actuators[0] = valid_actuators[-1] = 0

    dm.valid_actuators = valid_actuators

    assert dm.n_valid_actuators == (dm.n_acts - 2)
    assert not numpy.array_equal(dm.valid_act_coords[0], act_coord1)
    assert not numpy.array_equal(dm.valid_act_coords[-1], act_coord_last)
    assert numpy.array_equal(dm.valid_act_coords[0], act_coord2)
Beispiel #3
0
def testa_initDM():

    config = confParse.loadSoapyConfig(os.path.join(CONFIG_PATH, "sh_8x8.yaml"))

    mask = aotools.circle(config.sim.pupilSize/2., config.sim.simSize)

    wfs = WFS.ShackHartmann(config, mask=mask)
    dm = DM.DM(config, wfss=[wfs], mask=mask)
Beispiel #4
0
    def testa_initDM(self):

        config = confParse.Configurator(os.path.join(CONFIG_PATH, "sh_8x8.py"))
        config.loadSimParams()

        mask = aoSimLib.circle(config.sim.pupilSize / 2., config.sim.simSize)

        wfs = WFS.ShackHartmann(config, mask=mask)
        dm = DM.DM(config, wfss=[wfs], mask=mask)
Beispiel #5
0
def test_set_valid_actuators():
    """
    Tests that when you set the "valid actuators", the DM computes how many valid actuators there are correctly
    """

    config = confParse.loadSoapyConfig(os.path.join(CONFIG_PATH, "sh_8x8.yaml"))

    mask = aotools.circle(config.sim.pupilSize/2., config.sim.simSize)

    wfs = WFS.ShackHartmann(config, mask=mask)
    dm = DM.DM(config, n_dm=1, wfss=[wfs], mask=mask)

    valid_actuators = numpy.ones(dm.n_acts, dtype=int)
    valid_actuators[0] = valid_actuators[-1] = 0

    dm.valid_actuators = valid_actuators

    assert dm.n_valid_actuators == (dm.n_acts - 2)
Beispiel #6
0
import numpy
from soapy import confParse, SCI, atmosphere, DM
from SPGD import SPGD

# setup soapy conf
conf_path = "conf/sim.yaml"
conf = confParse.loadSoapyConfig(conf_path)

# setup atmospheric distortion
atmos = atmosphere.atmos(conf)
dist = atmos.randomScrns()

# setup simulations DM
dm = DM.Piezo(conf)
n_acts = dm.getActiveActs()

# initiate control object
control = numpy.zeros((conf.sim.nDM, conf.sim.scrnSize, conf.sim.scrnSize))

# setup camera
cam = SCI.PSF(conf)

# light with no correction
beam = cam.frame(dist[0]).copy()

# target
target = cam.frame(None).copy()

# import SPGDutils
# target = SPGDutils.generate_gaussian_target(beam, 10)