Skip to content

Commit 4c46f5e

Browse files
Add computation of std of drawer temperatures to the DQM (#309)
* feat(src/nectarchain/dqm): - camera_monitoring.py: add computation of std of temperature for each drawer * Bug fix: plotted mean temperatures instead of standard deviations --------- Co-authored-by: Jean-Philippe Lenain <jlenain@in2p3.fr>
1 parent bcb16b2 commit 4c46f5e

1 file changed

Lines changed: 77 additions & 6 deletions

File tree

src/nectarchain/dqm/camera_monitoring.py

Lines changed: 77 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ def __init__(self, gaink, r0=False):
4141
self.DrawerNum2 = None
4242
self.DrawerTemp1_mean = []
4343
self.DrawerTemp2_mean = []
44+
self.DrawerTemp1_std = []
45+
self.DrawerTemp2_std = []
4446
self.CameraMonitoring_Results_Dict = {}
4547
self.ChargeInt_Figures_Dict = {}
4648
self.ChargeInt_Figures_Names_Dict = {}
@@ -130,13 +132,25 @@ def finish_run(self):
130132
self.DrawerTemp1_mean.append(
131133
np.mean(self.DrawerTemp12[self.DrawerNum2 == i])
132134
)
135+
self.DrawerTemp1_std.append(
136+
np.std(self.DrawerTemp12[self.DrawerNum2 == i])
137+
)
133138
self.DrawerTemp2_mean.append(
134139
np.mean(self.DrawerTemp22[self.DrawerNum2 == i])
135140
)
141+
self.DrawerTemp2_std.append(
142+
np.std(self.DrawerTemp22[self.DrawerNum2 == i])
143+
)
144+
136145
self.DrawerTemp1_mean = np.array(self.DrawerTemp1_mean)
137146
self.DrawerTemp2_mean = np.array(self.DrawerTemp2_mean)
147+
self.DrawerTemp1_std = np.array(self.DrawerTemp1_std)
148+
self.DrawerTemp2_std = np.array(self.DrawerTemp2_std)
138149

139150
self.DrawerTemp_mean = (self.DrawerTemp1_mean + self.DrawerTemp2_mean) / 2
151+
# std of drawer temperatures as mean of std of temp FEB1 and temp FEB2
152+
self.DrawerTemp_std = (self.DrawerTemp1_std + self.DrawerTemp2_std) / 2
153+
140154
except Exception as err:
141155
log.error(
142156
f"Drawer temperature could not be retrieved. Received error "
@@ -148,6 +162,9 @@ def get_results(self):
148162
self.CameraMonitoring_Results_Dict[
149163
"CAMERA-TEMPERATURE-AVERAGE"
150164
] = self.DrawerTemp_mean
165+
self.CameraMonitoring_Results_Dict[
166+
"CAMERA-TEMPERATURE-STD"
167+
] = self.DrawerTemp_std
151168
except Exception as err:
152169
log.error(
153170
f"Drawer temperature could not be retrieved. Received error "
@@ -158,7 +175,7 @@ def get_results(self):
158175

159176
def plot_results(self, name, fig_path):
160177
try:
161-
fig, _ = plt.subplots()
178+
fig_mean, _ = plt.subplots()
162179
disp = CameraDisplay(self.camera)
163180
disp.image = self.DrawerTemp_mean
164181
disp.cmap = plt.cm.coolwarm
@@ -167,14 +184,14 @@ def plot_results(self, name, fig_path):
167184
plt.title("Camera temperature average")
168185
full_name = name + "_CameraTemperature_Mean.png"
169186
full_path = os.path.join(fig_path, full_name)
170-
self.ChargeInt_Figures_Dict["CAMERA-TEMPERATURE-IMAGE-AVERAGE"] = fig
187+
self.ChargeInt_Figures_Dict["CAMERA-TEMPERATURE-IMAGE-AVERAGE"] = fig_mean
171188
self.ChargeInt_Figures_Names_Dict[
172189
"CAMERA-TEMPERATURE-IMAGE-AVERAGE"
173190
] = full_path
174191

175192
plt.close()
176193

177-
fig1, disp = plt.subplots()
194+
fig1_mean, _ = plt.subplots()
178195
disp = CameraDisplay(self.camera)
179196
disp.image = self.DrawerTemp1_mean
180197
disp.cmap = plt.cm.coolwarm
@@ -183,14 +200,16 @@ def plot_results(self, name, fig_path):
183200
plt.title("Camera temperature average 1")
184201
full_name = name + "_CameraTemperature_average1.png"
185202
full_path = os.path.join(fig_path, full_name)
186-
self.ChargeInt_Figures_Dict["CAMERA-TEMPERATURE-IMAGE-AVERAGE-1"] = fig1
203+
self.ChargeInt_Figures_Dict[
204+
"CAMERA-TEMPERATURE-IMAGE-AVERAGE-1"
205+
] = fig1_mean
187206
self.ChargeInt_Figures_Names_Dict[
188207
"CAMERA-TEMPERATURE-IMAGE-AVERAGE-1"
189208
] = full_path
190209

191210
plt.close()
192211

193-
fig2, disp = plt.subplots()
212+
fig2_mean, _ = plt.subplots()
194213
disp = CameraDisplay(self.camera)
195214
disp.image = self.DrawerTemp2_mean
196215
disp.cmap = plt.cm.coolwarm
@@ -199,11 +218,63 @@ def plot_results(self, name, fig_path):
199218
plt.title("Camera temperature average 2")
200219
full_name = name + "_CameraTemperature_average2.png"
201220
full_path = os.path.join(fig_path, full_name)
202-
self.ChargeInt_Figures_Dict["CAMERA-TEMPERATURE-IMAGE-AVERAGE-2"] = fig2
221+
self.ChargeInt_Figures_Dict[
222+
"CAMERA-TEMPERATURE-IMAGE-AVERAGE-2"
223+
] = fig2_mean
203224
self.ChargeInt_Figures_Names_Dict[
204225
"CAMERA-TEMPERATURE-IMAGE-AVERAGE-2"
205226
] = full_path
206227

228+
plt.close()
229+
230+
fig_std, _ = plt.subplots()
231+
disp = CameraDisplay(self.camera)
232+
disp.image = self.DrawerTemp_std
233+
disp.cmap = plt.cm.coolwarm
234+
disp.axes.text(1.8, -0.3, "Temperature", fontsize=12, rotation=90)
235+
disp.add_colorbar()
236+
plt.title("Camera temperature std")
237+
full_name = name + "_CameraTemperature_Std.png"
238+
full_path = os.path.join(fig_path, full_name)
239+
self.ChargeInt_Figures_Dict["CAMERA-TEMPERATURE-IMAGE-STD"] = fig_std
240+
self.ChargeInt_Figures_Names_Dict[
241+
"CAMERA-TEMPERATURE-IMAGE-STD"
242+
] = full_path
243+
244+
plt.close()
245+
246+
fig1_std, _ = plt.subplots()
247+
disp = CameraDisplay(self.camera)
248+
disp.image = self.DrawerTemp1_std
249+
disp.cmap = plt.cm.coolwarm
250+
disp.axes.text(1.8, -0.3, "Temperature 1", fontsize=12, rotation=90)
251+
disp.add_colorbar()
252+
plt.title("Camera temperature std 1")
253+
full_name = name + "_CameraTemperature_Std1.png"
254+
full_path = os.path.join(fig_path, full_name)
255+
self.ChargeInt_Figures_Dict["CAMERA-TEMPERATURE-IMAGE-STD-1"] = fig1_std
256+
self.ChargeInt_Figures_Names_Dict[
257+
"CAMERA-TEMPERATURE-IMAGE-STD-1"
258+
] = full_path
259+
260+
plt.close()
261+
262+
fig2_std, _ = plt.subplots()
263+
disp = CameraDisplay(self.camera)
264+
disp.image = self.DrawerTemp2_std
265+
disp.cmap = plt.cm.coolwarm
266+
disp.axes.text(1.8, -0.3, "Temperature 2", fontsize=12, rotation=90)
267+
disp.add_colorbar()
268+
plt.title("Camera temperature std 2")
269+
full_name = name + "_CameraTemperature_Std2.png"
270+
full_path = os.path.join(fig_path, full_name)
271+
self.ChargeInt_Figures_Dict["CAMERA-TEMPERATURE-IMAGE-STD-2"] = fig2_std
272+
self.ChargeInt_Figures_Names_Dict[
273+
"CAMERA-TEMPERATURE-IMAGE-STD-2"
274+
] = full_path
275+
276+
plt.close()
277+
207278
except Exception as err:
208279
log.error(f"Received error code: {err}")
209280

0 commit comments

Comments
 (0)