petal-qc 0.0.0__py3-none-any.whl → 0.0.1__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.

@@ -104,6 +104,7 @@ def find_bus_tapes(session, petal, complain_func=complain):
104
104
  dict: a dict with the bustapes. Key is the BT type.
105
105
  """
106
106
  bt_list = {}
107
+ bt_valid = {}
107
108
  for child in petal["children"]:
108
109
  cstage = "Missing"
109
110
  if child["component"] is None:
@@ -117,14 +118,17 @@ def find_bus_tapes(session, petal, complain_func=complain):
117
118
 
118
119
  # We are left with the bus tapes
119
120
  cobj = session.get('getComponent', json={'component': child["component"]["id"]})
121
+ bt_list[comp_type] = cobj, child['id']
120
122
  cstage = cobj["currentStage"]['code']
121
123
  if cstage != "COMPLETED":
122
124
  complain_func("Bus tape not in final stages", cstage)
123
- continue
125
+ bt_valid[comp_type] = False
126
+
127
+ else:
128
+ bt_valid[comp_type] = True
124
129
 
125
- bt_list[comp_type] = cobj, child['id']
126
130
 
127
- return bt_list
131
+ return bt_list, bt_valid
128
132
 
129
133
 
130
134
  def find_but_tape_tests(session, petal_date, bt_sn, complain_func=complain):
@@ -209,8 +213,14 @@ def BTreport(session, SerialN, complain_func=complain):
209
213
  return None
210
214
 
211
215
  # Loop on children an find bustapes
212
- bt_list = find_bus_tapes(session, petal, complain_func=complain_func)
213
- if len(bt_list) == 0:
216
+ bt_list, bt_valid = find_bus_tapes(session, petal, complain_func=complain_func)
217
+
218
+ nvalid = 0
219
+ for valid in bt_valid.values():
220
+ if valid:
221
+ nvalid += 1
222
+
223
+ if nvalid != 2:
214
224
  complain_func("no valid bustape found", "Either not assembled or in incorrect stage.")
215
225
  return None
216
226
 
@@ -229,7 +239,7 @@ def BTreport(session, SerialN, complain_func=complain):
229
239
  }
230
240
  }
231
241
 
232
- # Check te tests in the bustapes
242
+ # Check the tests in the bustapes
233
243
  ngood = 0
234
244
  ntrouble = 0
235
245
  for bt, cp_id in bt_list.values():
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env python3
2
- from contextlib import redirect_stdout
3
-
2
+ """GUI for the BTtest."""
3
+ import dateutil.parser
4
4
  from itkdb_gtk import ITkDButils
5
5
  from itkdb_gtk import dbGtkUtils
6
6
  from itkdb_gtk import ITkDBlogin
@@ -16,6 +16,8 @@ from gi.repository import Gtk, Gio
16
16
  class BusTapeReport(dbGtkUtils.ITkDBWindow):
17
17
  """Makes a report of bustapes."""
18
18
 
19
+ BUSTAPE, SERIAL_NO, STAGE, DATE, PASSED = range(5)
20
+
19
21
  def __init__(self, session=None, title="", panel_size=100):
20
22
  """Initialization.
21
23
 
@@ -28,7 +30,9 @@ class BusTapeReport(dbGtkUtils.ITkDBWindow):
28
30
  self.petal_SN = None
29
31
  self.alternativeID = None
30
32
  self.outDB = None
31
-
33
+ self.tree = None
34
+ self.petal = None
35
+ self.petal_date = None
32
36
 
33
37
  # Active button in header
34
38
  button = Gtk.Button()
@@ -60,6 +64,10 @@ class BusTapeReport(dbGtkUtils.ITkDBWindow):
60
64
  grid.attach(self.SN.entry, 1, 0, 1, 1)
61
65
 
62
66
 
67
+ # the list of attachments
68
+ self.create_tree_view()
69
+ self.mainBox.pack_start(self.tree, True, True, 5)
70
+
63
71
  self.mainBox.pack_start(self.message_panel.frame, True, True, 0)
64
72
 
65
73
 
@@ -68,6 +76,32 @@ class BusTapeReport(dbGtkUtils.ITkDBWindow):
68
76
  self.hide()
69
77
  self.destroy()
70
78
 
79
+ def create_tree_view(self):
80
+ """Creates the Tree vvew"""
81
+ model = Gtk.ListStore(str, str, str, str, bool)
82
+ self.tree = Gtk.TreeView(model=model)
83
+
84
+ renderer = Gtk.CellRendererText()
85
+ column = Gtk.TreeViewColumn("Tape", renderer, text=BusTapeReport.BUSTAPE)
86
+ self.tree.append_column(column)
87
+
88
+ renderer = Gtk.CellRendererText()
89
+ column = Gtk.TreeViewColumn("SN", renderer, text=BusTapeReport.SERIAL_NO)
90
+ self.tree.append_column(column)
91
+
92
+ renderer = Gtk.CellRendererText()
93
+ column = Gtk.TreeViewColumn("Stage", renderer, text=BusTapeReport.STAGE)
94
+ self.tree.append_column(column)
95
+
96
+ renderer = Gtk.CellRendererText()
97
+ column = Gtk.TreeViewColumn("Test Date", renderer, text=BusTapeReport.DATE)
98
+ self.tree.append_column(column)
99
+
100
+ renderer = Gtk.CellRendererText()
101
+ column = Gtk.TreeViewColumn("Passed", renderer, text=BusTapeReport.PASSED)
102
+ self.tree.append_column(column)
103
+
104
+
71
105
  def on_SN_changed(self, entry, value):
72
106
  """New SN given. Ask in PDB,"""
73
107
  if len(value) <= 0:
@@ -76,19 +110,54 @@ class BusTapeReport(dbGtkUtils.ITkDBWindow):
76
110
 
77
111
  obj = ITkDButils.get_DB_component(self.session, value)
78
112
  if obj is not None:
79
- entry.set_text(obj["serialNumber"])
80
- self.alternativeID = obj["alternativeIdentifier"]
113
+ if self.check_petal(obj):
114
+ entry.set_text(obj["serialNumber"])
115
+ self.alternativeID = obj["alternativeIdentifier"]
116
+ self.petal = obj
117
+ self.petal_date = dateutil.parser.parse(self.petal["stateTs"])
118
+
119
+ self.query_db()
81
120
 
82
121
  else:
83
122
  dbGtkUtils.complain("Invalid SN", value)
84
123
 
124
+ def check_petal(self, petal):
125
+ """Check that the petal is a good one."""
126
+ comp_type = CheckBTtests.get_type(petal)
127
+ if comp_type != "CORE_AVS":
128
+ dbGtkUtils.complain("This is not a petal coree", comp_type)
129
+ return False
130
+
131
+ # Check that the petal core is in the proper stage.
132
+ stage = petal["currentStage"]['code']
133
+ if stage != "AT_QC_SITE":
134
+ dbGtkUtils.complain("Petal core is not at QC_SITE", "Current stage: {}".format(stage))
135
+ return False
136
+
137
+ return True
85
138
  def query_db(self, *args):
86
139
  """Search petal and bustapes."""
87
- SN = self.SN.get_text()
88
- if SN is None or len(SN)==0:
89
- dbGtkUtils.complain("Invalid Serial Number", "Wrong value: {}".format(SN))
140
+ if self.petal is None:
90
141
  return
91
-
142
+
143
+ model = Gtk.ListStore(str, str, str, str, bool)
144
+ self.tree = Gtk.TreeView(model=model)
145
+
146
+ # Loop on children an find bustapes
147
+ bt_list, bt_valid = CheckBTtests.find_bus_tapes(self.session,
148
+ self.petal,
149
+ complain_func=dbGtkUtils.complain)
150
+
151
+ for btype, item in bt_list.items():
152
+ bt_sn = item[0]["serialNumber"]
153
+ cstage = item[0]["currentStage"]['code']
154
+ bt_tests = CheckBTtests.find_but_tape_tests(self.session,
155
+ self.petal_date,
156
+ bt_sn,
157
+ complain_func=dbGtkUtils.complain)
158
+
159
+ values = [btype, child_sn, cstage]
160
+
92
161
  self.outDB = CheckBTtests.BTreport(self.session, SN, complain_func=dbGtkUtils.complain)
93
162
 
94
163
  if self.outDB is None:
petal_qc/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  """petal_qc python module."""
2
- __version__ = "0.0.0"
2
+ __version__ = "0.0.1"
3
3
 
4
4
 
5
5
  def coreMetrology():
petal_qc/dashBoard.py ADDED
@@ -0,0 +1,21 @@
1
+ """Test dashboard."""
2
+ import sys
3
+
4
+ try:
5
+ import petal_qc
6
+
7
+ except ImportError:
8
+ from pathlib import Path
9
+ cwd = Path(__file__).parent.parent
10
+ sys.path.append(cwd.as_posix())
11
+
12
+ from itkdb_gtk import dbGtkUtils
13
+ from itkdb_gtk import GetShipments
14
+ from itkdb_gtk import PetalReceptionTests
15
+ from itkdb_gtk import ITkDBlogin
16
+ from itkdb_gtk import CreateShipments
17
+ from itkdb_gtk import UploadTest
18
+ from itkdb_gtk import UploadMultipleTests
19
+ from itkdb_gtk import GlueWeight
20
+ from itkdb_gtk import UploadModuleIV
21
+ from itkdb_gtk import WireBondGui
@@ -3,11 +3,11 @@
3
3
  from pathlib import Path
4
4
  from argparse import Action
5
5
  from argparse import ArgumentParser
6
- import itkdb_gtk.ITkDButils
7
- import itkdb_gtk.dbGtkUtils
8
- import numpy as np
9
6
  from contextlib import redirect_stdout
7
+ import numpy as np
10
8
  import itkdb_gtk
9
+ import itkdb_gtk.ITkDButils
10
+ import itkdb_gtk.dbGtkUtils
11
11
  import itkdb_gtk.UploadTest
12
12
 
13
13
  from petal_qc.metrology.do_Metrology import do_analysis
@@ -147,6 +147,7 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
147
147
 
148
148
  self.mainBox.pack_start(self.message_panel.frame, True, True, 0)
149
149
 
150
+
150
151
  def quit(self, *args):
151
152
  """Quits the application."""
152
153
  self.hide()
@@ -333,6 +334,20 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
333
334
  uploadW = itkdb_gtk.UploadTest.UploadTest(self.session, payload=self.outDB)
334
335
 
335
336
 
337
+ class CoreMetrologyOptions(object):
338
+ """Dummy options"""
339
+ def __init__(self):
340
+ self.files = []
341
+ self.SN = None
342
+ self.desy = False
343
+ self.folder = None
344
+ self.prefix = None
345
+ self.locking_points = None
346
+ self.title = None
347
+ self.nbins = 25
348
+ self.label = "\\w+"
349
+ self.type = "Punto"
350
+
336
351
  def main():
337
352
  """Entry point."""
338
353
  parser = ArgumentParser()
@@ -14,6 +14,7 @@ class IRPetalParam(object):
14
14
  """
15
15
  self.institute = 'IFIC' # Either IFIC or DESY to treat the different files
16
16
  self.thrs = -20.0 # the threshold
17
+ self.tco2 = -35.0 # Inlet temperature
17
18
  self.gauss_size = 15 # Radius of gausian filtering
18
19
  self.grad_sigma = 2.5 # Sigma of grading calculation
19
20
  self.distance = 5 # Distance in contour between slices
@@ -58,6 +59,7 @@ class IRPetalParam(object):
58
59
  default=P.institute,
59
60
  help="Either IFIC or DESY to treat the different files")
60
61
  parser.add_argument("--thrs", type=float, default=P.thrs, help="Temperature threshold")
62
+ parser.add_argument("--tco2", type=float, default=P.tco2, help="CO2 Inlet temperature")
61
63
  parser.add_argument("--gauss_size", type=int, default=P.gauss_size, help="Radius of gausian filtering")
62
64
  parser.add_argument("--distance", type=float, default=P.distance, help="Distance in contour beteween slices")
63
65
  parser.add_argument("--npoints", type=int, default=P.npoints, help="Number of points per segment")
@@ -162,6 +162,15 @@ def create_golden_average(files, options):
162
162
 
163
163
  return golden, result_list
164
164
 
165
+ def golden_from_json(js_golden):
166
+ """Converst a JSon golden into a Golden object."""
167
+ golden = [Petal_IR_Analysis.AnalysisResult() for i in range(2)]
168
+ for i, G in enumerate(golden):
169
+ G.path_length = js_golden[i]["path_length"]
170
+ G.path_temp = js_golden[i]["path_temp"]
171
+ G.path_spread = js_golden[i]["path_spread"]
172
+ G.sensor_avg = js_golden[i]["sensor_avg"]
173
+ G.sensor_std = js_golden[i]["sensor_std"]
165
174
 
166
175
  def show_golden_average(golden, results, value):
167
176
  """Create golden average.
@@ -174,7 +183,7 @@ def show_golden_average(golden, results, value):
174
183
 
175
184
  """
176
185
  tick_labels = ["R0", "R1", "R2", "R3", "R3", "R4", "R4", "R5", "R5", "EoS"]
177
-
186
+ figures = []
178
187
  factor = 1.0
179
188
  if value.find("sensor") >= 0:
180
189
  factor = 2.0
@@ -184,6 +193,7 @@ def show_golden_average(golden, results, value):
184
193
 
185
194
  for iside in range(2):
186
195
  fig, ax = plt.subplots(2, 1, tight_layout=True, gridspec_kw={'height_ratios': (0.66, 0.34)}, figsize=(7, 6))
196
+ figures.append(fig)
187
197
  fig.suptitle("Golden average for {} - side {}.".format(value, iside))
188
198
  for a in ax:
189
199
  a.grid()
@@ -231,6 +241,7 @@ def show_golden_average(golden, results, value):
231
241
  if value.find("temp") >= 0 or value.find("_avg") >= 0:
232
242
  ax[1].set_ylim(-Tband, Tband)
233
243
 
244
+ return figures
234
245
 
235
246
  def compare_golden(core, golden, value):
236
247
  """Comapres petal core with golden average.
@@ -270,12 +281,15 @@ def analyze_petal_cores(files, golden, options):
270
281
  """Create golden average.
271
282
 
272
283
  Args:
273
- ----
274
284
  files (list): List of input files
275
285
  golden: the golden object
276
286
  options: other options.
277
-
287
+
288
+ Return:
289
+ array with JSon objects corresponding to the PDB test.
290
+
278
291
  """
292
+ output = []
279
293
  names = get_names(files)
280
294
  for i, ifile in enumerate(files):
281
295
  ifile = find_file(options.folder, ifile)
@@ -352,13 +366,17 @@ def analyze_petal_cores(files, golden, options):
352
366
 
353
367
  # Check if we are given an output folder
354
368
  ofile = output_folder(options.folder, ofile)
355
- with open(ofile, 'w') as fp:
369
+ with open(ofile, 'w', encoding="UTF-8") as fp:
356
370
  print("writing {}".format(ofile))
357
371
  json.dump(dbOut, fp, indent=3, cls=IRCore.NumpyArrayEncoder)
358
372
 
373
+ output.append(dbOut)
374
+
375
+ return output
359
376
 
360
377
  def analyze_IRCore(options):
361
378
  """Main entry."""
379
+ output = None
362
380
  if options.create_golden:
363
381
  golden, results = create_golden_average(options.files, options)
364
382
  if options.out is None:
@@ -390,9 +408,10 @@ def analyze_IRCore(options):
390
408
  for i, Jside in enumerate(J):
391
409
  golden[i].from_json(Jside)
392
410
 
393
- analyze_petal_cores(options.files, golden, options)
411
+ output = analyze_petal_cores(options.files, golden, options)
394
412
 
395
413
  plt.show()
414
+ return output
396
415
 
397
416
 
398
417
  if __name__ == "__main__":
@@ -0,0 +1,429 @@
1
+ #!/usr/bin/env python3
2
+ """GUI for thermal QC of petal cores."""
3
+ import sys
4
+ from pathlib import Path
5
+ from argparse import ArgumentParser
6
+ import json
7
+ import numpy as np
8
+ from matplotlib.backends.backend_gtk3agg import FigureCanvasGTK3Agg as FigureCanvas
9
+ from matplotlib.backends.backend_gtk3 import NavigationToolbar2GTK3 as NavigationToolbar
10
+ import itkdb_gtk
11
+ import itkdb_gtk.ITkDButils
12
+ import itkdb_gtk.dbGtkUtils
13
+ import itkdb_gtk.UploadTest
14
+ from petal_qc.thermal.IRPetalParam import IRPetalParam
15
+ from petal_qc.thermal.create_IRCore import create_IR_core
16
+ from petal_qc.thermal.analyze_IRCore import analyze_IRCore, golden_from_json, show_golden_average
17
+ from petal_qc.utils.utils import output_folder
18
+
19
+ import gi
20
+ gi.require_version("Gtk", "3.0")
21
+ from gi.repository import Gtk, GObject, Gio, GLib
22
+
23
+
24
+ def create_canvas(fig, sx=400, sy=300):
25
+ """Creates a canvas."""
26
+ sw = Gtk.ScrolledWindow() # Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
27
+ sw.set_border_width(10)
28
+ sw.set_size_request(310, 310)
29
+ canvas = FigureCanvas(fig) # a Gtk.DrawingArea
30
+ canvas.set_size_request(sx, sy)
31
+ sw.add(canvas)
32
+ return sw
33
+
34
+ class ShowThermalResults(Gtk.Window):
35
+ """Show thermal results."""
36
+ def __init__(self, golden, results):
37
+ """Create the window."""
38
+ super().__init__(title="Thermal Results")
39
+
40
+ # Create main content box
41
+ self.mainBox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
42
+ self.add(self.mainBox)
43
+
44
+ # The notebook
45
+ self.notebook = Gtk.Notebook()
46
+ self.notebook.set_tab_pos(Gtk.PositionType.LEFT)
47
+ self.mainBox.pack_start(self.notebook, True, True, 20)
48
+
49
+ # thermal path
50
+ box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
51
+ box.set_border_width(5)
52
+ label = Gtk.Label(label="Path Temp,")
53
+ self.notebook.append_page(box, label)
54
+
55
+ figs = show_golden_average(golden, results, "path_temp")
56
+ sw = create_canvas(figs[0])
57
+ box.pack_start(sw, True, True, 0)
58
+
59
+ sw = create_canvas(figs[q])
60
+ box.pack_start(sw, True, True, 0)
61
+
62
+ box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
63
+ box.set_border_width(5)
64
+ label = Gtk.Label(label="Sensor Avg,")
65
+ self.notebook.append_page(box, label)
66
+
67
+ figs = show_golden_average(golden, results, "sensor_avg")
68
+ sw = create_canvas(figs[0])
69
+ box.pack_start(sw, True, True, 0)
70
+
71
+ sw = create_canvas(figs[q])
72
+ box.pack_start(sw, True, True, 0)
73
+
74
+
75
+
76
+ # The button box
77
+ btnBox = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL)
78
+
79
+ btn = Gtk.Button(label="Quit")
80
+ btn.connect("clicked", self.quit)
81
+ btnBox.add(btn)
82
+
83
+ self.mainBox.pack_start(btnBox, False, True, 0)
84
+
85
+ self.show_all()
86
+
87
+ def quit(self, *args):
88
+ """Close window."""
89
+ self.hide()
90
+ self.destroy()
91
+
92
+ class CoreThermal(itkdb_gtk.dbGtkUtils.ITkDBWindow):
93
+ """Application window."""
94
+
95
+ def __init__(self, params=None, session=None, title="", panel_size=100):
96
+ """Initialization
97
+
98
+ Args:
99
+ params (IRPetalParam, optional): Petal thermal parameters.
100
+ session (itkdb.Client): ITk PDB session.
101
+ title: Window title.
102
+ panel_size: size of message pannel.
103
+ """
104
+ super().__init__(session=session, title=title)
105
+
106
+ self.petal_SN = None
107
+ self.param = params if params else IRPetalParam()
108
+ self.param.add_attachments = True
109
+ self.param.create_golden = False
110
+ self.irbfile = None
111
+ self.folder = None
112
+ self.golden = None
113
+ self.results = None
114
+ self.alternativeID = None
115
+ self.outDB = None
116
+
117
+ # Active button in header
118
+ button = Gtk.Button()
119
+ icon = Gio.ThemedIcon(name="document-send-symbolic")
120
+ image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
121
+ button.add(image)
122
+ button.set_tooltip_text("Click to upload test")
123
+ button.connect("clicked", self.upload_test_gui)
124
+ self.hb.pack_end(button)
125
+
126
+ # JScon edit
127
+ button = Gtk.Button()
128
+ icon = Gio.ThemedIcon(name="accessories-text-editor-symbolic")
129
+ image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
130
+ button.add(image)
131
+ button.set_tooltip_text("Click to see the test data")
132
+ button.connect("clicked", self.show_test_gui)
133
+ self.hb.pack_end(button)
134
+
135
+ # The file chooser
136
+ self.btnData = Gtk.FileChooserButton()
137
+ self.btnData.connect("file-set", self.on_file_set)
138
+
139
+
140
+ # The file chooser
141
+ self.goldenData = Gtk.FileChooserButton()
142
+ self.goldenData.connect("file-set", self.on_golden_set)
143
+
144
+ # The Serial number
145
+ self.SN = itkdb_gtk.dbGtkUtils.TextEntry()
146
+ self.SN.connect("text-changed", self.on_SN_changed)
147
+
148
+ self.run = Gtk.Button(label="Run")
149
+ self.run.connect("clicked", self.run_analysis)
150
+
151
+ self.btn_state = Gtk.Button(label="Undef")
152
+ self.btn_state.set_name("btnState")
153
+ self.btn_state.connect("clicked", self.show_state)
154
+ self.btn_state.set_tooltip_text("If green all good. Click to see commnets and defects.")
155
+
156
+ # Put the 3 objects in a Grid
157
+ grid = Gtk.Grid(column_spacing=5, row_spacing=5)
158
+ self.mainBox.pack_start(grid, False, True, 0)
159
+
160
+ irow = 0
161
+ grid.attach(Gtk.Label(label="Serial No."), 0, irow, 1, 1)
162
+ grid.attach(self.SN.entry, 1, irow, 1, 1)
163
+ grid.attach(self.btn_state, 3, irow, 1, 1)
164
+
165
+ irow += 1
166
+ grid.attach(Gtk.Label(label="IRB File"), 0, irow, 1, 1)
167
+ grid.attach(self.btnData, 1, irow, 1, 1)
168
+
169
+ self.entryTemp = Gtk.Entry()
170
+ self.entryTemp.set_text("{:.1f}".format(self.param.tco2))
171
+ self.entryTemp.set_tooltip_text("CO2 inlet temperature")
172
+ lbl = Gtk.Label(label="T<sub>CO2</sub>")
173
+ lbl.set_use_markup(True)
174
+ grid.attach(lbl, 2, irow, 1, 1)
175
+ grid.attach(self.entryTemp, 3, irow, 1, 1)
176
+
177
+
178
+ irow += 1
179
+ grid.attach(Gtk.Label(label="Golden File"), 0, 2, 1, 1)
180
+ grid.attach(self.goldenData, 1, 2, 1, 1)
181
+
182
+ self.entryTHrs = Gtk.Entry()
183
+ self.entryTHrs.set_tooltip_text("Temperature threshold.")
184
+ self.entryTHrs.set_text("{:.1f}".format(self.param.thrs))
185
+ lbl = Gtk.Label(label="Threshold")
186
+ grid.attach(lbl, 2, irow, 1, 1)
187
+ grid.attach(self.entryTHrs, 3, irow, 1, 1)
188
+
189
+
190
+ irow += 1
191
+ # the folder option
192
+ self.btnFolder = Gtk.FileChooserButton()
193
+ self.btnFolder.set_tooltip_text("Select folder for all output. If none selected, output in current folder.")
194
+ self.btnFolder.set_action(Gtk.FileChooserAction.SELECT_FOLDER)
195
+ self.btnFolder.connect("file-set", self.on_folder_set)
196
+ if self.param.folder and len(self.param.folder) > 0 :
197
+ ifile = Path(self.param.folder).expanduser().resolve().as_posix()
198
+ self.btnFolder.set_filename(ifile)
199
+
200
+ grid.attach(Gtk.Label(label="Folder"), 0, irow, 1, 1)
201
+ grid.attach(self.btnFolder, 1, irow, 1, 1)
202
+
203
+ self.entryDist = Gtk.Entry()
204
+ self.entryDist.set_text("{}".format(self.param.distance))
205
+ self.entryDist.set_tooltip_text("Distance in contour beteween slices")
206
+ lbl = Gtk.Label(label="Distance")
207
+ grid.attach(lbl, 2, irow, 1, 1)
208
+ grid.attach(self.entryDist, 3, irow, 1, 1)
209
+
210
+
211
+ grid.attach(self.run, 0, 4, 5, 1)
212
+
213
+ self.mainBox.pack_start(self.message_panel.frame, True, True, 0)
214
+
215
+
216
+ def on_file_set(self, *args):
217
+ """File chosen from FileChooser."""
218
+ PSF = self.btnData.get_filename()
219
+ if PSF is None or not Path(PSF).exists():
220
+ itkdb_gtk.dbGtkUtils.complain("Could not find Data File", PSF, parent=self)
221
+ return
222
+
223
+ self.irbfile = PSF
224
+ self.param.files =[PSF,]
225
+
226
+ def on_golden_set(self, *args):
227
+ """File chosen from FileChooser."""
228
+ PSF = self.goldenData.get_filename()
229
+ if PSF is None or not Path(PSF).exists():
230
+ itkdb_gtk.dbGtkUtils.complain("Could not find Golden File", PSF, parent=self)
231
+ return
232
+
233
+ with open(PSF, "r", encoding='utf-8') as fp:
234
+ self.golden = golden_from_json(json.load(fp))
235
+
236
+ self.param.golden = PSF
237
+
238
+ def on_folder_set(self, *args):
239
+ """Folder chosen."""
240
+ F = self.btnFolder.get_filename()
241
+ if F is None or not Path(F).exists():
242
+ itkdb_gtk.dbGtkUtils.complain("Could not find Output folder", F, parent=self)
243
+ return
244
+
245
+ self.folder = F
246
+ self.param.folder = F
247
+
248
+ def on_SN_changed(self, entry, value):
249
+ """New SN given. Ask in PDB,"""
250
+ if len(value) <= 0:
251
+ return None
252
+
253
+
254
+ obj = itkdb_gtk.ITkDButils.get_DB_component(self.session, value)
255
+ if obj is not None:
256
+ entry.set_text(obj["serialNumber"])
257
+ self.alternativeID = obj["alternativeIdentifier"]
258
+
259
+ else:
260
+ itkdb_gtk.dbGtkUtils.complain("Invalid SN", value)
261
+
262
+ def show_state(self, *arg):
263
+ """Shows the status"""
264
+ if self.outDB is None:
265
+ dialog = Gtk.MessageDialog(
266
+ transient_for=self,
267
+ flags=0,
268
+ message_type=Gtk.MessageType.INFO,
269
+ buttons=Gtk.ButtonsType.OK,
270
+ text="State undefined",
271
+ )
272
+ dialog.format_secondary_text(
273
+ "No analysis data available yet."
274
+ )
275
+ dialog.run()
276
+ dialog.destroy()
277
+ return
278
+
279
+ ndef = len(self.outDB["defects"])
280
+ ncomm = len(self.outDB["comments"])
281
+
282
+ if ndef+ncomm == 0:
283
+ dialog = Gtk.MessageDialog(
284
+ transient_for=self,
285
+ flags=0,
286
+ message_type=Gtk.MessageType.INFO,
287
+ buttons=Gtk.ButtonsType.OK,
288
+ text="All good",
289
+ )
290
+ dialog.format_secondary_text(
291
+ "Petal core passed without problems."
292
+ )
293
+ dialog.run()
294
+ dialog.destroy()
295
+ return
296
+
297
+ msg = ""
298
+ if ndef:
299
+ msg += "Defects\n"
300
+ for D in self.outDB["defects"]:
301
+ msg += "{}: {}\n".format(D["name"], D["description"])
302
+
303
+ if ncomm:
304
+ msg += "Comments\n"
305
+ for C in self.outDB["comments"]:
306
+ msg += "{}\n".format(C)
307
+
308
+
309
+ dialog = Gtk.MessageDialog(
310
+ transient_for=self,
311
+ flags=0,
312
+ message_type=Gtk.MessageType.INFO,
313
+ buttons=Gtk.ButtonsType.OK,
314
+ text="Problems found",
315
+ )
316
+
317
+ dialog.format_secondary_text(msg)
318
+ dialog.run()
319
+ dialog.destroy()
320
+
321
+
322
+ def show_test_gui(self, *args):
323
+ """Show test data."""
324
+ if self.outDB is None:
325
+ return
326
+
327
+ values, rc = itkdb_gtk.dbGtkUtils.DictDialog.create_json_data_editor(self.outDB)
328
+ if rc == Gtk.ResponseType.OK:
329
+ self.outDB = values
330
+
331
+ def upload_test_gui(self, *args):
332
+ """Uploads test and attachments."""
333
+ self.upload_test()
334
+
335
+ def upload_test(self):
336
+ """Uploads test and attachments."""
337
+ if self.outDB is None:
338
+ return
339
+ uploadW = itkdb_gtk.UploadTest.UploadTest(self.session, payload=self.outDB)
340
+
341
+ def run_analysis(self, *args):
342
+ """Run analysis."""
343
+ if self.irbfile is None:
344
+ self.write_message("Missing IRB file\n")
345
+ return
346
+
347
+ self.write_message("Start analysis\n.")
348
+ self.param.out = "{}.json".format(self.alternativeID)
349
+ self.param.alias = self.alternativeID
350
+ self.param.SN = self.SN.get_text()
351
+
352
+ core = create_IR_core(self.param)
353
+
354
+ self.param.files[0] = output_folder(self.param.folder, self.param.out)
355
+ self.param.out = None
356
+ out = analyze_IRCore(self.param)
357
+ self.outDB = out[0] if len(out) else None
358
+ self.param.files = []
359
+ self.write_message("Done\n")
360
+
361
+ outW = ShowThermalResults(self.golden, [core, ])
362
+ if self.outDB:
363
+ if len(self.outDB["defects"]) > 0:
364
+ itkdb_gtk.dbGtkUtils.set_button_color(self.btn_state, "red", "white")
365
+ self.btn_state.set_label("FAILED")
366
+ elif len(self.outDB["comments"]) > 0:
367
+ itkdb_gtk.dbGtkUtils.set_button_color(self.btn_state, "orange", "white")
368
+ self.btn_state.set_label("PROBLEMS")
369
+ else:
370
+ itkdb_gtk.dbGtkUtils.set_button_color(self.btn_state, "green", "white")
371
+ self.btn_state.set_label("PASSED")
372
+
373
+ def main():
374
+ """Entry point."""
375
+ # Argument parser
376
+ parser = ArgumentParser()
377
+ #parser.add_argument('files', nargs='*', help="Input files")
378
+ parser.add_argument("--nframe", type=int, default=-1, help="Number of frames. (negative means all.")
379
+ parser.add_argument('--frame', type=int, default=-1, help="First frame to start.")
380
+ parser.add_argument("--out", default="core.json", help="Output file name")
381
+ parser.add_argument("--alias", default="", help="Alias")
382
+ parser.add_argument("--SN", default="", help="serial number")
383
+ parser.add_argument("--folder", default=None, help="Folder to store output files. Superseeds folder in --out")
384
+
385
+ IRPetalParam.add_parameters(parser)
386
+
387
+ options = parser.parse_args()
388
+ #if len(options.files) == 0:
389
+ # print("I need an input file")
390
+ # sys.exit()
391
+
392
+ # ITk PDB authentication
393
+ dlg = None
394
+ try:
395
+ # We use here the Gtk GUI
396
+ from itkdb_gtk import ITkDBlogin
397
+ dlg = ITkDBlogin.ITkDBlogin()
398
+ client = dlg.get_client()
399
+
400
+ except Exception:
401
+ # Login with "standard" if the above fails.
402
+ import itkdb
403
+ import getpass
404
+ client = itkdb.Client()
405
+ client.user._access_code1 = getpass.getpass("Access 1: ")
406
+ client.user._access_code2 = getpass.getpass("Access 2: ")
407
+ client.user.authenticate()
408
+ print("Hello {} !".format(client.user.name))
409
+
410
+ CT = CoreThermal(options, session=client, title="Petal Thermal analysis.")
411
+ CT.show_all()
412
+ CT.connect("destroy", Gtk.main_quit)
413
+ CT.write_message("Welcome !")
414
+
415
+ try:
416
+ Gtk.main()
417
+
418
+ except KeyboardInterrupt:
419
+ print("Arrrgggg!!!")
420
+
421
+
422
+ try:
423
+ dlg.die()
424
+
425
+ except Exception:
426
+ print("Bye !")
427
+
428
+ if __name__ == "__main__":
429
+ main()
@@ -58,7 +58,7 @@ def create_IR_core(options):
58
58
 
59
59
  except NotImplemented:
60
60
  print("*** Invalid institute name. ***")
61
- return
61
+ return None
62
62
 
63
63
  # Set parameters from command line
64
64
  params = IRPetal.IRPetalParam(options)
@@ -154,11 +154,13 @@ def create_IR_core(options):
154
154
 
155
155
  # Check if we are given an output folder
156
156
  ofile = output_folder(options.folder, options.out)
157
- with open(ofile, "w") as ofile:
157
+ with open(ofile, "w", encoding="utf-8") as ofile:
158
158
  core.to_json(ofile)
159
159
 
160
160
  if options.debug:
161
161
  plt.show()
162
+
163
+ return core
162
164
 
163
165
 
164
166
  if __name__ == "__main__":
@@ -169,7 +171,6 @@ if __name__ == "__main__":
169
171
  parser.add_argument('files', nargs='*', help="Input files")
170
172
  parser.add_argument("--nframe", type=int, default=-1, help="Number of frames. (negative means all.")
171
173
  parser.add_argument('--frame', type=int, default=-1, help="First frame to start.")
172
- parser.add_argument("--tco2", default=0, type=float, help="CO2 inlet temperature.")
173
174
  parser.add_argument("--out", default="core.json", help="Output file name")
174
175
  parser.add_argument("--alias", default="", help="Alias")
175
176
  parser.add_argument("--SN", default="", help="serial number")
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: petal_qc
3
- Version: 0.0.0
3
+ Version: 0.0.1
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,7 +1,8 @@
1
- petal_qc/__init__.py,sha256=jVzpfX2cxFKJtyeuUIhf3o6dornHFtUkoUUjFRN9H08,337
2
- petal_qc/BTreport/CheckBTtests.py,sha256=WGENYpswLxs-BLQxXRxJC-6i-tdRZkIhNzhYtItfVBY,8845
1
+ petal_qc/__init__.py,sha256=2q00gtEJFdw6a2_u6tM6FVJIlBYFKb1bQ8iqoEugWpA,337
2
+ petal_qc/dashBoard.py,sha256=aPugRYhCcAzEBPrCyh8A8QKYaB4Q-_T1q3r5A3J2eog,553
3
+ petal_qc/BTreport/CheckBTtests.py,sha256=4hNP1V-zcFBN5UvWVbx9nAmittF8Jmb5J17L33t68Eg,9086
3
4
  petal_qc/BTreport/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- petal_qc/BTreport/bustapeReport.py,sha256=Db4WhOhvqku-YatNwxrIwZ4g7l7hVfMth2hAV3JRZ6A,4151
5
+ petal_qc/BTreport/bustapeReport.py,sha256=c5VERxPm6BOgW_yN9O_bEPmCYpuwZ_Yt_I2sMVAp0-I,6895
5
6
  petal_qc/metrology/Cluster.py,sha256=UtZ5q1EFb8f3qC0hEYBbhRg2pPbW_28aJX2EEMu00Ho,2105
6
7
  petal_qc/metrology/DataFile.py,sha256=PbFqy3-WSj69epV5EjhHc1GKhA8I74FmJYOXUjN0V20,1367
7
8
  petal_qc/metrology/PetalMetrology.py,sha256=H4MwuQ2QxP_Td9KtMly_-osXT1owigzC7QlmRub7oRo,11886
@@ -12,7 +13,7 @@ petal_qc/metrology/cold_noise.py,sha256=PuTaQ73WrQCJdE9ezS4UFmA3atwCuvM0ZsUOYu1Z
12
13
  petal_qc/metrology/comparisonTable.py,sha256=6Zmh-x0ahs28ZJQuHMrIiRcblUmTN1_-1otFSRNMPds,1743
13
14
  petal_qc/metrology/convert_mitutoyo.py,sha256=HdXQzFL5y7r8qXDzti91VItDQ-y6D9rEAYknn4yHwBs,5449
14
15
  petal_qc/metrology/convert_smartscope.py,sha256=es3PoUd5d5rpHebgwsS9nrc3uuy9uFKOQ00ZdU5XHQ0,3836
15
- petal_qc/metrology/coreMetrology.py,sha256=yDgChOmOZ7lKd6c_Je0pFLS0ahszYZoBBgyJ57Nbj3E,13256
16
+ petal_qc/metrology/coreMetrology.py,sha256=L_uoxq8ObmmiMSx41gFCdpQnalR-HgaVUPHzhDYsDiE,13610
16
17
  petal_qc/metrology/data2csv.py,sha256=2ttMSmfGLPIaOqZGima2dH6sdnSRAFTHlEbSOfW5ebA,1809
17
18
  petal_qc/metrology/do_Metrology.py,sha256=4tbZJfJYXY8QVLiG5_2pThNPzyuqbC3s8xhFdQfC1TU,3977
18
19
  petal_qc/metrology/flatness4nigel.py,sha256=SUHwn6pCEUWQV_62-_9-VKrmUdL4gVQcSA3aTtYq958,4071
@@ -27,14 +28,17 @@ petal_qc/thermal/IRBFile.py,sha256=zj82SdI-MDfZq1i0n47PuZMLLx_0oKpE-ZaykJZs6BU,2
27
28
  petal_qc/thermal/IRCore.py,sha256=Iasus1wy1pDQvBMPhcPYN1gFHZGv7tO5KJlpJZGuck4,3029
28
29
  petal_qc/thermal/IRDataGetter.py,sha256=dX_FjeGc7qxinJ1JPC_4rSLSJlYtkKuAL31LURfv2a8,9662
29
30
  petal_qc/thermal/IRPetal.py,sha256=X6I7JmyWf_9mPHjTsuBztM-1b5wre2NW4VM-6dz4Gow,38208
30
- petal_qc/thermal/IRPetalParam.py,sha256=BcS302s4kyAuGm_F9zIlKVsPJkftSG71GGMzAl5eZMo,3366
31
+ petal_qc/thermal/IRPetalParam.py,sha256=KlCJn0s9f0LSbQiUQG9aAJfwZ7EHApg2Aj665glZUr8,3516
31
32
  petal_qc/thermal/PetalColorMaps.py,sha256=6CvJHzRdojLHu3BROYSekHw8g_BJ1lJ_edyhovTIydU,3831
32
33
  petal_qc/thermal/Petal_IR_Analysis.py,sha256=8Deh_bJ5B7DdaUV18saboF7fXZ_8Bt1vkUlsk5RqVeo,3910
33
34
  petal_qc/thermal/PipeFit.py,sha256=qbNvi547U9EttfRxCaIrizK69Hw3mJOKuG4SGRQaHRk,17191
34
35
  petal_qc/thermal/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
- petal_qc/thermal/analyze_IRCore.py,sha256=v9cf5GAP_yfL829WK5Qyv1fOl5LdIsLfZEVPQQXiQ1A,13740
36
+ petal_qc/thermal/analyze_IRCore.py,sha256=A2i6_O2XfS8uRCpaUXDRm_p8_1zTBS3DJJHC4kS5s90,14463
36
37
  petal_qc/thermal/contours.py,sha256=ampCKm4byZYKb_4eJFjIkdFIl2bqVXD2mV13d2XUWlw,8244
37
- petal_qc/thermal/create_IRCore.py,sha256=S4M7OQYHcuh7lX3XmDHWOnIhT_1EIr-XdbsRgMGOOEQ,5678
38
+ petal_qc/thermal/coreThermal.py,sha256=B4LAOaZ6DWWoRtqQ0WU3VyRCluKxvQWZ_1GWRmLOF6o,14428
39
+ petal_qc/thermal/create_IRCore.py,sha256=u1sSSTX4nsBIW0bclu4O7tEvWL_bXlB97V8THJE_ppI,5638
40
+ petal_qc/thermal/pipe_back.npz,sha256=yooZuVYtHU541HcV6Gh_5B0BqdYAVEvYAuVvMMSY7Jc,3632
41
+ petal_qc/thermal/pipe_front.npz,sha256=DuwruG9C2Z1rLigqWMApY4Orsf1SGUQGKy0Yan8Bk8A,3697
38
42
  petal_qc/thermal/pipe_read.py,sha256=HrAtEbf8pMhJDETzkevodiTbuprIOh4yHv6PzpRoz7Q,5040
39
43
  petal_qc/thermal/show_IR_petal.py,sha256=PGAq7qiWmchYx4tGPgWJxeHi2N-pM_C1a4tmXYe0htY,13029
40
44
  petal_qc/utils/Geometry.py,sha256=XwA_aojk880N-jC1_bnMYFK0bcD-L96JPS81NUerJf0,19765
@@ -44,8 +48,8 @@ petal_qc/utils/all_files.py,sha256=4ja_DkbTYPY3gUPBAZq0p7KB9lnXZx-OCnpTHg9tm4I,1
44
48
  petal_qc/utils/docx_utils.py,sha256=Eye16PF8W0mPBVdQvgFKWxPYV7-hzBgANPDZtUEjzf8,5805
45
49
  petal_qc/utils/fit_utils.py,sha256=3KUGWpBMV-bVDkQHWBigXot8chOpjAVBJ5H5b5dbdjk,5349
46
50
  petal_qc/utils/utils.py,sha256=CqCsNIcEg6FQb3DN70tmqeLVLlQqsRfDzhfGevlnfBc,4035
47
- petal_qc-0.0.0.dist-info/METADATA,sha256=rg1E5POenrFwIY540PaK6cYolr9epkR7V3OPUO7HDWo,943
48
- petal_qc-0.0.0.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
49
- petal_qc-0.0.0.dist-info/entry_points.txt,sha256=ZsBmzA1gRvZSe4ZKcxlo0b-RBjySccqBhL6g_CJhNaM,92
50
- petal_qc-0.0.0.dist-info/top_level.txt,sha256=CCo1Xe6kLS79PruhsB6bk2CuL9VFtNdNpgJjYUs4jk4,9
51
- petal_qc-0.0.0.dist-info/RECORD,,
51
+ petal_qc-0.0.1.dist-info/METADATA,sha256=I0nY8IdvLJW9DEnt6pZ8TiRQWR-ammo41RonPXaPfpg,943
52
+ petal_qc-0.0.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
53
+ petal_qc-0.0.1.dist-info/entry_points.txt,sha256=ZsBmzA1gRvZSe4ZKcxlo0b-RBjySccqBhL6g_CJhNaM,92
54
+ petal_qc-0.0.1.dist-info/top_level.txt,sha256=CCo1Xe6kLS79PruhsB6bk2CuL9VFtNdNpgJjYUs4jk4,9
55
+ petal_qc-0.0.1.dist-info/RECORD,,