-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmanual_load.py
132 lines (106 loc) · 4.37 KB
/
manual_load.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
from datetime import datetime
import lcls_tools.common.data_analysis.archiver as archiver
from q0_linac import Calibration, Q0Cryomodule, Q0Measurement, Q0_CRYOMODULES
from q0_utils import HeaterRun, ValveParams
a = archiver.Archiver("lcls")
strptime_formatter = "%m/%d/%y %H:%M:%S"
def get_q0_data(
cm_name,
cal_timestamp,
heater_start: datetime,
heater_end: datetime,
rf_start: datetime,
rf_end: datetime,
cav_amps,
):
cm: Q0Cryomodule = Q0_CRYOMODULES[cm_name]
cm.load_calibration(cal_timestamp)
q0_meas = Q0Measurement(cm)
q0_meas.amplitudes = cav_amps
q0_meas.start_time = rf_start
q0_meas.heater_run_heatload = 48.0
q0_meas.heater_run.start_time = heater_start
q0_meas.heater_run.end_time = heater_end
q0_meas.rf_run.start_time = rf_start
q0_meas.rf_run.end_time = rf_end
heater_run_data = a.getValuesOverTimeRange(
pvList=[cm.ds_level_pv, cm.heater_readback_pv],
startTime=heater_start,
endTime=heater_end,
)
heater_timestamps = heater_run_data.timeStamps[cm.ds_level_pv]
heater_values = heater_run_data.values[cm.ds_level_pv]
for idx, value in enumerate(heater_values):
timestamp = heater_timestamps[idx].timestamp()
q0_meas.heater_run.ll_data[timestamp] = value
q0_meas.heater_run.heater_readback_buffer = heater_run_data.values[
cm.heater_readback_pv
]
rf_run_data = a.getValuesOverTimeRange(
pvList=[cm.ds_level_pv, cm.heater_readback_pv, cm.ds_pressure_pv],
startTime=rf_start,
endTime=rf_end,
)
rf_timestamps = rf_run_data.timeStamps[cm.ds_level_pv]
rf_values = rf_run_data.values[cm.ds_level_pv]
for idx, value in enumerate(rf_values):
timestamp = rf_timestamps[idx].timestamp()
q0_meas.rf_run.ll_data[timestamp] = value
q0_meas.rf_run.heater_readback_buffer = rf_run_data.values[cm.heater_readback_pv]
q0_meas.rf_run.pressure_buffer = rf_run_data.values[cm.ds_pressure_pv]
q0_meas.save_data()
q0_meas.save_results()
def get_cal_data():
cm: Q0Cryomodule = Q0_CRYOMODULES["12"]
cm.load_calibration("08/05/22 15:35:12")
cm.valveParams = ValveParams(
refHeatLoadAct=47.7, refHeatLoadDes=48.0, refValvePos=32.3
)
cal = Calibration(time_stamp="08/05/22 15:35:12", cryomodule=cm)
ref_heat = 47.7
cal_start_time = "08/03/22 15:42:36"
run_times = [
("08/03/22 15:42:36", "08/03/22 15:49:42"),
("08/03/22 15:54:53", "08/03/22 16:00:11"),
("08/03/22 16:06:01", "08/03/22 16:10:57"),
("08/03/22 16:16:16", "08/03/22 16:20:59"),
("08/03/22 16:26:09", "08/03/22 16:33:41"),
]
for start_time, end_time in run_times:
heat_load_data = a.getValuesOverTimeRange(
pvList=[cm.heater_readback_pv],
startTime=datetime.strptime(start_time, strptime_formatter),
endTime=datetime.strptime(end_time, strptime_formatter),
)
heater_run = HeaterRun(heat_load=48)
heater_run.start_time = datetime.strptime(start_time, strptime_formatter)
heater_run.end_time = datetime.strptime(end_time, strptime_formatter)
heater_run.reference_heat = 47.7
heater_run.heater_readback_buffer = heat_load_data.values[cm.heater_readback_pv]
ll_data = a.getValuesOverTimeRange(
pvList=[cm.ds_level_pv],
startTime=datetime.strptime(start_time, strptime_formatter),
endTime=datetime.strptime(end_time, strptime_formatter),
)
timestamps = ll_data.timeStamps[cm.ds_level_pv]
values = ll_data.values[cm.ds_level_pv]
for idx, value in enumerate(values):
timestamp = timestamps[idx].timestamp()
heater_run.ll_data[timestamp] = value
cal.heater_runs.append(heater_run)
cal.save_data()
cal.save_results()
if __name__ == "__main__":
heater_start = datetime.strptime("08/05/22 20:26:00", strptime_formatter)
heater_end = datetime.strptime("08/05/22 20:32:00", strptime_formatter)
rf_start = datetime.strptime("08/05/22 20:13:00", strptime_formatter)
rf_end = datetime.strptime("08/05/22 20:22:00", strptime_formatter)
get_q0_data(
cm_name="14",
cal_timestamp="08/05/22 16:00:32",
heater_start=heater_start,
heater_end=heater_end,
rf_start=rf_start,
rf_end=rf_end,
cav_amps={2: 16.6, 3: 16.6, 6: 16.6},
)