petal-qc 0.0.12__tar.gz → 0.0.14.dev1__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 (76) hide show
  1. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/PKG-INFO +1 -1
  2. petal_qc-0.0.14.dev1/petal_qc/PetalReceptionTests.py +330 -0
  3. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/__init__.py +5 -1
  4. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/dashBoard.py +26 -9
  5. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/PetalMetrology.py +17 -17
  6. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/test/getAVStests.py +70 -19
  7. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/test/prepareDESYfiles.py +12 -7
  8. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/create_core_report.py +7 -3
  9. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc.egg-info/PKG-INFO +1 -1
  10. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc.egg-info/SOURCES.txt +1 -0
  11. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc.egg-info/entry_points.txt +1 -0
  12. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/pyproject.toml +2 -2
  13. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/README.md +0 -0
  14. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/BTreport/CheckBTtests.py +0 -0
  15. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/BTreport/__init__.py +0 -0
  16. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/BTreport/bustapeReport.py +0 -0
  17. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/Cluster.py +0 -0
  18. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/DataFile.py +0 -0
  19. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/__init__.py +0 -0
  20. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/all2csv.py +0 -0
  21. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/analyze_locking_points.py +0 -0
  22. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/cold_noise.py +0 -0
  23. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/compare_Cores.py +0 -0
  24. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/comparisonTable.py +0 -0
  25. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/convert_mitutoyo.py +0 -0
  26. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/convert_smartscope.py +0 -0
  27. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/coreMetrology.py +0 -0
  28. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/data2csv.py +0 -0
  29. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/do_Metrology.py +0 -0
  30. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/flatness4nigel.py +0 -0
  31. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/gtkutils.py +0 -0
  32. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/petal_flatness.py +0 -0
  33. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/readAVSdata.py +0 -0
  34. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/show_data_file.py +0 -0
  35. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/testSummary.py +0 -0
  36. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/test_paralelism.py +0 -0
  37. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/metrology/uploadPetalInformation.py +0 -0
  38. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/test/checkAVStests.py +0 -0
  39. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/test/compare_golden.py +0 -0
  40. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/test/getAVSjson.py +0 -0
  41. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/test/getPetalCoreTestSummary.py +0 -0
  42. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/test/listPetalCoreComponents.py +0 -0
  43. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/test/test_Graphana.py +0 -0
  44. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/test/test_coreThermal.py +0 -0
  45. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/CSVImage.py +0 -0
  46. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/DESYdata.py +0 -0
  47. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/DebugPlot.py +0 -0
  48. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/IRBFile.py +0 -0
  49. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/IRCore.py +0 -0
  50. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/IRDataGetter.py +0 -0
  51. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/IRPetal.py +0 -0
  52. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/IRPetalParam.py +0 -0
  53. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/PetalColorMaps.py +0 -0
  54. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/Petal_IR_Analysis.py +0 -0
  55. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/PipeFit.py +0 -0
  56. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/__init__.py +0 -0
  57. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/analyze_IRCore.py +0 -0
  58. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/contours.py +0 -0
  59. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/coreThermal.py +0 -0
  60. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/create_IRCore.py +0 -0
  61. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/pipe_back.npz +0 -0
  62. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/pipe_front.npz +0 -0
  63. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/pipe_read.py +0 -0
  64. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/thermal/show_IR_petal.py +0 -0
  65. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/utils/Geometry.py +0 -0
  66. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/utils/Progress.py +0 -0
  67. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/utils/__init__.py +0 -0
  68. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/utils/all_files.py +0 -0
  69. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/utils/docx_utils.py +0 -0
  70. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/utils/fit_utils.py +0 -0
  71. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/utils/readGraphana.py +0 -0
  72. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc/utils/utils.py +0 -0
  73. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc.egg-info/dependency_links.txt +0 -0
  74. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc.egg-info/requires.txt +0 -0
  75. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/petal_qc.egg-info/top_level.txt +0 -0
  76. {petal_qc-0.0.12 → petal_qc-0.0.14.dev1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: petal_qc
3
- Version: 0.0.12
3
+ Version: 0.0.14.dev1
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
@@ -0,0 +1,330 @@
1
+ #!/usr/bin/env python3
2
+ """Test dashboard."""
3
+ import sys
4
+ import copy
5
+ from pathlib import Path
6
+
7
+ try:
8
+ import itkdb_gtk
9
+
10
+ except ImportError:
11
+ cwd = Path(__file__).parent.parent
12
+ sys.path.append(cwd.as_posix())
13
+ import itkdb_gtk
14
+
15
+ from itkdb_gtk import dbGtkUtils, ITkDBlogin, ITkDButils
16
+ from itkdb_gtk import UploadTest, UploadMultipleTests
17
+
18
+ HELP_LINK="https://itkdb-gtk.docs.cern.ch"
19
+
20
+
21
+ import gi
22
+ gi.require_version("Gtk", "3.0")
23
+ from gi.repository import Gtk, Gio
24
+
25
+
26
+ def find_children(W):
27
+ """Find DictDialog among the children."""
28
+ try:
29
+ for c in W.get_children():
30
+ if "DictDialog" in c.get_name():
31
+ return c
32
+
33
+ else:
34
+ return find_children(c)
35
+
36
+ except Exception:
37
+ return None
38
+
39
+ return None
40
+
41
+
42
+ class PetalReceptionTests(dbGtkUtils.ITkDBWindow):
43
+ """Petl Reception Test GUI."""
44
+
45
+ def __init__(self, session, help_link=None):
46
+ """Initialization."""
47
+ super().__init__(title="Petal Reception Tests",
48
+ session=session,
49
+ show_search="Find object with given SN.",
50
+ help_link=help_link)
51
+
52
+ # Members
53
+ self.dbObject = None
54
+
55
+ # action button in header
56
+ button = Gtk.Button()
57
+ icon = Gio.ThemedIcon(name="document-send-symbolic")
58
+ image = Gtk.Image.new_from_gicon(icon, Gtk.IconSize.BUTTON)
59
+ button.add(image)
60
+ button.set_tooltip_text("Click to upload ALL tests.")
61
+ button.connect("clicked", self.upload_tests)
62
+ self.hb.pack_end(button)
63
+
64
+ grid = Gtk.Grid(column_spacing=5, row_spacing=1)
65
+ self.mainBox.pack_start(grid, False, False, 5)
66
+
67
+ lbl = Gtk.Label(label="Serial Number")
68
+ lbl.set_xalign(0)
69
+ grid.attach(lbl, 0, 0, 1, 1)
70
+
71
+
72
+ self.SN = itkdb_gtk.dbGtkUtils.TextEntry()
73
+ self.SN.connect("text-changed", self.on_SN_changed)
74
+
75
+ #self.SN = Gtk.Entry()
76
+ #self.SN.connect("focus-in-event", self.on_sn_enter)
77
+ #self.SN.connect("focus-out-event", self.on_sn_leave)
78
+ grid.attach(self.SN.entry, 1, 0, 1, 1)
79
+
80
+ self.alias = Gtk.Label(label="")
81
+ grid.attach(self.alias, 2, 0, 1, 1)
82
+
83
+ self.stage = Gtk.Label(label="")
84
+ grid.attach(self.stage, 3, 0, 1, 1)
85
+
86
+ lbl = Gtk.Label(label="Institute")
87
+ lbl.set_xalign(0)
88
+ grid.attach(lbl, 0, 1, 1, 1)
89
+
90
+ self.institute = self.pdb_user["institutions"][0]["code"]
91
+ inst = self.create_institute_combo(only_user=True)
92
+ inst.connect("changed", self.new_institute)
93
+ inst.set_tooltip_text("Select the Institute.")
94
+ grid.attach(inst, 1, 1, 1, 1)
95
+ self.inst_cmb = inst
96
+
97
+ # The "Add/Remove/Send Item" buttons.
98
+ box = Gtk.ButtonBox(orientation=Gtk.Orientation.HORIZONTAL)
99
+ box.set_layout(Gtk.ButtonBoxStyle.END)
100
+ self.mainBox.pack_start(box, False, False, 0)
101
+ dbGtkUtils.add_button_to_container(box, "Upload test", "Upload this test", self.upload_single_test)
102
+ dbGtkUtils.add_button_to_container(box, "Add Defect", "Click to add a defect", self.add_defect)
103
+ dbGtkUtils.add_button_to_container(box, "Add Comment", "Click to add a comment", self.add_comment)
104
+
105
+ # The notebook
106
+ self.notebook = Gtk.Notebook()
107
+ self.notebook.set_tab_pos(Gtk.PositionType.LEFT)
108
+ self.notebook.set_size_request(-1, 250)
109
+ self.mainBox.pack_start(self.notebook, True, True, 0)
110
+
111
+ # Create the Notebook pages
112
+ self.create_test_box("Visual Inspection", "VISUAL_INSPECTION")
113
+ self.create_test_box("Grounding", "GROUNDING_CHECK")
114
+ self.create_test_box("Pipe bending", "BENDING120")
115
+ 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")
118
+ self.create_test_box("X-rays", "XRAYIMAGING")
119
+
120
+
121
+ # The text view
122
+ self.mainBox.pack_end(self.message_panel.frame, True, True, 5)
123
+
124
+ # Set the default institute
125
+ dbGtkUtils.set_combo_iter(inst, self.institute)
126
+
127
+
128
+ self.show_all()
129
+
130
+ def on_SN_changed(self, entry, value):
131
+ """New SN given. Ask in PDB,"""
132
+ if len(value) <= 0:
133
+ return None
134
+
135
+ self.query_db()
136
+ current_location = self.dbObject["currentLocation"]["code"]
137
+ dbGtkUtils.set_combo_iter(self.inst_cmb, current_location, 0)
138
+
139
+ stg = self.dbObject["currentStage"]["name"]
140
+ self.stage.set_text(stg)
141
+
142
+ entry.set_text(self.dbObject["serialNumber"])
143
+
144
+ alias = self.dbObject["alternativeIdentifier"]
145
+ self.alias.set_text(alias)
146
+
147
+ npages = self.notebook.get_n_pages()
148
+ for i in range(npages):
149
+ page = self.notebook.get_nth_page(i)
150
+ page.dict_dialog.factory_reset()
151
+
152
+
153
+ def create_test_box(self, label, test_name, institute=None):
154
+ """Create and add to notebook a test dialog.
155
+
156
+ Args:
157
+ label: The label for the Notebook
158
+ test_name: The DB name of the test
159
+ institute: The institute.
160
+
161
+ """
162
+ if institute is None:
163
+ institute = self.institute
164
+
165
+ defaults = {
166
+ "institution": institute,
167
+ "runNumber": "1",
168
+ }
169
+ dto = ITkDButils.get_test_skeleton(self.session, "CORE_PETAL", test_name, defaults)
170
+ if test_name == "VISUAL_INSPECTION":
171
+ scrolled, gM = dbGtkUtils.create_scrolled_dictdialog(dto, ("component", "testType", "results"))
172
+ else:
173
+ scrolled, gM = dbGtkUtils.create_scrolled_dictdialog(dto)
174
+
175
+ box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
176
+ box.set_border_width(5)
177
+ box.pack_end(scrolled, True, True, 0)
178
+ box.dict_dialog = gM
179
+ gM.box = box
180
+
181
+ self.notebook.append_page(box, Gtk.Label(label=label))
182
+
183
+ return gM
184
+
185
+ def query_db(self, *args):
186
+ """Search button clicked."""
187
+ SN = self.SN.get_text()
188
+ if len(SN) == 0:
189
+ dbGtkUtils.complain("Empty Serial number",
190
+ "You should enter a valid Serial number for the petal core.",
191
+ parent=self)
192
+
193
+ try:
194
+ self.dbObject = ITkDButils.get_DB_component(self.session, SN)
195
+
196
+ except Exception as E:
197
+ self.write_message(str(E)+'\n')
198
+ dbGtkUtils.complain("Could not find object in DB", str(E))
199
+ self.dbObject = None
200
+ return
201
+
202
+ #print(json.dumps(self.dbObject, indent=3))
203
+
204
+ def add_defect(self, btn):
205
+ """Add a new defect."""
206
+ page = self.notebook.get_nth_page(self.notebook.get_current_page())
207
+ values = dbGtkUtils.get_a_list_of_values("Insert new defect", ("Type", "Description/v"))
208
+ if len(values)>0:
209
+ defect = {"name": values[0], "description": values[1]}
210
+ page.dict_dialog.values["defects"].append(defect)
211
+ page.dict_dialog.refresh()
212
+
213
+ def add_comment(self, btn):
214
+ """Add a new comment."""
215
+ page = self.notebook.get_nth_page(self.notebook.get_current_page())
216
+ comment = dbGtkUtils.get_a_value("Insert new comment", is_tv=True)
217
+ if comment:
218
+ page.dict_dialog.values["comments"].append(comment)
219
+ page.dict_dialog.refresh()
220
+
221
+ def new_institute(self, combo):
222
+ """A new institute has been selected."""
223
+ inst = self.get_institute_from_combo(combo)
224
+ if inst:
225
+ self.institute = inst
226
+
227
+ npages = self.notebook.get_n_pages()
228
+ for i in range(npages):
229
+ page = self.notebook.get_nth_page(i)
230
+ page.dict_dialog.values["institution"] = self.institute
231
+ page.dict_dialog.refresh()
232
+
233
+ def upload_this_test(self, values):
234
+ """Upload a single test."""
235
+ # print(json.dumps(values, indent=2))
236
+
237
+ attachments = []
238
+ if values["testType"] == "XRAYIMAGING":
239
+ fnam = values["results"]["IMAGELINK"]
240
+ if fnam is not None and len(fnam)>0:
241
+ P = Path(fnam).expanduser().resolve()
242
+ if P.exists():
243
+ A = ITkDButils.Attachment(path=P.as_posix(), title=P.name, desc="X-ray image")
244
+ values["results"]["IMAGELINK"] = P.name
245
+ attachments.append(A)
246
+
247
+ # rc = ITkDButils.upload_test(self.session, values, attachments=attachments, check_runNumber=True)
248
+ # if rc is not None:
249
+ # dbGtkUtils.complain("Could not upload test", rc)
250
+ #
251
+ # else:
252
+ # self.write_message("Test uploaded. {} - {}\n".format(values["component"], values["testType"]))
253
+ uploadW = UploadTest.UploadTest(self.session, values, attachments)
254
+
255
+
256
+ def upload_single_test(self, *args):
257
+ """Upload the current test."""
258
+ SN = self.SN.get_text()
259
+ if len(SN) == 0:
260
+ dbGtkUtils.complain("Petal SN is empty")
261
+ return
262
+
263
+ page = self.notebook.get_nth_page(self.notebook.get_current_page())
264
+ dctD = find_children(page)
265
+ if dctD is None:
266
+ return
267
+
268
+ values = copy.deepcopy(dctD.values)
269
+ values["component"] = SN
270
+ self.upload_this_test(values)
271
+
272
+ def upload_tests(self, *args):
273
+ """Upload the current test."""
274
+ SN = self.SN.get_text()
275
+ if len(SN) == 0:
276
+ dbGtkUtils.complain("Petal SN is empty")
277
+ return
278
+
279
+ W = UploadMultipleTests.UploadMultipleTests(
280
+ self.session,
281
+ help_link="{}/uploadMultipleTests.html".format(HELP_LINK)
282
+ )
283
+
284
+ for ipage in range(self.notebook.get_n_pages()):
285
+ page = self.notebook.get_nth_page(ipage)
286
+ dctD = find_children(page)
287
+ if dctD is None:
288
+ continue
289
+
290
+ values = dctD.values
291
+ if values["testType"] == "XRAYIMAGING":
292
+ if values["institution"] != "IFIC":
293
+ continue
294
+
295
+ fnam = values["results"]["IMAGELINK"]
296
+ if fnam is None or len(fnam)==0:
297
+ continue
298
+
299
+ values["component"] = SN
300
+ W.add_test_data_to_view(values)
301
+
302
+ def main():
303
+ """Main entry."""
304
+ # DB login
305
+ HELP_LINK="https://petal-qc.docs.cern.ch/petalReceptionTests.html"
306
+
307
+ dlg = ITkDBlogin.ITkDBlogin()
308
+ client = dlg.get_client()
309
+ if client is None:
310
+ print("Could not connect to DB with provided credentials.")
311
+ dlg.die()
312
+ sys.exit()
313
+
314
+ client.user_gui = dlg
315
+
316
+ gTest = PetalReceptionTests(client, help_link=HELP_LINK)
317
+
318
+ gTest.present()
319
+ gTest.connect("destroy", Gtk.main_quit)
320
+ try:
321
+ Gtk.main()
322
+
323
+ except KeyboardInterrupt:
324
+ print("Arrrgggg!!!")
325
+
326
+ dlg.die()
327
+
328
+
329
+ if __name__ == "__main__":
330
+ main()
@@ -1,5 +1,5 @@
1
1
  """petal_qc python module."""
2
- __version__ = "0.0.12"
2
+ __version__ = "0.0.14.dev1"
3
3
 
4
4
 
5
5
  def coreMetrology():
@@ -38,6 +38,10 @@ def analyzeIRCore():
38
38
  from .thermal.analyze_IRCore import main
39
39
  main()
40
40
 
41
+ def petalReceptionTests():
42
+ """GND/VI tests."""
43
+ from .PetalReceptionTests import main
44
+ main()
41
45
 
42
46
  def dashBoard():
43
47
  """Launches the Core thermal analysis ahd PDB script."""
@@ -3,7 +3,7 @@ import sys
3
3
 
4
4
  try:
5
5
  import petal_qc
6
-
6
+
7
7
  except ImportError:
8
8
  from pathlib import Path
9
9
  cwd = Path(__file__).parent
@@ -12,6 +12,7 @@ except ImportError:
12
12
  from petal_qc.metrology.coreMetrology import CoreMetrology, CoreMetrologyOptions
13
13
  from petal_qc.thermal.coreThermal import CoreThermal
14
14
  from petal_qc.thermal.IRPetalParam import IRPetalParam
15
+ from petal_qc.PetalReceptionTests import PetalReceptionTests
15
16
 
16
17
  from itkdb_gtk import dbGtkUtils
17
18
  from itkdb_gtk import ITkDBlogin
@@ -27,7 +28,8 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
27
28
  """Dashboard class."""
28
29
  PETAL_CORE_METRO = 1
29
30
  PETAL_CORE_THERMAL = 2
30
-
31
+ PETAL_RECEPTION_TEST = 3
32
+
31
33
 
32
34
  def __init__(self, session):
33
35
  """Initialization."""
@@ -40,7 +42,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
40
42
  # Prepare dashboard
41
43
  grid = Gtk.Grid(column_spacing=5, row_spacing=5)
42
44
  self.mainBox.pack_start(grid, False, True, 5)
43
-
45
+
44
46
  irow = 0
45
47
  lbl = Gtk.Label()
46
48
  lbl.set_markup("<b>Tests</b>")
@@ -51,19 +53,34 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
51
53
  btnPetalMetrology = Gtk.Button(label="Petal Core Metrology")
52
54
  btnPetalMetrology.connect("clicked", self.petal_metrology)
53
55
  grid.attach(btnPetalMetrology, 0, irow, 1, 1)
54
-
56
+
55
57
  btnPetalThermal = Gtk.Button(label="Petal Core Thermal")
56
58
  btnPetalThermal.connect("clicked", self.petal_thermal)
57
59
  grid.attach(btnPetalThermal, 1, irow, 1, 1)
58
-
60
+
59
61
 
60
62
  irow += 1
61
- grid.attach(Gtk.Label(), 0, irow, 1, 1)
62
-
63
+ btnReception = Gtk.Button(label="Reception Tests")
64
+ btnReception.connect("clicked", self.petal_reception_test)
65
+ grid.attach(btnReception, 0, irow, 1, 1)
66
+
63
67
  self.mainBox.pack_start(Gtk.Separator(orientation=Gtk.Orientation.HORIZONTAL), False, True, 5)
64
68
 
65
69
  self.show_all()
66
-
70
+
71
+ def petal_reception_test(self, *args):
72
+ """Do petal reception test."""
73
+ bitn = DashWindow.PETAL_RECEPTION_TEST
74
+ bt = 1 << bitn
75
+ if self.mask & bt:
76
+ return
77
+
78
+ self.mask |= bt
79
+ W = PetalReceptionTests(
80
+ self.session,
81
+ help_link="{}/petalReceptionTests.html".format(HELP_LINK)
82
+ )
83
+ W.connect("destroy", self.app_closed, bitn)
67
84
 
68
85
  def petal_metrology(self, *args):
69
86
  """Do petal metrology"""
@@ -103,7 +120,7 @@ class DashWindow(dbGtkUtils.ITkDBWindow):
103
120
  bt = 1 << args[1]
104
121
  self.mask &= ~bt
105
122
  # print(bt, self.mask)
106
-
123
+
107
124
  def main():
108
125
  """Main entry"""
109
126
  # DB login
@@ -243,34 +243,34 @@ def petal_metrology(ifile, options):
243
243
  if key == "LOCATION_DELTA":
244
244
  for k, v in val.items():
245
245
  delta = np.linalg.norm(v)
246
- if not check_spec(delta, 0.050):
246
+ if not check_spec(delta, 0.075):
247
247
  dbOut["defects"].append({
248
248
  "name": key,
249
- "description": "Delta {} is {:.3f} mm > 0.050 mm.".format(k, delta)
249
+ "description": "Delta {} is {:.3f} mm > 0.075 mm.".format(k, delta)
250
250
  })
251
251
 
252
252
  elif key == "REL_POS_DELTA":
253
253
  for k, v in val.items():
254
254
  delta = np.linalg.norm(v)
255
- if not check_spec(delta, 0.050):
255
+ if not check_spec(delta, 0.075):
256
256
  dbOut["defects"].append({
257
257
  "name": key,
258
- "description": "Delta {} is {:.3f} mm > 0.050 mm.".format(k, delta)
258
+ "description": "Delta {} is {:.3f} mm > 0.075 mm.".format(k, delta)
259
259
  })
260
260
 
261
- elif "CHECK_" in key:
262
- if "OVERSIZE" in key:
263
- if not check_spec(abs(val), 0.050):
264
- dbOut["defects"].append({
265
- "name": key,
266
- "description": "LOC DIAM delta is {:.3f} mm > 0.050 mm.".format(abs(val))
267
- })
268
- else:
269
- if val < 0 or val > 0.012:
270
- dbOut["defects"].append({
271
- "name": key,
272
- "description": "LOC DIAM is not H7 0 <= {:.3f} <= 0.012 mm.".format(val)
273
- })
261
+ # elif "CHECK_" in key:
262
+ # if "OVERSIZE" in key:
263
+ # if not check_spec(abs(val), 0.050):
264
+ # dbOut["defects"].append({
265
+ # "name": key,
266
+ # "description": "LOC DIAM delta is {:.3f} mm > 0.050 mm.".format(abs(val))
267
+ # })
268
+ # else:
269
+ # if val < 0 or val > 0.012:
270
+ # dbOut["defects"].append({
271
+ # "name": key,
272
+ # "description": "LOC DIAM is not H7 0 <= {:.3f} <= 0.012 mm.".format(val)
273
+ # })
274
274
 
275
275
  ofile.close()
276
276
 
@@ -1,18 +1,20 @@
1
1
  #!/usr/bin/env python3
2
2
  """Analize AVS metrology tests."""
3
+ import sys
4
+ from pathlib import Path
3
5
  import numpy as np
4
6
  import matplotlib.pyplot as plt
5
7
 
6
8
  try:
7
- import itkdb_gtk
9
+ import petal_qc
8
10
 
9
11
  except ImportError:
10
- import sys
11
- from pathlib import Path
12
12
  cwd = Path(__file__).parent.parent
13
13
  sys.path.append(cwd.as_posix())
14
14
 
15
- from itkdb_gtk import ITkDBlogin, ITkDButils
15
+ from itkdb_gtk import ITkDBlogin
16
+ import petal_qc.utils.docx_utils as docx_utils
17
+
16
18
 
17
19
 
18
20
  def get_value(results, code):
@@ -108,24 +110,40 @@ def do_weighing(results, weights):
108
110
  weights.setdefault(value["code"][ipos+1:], []).append(value["value"])
109
111
 
110
112
 
111
- def plot_metrology(M_values, Mould_values, petal_ids):
113
+ def plot_metrology(M_values, Mould_values, petal_ids, document):
112
114
  """Plot metrology values."""
115
+ fsize = np.zeros(2)
116
+
117
+ document.add_heading('Deviation from nominal positions', level=1)
113
118
  for key, values in M_values.items():
114
119
  fig, ax = plt.subplots(ncols=1, nrows=1, tight_layout=True)
115
120
  ax.hist(values, bins=15, range=(0, 0.150))
116
121
  ax.set_title(key)
117
-
122
+ ax.grid(True)
123
+ ax.set_xlabel("Distance (mm)")
124
+ fsize = fig.get_size_inches()
125
+ if key != "FIDUCIAL1":
126
+ document.add_picture(fig, True, 14, caption=key)
127
+
128
+ fsize[1] = fsize[0]/0.82
129
+ document.add_heading('Dependency with moulds', level=1)
118
130
  for obj in M_values.keys():
119
- fig, ax = plt.subplots(ncols=1, nrows=4, tight_layout=True)
131
+ fig, ax = plt.subplots(ncols=1, nrows=4, tight_layout=True, figsize=fsize)
120
132
  fig.suptitle("{} - Mould".format(obj))
121
133
  for mould, m_values in Mould_values.items():
122
134
  im = int(mould) - 1
123
135
  ax[im].hist(m_values[obj], bins=15, range=(0, 0.150), label="Mould {}".format(mould))
124
136
 
125
137
  for i in range(4):
138
+ ax[i].grid(True)
139
+ ax[i].set_xlabel("Distance (mm)")
126
140
  ax[i].set_title("Mould {}".format(i+1))
127
141
 
128
- def plot_weighing(weights, tick_labels, show_total=False):
142
+ if obj != "FIDUCIAL1":
143
+ document.add_picture(fig, True, 14, caption=obj)
144
+
145
+
146
+ def plot_weighing(weights, tick_labels, document, show_total=False):
129
147
  """Make the plot of weights."""
130
148
  labels = ["COOLINGLOOPASSEMBLY", "LOCATOR_A", "LOCATOR_B", "LOCATOR_C",
131
149
  "HONEYCOMBSET", "FACING_FRONT", "FACING_BACK",
@@ -169,13 +187,19 @@ def main(session):
169
187
  }
170
188
 
171
189
  core_list = session.get("listComponents", json=payload)
172
- core_tests = ["METROLOGY_AVS", "WEIGHING", "MANUFACTURING"]
190
+ core_tests = ["METROLOGY_AVS", "WEIGHING", "MANUFACTURING", "DELAMINATION", "GROUNDING_CHECK", "VISUAL_INSPECTION"]
173
191
 
174
192
  weights = {}
175
193
  petal_ids = []
176
194
  M_values = {}
177
195
  Mould_values = {}
178
196
  mould_id = None
197
+ i = 0
198
+ bad_cores = {}
199
+ counter = {"TOTAL":0}
200
+ for T in core_tests:
201
+ counter[T]=0
202
+
179
203
  for core in core_list:
180
204
  SN = core["serialNumber"]
181
205
  altid = core['alternativeIdentifier']
@@ -222,6 +246,7 @@ def main(session):
222
246
  if mould_id not in Mould_values:
223
247
  Mould_values[mould_id] = {}
224
248
 
249
+ counter["TOTAL"] += 1
225
250
  for ttype, T in good_tests.items():
226
251
 
227
252
  if ttype == "WEIGHING":
@@ -233,20 +258,50 @@ def main(session):
233
258
  elif ttype == "MANUFACTURING":
234
259
  continue
235
260
 
236
- else:
237
- for value in T["results"]:
238
- print("\t{} - {}".format(value["code"], value["value"]))
261
+ # else:
262
+ # if T["results"]:
263
+ # for value in T["results"]:
264
+ # print("\t{} - {}".format(value["code"], value["value"]))
239
265
 
240
266
  if not T["passed"]:
241
267
  print("## test {} FAILED".format(T["testType"]["code"]))
268
+ bad_cores.setdefault(altid, []).append({ttype: T["defects"]})
269
+
270
+ else:
271
+ try:
272
+ counter[ttype] += 1
273
+ except KeyError:
274
+ pass
242
275
 
243
276
  if len(T["defects"]):
244
277
  print("+ Defects:")
245
278
  for D in T["defects"]:
246
279
  print("\t{} - {}".format(D["name"], D["description"]))
247
280
 
248
- plot_weighing(weights, petal_ids)
249
- plot_metrology(M_values, Mould_values, petal_ids)
281
+ document = docx_utils.Document()
282
+ document.add_page_numbers()
283
+ document.styles['Normal'].font.name = "Calibri"
284
+ document.add_heading("AVS QC tests.", 0)
285
+
286
+ document.add_heading('Results', level=1)
287
+ document.add_paragraph("Number of bad cores: {}.".format(len(bad_cores)))
288
+ document.add_heading("Bad cores", level=2)
289
+ for key, lst in bad_cores.items():
290
+ p = document.add_paragraph()
291
+ bf = p.add_run("{}:".format(key))
292
+ bf.bold = True
293
+ bf.italic = True
294
+ for item in lst:
295
+ for ttype, defects in item.items():
296
+ msg = "{}:".format(ttype)
297
+ for D in defects:
298
+ msg += "\r{} - {}".format(D["name"], D["description"])
299
+ document.add_paragraph(msg, style="List Bullet")
300
+
301
+
302
+ plot_weighing(weights, petal_ids, document)
303
+ plot_metrology(M_values, Mould_values, petal_ids, document)
304
+ document.save("AVStests.docx")
250
305
  plt.show()
251
306
 
252
307
  if __name__ == "__main__":
@@ -254,10 +309,6 @@ if __name__ == "__main__":
254
309
  dlg = ITkDBlogin.ITkDBlogin()
255
310
  session = dlg.get_client()
256
311
 
257
- try:
258
- main(session)
259
-
260
- except Exception as E:
261
- print(E)
312
+ main(session)
262
313
 
263
314
  dlg.die()
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env python3
2
2
  """Prepare raw data input files from DESY so that we can use them with this code."""
3
3
  import os
4
+ import sys
4
5
  import fnmatch
5
6
  import re
6
7
  from pathlib import Path
@@ -61,7 +62,7 @@ def main(folder, out_folder):
61
62
  P = Path(fnam).expanduser().resolve()
62
63
  with open(fnam, "r", encoding="UTF-8") as ff:
63
64
  R = rgx.search(ff.read())
64
- if R:
65
+ if R:
65
66
  petal_id = "PPC.{}".format(R.group(2))
66
67
  side = R.group(1).lower()
67
68
  if "_2D_" in P.name:
@@ -86,7 +87,7 @@ def main(folder, out_folder):
86
87
  for data_type, fnam in values.items():
87
88
  if fnam is None:
88
89
  print("This should not happen.")
89
-
90
+
90
91
  with open(fnam, "r", encoding="UTF-8") as ifile:
91
92
  data += ifile.read()
92
93
 
@@ -94,10 +95,14 @@ def main(folder, out_folder):
94
95
  ofile.write(data)
95
96
 
96
97
  list_file.close()
97
-
98
+
98
99
  if __name__ == "__main__":
99
100
  parser = argparse.ArgumentParser()
100
- parser.add_argument("--input-folder", default=None, help="Input folder")
101
- parser.add_argument("--output-folder", help="Outout fodler", default=None)
102
-
103
- main("/Users/lacasta/Downloads/Report_QC-desy_Sep2024", "/tmp/desy")
101
+ parser.add_argument("--input-folder", dest="input", default=None, help="Input folder")
102
+ parser.add_argument("--output-folder", dest="output", help="Outout fodler", default=None)
103
+ opts = parser.parse_args()
104
+ if opts.input is None or opts.output is None:
105
+ print("I need both an input and an output folder.")
106
+ sys.exit(-1)
107
+
108
+ main(opts.input, opts.output)
@@ -39,12 +39,19 @@ def create_report(options):
39
39
 
40
40
  print("\n## {} - {}".format(options.SN, options.alias))
41
41
 
42
+ # Do the core analysis.
43
+ core = create_IR_core(options)
44
+
45
+ if options.golden is None:
46
+ return core
47
+
42
48
  goldenFile = Path(options.golden).expanduser().resolve()
43
49
  if not goldenFile.exists():
44
50
  goldenFile = utils.output_folder(options.folder, options.golden)
45
51
  goldenFile = Path(goldenFile).expanduser().resolve()
46
52
  if not goldenFile.exists():
47
53
  print("I need a golden file.")
54
+ return core
48
55
 
49
56
  with open(goldenFile, "r", encoding='utf-8') as fp:
50
57
  golden = golden_from_json(json.load(fp))
@@ -65,9 +72,6 @@ def create_report(options):
65
72
  P = document.add_paragraph("Golden: {}".format(goldenFile.name), "Subtitle")
66
73
  P.alignment = docx_utils.paragraph_align_center()
67
74
 
68
-
69
- core = create_IR_core(options)
70
-
71
75
  figures = get_IRcore_plots()
72
76
  document.add_heading('Original image', level=1)
73
77
  document.add_picture(figures["original"], True, 14, caption="Original Thermal image.")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: petal_qc
3
- Version: 0.0.12
3
+ Version: 0.0.14.dev1
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,6 @@
1
1
  README.md
2
2
  pyproject.toml
3
+ petal_qc/PetalReceptionTests.py
3
4
  petal_qc/__init__.py
4
5
  petal_qc/dashBoard.py
5
6
  petal_qc.egg-info/PKG-INFO
@@ -5,5 +5,6 @@ coreMetrology = petal_qc:coreMetrology
5
5
  coreThermal = petal_qc:coreThermal
6
6
  createCoreThermalReport = petal_qc:createCoreThermalReport
7
7
  doMetrology = petal_qc:doMetrology
8
+ petalReceptionTests = petal_qc:petalReceptionTests
8
9
  petalqc_dashBoard = petal_qc:dashBoard
9
10
  uploadPetalInformation = petal_qc:uploadPetalInformation
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "petal_qc"
7
- version = "0.0.12"
7
+ version = "0.0.14.dev1"
8
8
  authors = [
9
9
  { name="Carlos Lacasta", email="carlos.lacasta@cern.ch" },
10
10
  ]
@@ -38,7 +38,7 @@ uploadPetalInformation = "petal_qc:uploadPetalInformation"
38
38
  petalqc_dashBoard = "petal_qc:dashBoard"
39
39
  createCoreThermalReport = "petal_qc:createCoreThermalReport"
40
40
  analyzeIRCore = "petal_qc:analyzeIRCore"
41
-
41
+ petalReceptionTests = "petal_qc:petalReceptionTests"
42
42
 
43
43
  [tool.setuptools]
44
44
  include-package-data = true
File without changes
File without changes