-
Notifications
You must be signed in to change notification settings - Fork 3
/
program_F1.py
84 lines (65 loc) · 2.32 KB
/
program_F1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
from turnon import TurnOnOffProcedure
import logging as log
DEFAULT_WAITTIME_S = 5.0
class F1Procedure(TurnOnOffProcedure):
def __init__(self, waittime_s=5, turnon=True):
super(F1Procedure, self).__init__()
def run(self):
turn_on_board = True
for cur_board in "ROYGBVIW":
for cur_horn_idx in range(7):
horn_name = f"{cur_board}{cur_horn_idx}"
# Horn W0 does not exist
if horn_name == "W0":
continue
self.set_board_horn_polarimeter(
new_board=cur_board, new_horn=horn_name, new_pol=None
)
self.run_turnon(
turn_on_board=turn_on_board, stable_acquisition_time_s=300
)
turn_on_board = False
self.run_turnoff()
if __name__ == "__main__":
from argparse import ArgumentParser, RawDescriptionHelpFormatter
parser = ArgumentParser(
description="Produce a command sequence to run the Strip F1 test",
formatter_class=RawDescriptionHelpFormatter,
epilog="""
Usage example:
python3 program_F1.py > f1_procedure.json
""",
)
parser.add_argument(
"--output",
"-o",
metavar="FILENAME",
type=str,
dest="output_filename",
default="",
help="Name of the file where to write the output (in JSON format). "
"If not provided, the output will be sent to stdout.",
)
parser.add_argument("--bias-steps", dest="bias_steps", action="append")
parser.add_argument(
"--wait-time-sec",
metavar="VALUE",
type=float,
dest="waittime_s",
default=DEFAULT_WAITTIME_S,
help="Time to wait after having altered the bias level for each amplifier "
f"(default: {DEFAULT_WAITTIME_S}, set to 0 to disable)",
)
args = parser.parse_args()
log.basicConfig(level=log.INFO, format="[%(asctime)s %(levelname)s] %(message)s")
proc = F1Procedure(waittime_s=args.waittime_s)
proc.run()
import json
output = json.dumps(proc.get_command_list(), indent=4)
if args.output_filename == "":
print(output)
else:
with open(args.output_filename, "wt") as outf:
outf.write(output)