petal-qc 0.0.0__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.

Files changed (51) hide show
  1. petal_qc/BTreport/CheckBTtests.py +321 -0
  2. petal_qc/BTreport/__init__.py +0 -0
  3. petal_qc/BTreport/bustapeReport.py +144 -0
  4. petal_qc/__init__.py +14 -0
  5. petal_qc/metrology/Cluster.py +90 -0
  6. petal_qc/metrology/DataFile.py +47 -0
  7. petal_qc/metrology/PetalMetrology.py +327 -0
  8. petal_qc/metrology/__init__.py +0 -0
  9. petal_qc/metrology/all2csv.py +57 -0
  10. petal_qc/metrology/analyze_locking_points.py +597 -0
  11. petal_qc/metrology/cold_noise.py +106 -0
  12. petal_qc/metrology/comparisonTable.py +59 -0
  13. petal_qc/metrology/convert_mitutoyo.py +175 -0
  14. petal_qc/metrology/convert_smartscope.py +145 -0
  15. petal_qc/metrology/coreMetrology.py +402 -0
  16. petal_qc/metrology/data2csv.py +63 -0
  17. petal_qc/metrology/do_Metrology.py +117 -0
  18. petal_qc/metrology/flatness4nigel.py +157 -0
  19. petal_qc/metrology/gtkutils.py +120 -0
  20. petal_qc/metrology/petal_flatness.py +353 -0
  21. petal_qc/metrology/show_data_file.py +118 -0
  22. petal_qc/metrology/testSummary.py +37 -0
  23. petal_qc/metrology/test_paralelism.py +71 -0
  24. petal_qc/thermal/CSVImage.py +69 -0
  25. petal_qc/thermal/DebugPlot.py +76 -0
  26. petal_qc/thermal/IRBFile.py +768 -0
  27. petal_qc/thermal/IRCore.py +110 -0
  28. petal_qc/thermal/IRDataGetter.py +359 -0
  29. petal_qc/thermal/IRPetal.py +1338 -0
  30. petal_qc/thermal/IRPetalParam.py +71 -0
  31. petal_qc/thermal/PetalColorMaps.py +62 -0
  32. petal_qc/thermal/Petal_IR_Analysis.py +142 -0
  33. petal_qc/thermal/PipeFit.py +598 -0
  34. petal_qc/thermal/__init__.py +0 -0
  35. petal_qc/thermal/analyze_IRCore.py +417 -0
  36. petal_qc/thermal/contours.py +378 -0
  37. petal_qc/thermal/create_IRCore.py +185 -0
  38. petal_qc/thermal/pipe_read.py +182 -0
  39. petal_qc/thermal/show_IR_petal.py +420 -0
  40. petal_qc/utils/Geometry.py +756 -0
  41. petal_qc/utils/Progress.py +182 -0
  42. petal_qc/utils/__init__.py +0 -0
  43. petal_qc/utils/all_files.py +35 -0
  44. petal_qc/utils/docx_utils.py +186 -0
  45. petal_qc/utils/fit_utils.py +188 -0
  46. petal_qc/utils/utils.py +180 -0
  47. petal_qc-0.0.0.dist-info/METADATA +29 -0
  48. petal_qc-0.0.0.dist-info/RECORD +51 -0
  49. petal_qc-0.0.0.dist-info/WHEEL +5 -0
  50. petal_qc-0.0.0.dist-info/entry_points.txt +3 -0
  51. petal_qc-0.0.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,71 @@
1
+ """Parameters needed for the thermal analysis of the petal."""
2
+
3
+
4
+ class IRPetalParam(object):
5
+ """Default values for IR image handling."""
6
+
7
+ def __init__(self, values=None):
8
+ """Initialize.
9
+
10
+ Args:
11
+ ----
12
+ values: ArgParser or dict with user values-
13
+
14
+ """
15
+ self.institute = 'IFIC' # Either IFIC or DESY to treat the different files
16
+ self.thrs = -20.0 # the threshold
17
+ self.gauss_size = 15 # Radius of gausian filtering
18
+ self.grad_sigma = 2.5 # Sigma of grading calculation
19
+ self.distance = 5 # Distance in contour between slices
20
+ self.npoints = 15 # Number of points per segment
21
+ self.min_area = 2500 # minumum area of a valid contour.
22
+ self.contour_cut = 0.2 # Fraction of IR image range to define contour.
23
+ self.contour_smooth = 25 # Value to smooth contour
24
+ self.width = 2 # half widh of rectangle around point in path when getting T.
25
+ self.do_fit = True # True to fit the segment points.
26
+ self.rotate = True # Rotate to have a vertical petal in mirror image
27
+ self.debug = False # To debug
28
+
29
+ if values is not None:
30
+ self.set_values(values)
31
+
32
+ def set_values(self, values):
33
+ """Set parameters from input values."""
34
+ if isinstance(values, dict):
35
+ for key in self.__dict__.keys():
36
+ if key in values:
37
+ setattr(self, key, values[key])
38
+
39
+ else:
40
+ for key in self.__dict__.keys():
41
+ if hasattr(values, key):
42
+ setattr(self, key, getattr(values, key))
43
+
44
+ def print(self):
45
+ """Print all values."""
46
+ print("\nParameters:")
47
+ for key, val in self.__dict__.items():
48
+ print("{}: {}".format(key, val))
49
+ print("")
50
+
51
+ @staticmethod
52
+ def add_parameters(parser):
53
+ """Add parameters to the ArgumentParser."""
54
+ # Get the default value for the parameters.
55
+ P = IRPetalParam()
56
+
57
+ parser.add_argument("--institute", type=str,
58
+ default=P.institute,
59
+ help="Either IFIC or DESY to treat the different files")
60
+ parser.add_argument("--thrs", type=float, default=P.thrs, help="Temperature threshold")
61
+ parser.add_argument("--gauss_size", type=int, default=P.gauss_size, help="Radius of gausian filtering")
62
+ parser.add_argument("--distance", type=float, default=P.distance, help="Distance in contour beteween slices")
63
+ parser.add_argument("--npoints", type=int, default=P.npoints, help="Number of points per segment")
64
+ parser.add_argument("--min_area", type=float, default=P.min_area, help="minumum area of a valid contour")
65
+ parser.add_argument("--width", type=int, default=P.width,
66
+ help="width of average rectangle en get_T_along_path.")
67
+ parser.add_argument("--contour_cut", type=float, default=P.contour_cut,
68
+ help="Fraction of IR image range to define contour.")
69
+ parser.add_argument("--contour_smooth", type=float, default=P.contour_smooth,
70
+ help="Value to smooth contour")
71
+ parser.add_argument("--debug", action="store_true", default=False, help="Show additional information.")
@@ -0,0 +1,62 @@
1
+ """Colormaps for Petal QC."""
2
+ from matplotlib import colors
3
+
4
+ cdict = {'blue': [[0.0, 0.17254901960784313, 0.17254901960784313],
5
+ [0.4596774193548387, 0.9215686274509803, 0.9215686274509803],
6
+ [0.49193548387096775, 0.9372549019607843, 0.9372549019607843],
7
+ [0.6048387096774194, 1.0, 1.0],
8
+ [0.6451612903225806, 0.9803921568627451, 0.9803921568627451],
9
+ [0.6774193548387096, 0.8156862745098039, 0.8156862745098039],
10
+ [0.7258064516129032, 0.35294117647058826, 0.35294117647058826],
11
+ [0.75, 0.050980392156862744, 0.050980392156862744],
12
+ [0.782258064516129, 0.0196078431372549, 0.0196078431372549],
13
+ [0.7983870967741935, 0.01568627450980392, 0.01568627450980392],
14
+ [0.8306451612903226, 0.00784313725490196, 0.00784313725490196],
15
+ [0.8548387096774194, 0.00784313725490196, 0.00784313725490196],
16
+ [0.9435483870967742, 0.00392156862745098, 0.00392156862745098],
17
+ [0.9838709677419355, 0.2235294117647059, 0.2235294117647059],
18
+ [1.0, 0.5019607843137255, 0.5019607843137255]],
19
+ 'green': [[0.0, 0.16470588235294117, 0.16470588235294117],
20
+ [0.4596774193548387, 0.9176470588235294, 0.9176470588235294],
21
+ [0.49193548387096775, 0.9294117647058824, 0.9294117647058824],
22
+ [0.6048387096774194, 0.4549019607843137, 0.4549019607843137],
23
+ [0.6451612903225806, 0.35294117647058826, 0.35294117647058826],
24
+ [0.6774193548387096, 0.403921568627451, 0.403921568627451],
25
+ [0.7258064516129032, 0.6431372549019608, 0.6431372549019608],
26
+ [0.75, 0.8274509803921568, 0.8274509803921568],
27
+ [0.782258064516129, 1.0, 1.0],
28
+ [0.7983870967741935, 0.984313725490196, 0.984313725490196],
29
+ [0.8306451612903226, 0.9686274509803922, 0.9686274509803922],
30
+ [0.8548387096774194, 0.8117647058823529, 0.8117647058823529],
31
+ [0.9435483870967742, 0.21176470588235294, 0.21176470588235294],
32
+ [0.9838709677419355, 0.01568627450980392, 0.01568627450980392],
33
+ [1.0, 0.0, 0.0]],
34
+ 'red': [[0.0, 0.16862745098039217, 0.16862745098039217],
35
+ [0.4596774193548387, 0.9254901960784314, 0.9254901960784314],
36
+ [0.49193548387096775, 0.9372549019607843, 0.9372549019607843],
37
+ [0.6048387096774194, 0.25882352941176473, 0.25882352941176473],
38
+ [0.6451612903225806, 0.10980392156862745, 0.10980392156862745],
39
+ [0.6774193548387096, 0.0, 0.0],
40
+ [0.7258064516129032, 0.0, 0.0],
41
+ [0.75, 0.00392156862745098, 0.00392156862745098],
42
+ [0.782258064516129, 0.07450980392156863, 0.07450980392156863],
43
+ [0.7983870967741935, 0.47843137254901963, 0.47843137254901963],
44
+ [0.8306451612903226, 0.796078431372549, 0.796078431372549],
45
+ [0.8548387096774194, 0.9568627450980393, 0.9568627450980393],
46
+ [0.9435483870967742, 0.9803921568627451, 0.9803921568627451],
47
+ [0.9838709677419355, 1.0, 1.0],
48
+ [1.0, 0.996078431372549, 0.996078431372549]]}
49
+
50
+ HighContrast = colors.LinearSegmentedColormap('HighContrast', segmentdata=cdict)
51
+
52
+ if __name__ == "__main__":
53
+ import matplotlib.pyplot as plt
54
+ from matplotlib import cm
55
+
56
+ fig, ax = plt.subplots()
57
+ fig.colorbar(cm.ScalarMappable(
58
+ norm=colors.Normalize(), cmap=HighContrast), ax=ax)
59
+ fig.colorbar(cm.ScalarMappable(norm=colors.Normalize(),
60
+ cmap=HighContrast.reversed()), ax=ax)
61
+
62
+ plt.show()
@@ -0,0 +1,142 @@
1
+ """Store resutls."""
2
+ import matplotlib.pyplot as plt
3
+ import matplotlib.ticker as ticker
4
+ import numpy as np
5
+ from petal_qc.thermal import IRPetal
6
+ from petal_qc.thermal import contours
7
+ from petal_qc.thermal.PetalColorMaps import HighContrast
8
+
9
+
10
+ class AnalysisResult(object):
11
+ """Contains results of IR image analysis."""
12
+
13
+ def __init__(self) -> None:
14
+ """Initialization."""
15
+ self.path_length = [] # position within pipe (0 U-bend at bottom)
16
+ self.path_temp = [] # temperatrure at given positions
17
+ self.path_spread = [] # spread at given positions
18
+ self.sensor_avg = [] # average on sensors
19
+ self.sensor_std = [] # spread on sensors
20
+
21
+ def from_json(self, J):
22
+ """Get values from JSon."""
23
+ for key in self.__dict__.keys():
24
+ try:
25
+ if hasattr(self, key):
26
+ setattr(self, key, np.array(J[key]))
27
+
28
+ except Exception:
29
+ print("AnalysisResult.from_json: Ignoring {} component".format(key))
30
+ continue
31
+
32
+
33
+ def show_2D_image(img, title=None):
34
+ """Show a 2D image."""
35
+ if isinstance(img, list):
36
+ fig, ax = plt.subplots(1, len(img))
37
+ if title:
38
+ fig.suptitle(title)
39
+
40
+ if len(img) == 1:
41
+ ax = [ax, ]
42
+
43
+ for i, im in enumerate(img):
44
+ pcm = ax[i].imshow(im, origin='lower', cmap=HighContrast.reversed()) # cmap="jet")
45
+ fig.colorbar(pcm, ax=ax[i])
46
+
47
+ else:
48
+ fig, ax = plt.subplots(1, 1)
49
+ if title:
50
+ fig.suptitle(title)
51
+ pcm = ax.imshow(img, origin='lower', cmap=HighContrast.reversed()) # cmap="jet")
52
+ fig.colorbar(pcm, ax=ax)
53
+
54
+ plt.draw()
55
+ plt.pause(0.001)
56
+
57
+ return fig, ax
58
+
59
+
60
+ def analyze_IR_image(img, pipe, sensors, iside, params) -> AnalysisResult:
61
+ """Analyze the IR image at input.
62
+
63
+ Args:
64
+ ----
65
+ img (ndarray): THe image
66
+ pipes: The pipe
67
+ sensors: The sensor areas
68
+ iside: petal image with EoS on the left(0) or right (1)
69
+ params: IRPetal parameters
70
+
71
+ Returns
72
+ -------
73
+ An AnalysisResult object.
74
+
75
+ """
76
+ sensor_order = [
77
+ [0, 1, 2, 4, 3, 6, 5, 9, 8, 7],
78
+ [0, 1, 2, 3, 4, 5, 6, 8, 9, 7]
79
+ ]
80
+ width = 25
81
+ if img.shape[0] > 700:
82
+ width = 2*width
83
+
84
+ result = AnalysisResult()
85
+ result.path_temp, result.path_length = IRPetal.get_T_along_path(pipe, img, params.width, True)
86
+ result.path_spread, pL = IRPetal.get_spread_along_path(pipe, img, width, True)
87
+ Savg = []
88
+ Sstd = []
89
+ for S in sensors:
90
+ avg, std = contours.get_average_in_contour(img, S)
91
+ Savg.append(avg)
92
+ Sstd.append(std)
93
+
94
+ result.sensor_avg = [Savg[sensor_order[iside][j]] for j in range(10)]
95
+ result.sensor_std = [Sstd[sensor_order[iside][j]] for j in range(10)]
96
+
97
+ return result
98
+
99
+
100
+ def analyze_IR_image_list(imgs, pipes, sensors, params):
101
+ """Analyze a list of IR images at input.
102
+
103
+ Args:
104
+ ----
105
+ img (list(IRBImage)): THe images. Assumed to be type0, type1, type0, type1...
106
+ pipes: The pipes
107
+ sensors: The sensor areas
108
+ params: IRPetal parameters
109
+
110
+ Returns
111
+ -------
112
+ list of AnalysisResult objects
113
+
114
+ """
115
+ out = []
116
+ for i, img in enumerate(imgs):
117
+ j = i % 2
118
+ res = analyze_IR_image(img, pipes[j], sensors[j], j, params)
119
+ out.append(res)
120
+
121
+ return out
122
+
123
+
124
+ def analyze_IR_mirrored_image(img, pipes, sensors, params):
125
+ """Analyze the mirrored IR image at input.
126
+
127
+ Args:
128
+ ----
129
+ img (IRBImage): THe image
130
+ pipes: The pipes
131
+ sensors: The sensor areas
132
+ params: IRPetal parameters
133
+
134
+ Returns
135
+ -------
136
+ list of AnalysisResult objects
137
+ images: the image data
138
+
139
+ """
140
+ images = IRPetal.get_mirrored_petal_images(img, params)
141
+ results = analyze_IR_image_list(images, pipes, sensors, params)
142
+ return results, images