petal-qc 0.0.17__py3-none-any.whl → 0.0.24__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.
Files changed (36) hide show
  1. petal_qc/PetalReceptionTests.py +23 -5
  2. petal_qc/__init__.py +6 -1
  3. petal_qc/getPetalCoreTestSummary.py +69 -9
  4. petal_qc/metrology/PetalMetrology.py +23 -11
  5. petal_qc/metrology/analyze_locking_points.py +14 -3
  6. petal_qc/metrology/compare_Cores.py +15 -2
  7. petal_qc/metrology/convert_mitutoyo.py +5 -0
  8. petal_qc/metrology/coreMetrology.py +16 -26
  9. petal_qc/metrology/do_Metrology.py +1 -1
  10. petal_qc/metrology/petal_flatness.py +10 -9
  11. petal_qc/metrology/readAVSdata.py +11 -4
  12. petal_qc/metrology/test_paralelism.py +2 -2
  13. petal_qc/metrology/uploadPetalInformation.py +35 -3
  14. petal_qc/readTemplateTable.py +313 -0
  15. petal_qc/test/analyzeMetrologyTable.py +158 -29
  16. petal_qc/test/checkPipeShipments.py +60 -0
  17. petal_qc/test/getAVStests.py +2 -2
  18. petal_qc/test/reportFromJSon.py +35 -6
  19. petal_qc/test/testMitutoyo.py +10 -0
  20. petal_qc/test/thermalReportFromJSon.py +99 -0
  21. petal_qc/thermal/IRDataGetter.py +2 -0
  22. petal_qc/thermal/IRPetal.py +20 -6
  23. petal_qc/thermal/IRPetalParam.py +12 -3
  24. petal_qc/thermal/Petal_IR_Analysis.py +1 -1
  25. petal_qc/thermal/PipeFit.py +24 -10
  26. petal_qc/thermal/PipeIterFit.py +94 -0
  27. petal_qc/thermal/contours.py +82 -3
  28. petal_qc/thermal/coreThermal.py +2 -2
  29. petal_qc/thermal/create_IRCore.py +11 -6
  30. petal_qc/thermal/create_core_report.py +0 -3
  31. petal_qc/uploadXrays.py +86 -0
  32. {petal_qc-0.0.17.dist-info → petal_qc-0.0.24.dist-info}/METADATA +2 -3
  33. {petal_qc-0.0.17.dist-info → petal_qc-0.0.24.dist-info}/RECORD +36 -30
  34. {petal_qc-0.0.17.dist-info → petal_qc-0.0.24.dist-info}/WHEEL +1 -1
  35. {petal_qc-0.0.17.dist-info → petal_qc-0.0.24.dist-info}/entry_points.txt +1 -0
  36. {petal_qc-0.0.17.dist-info → petal_qc-0.0.24.dist-info}/top_level.txt +0 -0
@@ -112,9 +112,9 @@ class PetalReceptionTests(dbGtkUtils.ITkDBWindow):
112
112
  self.create_test_box("Visual Inspection", "VISUAL_INSPECTION")
113
113
  self.create_test_box("Grounding", "GROUNDING_CHECK")
114
114
  self.create_test_box("Pipe bending", "BENDING120")
115
+ self.create_test_box("Delamination", "DELAMINATION")
115
116
  self.create_test_box("Weight", "PETAL_CORE_WEIGHT")
116
- self.create_test_box("Bot. loc. Diam", "PETAL_CORE_LOC_DIAM")
117
- self.create_test_box("Slot loc. Diam", "PETAL_CORE_SLOT_DIAM")
117
+ self.create_test_box("Metrology Template", "METROLOGY_TEMPLATE").set_callback("results.4H7_FIT", self.on_fit_changed)
118
118
  self.create_test_box("X-rays", "XRAYIMAGING")
119
119
 
120
120
 
@@ -127,6 +127,22 @@ class PetalReceptionTests(dbGtkUtils.ITkDBWindow):
127
127
 
128
128
  self.show_all()
129
129
 
130
+ def on_fit_changed(self, gM):
131
+ """Called when fit type changes."""
132
+ val = gM.get_value("results.4H7_FIT").lower()
133
+ if "loose" in val:
134
+ gM.set_value("passed", False)
135
+ gM.set_value("problems", False)
136
+
137
+
138
+ elif "slide" in val or "tight" in val:
139
+ gM.set_value("passed", True)
140
+ gM.set_value("problems", False)
141
+
142
+ elif "press" in val:
143
+ gM.set_value("passed", True)
144
+ gM.set_value("problems", True)
145
+
130
146
  def on_SN_changed(self, entry, value):
131
147
  """New SN given. Ask in PDB,"""
132
148
  if len(value) <= 0:
@@ -178,7 +194,9 @@ class PetalReceptionTests(dbGtkUtils.ITkDBWindow):
178
194
  box.dict_dialog = gM
179
195
  gM.box = box
180
196
 
181
- self.notebook.append_page(box, Gtk.Label(label=label))
197
+ g_label = Gtk.Label(label=label)
198
+ g_label.set_halign(Gtk.Align.START)
199
+ self.notebook.append_page(box, g_label)
182
200
 
183
201
  return gM
184
202
 
@@ -247,7 +265,7 @@ class PetalReceptionTests(dbGtkUtils.ITkDBWindow):
247
265
  # rc = ITkDButils.upload_test(self.session, values, attachments=attachments, check_runNumber=True)
248
266
  # if rc is not None:
249
267
  # dbGtkUtils.complain("Could not upload test", rc)
250
- #
268
+ #
251
269
  # else:
252
270
  # self.write_message("Test uploaded. {} - {}\n".format(values["component"], values["testType"]))
253
271
  uploadW = UploadTest.UploadTest(self.session, values, attachments)
@@ -291,7 +309,7 @@ class PetalReceptionTests(dbGtkUtils.ITkDBWindow):
291
309
  if values["testType"] == "XRAYIMAGING":
292
310
  if values["institution"] != "IFIC":
293
311
  continue
294
-
312
+
295
313
  fnam = values["results"]["IMAGELINK"]
296
314
  if fnam is None or len(fnam)==0:
297
315
  continue
petal_qc/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  """petal_qc python module."""
2
- __version__ = "0.0.17"
2
+ __version__ = "0.0.24"
3
3
 
4
4
 
5
5
  def coreMetrology():
@@ -53,6 +53,11 @@ def petalCoreTestSummary():
53
53
  from .getPetalCoreTestSummary import main
54
54
  main()
55
55
 
56
+ def readReceptionTests():
57
+ """Read tamplate table with results of REception tests."""
58
+ from .readTemplateTable import main
59
+ main()
60
+
56
61
  def dashBoard():
57
62
  """Launches the Core thermal analysis ahd PDB script."""
58
63
  from .dashBoard import main
@@ -3,6 +3,7 @@
3
3
  import json
4
4
  import sys
5
5
  import re
6
+ import copy
6
7
  from argparse import ArgumentParser
7
8
 
8
9
 
@@ -42,10 +43,36 @@ def petalCoreTest(session, options):
42
43
  suff = options.institute
43
44
 
44
45
  core_list = session.get("listComponents", json=payload)
45
- core_tests = ["PETAL_METROLOGY_FRONT", "PETAL_METROLOGY_BACK", "XRAYIMAGING", "THERMAL_EVALUATION", "BTTESTING"]
46
+
47
+ # We want details about these tests
48
+ core_tests = [
49
+ "PETAL_METROLOGY_FRONT",
50
+ "PETAL_METROLOGY_BACK",
51
+ "XRAYIMAGING",
52
+ "THERMAL_EVALUATION",
53
+ "BTTESTING",
54
+ "METROLOGY_TEMPLATE",
55
+ "PETAL_CORE_WEIGHT"
56
+ ]
57
+
58
+ # this is the full list
59
+ at_qc_tests = [
60
+ "VISUAL_INSPECTION",
61
+ "BTTESTING",
62
+ "GROUNDING_CHECK",
63
+ "BENDING120",
64
+ "THERMAL_EVALUATION",
65
+ "XRAYIMAGING",
66
+ "METROLOGY_TEMPLATE",
67
+ "PETAL_METROLOGY_FRONT",
68
+ "PETAL_METROLOGY_BACK",
69
+ "PETAL_CORE_WEIGHT",
70
+ "CORE_THICKNESS",
71
+ "DELAMINATION",
72
+ ]
46
73
 
47
74
  do_check_stage = "AT_QC_SITE"
48
- #do_check_stage = None
75
+ do_check_stage = None
49
76
  petal_id_db = {}
50
77
 
51
78
  has_list = len(options.cores) != 0
@@ -76,19 +103,35 @@ def petalCoreTest(session, options):
76
103
  return False
77
104
 
78
105
  print("\n\nPetal {} [{}] - {}. {}".format(SN, altid, coreStage, location))
79
-
80
- test_list = session.get("listTestRunsByComponent", json={"filterMap":{"serialNumber": SN, "state": "ready", "testType":core_tests}})
81
-
106
+ test_status = {}
107
+ test_list = session.get("listTestRunsByComponent", json={"filterMap":{"serialNumber": SN, "state": "ready", "stage": "AT_QC_SITE", "testType":at_qc_tests}})
108
+ missing_tests = copy.deepcopy(at_qc_tests)
82
109
  for tst in test_list:
83
110
  ttype = tst["testType"]["code"]
84
- if ttype not in core_tests:
85
- print(ttype)
86
- continue
111
+ if ttype in missing_tests:
112
+ missing_tests.remove(ttype)
113
+
114
+ #if ttype not in core_tests:
115
+ # print(ttype)
116
+ # continue
87
117
 
88
118
  T = session.get("getTestRun", json={"testRun": tst["id"]})
89
119
  if T["state"] != "ready":
90
120
  print(T)
91
121
 
122
+
123
+ if ttype in test_status:
124
+ try:
125
+ if int(T["runNumber"]) > int(test_status[ttype]["runNumber"]):
126
+ test_status[ttype] = T
127
+
128
+ except ValueError:
129
+ if T["date"] > test_status[ttype]["date"]:
130
+ test_status[ttype] = T
131
+
132
+ else:
133
+ test_status[ttype] = T
134
+
92
135
  print("-- {} [{}]".format(T["testType"]["name"], T["runNumber"]))
93
136
  if not T["passed"]:
94
137
  print("\t## test FAILED")
@@ -96,12 +139,30 @@ def petalCoreTest(session, options):
96
139
  for D in T["defects"]:
97
140
  print("\t{} - {}".format(D["name"], D["description"]))
98
141
 
142
+ if len(test_status):
143
+ passed = True
144
+ for ttype, T in test_status.items():
145
+ if not T["passed"]:
146
+ passed = False
147
+ break
148
+
149
+ if passed:
150
+ print("\n--- PASSED")
151
+ else:
152
+ print("\n*** FAILED")
153
+
154
+ if options.show_missing:
155
+ print("missing tests:")
156
+ for tst in missing_tests:
157
+ print("-- {}".format(tst))
158
+
99
159
  with open("petal_ID_db_{}.json".format(suff), "w", encoding="utf-8") as fOut:
100
160
  json.dump(petal_id_db, fOut, indent=3)
101
161
 
102
162
  def main():
103
163
  """Main entry"""
104
164
  parser = ArgumentParser()
165
+ parser.add_argument("--show_missing", default=False, action="store_true", help="Show missing tests.")
105
166
  parser.add_argument("--institute", default=None, help="The petal current location")
106
167
  parser.add_argument("--cores", dest="cores", action=RangeListAction, default=[],
107
168
  help="Create list of cores to analyze. The list is made with numbers or ranges (ch1:ch2 or ch1:ch2:step) ")
@@ -121,4 +182,3 @@ def main():
121
182
 
122
183
  if __name__ == "__main__":
123
184
  main()
124
-
@@ -78,8 +78,8 @@ def petal_metrology(ifile, options):
78
78
  "passed": True,
79
79
  "problems": False,
80
80
  "properties": {
81
- "OPERATOR": "Ohian Elesgaray",
82
- "MACHINETYPE": "Mitutoyo"
81
+ "OPERATOR": "Dario Ariza" if options.desy else "Ohian Elesgaray",
82
+ "MACHINETYPE": "SmartScope" if options.desy else "Mitutoyo",
83
83
  },
84
84
  "comments": [],
85
85
  "defects": [],
@@ -154,17 +154,27 @@ def petal_metrology(ifile, options):
154
154
  data = np.concatenate((flatness_data, locator_data))
155
155
  out = analyze_locking_point_data(data, document=document, nbins=options.nbins, plane_fit=True)
156
156
 
157
+ if "defects" in out:
158
+ for D in out["defects"]:
159
+ dbOut["defects"].append(D)
160
+
161
+ del out["defects"]
162
+
163
+ # SEt the percentage of deviation from nominal
164
+ fail_allowance = 0 # 0.05
165
+ parallelism_cut = 0.250
166
+
157
167
  for key, val in out.items():
158
168
  results[key] = val
159
- if key == "COPLANARITY_LOCATORS" and not check_spec(val, 0.1):
169
+ if key == "COPLANARITY_LOCATORS" and not check_spec(val, 0.1, fail_allowance):
160
170
  dbOut["comments"].append(
161
171
  "Coplanarity of locators: {:.3f} mm".format(val))
162
- elif key == "PARALLELISM" and not check_spec(abs(val), 0.2):
172
+ elif key == "PARALLELISM" and not check_spec(abs(val), parallelism_cut, fail_allowance):
163
173
  dbOut["defects"].append({
164
174
  "name": key,
165
- "description": "Paralelism of locators is {:.3f} mm > 0.200 mm".format(val)
175
+ "description": "Paralelism of locators is {:.3f} mm > {:.3f} mm".format(val, parallelism_cut)
166
176
  })
167
- elif key == "OFFSET" and not check_spec(abs(val), 0.100):
177
+ elif key == "OFFSET" and not check_spec(abs(val), 0.100, fail_allowance):
168
178
  dbOut["comments"].append("Offset of locator plane w.r.t BT is {:.3f} mm".format(val))
169
179
 
170
180
  # Analyze locking point positions
@@ -223,26 +233,28 @@ def petal_metrology(ifile, options):
223
233
  results["DIAM"]["PL01"] = ninput[0, 2]
224
234
  results["DIAM"]["PL02"] = ninput[1, 2]
225
235
  results["DIAM"]["PL03"] = ninput[2, 2]
226
-
236
+
237
+
238
+ max_delta = 0.1 #0.075
227
239
  out = locking_point_positions(ninput, document)
228
240
  for key, val in out.items():
229
241
  results[key] = val
230
242
  if key == "LOCATION_DELTA":
231
243
  for k, v in val.items():
232
244
  delta = np.linalg.norm(v)
233
- if not check_spec(delta, 0.075):
245
+ if not check_spec(delta, max_delta, fail_allowance):
234
246
  dbOut["defects"].append({
235
247
  "name": key,
236
- "description": "Delta {} is {:.3f} mm > 0.075 mm.".format(k, delta)
248
+ "description": "Delta {} is {:.3f} mm > {:.3f} mm.".format(k, delta, max_delta)
237
249
  })
238
250
 
239
251
  elif key == "REL_POS_DELTA":
240
252
  for k, v in val.items():
241
253
  delta = np.linalg.norm(v)
242
- if not check_spec(delta, 0.075):
254
+ if not check_spec(delta, max_delta, fail_allowance):
243
255
  dbOut["defects"].append({
244
256
  "name": key,
245
- "description": "Delta {} is {:.3f} mm > 0.075 mm.".format(k, delta)
257
+ "description": "Delta {} is {:.3f} mm > {:.3f} mm.".format(k, delta, max_delta)
246
258
  })
247
259
 
248
260
  # elif "CHECK_" in key:
@@ -284,9 +284,10 @@ def analyze_locking_point_data(orig_data, nbins=50, plane_fit=True, cut=3, docum
284
284
 
285
285
  # Show the Z band
286
286
  Zband = Zp + 0.435
287
- vmin, vmax, all_band = get_min_max(Zband)
287
+ indx = remove_outliers(Zband, 7.5)
288
+ vmin, vmax, all_band = get_min_max(Zband[indx])
288
289
  parallelism = all_band
289
-
290
+
290
291
  print("Parallelism {:.3f} mm".format(parallelism))
291
292
 
292
293
  lxmin = min(vmin, -0.1)
@@ -308,7 +309,7 @@ def analyze_locking_point_data(orig_data, nbins=50, plane_fit=True, cut=3, docum
308
309
  if abs(avg_pts) > max_par:
309
310
  max_par = abs(avg_pts)
310
311
  max_avg = avg_pts
311
-
312
+
312
313
  print("Loc par. {} - {:.3f} avg: {:.3f}".format(i, band, avg_pts))
313
314
  ax.hist(pts, bins=xaxis, label="Avg {:.3f} band {:.3f} mm".format(avg_pts, band))
314
315
 
@@ -435,6 +436,16 @@ def analyze_locking_point_data(orig_data, nbins=50, plane_fit=True, cut=3, docum
435
436
  color_bar=True)
436
437
  zmean = np.mean(plane[C.xtra, 2])
437
438
  zstd = np.std(plane[C.xtra, 2])
439
+
440
+ if len(C.xtra) < 10 or zstd>0.05:
441
+ dl = outDB.setdefault("defects", [])
442
+ dl.append(
443
+ {
444
+ "name": "LOCATOR_CLUSTERS",
445
+ "description": "Cluster at {:.3f}, {:.3f} has few points [{}] or large spread {:.3f}".format(C.x, C.y, len(C.xtra), zstd)
446
+ }
447
+ )
448
+
438
449
  print("\t\t-> Z mean {:.3f} std {:.3f} [{}]".format(zmean, zstd, len(C.xtra)))
439
450
  if document:
440
451
  document.add_picture(fig, True, figure_width,
@@ -158,7 +158,7 @@ def draw_deltas(data, keys, fnam=None, title="Front", draw_text=True):
158
158
  ax[i].set_aspect('equal', adjustable='box')
159
159
  ax[i].set_xlim(-150, 150)
160
160
  ax[i].set_ylim(-150, 150)
161
- circle = plt.Circle((0,0), 75, color="red", alpha=0.25)
161
+ circle = plt.Circle((0,0), 100, color="red", alpha=0.25)
162
162
  ax[i].add_patch(circle)
163
163
  circle = plt.Circle((0,0), 25, color="green", alpha=0.25)
164
164
  ax[i].add_patch(circle)
@@ -243,7 +243,8 @@ def show_flatness(options):
243
243
  y_lim.append(ax[i].get_ylim())
244
244
 
245
245
  for a in ax:
246
- a.set_ylim(0, 1.2*max(y_lim[0][1], y_lim[1][1]))
246
+ #a.set_ylim(0, 1.2*max(y_lim[0][1], y_lim[1][1]))
247
+ a.set_ylim(0, 0.150)
247
248
  x_lim = a.get_xlim()
248
249
  a.fill_between(x_lim, 0, 0.050, facecolor="darkseagreen", alpha=0.1)
249
250
  a.fill_between(x_lim, 0.050, 0.100, facecolor="mediumseagreen", alpha=0.1)
@@ -280,6 +281,18 @@ def main(options):
280
281
 
281
282
  save_figure(fig, options.out, prefix=options.prefix)
282
283
 
284
+ fig, ax = plt.subplots(1, 2, tight_layout=True)
285
+ fig.suptitle("Histogram: {}".format(options.value))
286
+ ax[0].hist(vfront, bins=15)
287
+ ax[0].set_title("Front")
288
+ ax[0].grid()
289
+ ax[1].hist(vback, bins=15)
290
+ ax[1].set_title("Back")
291
+ ax[1].grid()
292
+ name = Path(options.out)
293
+ name = name.parent / "{}-hst.png".format(name.stem)
294
+ save_figure(fig, name, prefix=options.prefix)
295
+
283
296
  if not options.no_show:
284
297
  plt.show()
285
298
 
@@ -111,6 +111,11 @@ def mitutoyo2cvs(infiles, ofile, label='\\w+', data_type="Punto", keep=False, fi
111
111
  while len(line_data) < fill:
112
112
  line_data.append(0.0)
113
113
 
114
+ else:
115
+ if len(line_data)<3:
116
+ print("Warning: less than three data points: {}".format(','.join([str(v) for v in line_data])))
117
+ continue
118
+
114
119
  slin = ','.join([str(v) for v in line_data])
115
120
  fout.write(slin)
116
121
  if keep:
@@ -5,10 +5,7 @@ from argparse import Action
5
5
  from argparse import ArgumentParser
6
6
  from contextlib import redirect_stdout
7
7
  import numpy as np
8
- import itkdb_gtk
9
- import itkdb_gtk.ITkDButils
10
- import itkdb_gtk.dbGtkUtils
11
- import itkdb_gtk.UploadTest
8
+ from itkdb_gtk import ITkDButils, ITkDBlogin, dbGtkUtils, UploadTest
12
9
 
13
10
  from petal_qc.metrology.do_Metrology import do_analysis
14
11
 
@@ -18,7 +15,7 @@ from gi.repository import Gtk, GObject, Gio, GLib
18
15
 
19
16
  __HELP__ = "https://petal-qc.docs.cern.ch/metrology.html"
20
17
 
21
- class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
18
+ class CoreMetrology(dbGtkUtils.ITkDBWindow):
22
19
  """Application window."""
23
20
 
24
21
  def __init__(self, options, session=None, title="", panel_size=100):
@@ -75,7 +72,7 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
75
72
  self.btnFolder.set_filename(ifile)
76
73
 
77
74
  # The Serial number
78
- self.SN = itkdb_gtk.dbGtkUtils.TextEntry()
75
+ self.SN = dbGtkUtils.TextEntry()
79
76
  self.SN.connect("text-changed", self.on_SN_changed)
80
77
 
81
78
  # The prefix
@@ -159,7 +156,7 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
159
156
  """File chosen from FileChooser."""
160
157
  PSF = self.btnData.get_filename()
161
158
  if PSF is None or not Path(PSF).exists():
162
- itkdb_gtk.dbGtkUtils.complain("Could not find Data File", PSF, parent=self)
159
+ dbGtkUtils.complain("Could not find Data File", PSF, parent=self)
163
160
  return
164
161
 
165
162
  self.data_file = PSF
@@ -168,7 +165,7 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
168
165
  """Folder chosen."""
169
166
  F = self.btnFolder.get_filename()
170
167
  if F is None or not Path(F).exists():
171
- itkdb_gtk.dbGtkUtils.complain("Could not find Output folder", F, parent=self)
168
+ dbGtkUtils.complain("Could not find Output folder", F, parent=self)
172
169
  return
173
170
 
174
171
  self.folder = F
@@ -180,14 +177,14 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
180
177
  return None
181
178
 
182
179
 
183
- obj = itkdb_gtk.ITkDButils.get_DB_component(self.session, value)
180
+ obj = ITkDButils.get_DB_component(self.session, value)
184
181
  if obj is not None:
185
182
  entry.set_text(obj["serialNumber"])
186
183
  self.alternativeID = obj["alternativeIdentifier"]
187
184
  self.change_to_back(None)
188
185
 
189
186
  else:
190
- itkdb_gtk.dbGtkUtils.complain("Invalid SN", value)
187
+ dbGtkUtils.complain("Invalid SN", value)
191
188
 
192
189
  def change_to_back(self, *args):
193
190
  """The front/back switch has changed."""
@@ -207,7 +204,7 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
207
204
  if len(SN) <= 0:
208
205
  return None
209
206
 
210
- obj = itkdb_gtk.ITkDButils.get_DB_component(self.session, SN)
207
+ obj = ITkDButils.get_DB_component(self.session, SN)
211
208
  if obj is None:
212
209
  return None
213
210
 
@@ -279,7 +276,7 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
279
276
  def run_analysis(self, *args):
280
277
  """Run metrology."""
281
278
  if self.data_file is None:
282
- itkdb_gtk.dbGtkUtils.complain("No data file set", "Select one", parent=self)
279
+ dbGtkUtils.complain("No data file set", "Select one", parent=self)
283
280
  return
284
281
 
285
282
  if self.desy.get_active():
@@ -297,7 +294,7 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
297
294
 
298
295
  self.petal_SN = self.SN.get_text().strip()
299
296
  if len(self.petal_SN) == 0 or self.petal_SN is None:
300
- itkdb_gtk.dbGtkUtils.complain("Invalid SN", "SN: {}".format(self.petal_SN), parent=self)
297
+ dbGtkUtils.complain("Invalid SN", "SN: {}".format(self.petal_SN), parent=self)
301
298
  return
302
299
 
303
300
 
@@ -305,13 +302,13 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
305
302
  self.outDB = do_analysis(self.data_file, self.petal_prefix, self.petal_SN, self.options)
306
303
 
307
304
  if len(self.outDB["defects"]) > 0:
308
- itkdb_gtk.dbGtkUtils.set_button_color(self.btn_state, "red", "white")
305
+ dbGtkUtils.set_button_color(self.btn_state, "red", "white")
309
306
  self.btn_state.set_label("FAILED")
310
307
  elif len(self.outDB["comments"]) > 0:
311
- itkdb_gtk.dbGtkUtils.set_button_color(self.btn_state, "orange", "white")
308
+ dbGtkUtils.set_button_color(self.btn_state, "orange", "white")
312
309
  self.btn_state.set_label("PROBLEMS")
313
310
  else:
314
- itkdb_gtk.dbGtkUtils.set_button_color(self.btn_state, "green", "white")
311
+ dbGtkUtils.set_button_color(self.btn_state, "green", "white")
315
312
  self.btn_state.set_label("PASSED")
316
313
 
317
314
 
@@ -320,7 +317,7 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
320
317
  if self.outDB is None:
321
318
  return
322
319
 
323
- values, rc = itkdb_gtk.dbGtkUtils.DictDialog.create_json_data_editor(self.outDB)
320
+ values, rc = dbGtkUtils.DictDialog.create_json_data_editor(self.outDB)
324
321
  if rc == Gtk.ResponseType.OK:
325
322
  self.outDB = values
326
323
 
@@ -332,7 +329,7 @@ class CoreMetrology(itkdb_gtk.dbGtkUtils.ITkDBWindow):
332
329
  """Uploads test and attachments."""
333
330
  if self.outDB is None:
334
331
  return
335
- uploadW = itkdb_gtk.UploadTest.UploadTest(self.session, payload=self.outDB)
332
+ uploadW = UploadTest.UploadTest(self.session, payload=self.outDB)
336
333
 
337
334
 
338
335
  class CoreMetrologyOptions(object):
@@ -380,19 +377,12 @@ def main():
380
377
  dlg = None
381
378
  try:
382
379
  # We use here the Gtk GUI
383
- from itkdb_gtk import ITkDBlogin
384
380
  dlg = ITkDBlogin.ITkDBlogin()
385
381
  client = dlg.get_client()
386
382
 
387
383
  except Exception:
388
384
  # Login with "standard" if the above fails.
389
- import itkdb
390
- import getpass
391
- client = itkdb.Client()
392
- client.user._access_code1 = getpass.getpass("Access 1: ")
393
- client.user._access_code2 = getpass.getpass("Access 2: ")
394
- client.user.authenticate()
395
- print("Hello {} !".format(client.user.name))
385
+ client = ITkDButils.create_client()
396
386
 
397
387
  CM = CoreMetrology(options, session=client, title="Petal core metrology")
398
388
  CM.write_message("Welcome !\n")
@@ -56,7 +56,7 @@ def do_analysis(fnam, prefix, SN, options):
56
56
  def analyze_files(ifile, options):
57
57
  """Main entry."""
58
58
  failed_files = []
59
- with open(ifile, 'r', encoding='UTF-8') as inp:
59
+ with open(ifile, 'r', encoding='ISO-8859-1') as inp:
60
60
 
61
61
  for line in inp:
62
62
  line = line.strip()
@@ -24,10 +24,10 @@ from petal_qc.utils.Geometry import fit_plane
24
24
  from petal_qc.utils.Geometry import flatness_conhull, flatness_LSPL
25
25
  from petal_qc.utils.Geometry import project_to_plane
26
26
 
27
- from .analyze_locking_points import analyze_locking_point_data, locking_point_positions
28
- from .analyze_locking_points import remove_outliers
29
- from .Cluster import cluster_points
30
- from .show_data_file import show_data, TOP_VIEW
27
+ from petal_qc.metrology.analyze_locking_points import analyze_locking_point_data, locking_point_positions
28
+ from petal_qc.metrology.analyze_locking_points import remove_outliers
29
+ from petal_qc.metrology.Cluster import cluster_points
30
+ from petal_qc.metrology.show_data_file import show_data, TOP_VIEW
31
31
 
32
32
  figure_width = 14
33
33
 
@@ -132,7 +132,7 @@ def petal_flatness(orig_data, options, document=None):
132
132
 
133
133
  # group points by sensors.
134
134
  sensor_dict = {0: "R0", 10: "R1", 20: "R2", 30: "R3_0", 31: "R3_1", 40: "R4_0", 41: "R4_1", 50: "R5_0", 51: "R5_1"}
135
- sensors, *_ = group_by_sensors(M, options.is_front, False)
135
+ sensors, *_ = group_by_sensors(M, options.is_front, True)
136
136
  all_data = np.vstack(list(sensors.values()))
137
137
 
138
138
  fig = show_data(all_data, "All points in core", view=TOP_VIEW, surf=False)
@@ -257,7 +257,7 @@ def get_iring(P, is_front):
257
257
  return -1
258
258
 
259
259
 
260
- def group_by_sensors(Min, is_front=True, remove_outliers=False):
260
+ def group_by_sensors(Min, is_front=True, no_outliers=False):
261
261
  """Groups data points by sensors."""
262
262
  # Now move in Y to be on the ATLAS reference
263
263
  M = np.array(Min)
@@ -275,10 +275,11 @@ def group_by_sensors(Min, is_front=True, remove_outliers=False):
275
275
  else:
276
276
  sensors.setdefault(iring, []).append(P)
277
277
 
278
- if remove_outliers:
278
+ if no_outliers:
279
279
  for key, val in sensors.items():
280
- if remove_outliers:
281
- sensors[key] = remove_outliers(sensors[key][:, 2], 0.075)
280
+ points = np.vstack(val)
281
+ indx = remove_outliers(points[:, 2])
282
+ sensors[key] = points[indx, :]
282
283
 
283
284
  return sensors, np.array(other)
284
285
 
@@ -641,8 +641,15 @@ def readProductionSheet(session, file_path, SN):
641
641
  print(ee.message)
642
642
  return None
643
643
 
644
- # Assume active sheet is the good one, otherwise will have tofind in wb.sheetnames
645
- sheet = wb.active
644
+ # Sometimes it comes with an empty sheet in front
645
+ sheet = None
646
+ for name in wb.sheetnames:
647
+ value = wb[name]["C7"].value
648
+ if value is not None:
649
+ sheet = wb[name]
650
+ break
651
+
652
+ #sheet = wb.active
646
653
  if sheet.max_row > 30 or sheet.max_column > 9:
647
654
  raise AVSDataException("Wrong PS file:\nmx row {} mx_col {}".format(sheet.max_row, sheet.max_column))
648
655
 
@@ -759,6 +766,6 @@ if __name__ == "__main__":
759
766
  sys.exit()
760
767
 
761
768
  fnam = Path(options.files[0]).expanduser().resolve()
762
- # readProductionSheet(client, fnam, options.SN)
763
- readFATfile(client, fnam, options.SN)
769
+ readProductionSheet(client, fnam, options.SN)
770
+ # readFATfile(client, fnam, options.SN)
764
771
  dlg.die()
@@ -8,8 +8,8 @@ from pathlib import Path
8
8
  import numpy as np
9
9
  import matplotlib.pyplot as plt
10
10
 
11
- import DataFile
12
- from analyze_locking_points import analyze_locking_point_data
11
+ from petal_qc.metrology import DataFile
12
+ from petal_qc.metrology.analyze_locking_points import analyze_locking_point_data
13
13
 
14
14
 
15
15
  def do_paralelism(ifile, options):