Exemple #1
0
        print("Saving raw data.")
        data_lists = []
        for channel in self.data_channels:
            if not data_lists:
                data_lists = [sorted_data[channel].wl]
            data_lists.append(sorted_data[channel].data)
        np.savetxt(filename,
                   np.column_stack(data_lists),
                   delimiter="\t",
                   header=FILE_HEADER)

    def teardown(self):
        pass


if __name__ == "__main__":
    from autogator.circuits import CircuitMap
    from autogator.experiments import ExperimentRunner

    cmap = CircuitMap.loadtxt("data/circuitmap.txt")

    mzis = cmap.filterby(name="MZI4", grouping="1")
    stage = load_default_configuration().get_stage()

    try:
        runner = ExperimentRunner(mzis, WavelengthSweepExperiment, stage=stage)
        runner.run()
    except Exception as e:
        print(stage.scope.measure())
        raise e
    cmds = {
        "COMMAND": "DESCRIPTION",
        "set <value>": "save current position as <value>",
        "goto <value>": "go to position <value>",
        "list": "list all saved positions",
        "ctrl": "enter keyboard control loop",
        "help": "print this help message",
        "q": "quit this script",
    }
    width = max(len(name) for name in cmds)
    for cmd, desc in cmds.items():
        print(f"{cmd:<{width+2}} {desc}")


if __name__ == "__main__":
    scfg = load_default_configuration()
    stage = scfg.get_stage()

    positions = {}
    while True:
        cmd = input(">>> ")
        
        if cmd.startswith("set "):
            name = cmd[4:]
            positions[name] = stage.get_position()
            positions[name] = name
            print("Saved position {} at {}".format(name, positions[name]))
        elif cmd.startswith("goto "):
            name = cmd[5:]
            stage.move_to(positions[name])
        elif cmd == "list":