petal-qc 0.0.9__py3-none-any.whl → 0.0.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of petal-qc might be problematic. Click here for more details.
- petal_qc/BTreport/CheckBTtests.py +2 -6
- petal_qc/__init__.py +17 -1
- petal_qc/metrology/PetalMetrology.py +0 -5
- petal_qc/metrology/compare_Cores.py +27 -15
- petal_qc/metrology/coreMetrology.py +20 -10
- petal_qc/metrology/do_Metrology.py +0 -5
- petal_qc/metrology/petal_flatness.py +0 -4
- petal_qc/metrology/readAVSdata.py +762 -0
- petal_qc/metrology/uploadPetalInformation.py +769 -0
- petal_qc/test/checkAVStests.py +181 -0
- petal_qc/test/compare_golden.py +44 -0
- petal_qc/test/getAVSjson.py +27 -0
- petal_qc/test/getAVStests.py +263 -0
- petal_qc/test/getPetalCoreTestSummary.py +89 -0
- petal_qc/test/listPetalCoreComponents.py +89 -0
- petal_qc/test/prepareDESYfiles.py +25 -8
- petal_qc/thermal/DESYdata.py +58 -0
- petal_qc/thermal/IRBFile.py +51 -7
- petal_qc/thermal/IRCore.py +1 -1
- petal_qc/thermal/IRDataGetter.py +43 -24
- petal_qc/thermal/IRPetal.py +84 -7
- petal_qc/thermal/IRPetalParam.py +1 -1
- petal_qc/thermal/Petal_IR_Analysis.py +4 -3
- petal_qc/thermal/PipeFit.py +12 -3
- petal_qc/thermal/analyze_IRCore.py +24 -15
- petal_qc/thermal/coreThermal.py +124 -28
- petal_qc/thermal/create_IRCore.py +35 -9
- petal_qc/thermal/create_core_report.py +31 -8
- petal_qc/utils/Geometry.py +2 -2
- petal_qc/utils/readGraphana.py +2 -1
- {petal_qc-0.0.9.dist-info → petal_qc-0.0.11.dist-info}/METADATA +2 -2
- petal_qc-0.0.11.dist-info/RECORD +70 -0
- {petal_qc-0.0.9.dist-info → petal_qc-0.0.11.dist-info}/WHEEL +1 -1
- {petal_qc-0.0.9.dist-info → petal_qc-0.0.11.dist-info}/entry_points.txt +3 -0
- petal_qc-0.0.9.dist-info/RECORD +0 -61
- {petal_qc-0.0.9.dist-info → petal_qc-0.0.11.dist-info}/top_level.txt +0 -0
|
@@ -6,9 +6,7 @@ import sys
|
|
|
6
6
|
import bisect
|
|
7
7
|
from pathlib import Path
|
|
8
8
|
|
|
9
|
-
import matplotlib.dates as pldates
|
|
10
9
|
import matplotlib.pyplot as plt
|
|
11
|
-
import matplotlib.ticker as ticker
|
|
12
10
|
import numpy as np
|
|
13
11
|
from scipy.interpolate import CubicSpline
|
|
14
12
|
from petal_qc.utils.utils import find_file
|
|
@@ -17,6 +15,7 @@ import petal_qc.utils.docx_utils as docx_utils
|
|
|
17
15
|
|
|
18
16
|
from petal_qc.thermal import IRCore
|
|
19
17
|
from petal_qc.thermal import Petal_IR_Analysis
|
|
18
|
+
import petal_qc.utils.utils as utils
|
|
20
19
|
|
|
21
20
|
CO2_Temp_setting = -35
|
|
22
21
|
|
|
@@ -237,7 +236,7 @@ def plot_profile_and_golden(golden, core, value):
|
|
|
237
236
|
band = get_acceptance_band()
|
|
238
237
|
|
|
239
238
|
for iside in range(2):
|
|
240
|
-
fig, ax = plt.subplots(2, 1, tight_layout=True, gridspec_kw={'height_ratios': (0.
|
|
239
|
+
fig, ax = plt.subplots(2, 1, tight_layout=True, figsize=(7, 9), gridspec_kw={'height_ratios': (0.6, 0.4)})
|
|
241
240
|
figures.append(fig)
|
|
242
241
|
fig.suptitle("Petal core .vs. Golden for {} - side {}.".format(value, iside))
|
|
243
242
|
for a in ax:
|
|
@@ -271,7 +270,7 @@ def plot_profile_and_golden(golden, core, value):
|
|
|
271
270
|
Tmean = np.mean(Y)
|
|
272
271
|
Tband = factor*abs(Tmean)/3
|
|
273
272
|
|
|
274
|
-
ax[0].legend(ncol=
|
|
273
|
+
ax[0].legend(ncol=4, fontsize="x-small")
|
|
275
274
|
ax[0].set_title("T$_{prof}$ values")
|
|
276
275
|
if value.find("temp") >= 0 or value.find("_avg") >= 0:
|
|
277
276
|
ax[0].set_ylim(Tmean-Tband, Tmean+Tband)
|
|
@@ -310,7 +309,7 @@ def show_golden_average(golden, results, value):
|
|
|
310
309
|
band = get_acceptance_band()
|
|
311
310
|
|
|
312
311
|
for iside in range(2):
|
|
313
|
-
fig, ax = plt.subplots(2, 1, tight_layout=True, gridspec_kw={'height_ratios': (0.
|
|
312
|
+
fig, ax = plt.subplots(2, 1, tight_layout=True, figsize=(7,9), gridspec_kw={'height_ratios': (0.6, 0.4)})
|
|
314
313
|
figures.append(fig)
|
|
315
314
|
fig.suptitle("Golden average for {} - side {}.".format(value, iside))
|
|
316
315
|
for a in ax:
|
|
@@ -329,19 +328,22 @@ def show_golden_average(golden, results, value):
|
|
|
329
328
|
if value.find("path") >= 0:
|
|
330
329
|
X = RS.path_length
|
|
331
330
|
gX = golden[iside].path_length
|
|
331
|
+
spln = CubicSpline(gX, gY)
|
|
332
|
+
delta = Y - np.array([spln(x) for x in X])
|
|
332
333
|
|
|
333
334
|
else:
|
|
334
335
|
X = np.array([float(x) for x in range(10)])
|
|
335
336
|
gX = X
|
|
337
|
+
delta = Y - gY
|
|
336
338
|
|
|
337
339
|
ax[0].plot(X, Y, '-', label=R.aliasID, linewidth=1)
|
|
338
|
-
ax[1].plot(
|
|
340
|
+
ax[1].plot(X, delta, '-', label=R.aliasID, linewidth=1)
|
|
339
341
|
|
|
340
342
|
Tmean = np.mean(Y)
|
|
341
343
|
Tband = factor*abs(Tmean)/3
|
|
342
344
|
ax[0].plot(gX, gY, '-', label="Golden", linewidth=4, alpha=0.4, color="black")
|
|
343
345
|
|
|
344
|
-
ax[0].legend(ncol=
|
|
346
|
+
ax[0].legend(ncol=4, fontsize="x-small")
|
|
345
347
|
ax[0].set_title("T$_{prof}$ values")
|
|
346
348
|
if value.find("temp") >= 0 or value.find("_avg") >= 0:
|
|
347
349
|
ax[0].set_ylim(Tmean-Tband, Tmean+Tband)
|
|
@@ -526,12 +528,14 @@ def analyze_IRCore(options, show=True):
|
|
|
526
528
|
print("I need a golden file to compare with")
|
|
527
529
|
sys.exit(1)
|
|
528
530
|
|
|
529
|
-
golden_file =
|
|
531
|
+
golden_file = Path(options.golden).expanduser().resolve()
|
|
530
532
|
if not golden_file.exists():
|
|
531
|
-
|
|
532
|
-
|
|
533
|
+
golden_file = find_file(options.folder, options.golden)
|
|
534
|
+
if not golden_file.exists():
|
|
535
|
+
print("Golden file {} does not exist.".format(options.golden))
|
|
536
|
+
sys.exit(1)
|
|
533
537
|
|
|
534
|
-
with open(golden_file, 'r') as fp:
|
|
538
|
+
with open(golden_file, 'r', encoding="utf-8") as fp:
|
|
535
539
|
J = json.load(fp)
|
|
536
540
|
|
|
537
541
|
golden = [Petal_IR_Analysis.AnalysisResult() for i in range(2)]
|
|
@@ -559,10 +563,11 @@ def analyze_IRCore(options, show=True):
|
|
|
559
563
|
F = show_golden_average(golden, cores, "sensor_avg")
|
|
560
564
|
add_figures_to_doc(document, F, "Sensor avg")
|
|
561
565
|
F = show_golden_average(golden, cores, "sensor_std")
|
|
562
|
-
add_figures_to_doc(document, F, "
|
|
566
|
+
add_figures_to_doc(document, F, "Sensor std")
|
|
563
567
|
|
|
564
|
-
if document:
|
|
565
|
-
|
|
568
|
+
if document and not hasattr(options, "no_golden_doc"):
|
|
569
|
+
ofile = utils.output_folder(options.folder, "Compare-to-Golden.docx")
|
|
570
|
+
document.save(ofile)
|
|
566
571
|
|
|
567
572
|
if show:
|
|
568
573
|
plt.show()
|
|
@@ -570,7 +575,8 @@ def analyze_IRCore(options, show=True):
|
|
|
570
575
|
return output
|
|
571
576
|
|
|
572
577
|
|
|
573
|
-
|
|
578
|
+
def main():
|
|
579
|
+
"""Main entry."""
|
|
574
580
|
from argparse import ArgumentParser
|
|
575
581
|
# Argument parser
|
|
576
582
|
parser = ArgumentParser()
|
|
@@ -592,3 +598,6 @@ if __name__ == "__main__":
|
|
|
592
598
|
sys.exit()
|
|
593
599
|
|
|
594
600
|
analyze_IRCore(options)
|
|
601
|
+
|
|
602
|
+
if __name__ == "__main__":
|
|
603
|
+
main()
|
petal_qc/thermal/coreThermal.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env python3
|
|
2
2
|
"""GUI for thermal QC of petal cores."""
|
|
3
3
|
import sys
|
|
4
|
+
import os
|
|
5
|
+
import copy
|
|
4
6
|
from pathlib import Path
|
|
5
7
|
from argparse import ArgumentParser
|
|
6
8
|
import json
|
|
@@ -11,7 +13,7 @@ import itkdb_gtk.ITkDButils
|
|
|
11
13
|
import itkdb_gtk.dbGtkUtils
|
|
12
14
|
import itkdb_gtk.UploadTest
|
|
13
15
|
|
|
14
|
-
__HELP__ = "https://petal-qc.docs.cern.ch"
|
|
16
|
+
__HELP__ = "https://petal-qc.docs.cern.ch/thermal.html"
|
|
15
17
|
|
|
16
18
|
try:
|
|
17
19
|
import petal_qc
|
|
@@ -24,15 +26,16 @@ except ImportError:
|
|
|
24
26
|
from petal_qc.thermal.IRPetalParam import IRPetalParam
|
|
25
27
|
from petal_qc.thermal import IRBFile
|
|
26
28
|
from petal_qc.thermal.IRDataGetter import IRDataGetter
|
|
29
|
+
from petal_qc.thermal.DESYdata import DesyData
|
|
27
30
|
|
|
28
31
|
from petal_qc.thermal.analyze_IRCore import golden_from_json
|
|
32
|
+
from petal_qc.thermal.create_core_report import create_report
|
|
29
33
|
from petal_qc.utils.readGraphana import ReadGraphana
|
|
30
34
|
|
|
31
35
|
import gi
|
|
32
36
|
gi.require_version("Gtk", "3.0")
|
|
33
|
-
from gi.repository import Gtk,
|
|
37
|
+
from gi.repository import Gtk, Gio
|
|
34
38
|
|
|
35
|
-
from petal_qc.thermal.create_core_report import create_report
|
|
36
39
|
|
|
37
40
|
class CoreThermal(itkdb_gtk.dbGtkUtils.ITkDBWindow):
|
|
38
41
|
"""Application window."""
|
|
@@ -52,12 +55,27 @@ class CoreThermal(itkdb_gtk.dbGtkUtils.ITkDBWindow):
|
|
|
52
55
|
self.param = params if params else IRPetalParam()
|
|
53
56
|
self.param.add_attachments = True
|
|
54
57
|
self.param.create_golden = False
|
|
55
|
-
self.irbfile = None
|
|
58
|
+
self.irbfile = self.param.files if len(self.param.files)>0 else None
|
|
56
59
|
self.folder = None
|
|
57
60
|
self.golden = None
|
|
58
61
|
self.results = None
|
|
59
62
|
self.alternativeID = None
|
|
60
63
|
self.outDB = None
|
|
64
|
+
self.desy_opts = None
|
|
65
|
+
self.ific_opts = None
|
|
66
|
+
if self.param.institute is None:
|
|
67
|
+
is_desy = False
|
|
68
|
+
for site in self.pdb_user["institutions"]:
|
|
69
|
+
if "DESY" in site["code"]:
|
|
70
|
+
is_desy = True
|
|
71
|
+
break
|
|
72
|
+
|
|
73
|
+
self.param.institute = "DESY" if is_desy else "IFIC"
|
|
74
|
+
|
|
75
|
+
if self.param.institute == "IFIC":
|
|
76
|
+
self.ific_opts = copy.deepcopy(self.param)
|
|
77
|
+
else:
|
|
78
|
+
self.desy_opts = copy.deepcopy(self.param)
|
|
61
79
|
|
|
62
80
|
# Active button in header
|
|
63
81
|
button = Gtk.Button()
|
|
@@ -78,20 +96,36 @@ class CoreThermal(itkdb_gtk.dbGtkUtils.ITkDBWindow):
|
|
|
78
96
|
self.hb.pack_end(button)
|
|
79
97
|
|
|
80
98
|
# The file chooser
|
|
99
|
+
self.dataBox = Gtk.Box()
|
|
81
100
|
self.btnData = Gtk.FileChooserButton()
|
|
82
101
|
self.btnData.connect("file-set", self.on_file_set)
|
|
83
102
|
|
|
103
|
+
self.desyData = Gtk.Button(label="Chose Files")
|
|
104
|
+
self.desyData.connect("clicked", self.on_desy_data)
|
|
105
|
+
|
|
106
|
+
if self.param.institute == "IFIC":
|
|
107
|
+
self.dataBox.pack_start(self.btnData, False, False, 0)
|
|
108
|
+
else:
|
|
109
|
+
self.dataBox.pack_start(self.desyData, False, False, 0)
|
|
110
|
+
|
|
84
111
|
|
|
85
112
|
# The file chooser
|
|
86
113
|
self.goldenData = Gtk.FileChooserButton()
|
|
87
114
|
self.goldenData.connect("file-set", self.on_golden_set)
|
|
115
|
+
if self.param.golden and len(self.param.golden)>0:
|
|
116
|
+
self.goldenData.set_file(Gio.File.new_for_path(self.param.golden))
|
|
117
|
+
self.on_golden_set(self.goldenData)
|
|
118
|
+
|
|
88
119
|
|
|
89
120
|
# The Serial number
|
|
90
121
|
self.SN = itkdb_gtk.dbGtkUtils.TextEntry()
|
|
91
|
-
self.SN
|
|
122
|
+
if len(self.param.SN)>0:
|
|
123
|
+
self.SN.set_text(self.param.SN)
|
|
124
|
+
elif self.param.alias and len(self.param.alias)>0:
|
|
125
|
+
self.SN.set_text(self.param.alias)
|
|
126
|
+
self.on_SN_changed(self.SN.entry, self.param.alias)
|
|
92
127
|
|
|
93
|
-
self.
|
|
94
|
-
self.run.connect("clicked", self.create_report)
|
|
128
|
+
self.SN.connect("text-changed", self.on_SN_changed)
|
|
95
129
|
|
|
96
130
|
self.btn_state = Gtk.Button(label="Undef")
|
|
97
131
|
self.btn_state.set_name("btnState")
|
|
@@ -109,7 +143,7 @@ class CoreThermal(itkdb_gtk.dbGtkUtils.ITkDBWindow):
|
|
|
109
143
|
|
|
110
144
|
irow += 1
|
|
111
145
|
grid.attach(Gtk.Label(label="IRB File"), 0, irow, 1, 1)
|
|
112
|
-
grid.attach(self.
|
|
146
|
+
grid.attach(self.dataBox, 1, irow, 1, 1)
|
|
113
147
|
|
|
114
148
|
self.entryTemp = Gtk.Entry()
|
|
115
149
|
self.entryTemp.set_text("{:.1f}".format(self.param.tco2))
|
|
@@ -152,11 +186,35 @@ class CoreThermal(itkdb_gtk.dbGtkUtils.ITkDBWindow):
|
|
|
152
186
|
grid.attach(lbl, 2, irow, 1, 1)
|
|
153
187
|
grid.attach(self.entryDist, 3, irow, 1, 1)
|
|
154
188
|
|
|
189
|
+
irow += 1
|
|
190
|
+
self.desy = Gtk.Switch()
|
|
191
|
+
self.desy.props.halign = Gtk.Align.START
|
|
192
|
+
self.desy.connect("state_set", self.change_institute)
|
|
193
|
+
if params.desy or self.param.institute == "DESY":
|
|
194
|
+
self.desy.set_active(True)
|
|
195
|
+
grid.attach(Gtk.Label(label="DESY"), 0, irow, 1, 1)
|
|
196
|
+
grid.attach(self.desy, 1, irow, 1, 1)
|
|
155
197
|
|
|
156
|
-
|
|
198
|
+
irow += 1
|
|
199
|
+
self.run = Gtk.Button(label="Run")
|
|
200
|
+
self.run.connect("clicked", self.create_report)
|
|
201
|
+
|
|
202
|
+
grid.attach(self.run, 0, irow, 5, 1)
|
|
157
203
|
|
|
158
204
|
self.mainBox.pack_start(self.message_panel.frame, True, True, 0)
|
|
159
205
|
|
|
206
|
+
def on_desy_data(self, *args):
|
|
207
|
+
"""DESY data button clicked."""
|
|
208
|
+
dlg = DesyData(self.irbfile)
|
|
209
|
+
dlg.show_all()
|
|
210
|
+
if dlg.run() == Gtk.ResponseType.OK:
|
|
211
|
+
self.irbfile = [dlg.front, dlg.back]
|
|
212
|
+
self.param.files = self.irbfile
|
|
213
|
+
self.on_open_file()
|
|
214
|
+
|
|
215
|
+
dlg.hide()
|
|
216
|
+
dlg.destroy()
|
|
217
|
+
|
|
160
218
|
|
|
161
219
|
def on_file_set(self, *args):
|
|
162
220
|
"""File chosen from FileChooser."""
|
|
@@ -165,21 +223,59 @@ class CoreThermal(itkdb_gtk.dbGtkUtils.ITkDBWindow):
|
|
|
165
223
|
itkdb_gtk.dbGtkUtils.complain("Could not find Data File", PSF, parent=self)
|
|
166
224
|
return
|
|
167
225
|
|
|
168
|
-
self.irbfile = PSF
|
|
169
|
-
self.param.files =
|
|
170
|
-
|
|
226
|
+
self.irbfile = [PSF, ]
|
|
227
|
+
self.param.files = self.irbfile
|
|
228
|
+
self.on_open_file()
|
|
229
|
+
|
|
230
|
+
def on_open_file(self):
|
|
231
|
+
"""Open the files given in the GUI."""
|
|
171
232
|
#DB = ReadGraphana("localhost")
|
|
172
|
-
DB = ReadGraphana()
|
|
173
233
|
irbf = IRBFile.open_file(self.irbfile)
|
|
174
234
|
getter = IRDataGetter.factory(self.param.institute, self.param)
|
|
175
235
|
frames = getter.get_analysis_frame(irbf)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
236
|
+
|
|
237
|
+
if self.param.institute == "IFIC":
|
|
238
|
+
server = os.getenv("GRAFANA_SERVER")
|
|
239
|
+
if server is None:
|
|
240
|
+
DB = ReadGraphana()
|
|
241
|
+
else:
|
|
242
|
+
DB = ReadGraphana(server)
|
|
243
|
+
|
|
244
|
+
try:
|
|
245
|
+
X, val = DB.get_temperature(frames[0].timestamp, 3)
|
|
246
|
+
inlet = np.min(val)
|
|
247
|
+
self.entryTemp.set_text("{:.1f}".format(inlet))
|
|
248
|
+
|
|
249
|
+
except Exception as E:
|
|
250
|
+
print(E)
|
|
251
|
+
self.entryTemp.set_text("-30")
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def change_institute(self, *args):
|
|
255
|
+
"""Switch clicked."""
|
|
256
|
+
if self.desy.get_active():
|
|
257
|
+
self.param.institute = "DESY"
|
|
258
|
+
upper = self.btnData.get_parent()
|
|
259
|
+
if upper:
|
|
260
|
+
self.dataBox.remove(self.btnData)
|
|
261
|
+
self.dataBox.add(self.desyData)
|
|
262
|
+
|
|
263
|
+
self.param.distance = 16
|
|
264
|
+
self.param.width = 16
|
|
265
|
+
|
|
266
|
+
else:
|
|
267
|
+
self.param.institute = "IFIC"
|
|
268
|
+
upper = self.desyData.get_parent()
|
|
269
|
+
if upper:
|
|
270
|
+
self.dataBox.remove(self.desyData)
|
|
271
|
+
self.dataBox.add(self.btnData)
|
|
180
272
|
|
|
181
|
-
|
|
182
|
-
|
|
273
|
+
self.param.distance = 5
|
|
274
|
+
self.param.width = 2
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
self.entryDist.set_text("{}".format(self.param.distance))
|
|
278
|
+
self.dataBox.show_all()
|
|
183
279
|
|
|
184
280
|
def on_golden_set(self, *args):
|
|
185
281
|
"""File chosen from FileChooser."""
|
|
@@ -306,12 +402,14 @@ class CoreThermal(itkdb_gtk.dbGtkUtils.ITkDBWindow):
|
|
|
306
402
|
self.param.out = "{}.json".format(self.alternativeID)
|
|
307
403
|
self.param.alias = self.alternativeID
|
|
308
404
|
self.param.SN = self.SN.get_text()
|
|
405
|
+
self.param.desy = self.desy.get_active()
|
|
309
406
|
|
|
310
407
|
self.param.tco2 = float(self.entryTemp.get_text())
|
|
311
408
|
self.param.distance = int(self.entryDist.get_text())
|
|
312
409
|
self.param.thrs = float(self.entryTHrs.get_text())
|
|
313
410
|
self.param.debug = False
|
|
314
411
|
self.param.report = True
|
|
412
|
+
self.param.files = self.irbfile
|
|
315
413
|
|
|
316
414
|
self.outDB = create_report(self.param)
|
|
317
415
|
if self.outDB:
|
|
@@ -329,13 +427,17 @@ def main():
|
|
|
329
427
|
"""Entry point."""
|
|
330
428
|
# Argument parser
|
|
331
429
|
parser = ArgumentParser()
|
|
332
|
-
|
|
430
|
+
parser.add_argument('files', nargs='*', help="Input files")
|
|
333
431
|
parser.add_argument("--nframe", type=int, default=-1, help="Number of frames. (negative means all.")
|
|
334
432
|
parser.add_argument('--frame', type=int, default=-1, help="First frame to start.")
|
|
335
433
|
parser.add_argument("--out", default="core.json", help="Output file name")
|
|
434
|
+
parser.add_argument("--desy", dest='desy', action="store_true", default=False)
|
|
435
|
+
|
|
336
436
|
parser.add_argument("--alias", default="", help="Alias")
|
|
337
437
|
parser.add_argument("--SN", default="", help="serial number")
|
|
338
438
|
parser.add_argument("--folder", default=None, help="Folder to store output files. Superseeds folder in --out")
|
|
439
|
+
parser.add_argument("--golden", default=None, help="The golden to compare width")
|
|
440
|
+
|
|
339
441
|
|
|
340
442
|
IRPetalParam.add_parameters(parser)
|
|
341
443
|
|
|
@@ -354,18 +456,12 @@ def main():
|
|
|
354
456
|
|
|
355
457
|
except Exception:
|
|
356
458
|
# Login with "standard" if the above fails.
|
|
357
|
-
|
|
358
|
-
import getpass
|
|
359
|
-
client = itkdb.Client()
|
|
360
|
-
client.user._access_code1 = getpass.getpass("Access 1: ")
|
|
361
|
-
client.user._access_code2 = getpass.getpass("Access 2: ")
|
|
362
|
-
client.user.authenticate()
|
|
363
|
-
print("Hello {} !".format(client.user.name))
|
|
459
|
+
client = itkdb_gtk.ITkDButils.create_client()
|
|
364
460
|
|
|
365
461
|
CT = CoreThermal(options, session=client, title="Petal Thermal analysis.")
|
|
366
462
|
CT.show_all()
|
|
367
463
|
CT.connect("destroy", Gtk.main_quit)
|
|
368
|
-
CT.write_message("Welcome
|
|
464
|
+
CT.write_message("Welcome !\n")
|
|
369
465
|
|
|
370
466
|
try:
|
|
371
467
|
Gtk.main()
|
|
@@ -65,11 +65,13 @@ def get_IRcore_plots():
|
|
|
65
65
|
return __figures__
|
|
66
66
|
|
|
67
67
|
def clean_figures():
|
|
68
|
+
"""Clean existingfigures."""
|
|
68
69
|
global __figures__
|
|
69
|
-
for key, fig in __figures__:
|
|
70
|
-
fig.
|
|
70
|
+
for key, fig in __figures__.items():
|
|
71
|
+
fig.clear()
|
|
71
72
|
plt.close(fig)
|
|
72
73
|
|
|
74
|
+
plt.close("all")
|
|
73
75
|
__figures__ = {}
|
|
74
76
|
|
|
75
77
|
def get_inlet_temp(irbf, param):
|
|
@@ -78,8 +80,15 @@ def get_inlet_temp(irbf, param):
|
|
|
78
80
|
print("# Getting the Inlet temperature. Contacting Graphana...")
|
|
79
81
|
out = -9999
|
|
80
82
|
getter = IRDataGetter.factory(param.institute, param)
|
|
81
|
-
|
|
82
|
-
|
|
83
|
+
|
|
84
|
+
# TODO: get the server from thhe options
|
|
85
|
+
server = os.getenv("GRAFANA_SERVER")
|
|
86
|
+
if server is None:
|
|
87
|
+
DB = ReadGraphana()
|
|
88
|
+
else:
|
|
89
|
+
print("Connecting to Graphana serfer {}".format(server))
|
|
90
|
+
DB = ReadGraphana(server)
|
|
91
|
+
|
|
83
92
|
frames = getter.get_analysis_frame(irbf)
|
|
84
93
|
the_time = frames[0].timestamp
|
|
85
94
|
try:
|
|
@@ -105,7 +114,7 @@ def create_IR_core(options):
|
|
|
105
114
|
try:
|
|
106
115
|
getter = IRDataGetter.factory(options.institute, options)
|
|
107
116
|
|
|
108
|
-
except
|
|
117
|
+
except NotImplementedError:
|
|
109
118
|
print("*** Invalid institute name. ***")
|
|
110
119
|
return None
|
|
111
120
|
|
|
@@ -138,7 +147,7 @@ def create_IR_core(options):
|
|
|
138
147
|
print("Image size: {} x {}".format(values[0].shape[0], values[0].shape[1]))
|
|
139
148
|
|
|
140
149
|
if options.debug or options.report:
|
|
141
|
-
fig, ax = Petal_IR_Analysis.show_2D_image(values)
|
|
150
|
+
fig, ax = Petal_IR_Analysis.show_2D_image(values, show_fig=False)
|
|
142
151
|
__figures__["original"] = fig
|
|
143
152
|
|
|
144
153
|
except LookupError as e:
|
|
@@ -156,15 +165,28 @@ def create_IR_core(options):
|
|
|
156
165
|
print("Fit pipes and find sensor positions.")
|
|
157
166
|
ordered_pipes = [None, None]
|
|
158
167
|
pipe_order = [0, 0]
|
|
168
|
+
all_3d_points = IRPetal.get_all_3d_points()
|
|
159
169
|
for i in range(2):
|
|
160
170
|
pipe_type = PipeFit.PipeFit.guess_pipe_type(pipes[i])
|
|
161
171
|
pipe_order[i] = pipe_type
|
|
162
172
|
PF = PipeFit.PipeFit(pipe_type)
|
|
163
173
|
R = PF.fit_ex(pipes[i], factor=getter.factor)
|
|
164
174
|
if options.debug or options.report:
|
|
165
|
-
fig, _ =PF.plot()
|
|
175
|
+
fig, _ = PF.plot(show_fig=False)
|
|
166
176
|
__figures__["fit_{}".format(i)] = fig
|
|
167
177
|
|
|
178
|
+
fig = plt.figure(tight_layout=True, figsize=(7, 6))
|
|
179
|
+
fig.subplots_adjust(left=0.0, right=1.)
|
|
180
|
+
|
|
181
|
+
ax = fig.add_subplot(1, 1, 1, projection='3d')
|
|
182
|
+
ax.view_init(elev=90, azim=-90)
|
|
183
|
+
_X = all_3d_points[i][:, 0]
|
|
184
|
+
_Y = all_3d_points[i][:, 1]
|
|
185
|
+
_Z = all_3d_points[i][:, 2]
|
|
186
|
+
sct = ax.scatter(_X, _Y, _Z, c=_Z, marker='o', cmap=plt.cm.jet)
|
|
187
|
+
fig.colorbar(sct, shrink=0.75, aspect=5)
|
|
188
|
+
__figures__["pipe_path_{}".format(i)] = fig
|
|
189
|
+
|
|
168
190
|
transforms[pipe_type] = R
|
|
169
191
|
fitter[pipe_type] = PF
|
|
170
192
|
|
|
@@ -172,7 +194,7 @@ def create_IR_core(options):
|
|
|
172
194
|
# the U-shape pipe minimum.
|
|
173
195
|
pipes[i] = IRPetal.reorder_pipe_points(pipes[i], pipe_type, R)
|
|
174
196
|
if ordered_pipes[pipe_type] is not None:
|
|
175
|
-
print("### Expect
|
|
197
|
+
print("### Expect problems. 2 pipes of same type")
|
|
176
198
|
|
|
177
199
|
ordered_pipes[pipe_type] = pipes[i]
|
|
178
200
|
|
|
@@ -226,7 +248,8 @@ def create_IR_core(options):
|
|
|
226
248
|
return core
|
|
227
249
|
|
|
228
250
|
|
|
229
|
-
|
|
251
|
+
def main():
|
|
252
|
+
"""Main entry."""
|
|
230
253
|
from argparse import ArgumentParser
|
|
231
254
|
|
|
232
255
|
# Argument parser
|
|
@@ -247,3 +270,6 @@ if __name__ == "__main__":
|
|
|
247
270
|
sys.exit()
|
|
248
271
|
|
|
249
272
|
create_IR_core(options)
|
|
273
|
+
|
|
274
|
+
if __name__ == "__main__":
|
|
275
|
+
main()
|
|
@@ -36,9 +36,15 @@ def create_report(options):
|
|
|
36
36
|
print("input file {} does not exist.".format(ifile))
|
|
37
37
|
return
|
|
38
38
|
|
|
39
|
+
|
|
40
|
+
print("\n## {} - {}".format(options.SN, options.alias))
|
|
41
|
+
|
|
39
42
|
goldenFile = Path(options.golden).expanduser().resolve()
|
|
40
43
|
if not goldenFile.exists():
|
|
41
|
-
|
|
44
|
+
goldenFile = utils.output_folder(options.folder, options.golden)
|
|
45
|
+
goldenFile = Path(goldenFile).expanduser().resolve()
|
|
46
|
+
if not goldenFile.exists():
|
|
47
|
+
print("I need a golden file.")
|
|
42
48
|
|
|
43
49
|
with open(goldenFile, "r", encoding='utf-8') as fp:
|
|
44
50
|
golden = golden_from_json(json.load(fp))
|
|
@@ -50,6 +56,9 @@ def create_report(options):
|
|
|
50
56
|
document.styles['Normal'].font.name = "Calibri"
|
|
51
57
|
document.add_heading(options.SN, 0)
|
|
52
58
|
|
|
59
|
+
P = document.add_paragraph(options.alias, "Subtitle")
|
|
60
|
+
P.alignment = docx_utils.paragraph_align_center()
|
|
61
|
+
|
|
53
62
|
P = document.add_paragraph(ifile.name, "Subtitle")
|
|
54
63
|
P.alignment = docx_utils.paragraph_align_center()
|
|
55
64
|
|
|
@@ -64,20 +73,23 @@ def create_report(options):
|
|
|
64
73
|
document.add_picture(figures["original"], True, 14, caption="Original Thermal image.")
|
|
65
74
|
|
|
66
75
|
document.add_heading('Result of Pipe Fit', level=1)
|
|
67
|
-
document.add_picture(figures["fit_0"], True, 10, caption="
|
|
68
|
-
document.add_picture(figures["fit_1"], True, 10, caption="
|
|
76
|
+
document.add_picture(figures["fit_0"], True, 10, caption="Side 0 fit.")
|
|
77
|
+
document.add_picture(figures["fit_1"], True, 10, caption="Side 1 fit.")
|
|
78
|
+
|
|
79
|
+
document.add_heading('Pipe Path', level=1)
|
|
80
|
+
document.add_picture(figures["pipe_path_0"], True, 10, caption="Side 0 pipe temp.")
|
|
81
|
+
document.add_picture(figures["pipe_path_1"], True, 10, caption="Side 1 pipe temp.")
|
|
69
82
|
|
|
70
83
|
options.add_attachments = True
|
|
71
84
|
options.create_golden = False
|
|
72
85
|
|
|
73
|
-
options.files
|
|
86
|
+
options.files = [utils.output_folder(options.folder, options.out)]
|
|
74
87
|
options.out = None
|
|
88
|
+
options.no_golden_doc = True
|
|
75
89
|
out = analyze_IRCore(options, show=False)
|
|
76
90
|
outDB = out[0] if len(out) else None
|
|
77
91
|
options.files = []
|
|
78
92
|
|
|
79
|
-
get_golden_axis(core, golden)
|
|
80
|
-
|
|
81
93
|
figures = plot_profile_and_golden(golden, core, "path_temp")
|
|
82
94
|
document.add_heading('Temperature along path', level=1)
|
|
83
95
|
document.add_picture(figures[0], True, 12, caption="Petal core .vs. Golden (side 0).")
|
|
@@ -92,6 +104,13 @@ def create_report(options):
|
|
|
92
104
|
for F in figures:
|
|
93
105
|
plt.close(F)
|
|
94
106
|
|
|
107
|
+
figures = plot_profile_and_golden(golden, core, "sensor_std")
|
|
108
|
+
document.add_heading('STD of Temperature on sensors areas.', level=1)
|
|
109
|
+
document.add_picture(figures[0], True, 12, caption="Sensors .vs. Golden (side 0).")
|
|
110
|
+
document.add_picture(figures[1], True, 12, caption="Sensors .vs. Golden (side 1).")
|
|
111
|
+
for F in figures:
|
|
112
|
+
plt.close(F)
|
|
113
|
+
|
|
95
114
|
document.add_heading('Comments and Defects.', level=1)
|
|
96
115
|
added_defects = False
|
|
97
116
|
if len(outDB["comments"])>0:
|
|
@@ -115,7 +134,8 @@ def create_report(options):
|
|
|
115
134
|
|
|
116
135
|
return outDB
|
|
117
136
|
|
|
118
|
-
|
|
137
|
+
def main():
|
|
138
|
+
"""Main entry."""
|
|
119
139
|
P = IRPetalParam()
|
|
120
140
|
parser = ArgumentParser()
|
|
121
141
|
parser.add_argument('files', nargs='*', help="Input files")
|
|
@@ -141,4 +161,7 @@ if __name__ == "__main__":
|
|
|
141
161
|
|
|
142
162
|
options.debug = False
|
|
143
163
|
options.report = True
|
|
144
|
-
create_report(options)
|
|
164
|
+
create_report(options)
|
|
165
|
+
|
|
166
|
+
if __name__ == "__main__":
|
|
167
|
+
main()
|
petal_qc/utils/Geometry.py
CHANGED
|
@@ -528,7 +528,7 @@ class Line(object):
|
|
|
528
528
|
delta_y = (n.y - m.y)
|
|
529
529
|
if delta_x == 0.0: # vertical line
|
|
530
530
|
self.O = Point(n.x, n.y)
|
|
531
|
-
self.V =
|
|
531
|
+
self.V = (m-n).unit()
|
|
532
532
|
self.m = None
|
|
533
533
|
self.b = None
|
|
534
534
|
return
|
|
@@ -589,7 +589,7 @@ class Line(object):
|
|
|
589
589
|
|
|
590
590
|
def param(self, t):
|
|
591
591
|
"""Return point corresponding to given parameter."""
|
|
592
|
-
out = self.
|
|
592
|
+
out = self.O + t*self.V
|
|
593
593
|
if not isinstance(out, Point):
|
|
594
594
|
out = Point(out)
|
|
595
595
|
|
petal_qc/utils/readGraphana.py
CHANGED
|
@@ -19,7 +19,8 @@ class ReadGraphana(object):
|
|
|
19
19
|
"""
|
|
20
20
|
self.client = influxdb.InfluxDBClient(host=host, port=port,
|
|
21
21
|
username="matlab", password="matlab",
|
|
22
|
-
database="clean_room"
|
|
22
|
+
database="clean_room",
|
|
23
|
+
timeout=2)
|
|
23
24
|
|
|
24
25
|
def get_temperature(self, the_time, window=10):
|
|
25
26
|
"""REturns the temperature
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: petal_qc
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.11
|
|
4
4
|
Summary: A collection of scripts for Petal CORE QC.
|
|
5
5
|
Author-email: Carlos Lacasta <carlos.lacasta@cern.ch>
|
|
6
6
|
Project-URL: Homepage, https://gitlab.cern.ch/atlas-itk/sw/db/itk-pdb-gtk-gui-utils
|
|
@@ -10,7 +10,7 @@ Classifier: Operating System :: OS Independent
|
|
|
10
10
|
Requires-Python: >=3.7
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: itkdb
|
|
13
|
-
Requires-Dist: itkdb-gtk
|
|
13
|
+
Requires-Dist: itkdb-gtk >=0.10.10
|
|
14
14
|
Requires-Dist: numpy
|
|
15
15
|
Requires-Dist: matplotlib
|
|
16
16
|
Requires-Dist: lmfit
|