petal-qc 0.0.20__tar.gz → 0.0.22__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 (89) hide show
  1. {petal_qc-0.0.20 → petal_qc-0.0.22}/PKG-INFO +1 -1
  2. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/PetalReceptionTests.py +2 -2
  3. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/__init__.py +6 -1
  4. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/getPetalCoreTestSummary.py +69 -9
  5. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/PetalMetrology.py +21 -9
  6. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/analyze_locking_points.py +14 -3
  7. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/compare_Cores.py +15 -2
  8. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/coreMetrology.py +16 -26
  9. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/test_paralelism.py +2 -2
  10. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/uploadPetalInformation.py +20 -2
  11. petal_qc-0.0.22/petal_qc/readTemplateTable.py +313 -0
  12. petal_qc-0.0.22/petal_qc/test/analyzeMetrologyTable.py +248 -0
  13. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/getAVStests.py +2 -2
  14. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/reportFromJSon.py +9 -7
  15. petal_qc-0.0.22/petal_qc/test/testMitutoyo.py +10 -0
  16. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/IRDataGetter.py +2 -0
  17. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/IRPetal.py +20 -6
  18. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/IRPetalParam.py +6 -2
  19. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/Petal_IR_Analysis.py +1 -1
  20. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/PipeFit.py +11 -8
  21. petal_qc-0.0.22/petal_qc/thermal/PipeIterFit.py +74 -0
  22. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/contours.py +46 -3
  23. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/create_IRCore.py +8 -3
  24. petal_qc-0.0.22/petal_qc/uploadXrays.py +86 -0
  25. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc.egg-info/PKG-INFO +1 -1
  26. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc.egg-info/SOURCES.txt +4 -0
  27. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc.egg-info/entry_points.txt +1 -0
  28. {petal_qc-0.0.20 → petal_qc-0.0.22}/pyproject.toml +2 -1
  29. petal_qc-0.0.20/petal_qc/test/analyzeMetrologyTable.py +0 -119
  30. {petal_qc-0.0.20 → petal_qc-0.0.22}/README.md +0 -0
  31. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/BTreport/CheckBTtests.py +0 -0
  32. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/BTreport/__init__.py +0 -0
  33. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/BTreport/bustapeReport.py +0 -0
  34. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/dashBoard.py +0 -0
  35. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/Cluster.py +0 -0
  36. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/DataFile.py +0 -0
  37. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/__init__.py +0 -0
  38. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/all2csv.py +0 -0
  39. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/cold_noise.py +0 -0
  40. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/comparisonTable.py +0 -0
  41. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/convert_mitutoyo.py +0 -0
  42. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/convert_smartscope.py +0 -0
  43. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/data2csv.py +0 -0
  44. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/do_Metrology.py +0 -0
  45. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/flatness4nigel.py +0 -0
  46. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/gtkutils.py +0 -0
  47. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/petal_flatness.py +0 -0
  48. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/readAVSdata.py +0 -0
  49. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/show_data_file.py +0 -0
  50. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/metrology/testSummary.py +0 -0
  51. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/checkAVStests.py +0 -0
  52. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/checkCoreShipments.py +0 -0
  53. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/compare_golden.py +0 -0
  54. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/createMetrologyFile.py +0 -0
  55. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/createMetrologyTable.py +0 -0
  56. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/desyModuleBow.py +0 -0
  57. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/findRawData.py +0 -0
  58. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/getAVSjson.py +0 -0
  59. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/listPetalCoreComponents.py +0 -0
  60. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/prepareDESYfiles.py +0 -0
  61. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/test_Graphana.py +0 -0
  62. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/test/test_coreThermal.py +0 -0
  63. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/CSVImage.py +0 -0
  64. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/DESYdata.py +0 -0
  65. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/DebugPlot.py +0 -0
  66. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/IRBFile.py +0 -0
  67. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/IRCore.py +0 -0
  68. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/PetalColorMaps.py +0 -0
  69. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/__init__.py +0 -0
  70. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/analyze_IRCore.py +0 -0
  71. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/coreThermal.py +0 -0
  72. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/create_core_report.py +0 -0
  73. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/pipe_back.npz +0 -0
  74. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/pipe_front.npz +0 -0
  75. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/pipe_read.py +0 -0
  76. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/thermal/show_IR_petal.py +0 -0
  77. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/utils/ArgParserUtils.py +0 -0
  78. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/utils/Geometry.py +0 -0
  79. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/utils/Progress.py +0 -0
  80. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/utils/__init__.py +0 -0
  81. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/utils/all_files.py +0 -0
  82. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/utils/docx_utils.py +0 -0
  83. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/utils/fit_utils.py +0 -0
  84. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/utils/readGraphana.py +0 -0
  85. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc/utils/utils.py +0 -0
  86. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc.egg-info/dependency_links.txt +0 -0
  87. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc.egg-info/requires.txt +0 -0
  88. {petal_qc-0.0.20 → petal_qc-0.0.22}/petal_qc.egg-info/top_level.txt +0 -0
  89. {petal_qc-0.0.20 → petal_qc-0.0.22}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: petal_qc
3
- Version: 0.0.20
3
+ Version: 0.0.22
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
@@ -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")
118
118
  self.create_test_box("X-rays", "XRAYIMAGING")
119
119
 
120
120
 
@@ -1,5 +1,5 @@
1
1
  """petal_qc python module."""
2
- __version__ = "0.0.20"
2
+ __version__ = "0.0.22"
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
-
@@ -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
 
@@ -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")
@@ -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):
@@ -317,7 +317,10 @@ class AVSPanel(dbGtkUtils.ITkDBWindow):
317
317
  return
318
318
 
319
319
  self.find_petal(SN, silent=True)
320
- if self.petal_core:
320
+ if self.petal_core and self.petal_core["alternativeIdentifier"] is not None:
321
+ if len(self.petal_core["batches"])==0:
322
+ ITkDButils.set_petal_core_batch(self.session, self.petal_core)
323
+
321
324
  return
322
325
 
323
326
  dialog = Gtk.MessageDialog(
@@ -340,7 +343,7 @@ class AVSPanel(dbGtkUtils.ITkDBWindow):
340
343
  if len(petal_alias) == 0:
341
344
  petal_alias = self.alias
342
345
 
343
- rc = ITkDButils.registerPetalCore(self.session, SN, petal_alias)
346
+ rc = ITkDButils.registerPetalCore(self.session, SN, petal_alias, petal_core=self.petal_core)
344
347
  if rc is None:
345
348
  dbGtkUtils.complain("Could not Register petal {} ({})".format(SN, petal_alias))
346
349
 
@@ -719,8 +722,23 @@ class AVSPanel(dbGtkUtils.ITkDBWindow):
719
722
  if self.petal_core is None:
720
723
  return
721
724
 
725
+ # First Visual Inspection
726
+ for test in self.test_list:
727
+ values = test.values
728
+ if values["testType"] != "VISUAL_INSPECTION":
729
+ continue
730
+
731
+ self.write_message("{}\n".format(values["testType"]))
732
+ res = ITkDButils.upload_test(self.session, values, check_runNumber=True)
733
+ if res is not None:
734
+ dbGtkUtils.complain("Could not upload test {}".format(values["testType"]), res)
735
+
736
+ # Then the rest
722
737
  for test in self.test_list:
723
738
  values = test.values
739
+ if values["testType"] == "VISUAL_INSPECTION":
740
+ continue
741
+
724
742
  self.write_message("{}\n".format(values["testType"]))
725
743
  res = ITkDButils.upload_test(self.session, values, check_runNumber=True)
726
744
  if res is not None: