petal-qc 0.0.2__tar.gz → 0.0.3__tar.gz

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.

Files changed (65) hide show
  1. {petal_qc-0.0.2 → petal_qc-0.0.3}/PKG-INFO +1 -1
  2. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/__init__.py +7 -1
  3. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/analyze_locking_points.py +2 -4
  4. petal_qc-0.0.3/petal_qc/metrology/compare_Cores.py +96 -0
  5. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/do_Metrology.py +8 -0
  6. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/IRBFile.py +1 -1
  7. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/IRDataGetter.py +21 -14
  8. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/analyze_IRCore.py +48 -3
  9. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/coreThermal.py +19 -3
  10. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/create_IRCore.py +41 -5
  11. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/create_core_report.py +4 -0
  12. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/test_Graphana.py +12 -5
  13. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/utils/readGraphana.py +11 -8
  14. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc.egg-info/PKG-INFO +1 -1
  15. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc.egg-info/SOURCES.txt +1 -0
  16. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc.egg-info/entry_points.txt +1 -0
  17. {petal_qc-0.0.2 → petal_qc-0.0.3}/pyproject.toml +2 -1
  18. {petal_qc-0.0.2 → petal_qc-0.0.3}/README.md +0 -0
  19. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/BTreport/CheckBTtests.py +0 -0
  20. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/BTreport/__init__.py +0 -0
  21. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/BTreport/bustapeReport.py +0 -0
  22. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/dashBoard.py +0 -0
  23. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/Cluster.py +0 -0
  24. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/DataFile.py +0 -0
  25. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/PetalMetrology.py +0 -0
  26. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/__init__.py +0 -0
  27. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/all2csv.py +0 -0
  28. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/cold_noise.py +0 -0
  29. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/comparisonTable.py +0 -0
  30. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/convert_mitutoyo.py +0 -0
  31. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/convert_smartscope.py +0 -0
  32. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/coreMetrology.py +0 -0
  33. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/data2csv.py +0 -0
  34. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/flatness4nigel.py +0 -0
  35. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/gtkutils.py +0 -0
  36. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/petal_flatness.py +0 -0
  37. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/show_data_file.py +0 -0
  38. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/testSummary.py +0 -0
  39. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/metrology/test_paralelism.py +0 -0
  40. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/CSVImage.py +0 -0
  41. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/DebugPlot.py +0 -0
  42. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/IRCore.py +0 -0
  43. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/IRPetal.py +0 -0
  44. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/IRPetalParam.py +0 -0
  45. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/PetalColorMaps.py +0 -0
  46. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/Petal_IR_Analysis.py +0 -0
  47. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/PipeFit.py +0 -0
  48. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/__init__.py +0 -0
  49. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/contours.py +0 -0
  50. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/pipe_back.npz +0 -0
  51. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/pipe_front.npz +0 -0
  52. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/pipe_read.py +0 -0
  53. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/show_IR_petal.py +0 -0
  54. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/thermal/test_coreThermal.py +0 -0
  55. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/utils/Geometry.py +0 -0
  56. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/utils/Progress.py +0 -0
  57. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/utils/__init__.py +0 -0
  58. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/utils/all_files.py +0 -0
  59. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/utils/docx_utils.py +0 -0
  60. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/utils/fit_utils.py +0 -0
  61. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc/utils/utils.py +0 -0
  62. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc.egg-info/dependency_links.txt +0 -0
  63. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc.egg-info/requires.txt +0 -0
  64. {petal_qc-0.0.2 → petal_qc-0.0.3}/petal_qc.egg-info/top_level.txt +0 -0
  65. {petal_qc-0.0.2 → petal_qc-0.0.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: petal_qc
3
- Version: 0.0.2
3
+ Version: 0.0.3
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
@@ -1,5 +1,5 @@
1
1
  """petal_qc python module."""
2
- __version__ = "0.0.2"
2
+ __version__ = "0.0.3"
3
3
 
4
4
 
5
5
  def coreMetrology():
@@ -7,6 +7,12 @@ def coreMetrology():
7
7
  from .metrology.coreMetrology import main
8
8
  main()
9
9
 
10
+ def coreThermal():
11
+ """Launches the Core thermal analysis ahd PDB script."""
12
+ from .thermal.coreThermal import main
13
+ main()
14
+
15
+
10
16
  def bustapeReport():
11
17
  """Launches the Core metrology analysis ahd PDB script."""
12
18
  from .BTreport.bustapeReport import main
@@ -303,7 +303,7 @@ def analyze_locking_point_data(orig_data, nbins=50, plane_fit=True, cut=3, docum
303
303
  max_par = -9999
304
304
  for i in range(3):
305
305
  pts = M[iloc_indx[i], 2] + 0.435
306
- _, _, band = get_min_max(pts)
306
+ vmin, vmax, band = get_min_max(pts)
307
307
  avg_pts = np.mean(pts)
308
308
  if abs(avg_pts) > max_par:
309
309
  max_par = abs(avg_pts)
@@ -312,8 +312,6 @@ def analyze_locking_point_data(orig_data, nbins=50, plane_fit=True, cut=3, docum
312
312
  print("Loc par. {} - {:.3f} avg: {:.3f}".format(i, band, avg_pts))
313
313
  ax.hist(pts, bins=xaxis, label="Avg {:.3f} band {:.3f} mm".format(avg_pts, band))
314
314
 
315
- parallelism = max_avg
316
-
317
315
  ax.legend(loc='upper left')
318
316
  y_lim = ax.get_ylim()
319
317
  ax.fill_between([-0.100, 0.100], y_lim[0], y_lim[1], facecolor="grey", alpha=0.1)
@@ -330,7 +328,7 @@ def analyze_locking_point_data(orig_data, nbins=50, plane_fit=True, cut=3, docum
330
328
 
331
329
  outDB["PARALLELISM"] = parallelism
332
330
  outDB["OFFSET"] = mean_dist
333
- print("Paralelism test: {:.4f}.\n{}".format(parallelism, txt))
331
+ print("Parallelism test: {:.4f}.\n{}".format(parallelism, txt))
334
332
  if document:
335
333
  txt = """To study parallelism, we subtract -0.435 mm to the Z values. \
336
334
  This is the nominal position of locator points. \
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env python3
2
+ """Compare quantities."""
3
+
4
+ import sys
5
+ import argparse
6
+ import glob
7
+ import json
8
+ from pathlib import Path
9
+ import numpy as np
10
+ import matplotlib.pyplot as plt
11
+
12
+
13
+ def get_value(data, value_path):
14
+ """Get the value."""
15
+ a = data
16
+ for k in value_path.split('/'):
17
+ a = a[k]
18
+
19
+ return a
20
+
21
+
22
+ def main(options):
23
+ labels = []
24
+ front = {}
25
+ back = {}
26
+
27
+ for fnam in options.files:
28
+ ifile = Path(fnam).expanduser().resolve()
29
+ print(ifile.name)
30
+ if not ifile.exists():
31
+ print("File does not exist: ", fnam)
32
+ continue
33
+
34
+ data = None
35
+ with open(ifile, 'r', encoding="UTF-8") as fp:
36
+ data = json.load(fp)
37
+
38
+ if data is None:
39
+ print("Problems reading ", fnam)
40
+ continue
41
+
42
+ tmp = ifile.name.split('-')
43
+ label = tmp[0]
44
+ if not label in labels:
45
+ labels.append(label)
46
+
47
+ is_front = False
48
+ if "front" in tmp[1].lower():
49
+ is_front = True
50
+
51
+ val = get_value(data, options.value)
52
+ if is_front:
53
+ front[label] = val
54
+ else:
55
+ back[label] = val
56
+
57
+ labels.sort()
58
+ X = np.arange(0, len(labels))
59
+ fig, ax = plt.subplots(1, 1, tight_layout=True)
60
+ fig.suptitle(options.value)
61
+ ax.set_xticks(range(len(labels)), labels=labels)
62
+ ax.grid()
63
+
64
+ vfront = [front[x] for x in labels]
65
+ vback = [back[x] for x in labels]
66
+ ax.plot(X, vfront, '*', label="Front")
67
+ ax.plot(X, vback, 'o', label="Back")
68
+ ax.legend()
69
+
70
+ if options.out:
71
+ fig.savefig(options.out, dpi=300)
72
+
73
+ plt.show()
74
+
75
+
76
+ if __name__ == "__main__":
77
+ # Argument parser
78
+ parser = argparse.ArgumentParser()
79
+ parser.add_argument('files', nargs='*', help="Input files")
80
+ parser.add_argument("--value", default=None, help="Value to plot")
81
+ parser.add_argument("--out", default=None, help="File to store the figure.")
82
+
83
+ options = parser.parse_args()
84
+ if len(options.files) == 0:
85
+ print("I need at least one input file")
86
+ sys.exit()
87
+
88
+ if len(options.files) == 1:
89
+ xxx = any(elem in options.files[0] for elem in r"*?")
90
+ if xxx:
91
+ options.files = glob.glob(options.files[0])
92
+
93
+ if options.value[0] == '/':
94
+ options.value = options.value[1:]
95
+ options.value = "results/METROLOGY/" + options.value
96
+ main(options)
@@ -14,6 +14,14 @@ from argparse import Action
14
14
  from argparse import ArgumentParser
15
15
  from pathlib import Path
16
16
  import numpy as np
17
+
18
+ try:
19
+ import petal_qc
20
+
21
+ except ImportError:
22
+ cwd = Path(__file__).parent.parent.parent
23
+ sys.path.append(cwd.as_posix())
24
+
17
25
  from petal_qc.utils.utils import output_folder
18
26
 
19
27
  from petal_qc.metrology.PetalMetrology import petal_metrology
@@ -690,7 +690,7 @@ def open_file(fname):
690
690
  fname: Path of input file or list of files.
691
691
 
692
692
  """
693
- irb = None
693
+ irbf = None
694
694
  if is_iterable(fname):
695
695
  # we assume it is a list of IRB files...
696
696
  try:
@@ -31,6 +31,7 @@ class IRDataGetter(object):
31
31
  def __init__(self):
32
32
  """Initialization."""
33
33
  self.factor = 1
34
+ self.indx = -1
34
35
  return
35
36
 
36
37
  @staticmethod
@@ -153,17 +154,23 @@ class IRDataIFIC(IRDataGetter):
153
154
 
154
155
 
155
156
  """
156
- if len(args) == 0:
157
- T_min = -22.0
158
- else:
159
- T_min = args[0]
160
-
161
157
  irbf.set_concatenate(True)
162
- min_T, i_min, ref_img = IRPetal.find_reference_image(irbf, T_min)
163
- values = self.get_IR_data(ref_img)
164
- self.factor = values.shape[0]/640
165
-
166
- return min_T, i_min, [values, ]
158
+ frame = self.get_analysis_frame(irbf)
159
+ i_min = self.indx
160
+ min_T = np.min(frame[0].image)
161
+ return min_T, i_min, frame
162
+
163
+ # if len(args) == 0:
164
+ # T_min = -22.0
165
+ # else:
166
+ # T_min = args[0]
167
+ #
168
+ # irbf.set_concatenate(True)
169
+ # min_T, i_min, ref_img = IRPetal.find_reference_image(irbf, T_min)
170
+ # values = self.get_IR_data(ref_img)
171
+ # self.factor = values.shape[0]/640
172
+ #
173
+ # return min_T, i_min, [values, ]
167
174
 
168
175
  def get_IR_data(self, image, **kargs):
169
176
  """Get the data from the image in the proper orientation.
@@ -262,16 +269,16 @@ class IRDataIFIC(IRDataGetter):
262
269
  for img in irbf.images():
263
270
  min_T.append(np.min(img[0].image))
264
271
 
265
- indx = IRDataIFIC.find_minimum(min_T)
266
- self.analysis_frame = [irbf.getImage(indx[-1])]
272
+ self.indx = IRDataIFIC.find_minimum(min_T)
273
+ self.analysis_frame = [irbf.getImage(self.indx[-1])]
267
274
  return self.analysis_frame
268
275
 
269
276
  def get_inlet_temperature(self):
270
277
  """REturn the inlet temperature."""
271
278
  if self.DB:
272
279
  img = self.analysis_frame[0]
273
- val = self.DB.get_temperature(img.timestamp, 10)
274
- return val
280
+ X, T = self.DB.get_temperature(img.timestamp, 1)
281
+ return np.min(T)
275
282
 
276
283
  else:
277
284
  return -9999
@@ -12,6 +12,7 @@ import numpy as np
12
12
  from scipy.interpolate import CubicSpline
13
13
  from petal_qc.utils.utils import find_file
14
14
  from petal_qc.utils.utils import output_folder
15
+ import petal_qc.utils.docx_utils as docx_utils
15
16
 
16
17
  from petal_qc.thermal import IRCore
17
18
  from petal_qc.thermal import Petal_IR_Analysis
@@ -33,6 +34,23 @@ def get_names(files):
33
34
  names.append(ifile.stem)
34
35
  return names
35
36
 
37
+ def add_figures_to_doc(doc, figures, name=None):
38
+ """Add figures to doc.
39
+
40
+ Args:
41
+ doc (Document): Document
42
+ figures (list): List of figures.
43
+
44
+ """
45
+ if doc is None or len(figures)==0:
46
+ return
47
+
48
+ if name:
49
+ doc.add_heading(name, level=1)
50
+
51
+ for F in figures:
52
+ doc.add_picture(F, True, 12, caption=F._suptitle.get_text())
53
+
36
54
 
37
55
  class GoldenAxis(object):
38
56
  """Get best X path."""
@@ -293,10 +311,11 @@ def show_golden_average(golden, results, value):
293
311
  for i in range(2):
294
312
  ax[i].set_xticks(range(10), labels=tick_labels)
295
313
 
314
+ G = golden[iside]
296
315
  for R in results:
297
316
  RS = R.results[iside]
298
317
  Y = getattr(RS, value)
299
- gY = getattr(golden[iside], value)
318
+ gY = getattr(G, value)
300
319
  O = getattr(R.golden[iside], value) - gY
301
320
  if value.find("path") >= 0:
302
321
  X = RS.path_length
@@ -381,6 +400,7 @@ def analyze_petal_cores(files, golden, options):
381
400
 
382
401
  """
383
402
  output = []
403
+ cores = []
384
404
  names = get_names(files)
385
405
  for i, ifile in enumerate(files):
386
406
  ifile = find_file(options.folder, ifile)
@@ -397,6 +417,7 @@ def analyze_petal_cores(files, golden, options):
397
417
  print("+++ File {} does not have component serial number.")
398
418
  continue
399
419
 
420
+ cores.append(core)
400
421
  out = [{}, {}]
401
422
  for iside in range(2):
402
423
  for val in ("path_temp", "sensor_avg", "sensor_std"):
@@ -463,7 +484,7 @@ def analyze_petal_cores(files, golden, options):
463
484
 
464
485
  output.append(dbOut)
465
486
 
466
- return output
487
+ return output, cores
467
488
 
468
489
  def analyze_IRCore(options, show=True):
469
490
  """Main entry."""
@@ -499,7 +520,31 @@ def analyze_IRCore(options, show=True):
499
520
  for i, Jside in enumerate(J):
500
521
  golden[i].from_json(Jside)
501
522
 
502
- output = analyze_petal_cores(options.files, golden, options)
523
+ output, cores = analyze_petal_cores(options.files, golden, options)
524
+
525
+ if show or options.report:
526
+ for C in cores:
527
+ get_golden_axis(C, golden)
528
+
529
+ if options.report:
530
+ document = docx_utils.Document()
531
+ document.add_page_numbers()
532
+ document.styles['Normal'].font.name = "Calibri"
533
+ document.add_heading("Comparing to Golden", 0)
534
+ else:
535
+ document = None
536
+
537
+ F = show_golden_average(golden, cores, "path_temp")
538
+ add_figures_to_doc(document, F, "Temperature along pipe")
539
+ F = show_golden_average(golden, cores, "path_spread")
540
+ add_figures_to_doc(document, F, "Spread along pipe")
541
+ F = show_golden_average(golden, cores, "sensor_avg")
542
+ add_figures_to_doc(document, F, "Sensor avg")
543
+ F = show_golden_average(golden, cores, "sensor_std")
544
+ add_figures_to_doc(document, F, "Sendor std")
545
+
546
+ if document:
547
+ document.save("Compare-to-Golden.docx")
503
548
 
504
549
  if show:
505
550
  plt.show()
@@ -4,6 +4,8 @@ import sys
4
4
  from pathlib import Path
5
5
  from argparse import ArgumentParser
6
6
  import json
7
+ import numpy as np
8
+
7
9
  import itkdb_gtk
8
10
  import itkdb_gtk.ITkDButils
9
11
  import itkdb_gtk.dbGtkUtils
@@ -19,9 +21,11 @@ except ImportError:
19
21
 
20
22
 
21
23
  from petal_qc.thermal.IRPetalParam import IRPetalParam
22
- from petal_qc.thermal.create_IRCore import create_IR_core
23
- from petal_qc.thermal.analyze_IRCore import analyze_IRCore, golden_from_json, get_golden_axis, plot_profile_and_golden
24
- from petal_qc.utils.utils import output_folder
24
+ from petal_qc.thermal import IRBFile
25
+ from petal_qc.thermal.IRDataGetter import IRDataGetter
26
+
27
+ from petal_qc.thermal.analyze_IRCore import golden_from_json
28
+ from petal_qc.utils.readGraphana import ReadGraphana
25
29
 
26
30
  import gi
27
31
  gi.require_version("Gtk", "3.0")
@@ -162,6 +166,18 @@ class CoreThermal(itkdb_gtk.dbGtkUtils.ITkDBWindow):
162
166
 
163
167
  self.irbfile = PSF
164
168
  self.param.files =[PSF,]
169
+
170
+ DB = ReadGraphana("localhost")
171
+ irbf = IRBFile.open_file(self.irbfile)
172
+ getter = IRDataGetter.factory(self.param.institute, self.param)
173
+ frames = getter.get_analysis_frame(irbf)
174
+ try:
175
+ X, val = DB.get_temperature(frames[0].timestamp, 3)
176
+ inlet = np.min(val)
177
+ self.entryTemp.set_text("{:.1f}".format(inlet))
178
+
179
+ except ValueError:
180
+ pass
165
181
 
166
182
  def on_golden_set(self, *args):
167
183
  """File chosen from FileChooser."""
@@ -7,6 +7,7 @@ from datetime import datetime
7
7
  from pathlib import Path
8
8
 
9
9
  import dateutil
10
+ import numpy as np
10
11
  import matplotlib.pyplot as plt
11
12
 
12
13
  try:
@@ -23,6 +24,7 @@ from petal_qc.thermal import Petal_IR_Analysis
23
24
  from petal_qc.thermal import PipeFit
24
25
  from petal_qc.thermal.IRDataGetter import IRDataGetter
25
26
  from petal_qc.thermal.IRPetalParam import IRPetalParam
27
+ from petal_qc.utils.readGraphana import ReadGraphana
26
28
  from petal_qc.utils.utils import output_folder
27
29
 
28
30
 
@@ -70,6 +72,28 @@ def clean_figures():
70
72
 
71
73
  __figures__ = {}
72
74
 
75
+ def get_inlet_temp(irbf, param):
76
+ """Gets the value of the inlet temperature from Graphana."""
77
+
78
+ out = -9999
79
+ getter = IRDataGetter.factory(param.institute, param)
80
+ DB = ReadGraphana("localhost")
81
+ frames = getter.get_analysis_frame(irbf)
82
+ the_time = frames[0].timestamp
83
+ try:
84
+ X, val = DB.get_temperature(the_time, 5)
85
+ for x, y in zip(X, val):
86
+ print("{} - {:.1f}".format(x, y))
87
+
88
+ imin = np.argmin(val)
89
+ out = val[imin]
90
+ print("{}: T_co2 = {:.1f}".format(X[imin], out))
91
+
92
+ except ValueError:
93
+ out = -9999
94
+
95
+ return out
96
+
73
97
  def create_IR_core(options):
74
98
  """Entry point."""
75
99
  global __figures__
@@ -83,13 +107,25 @@ def create_IR_core(options):
83
107
  print("*** Invalid institute name. ***")
84
108
  return None
85
109
 
86
- # Set parameters from command line
87
- params = IRPetal.IRPetalParam(options)
88
- params.debug = False
89
-
90
110
  # Open the sequence file
91
111
  print("## ", options.files)
92
112
  irbf = IRBFile.open_file(options.files)
113
+ if irbf is None:
114
+ print("Could not fine input file: {}".format(options.files))
115
+ return
116
+
117
+ if options.tco2 <= -999:
118
+ out = get_inlet_temp(irbf, options)
119
+ if out <= -999:
120
+ print("### Cannot get Tcos. Setting to default.")
121
+ P = IRPetalParam()
122
+ out = P.tco2
123
+
124
+ options.tco2 = out
125
+
126
+ # Set parameters from command line
127
+ params = IRPetal.IRPetalParam(options)
128
+ params.debug = False
93
129
 
94
130
  # FInd first image below the threshold or the corresponding frame
95
131
  # We will use the pipe obtained from here as the reference
@@ -153,7 +189,7 @@ def create_IR_core(options):
153
189
 
154
190
  # get the framea from where extract the data
155
191
  # reorder if needed
156
- frames = getter.get_analysis_frame(irbf)
192
+ frames = getter.get_analysis_frame(irbf)
157
193
  if pipe_order[0]:
158
194
  tmp = frames[0]
159
195
  frames[0] = frames[1]
@@ -82,11 +82,15 @@ def create_report(options):
82
82
  document.add_heading('Temperature along path', level=1)
83
83
  document.add_picture(figures[0], True, 12, caption="Petal core .vs. Golden (side 0).")
84
84
  document.add_picture(figures[0], True, 12, caption="Petal core .vs. Golden (side 1).")
85
+ for F in figures:
86
+ plt.close(F)
85
87
 
86
88
  figures = plot_profile_and_golden(golden, core, "sensor_avg")
87
89
  document.add_heading('Average Temperatur on sensors areas.', level=1)
88
90
  document.add_picture(figures[0], True, 12, caption="Sensors .vs. Golden (side 0).")
89
91
  document.add_picture(figures[0], True, 12, caption="Sensors .vs. Golden (side 1).")
92
+ for F in figures:
93
+ plt.close(F)
90
94
 
91
95
  ofile = utils.output_folder(options.folder, "{}-thermal.docx".format(options.SN))
92
96
  document.save(ofile)
@@ -3,6 +3,7 @@
3
3
  import sys
4
4
  from pathlib import Path
5
5
  import datetime
6
+ import numpy as np
6
7
  try:
7
8
  import petal_qc
8
9
 
@@ -16,15 +17,21 @@ from petal_qc.thermal.IRPetalParam import IRPetalParam
16
17
  from petal_qc.thermal import IRBFile
17
18
 
18
19
 
20
+
19
21
  options = IRPetalParam()
20
- options.files = ["/Users/lacasta/tmp/thermal/PPC.007.irb"]
22
+ options.files = [Path("~/tmp/thermal/PPC.008.irb").expanduser().resolve()]
21
23
  getter = IRDataGetter.factory(options.institute, options)
22
24
  DB = ReadGraphana("localhost")
23
25
  irbf = IRBFile.open_file(options.files)
24
26
 
25
27
  frames = getter.get_analysis_frame(irbf)
26
28
  print(frames[0].timestamp)
27
- the_time = datetime.fromtimestamp(timestamp, timezone.utc)
28
- val = DB.get_temperature(frames[0].timestamp, 10)
29
-
30
- print(val)
29
+ the_time = frames[0].timestamp
30
+ try:
31
+ X, val = DB.get_temperature(the_time, 5)
32
+ for x, y in zip(X, val):
33
+ print("{} - {:.1f}".format(x, y))
34
+
35
+ print("{:.1f}".format(np.min(val)))
36
+ except ValueError as e:
37
+ print(e)
@@ -31,31 +31,34 @@ class ReadGraphana(object):
31
31
  if not isinstance(the_time, datetime.datetime):
32
32
  the_time = parse(the_time)
33
33
 
34
- td = datetime.timedelta(minutes=window/2)
35
- t1 = the_time - td # datetime.datetime(year=2024, month=5, day=22, hour=15)
36
- t2 = the_time + td #datetime.datetime(year=2024, month=5, day=23, hour=15)
34
+ wnd = int(window/2.0+0.5)
35
+ td = datetime.timedelta(minutes=wnd)
36
+ t1 = the_time - td
37
+ t2 = the_time + td
37
38
 
38
39
  measure="Temp"
39
40
  setup="MARTA_APP|MARTA_tt06"
40
41
  query = "select location,value from {measure} where (location =~ /.*{location}*/ and time>'{t1}' and time < '{t2}') group by \"location\"".format(
41
42
  measure=measure,
42
43
  location=setup,
43
- t1=t1.isoformat()+'Z',
44
- t2=t2.isoformat()+'Z')
44
+ t1=t1.astimezone(datetime.UTC).isoformat(),
45
+ t2=t2.astimezone(datetime.UTC).isoformat()
46
+ )
45
47
 
46
48
  ss = self.client.query(query)
47
49
  nitems = 0
48
50
  for s in ss:
51
+
49
52
  nitems += len(s)
50
53
 
51
54
  if nitems==0:
52
55
  raise ValueError(("No data found"))
53
56
 
54
57
  T = []
58
+ X = []
55
59
  for s in ss:
56
60
  for v in s:
57
61
  T.append(v['value'])
62
+ X.append(v['time'])
58
63
 
59
-
60
- val = np.mean(T)
61
- return val
64
+ return X, T
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: petal_qc
3
- Version: 0.0.2
3
+ Version: 0.0.3
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
@@ -18,6 +18,7 @@ petal_qc/metrology/__init__.py
18
18
  petal_qc/metrology/all2csv.py
19
19
  petal_qc/metrology/analyze_locking_points.py
20
20
  petal_qc/metrology/cold_noise.py
21
+ petal_qc/metrology/compare_Cores.py
21
22
  petal_qc/metrology/comparisonTable.py
22
23
  petal_qc/metrology/convert_mitutoyo.py
23
24
  petal_qc/metrology/convert_smartscope.py
@@ -1,3 +1,4 @@
1
1
  [gui_scripts]
2
2
  bustapeReport = petal_qc:bustapeReport
3
3
  coreMetrology = petal_qc:coreMetrology
4
+ coreThermal = petal_qc:coreThermal
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "petal_qc"
7
- version = "0.0.2"
7
+ version = "0.0.3"
8
8
  authors = [
9
9
  { name="Carlos Lacasta", email="carlos.lacasta@cern.ch" },
10
10
  ]
@@ -31,6 +31,7 @@ classifiers = [
31
31
 
32
32
  [project.gui-scripts]
33
33
  coreMetrology = "petal_qc:coreMetrology"
34
+ coreThermal = "petal_qc:coreThermal"
34
35
  bustapeReport = "petal_qc:bustapeReport"
35
36
 
36
37
  [tool.setuptools]
File without changes
File without changes
File without changes