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

petal_qc/__init__.py CHANGED
@@ -1,5 +1,5 @@
1
1
  """petal_qc python module."""
2
- __version__ = "0.0.1"
2
+ __version__ = "0.0.3"
3
3
 
4
4
 
5
5
  def coreMetrology():
@@ -7,6 +7,12 @@ def coreMetrology():
7
7
  from .metrology.coreMetrology import main
8
8
  main()
9
9
 
10
+ def coreThermal():
11
+ """Launches the Core thermal analysis ahd PDB script."""
12
+ from .thermal.coreThermal import main
13
+ main()
14
+
15
+
10
16
  def bustapeReport():
11
17
  """Launches the Core metrology analysis ahd PDB script."""
12
18
  from .BTreport.bustapeReport import main
@@ -303,7 +303,7 @@ def analyze_locking_point_data(orig_data, nbins=50, plane_fit=True, cut=3, docum
303
303
  max_par = -9999
304
304
  for i in range(3):
305
305
  pts = M[iloc_indx[i], 2] + 0.435
306
- _, _, band = get_min_max(pts)
306
+ vmin, vmax, band = get_min_max(pts)
307
307
  avg_pts = np.mean(pts)
308
308
  if abs(avg_pts) > max_par:
309
309
  max_par = abs(avg_pts)
@@ -312,8 +312,6 @@ def analyze_locking_point_data(orig_data, nbins=50, plane_fit=True, cut=3, docum
312
312
  print("Loc par. {} - {:.3f} avg: {:.3f}".format(i, band, avg_pts))
313
313
  ax.hist(pts, bins=xaxis, label="Avg {:.3f} band {:.3f} mm".format(avg_pts, band))
314
314
 
315
- parallelism = max_avg
316
-
317
315
  ax.legend(loc='upper left')
318
316
  y_lim = ax.get_ylim()
319
317
  ax.fill_between([-0.100, 0.100], y_lim[0], y_lim[1], facecolor="grey", alpha=0.1)
@@ -330,7 +328,7 @@ def analyze_locking_point_data(orig_data, nbins=50, plane_fit=True, cut=3, docum
330
328
 
331
329
  outDB["PARALLELISM"] = parallelism
332
330
  outDB["OFFSET"] = mean_dist
333
- print("Paralelism test: {:.4f}.\n{}".format(parallelism, txt))
331
+ print("Parallelism test: {:.4f}.\n{}".format(parallelism, txt))
334
332
  if document:
335
333
  txt = """To study parallelism, we subtract -0.435 mm to the Z values. \
336
334
  This is the nominal position of locator points. \
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env python3
2
+ """Compare quantities."""
3
+
4
+ import sys
5
+ import argparse
6
+ import glob
7
+ import json
8
+ from pathlib import Path
9
+ import numpy as np
10
+ import matplotlib.pyplot as plt
11
+
12
+
13
+ def get_value(data, value_path):
14
+ """Get the value."""
15
+ a = data
16
+ for k in value_path.split('/'):
17
+ a = a[k]
18
+
19
+ return a
20
+
21
+
22
+ def main(options):
23
+ labels = []
24
+ front = {}
25
+ back = {}
26
+
27
+ for fnam in options.files:
28
+ ifile = Path(fnam).expanduser().resolve()
29
+ print(ifile.name)
30
+ if not ifile.exists():
31
+ print("File does not exist: ", fnam)
32
+ continue
33
+
34
+ data = None
35
+ with open(ifile, 'r', encoding="UTF-8") as fp:
36
+ data = json.load(fp)
37
+
38
+ if data is None:
39
+ print("Problems reading ", fnam)
40
+ continue
41
+
42
+ tmp = ifile.name.split('-')
43
+ label = tmp[0]
44
+ if not label in labels:
45
+ labels.append(label)
46
+
47
+ is_front = False
48
+ if "front" in tmp[1].lower():
49
+ is_front = True
50
+
51
+ val = get_value(data, options.value)
52
+ if is_front:
53
+ front[label] = val
54
+ else:
55
+ back[label] = val
56
+
57
+ labels.sort()
58
+ X = np.arange(0, len(labels))
59
+ fig, ax = plt.subplots(1, 1, tight_layout=True)
60
+ fig.suptitle(options.value)
61
+ ax.set_xticks(range(len(labels)), labels=labels)
62
+ ax.grid()
63
+
64
+ vfront = [front[x] for x in labels]
65
+ vback = [back[x] for x in labels]
66
+ ax.plot(X, vfront, '*', label="Front")
67
+ ax.plot(X, vback, 'o', label="Back")
68
+ ax.legend()
69
+
70
+ if options.out:
71
+ fig.savefig(options.out, dpi=300)
72
+
73
+ plt.show()
74
+
75
+
76
+ if __name__ == "__main__":
77
+ # Argument parser
78
+ parser = argparse.ArgumentParser()
79
+ parser.add_argument('files', nargs='*', help="Input files")
80
+ parser.add_argument("--value", default=None, help="Value to plot")
81
+ parser.add_argument("--out", default=None, help="File to store the figure.")
82
+
83
+ options = parser.parse_args()
84
+ if len(options.files) == 0:
85
+ print("I need at least one input file")
86
+ sys.exit()
87
+
88
+ if len(options.files) == 1:
89
+ xxx = any(elem in options.files[0] for elem in r"*?")
90
+ if xxx:
91
+ options.files = glob.glob(options.files[0])
92
+
93
+ if options.value[0] == '/':
94
+ options.value = options.value[1:]
95
+ options.value = "results/METROLOGY/" + options.value
96
+ main(options)
@@ -14,6 +14,14 @@ from argparse import Action
14
14
  from argparse import ArgumentParser
15
15
  from pathlib import Path
16
16
  import numpy as np
17
+
18
+ try:
19
+ import petal_qc
20
+
21
+ except ImportError:
22
+ cwd = Path(__file__).parent.parent.parent
23
+ sys.path.append(cwd.as_posix())
24
+
17
25
  from petal_qc.utils.utils import output_folder
18
26
 
19
27
  from petal_qc.metrology.PetalMetrology import petal_metrology
@@ -12,6 +12,7 @@ import os
12
12
  import pickle
13
13
  import struct
14
14
  import sys
15
+ from argparse import ArgumentParser
15
16
  from collections.abc import Iterable
16
17
  from pathlib import Path
17
18
 
@@ -689,7 +690,7 @@ def open_file(fname):
689
690
  fname: Path of input file or list of files.
690
691
 
691
692
  """
692
- irb = None
693
+ irbf = None
693
694
  if is_iterable(fname):
694
695
  # we assume it is a list of IRB files...
695
696
  try:
@@ -719,13 +720,12 @@ def open_file(fname):
719
720
  return irbf
720
721
 
721
722
 
722
- if __name__ == "__main__":
723
+ def main():
723
724
  """Example of use of IRBFile.
724
725
 
725
- Shows all the images in a file.
726
+ Shows all the images in a file.
726
727
 
727
728
  """
728
- from argparse import ArgumentParser
729
729
  parser = ArgumentParser()
730
730
  parser.add_argument('files', nargs='*', help="Input files")
731
731
  parser.add_argument("--save", action="store_true",
@@ -743,7 +743,8 @@ if __name__ == "__main__":
743
743
  fig = None
744
744
  nimg = 0
745
745
  ratio = -1
746
- for img in IRfile.images():
746
+ for ximg in IRfile.images():
747
+ img = ximg[0]
747
748
  tmin = np.min(img.image)
748
749
  print("Tmin {:1f} - {}x{}".format(tmin, img.width, img.height))
749
750
  if ratio < 0:
@@ -766,3 +767,6 @@ if __name__ == "__main__":
766
767
  plt.pause(0.00001)
767
768
 
768
769
  plt.show()
770
+
771
+ if __name__ == "__main__":
772
+ main()
@@ -41,6 +41,7 @@ class IRCore(object):
41
41
  self.files = []
42
42
  self.results = [] if results is None else results # list of AnalysisResults. One per side
43
43
  self.golden = [] # list of Golden results. One per side.
44
+ self.inlet = -9999
44
45
 
45
46
  def set_files(self, files):
46
47
  """Set the input files."""
@@ -1,11 +1,29 @@
1
1
  """Encapsulates different data structure at DESY and IFIC.
2
2
  """
3
+ import sys
4
+ from pathlib import Path
5
+ import numpy as np
6
+
7
+ try:
8
+ import petal_qc
9
+
10
+ except ImportError:
11
+ cwd = Path(__file__).parent.parent.parent
12
+ sys.path.append(cwd.as_posix())
3
13
 
4
14
 
5
- import numpy as np
6
15
  from petal_qc.thermal import IRPetal
7
16
  from petal_qc.thermal import Petal_IR_Analysis
8
17
 
18
+ HAS_GRAPHANA = False
19
+ try:
20
+ from petal_qc.utils.readGraphana import ReadGraphana
21
+ HAS_GRAPHANA = True
22
+
23
+ except ImportError:
24
+ HAS_GRAPHANA = False
25
+
26
+
9
27
 
10
28
  class IRDataGetter(object):
11
29
  """BAse class defining the interface."""
@@ -13,6 +31,7 @@ class IRDataGetter(object):
13
31
  def __init__(self):
14
32
  """Initialization."""
15
33
  self.factor = 1
34
+ self.indx = -1
16
35
  return
17
36
 
18
37
  @staticmethod
@@ -101,6 +120,10 @@ class IRDataGetter(object):
101
120
  """Get the frame where we want to perform the analysis."""
102
121
  return None
103
122
 
123
+ def get_inlet_temperature(self):
124
+ """REturn the inlet temperature."""
125
+ return -9999
126
+
104
127
 
105
128
  class IRDataIFIC(IRDataGetter):
106
129
  """Gets data for IFIC analysis."""
@@ -108,6 +131,11 @@ class IRDataIFIC(IRDataGetter):
108
131
  def __init__(self) -> None:
109
132
  """Initialization."""
110
133
  super().__init__()
134
+ self.analysis_frame = None
135
+ if HAS_GRAPHANA:
136
+ self.DB = ReadGraphana("localhost")
137
+ else:
138
+ self.DB = None
111
139
 
112
140
  def find_reference_image(self, irbf, *args, **kargs):
113
141
  """Find first image in sequence with T < T_min.
@@ -126,17 +154,23 @@ class IRDataIFIC(IRDataGetter):
126
154
 
127
155
 
128
156
  """
129
- if len(args) == 0:
130
- T_min = -22.0
131
- else:
132
- T_min = args[0]
133
-
134
157
  irbf.set_concatenate(True)
135
- min_T, i_min, ref_img = IRPetal.find_reference_image(irbf, T_min)
136
- values = self.get_IR_data(ref_img)
137
- self.factor = values.shape[0]/640
138
-
139
- return min_T, i_min, [values, ]
158
+ frame = self.get_analysis_frame(irbf)
159
+ i_min = self.indx
160
+ min_T = np.min(frame[0].image)
161
+ return min_T, i_min, frame
162
+
163
+ # if len(args) == 0:
164
+ # T_min = -22.0
165
+ # else:
166
+ # T_min = args[0]
167
+ #
168
+ # irbf.set_concatenate(True)
169
+ # min_T, i_min, ref_img = IRPetal.find_reference_image(irbf, T_min)
170
+ # values = self.get_IR_data(ref_img)
171
+ # self.factor = values.shape[0]/640
172
+ #
173
+ # return min_T, i_min, [values, ]
140
174
 
141
175
  def get_IR_data(self, image, **kargs):
142
176
  """Get the data from the image in the proper orientation.
@@ -235,8 +269,20 @@ class IRDataIFIC(IRDataGetter):
235
269
  for img in irbf.images():
236
270
  min_T.append(np.min(img[0].image))
237
271
 
238
- indx = IRDataIFIC.find_minimum(min_T)
239
- return [irbf.getImage(indx[-1])]
272
+ self.indx = IRDataIFIC.find_minimum(min_T)
273
+ self.analysis_frame = [irbf.getImage(self.indx[-1])]
274
+ return self.analysis_frame
275
+
276
+ def get_inlet_temperature(self):
277
+ """REturn the inlet temperature."""
278
+ if self.DB:
279
+ img = self.analysis_frame[0]
280
+ X, T = self.DB.get_temperature(img.timestamp, 1)
281
+ return np.min(T)
282
+
283
+ else:
284
+ return -9999
285
+
240
286
 
241
287
 
242
288
  class IRDataDESY(IRDataGetter):
@@ -13,6 +13,13 @@ from scipy import ndimage
13
13
  from scipy.optimize import minimize
14
14
  from skimage import measure
15
15
 
16
+ try:
17
+ import petal_qc
18
+
19
+ except ImportError:
20
+ cwd = Path(__file__).parent.parent.parent
21
+ sys.path.append(cwd.as_posix())
22
+
16
23
  from petal_qc.thermal import contours
17
24
  from petal_qc.thermal import CSVImage
18
25
  from petal_qc.thermal import DebugPlot
@@ -1212,7 +1219,7 @@ def get_image_from_irb(irbf, frame, thrs):
1212
1219
  """
1213
1220
  img = None
1214
1221
  i_min = frame
1215
- if irbf.n_images() == 0:
1222
+ if irbf.nimages == 0:
1216
1223
  print("Input file does not contain images.")
1217
1224
 
1218
1225
  else:
@@ -1246,12 +1253,12 @@ def read_image(fnam, frame=-1, thrs=-20):
1246
1253
  ifile = Path(fnam).expanduser().resolve()
1247
1254
  if not ifile.exists():
1248
1255
  print("Input file does not exist.")
1249
- return None
1256
+ return None, None
1250
1257
 
1251
1258
  suffix = ifile.suffix.lower()
1252
- img = None
1259
+ img = None, None
1253
1260
  if suffix == ".csv":
1254
- img = CSVImage.CSVImage(ifile)
1261
+ img = CSVImage.CSVImage(ifile), 0
1255
1262
 
1256
1263
  elif suffix == ".irb":
1257
1264
  irbf = IRBFile.IRBFile(ifile)
@@ -1274,12 +1281,12 @@ def main(fnam, options):
1274
1281
  params.debug = False
1275
1282
 
1276
1283
  print("Open file")
1277
- img = read_image(fnam, options.frame, options.thrs)
1284
+ img, _ = read_image(fnam, options.frame, options.thrs)
1278
1285
  if img is None:
1279
1286
  sys.exit()
1280
1287
 
1281
1288
  # Show original Image
1282
- fig, ax = plt.subplots(1, 1, dpi=300)
1289
+ fig, ax = plt.subplots(1, 1)
1283
1290
  values = get_IR_data(img, False)
1284
1291
  min_T = np.min(values)
1285
1292
  fig.suptitle("Original image - Temp. {:.1f}".format(min_T))
@@ -1290,7 +1297,7 @@ def main(fnam, options):
1290
1297
  # Show rotated image
1291
1298
  values = get_IR_data(img, True)
1292
1299
  min_T = np.min(values)
1293
- fig, ax = plt.subplots(1, 1, dpi=300)
1300
+ fig, ax = plt.subplots(1, 1)
1294
1301
  fig.suptitle("Rotated image - Temp. {:.1f}".format(min_T))
1295
1302
  pcm = ax.imshow(values, origin='lower', cmap="jet")
1296
1303
  fig.colorbar(pcm, ax=ax)
@@ -13,7 +13,7 @@ class IRPetalParam(object):
13
13
 
14
14
  """
15
15
  self.institute = 'IFIC' # Either IFIC or DESY to treat the different files
16
- self.thrs = -20.0 # the threshold
16
+ self.thrs = -22.0 # the threshold
17
17
  self.tco2 = -35.0 # Inlet temperature
18
18
  self.gauss_size = 15 # Radius of gausian filtering
19
19
  self.grad_sigma = 2.5 # Sigma of grading calculation
@@ -26,6 +26,7 @@ class IRPetalParam(object):
26
26
  self.do_fit = True # True to fit the segment points.
27
27
  self.rotate = True # Rotate to have a vertical petal in mirror image
28
28
  self.debug = False # To debug
29
+ self.report = False #
29
30
 
30
31
  if values is not None:
31
32
  self.set_values(values)
@@ -71,3 +72,4 @@ class IRPetalParam(object):
71
72
  parser.add_argument("--contour_smooth", type=float, default=P.contour_smooth,
72
73
  help="Value to smooth contour")
73
74
  parser.add_argument("--debug", action="store_true", default=False, help="Show additional information.")
75
+ parser.add_argument("--report", action="store_true", default=False, help="True if figures kept for the report.")
@@ -511,6 +511,7 @@ class PipeFit(object):
511
511
  ax.legend()
512
512
  plt.draw()
513
513
  plt.pause(0.0001)
514
+ return fig, ax
514
515
 
515
516
 
516
517
  def main(data_file, opts):
@@ -12,6 +12,7 @@ import numpy as np
12
12
  from scipy.interpolate import CubicSpline
13
13
  from petal_qc.utils.utils import find_file
14
14
  from petal_qc.utils.utils import output_folder
15
+ import petal_qc.utils.docx_utils as docx_utils
15
16
 
16
17
  from petal_qc.thermal import IRCore
17
18
  from petal_qc.thermal import Petal_IR_Analysis
@@ -33,6 +34,23 @@ def get_names(files):
33
34
  names.append(ifile.stem)
34
35
  return names
35
36
 
37
+ def add_figures_to_doc(doc, figures, name=None):
38
+ """Add figures to doc.
39
+
40
+ Args:
41
+ doc (Document): Document
42
+ figures (list): List of figures.
43
+
44
+ """
45
+ if doc is None or len(figures)==0:
46
+ return
47
+
48
+ if name:
49
+ doc.add_heading(name, level=1)
50
+
51
+ for F in figures:
52
+ doc.add_picture(F, True, 12, caption=F._suptitle.get_text())
53
+
36
54
 
37
55
  class GoldenAxis(object):
38
56
  """Get best X path."""
@@ -166,11 +184,102 @@ def golden_from_json(js_golden):
166
184
  """Converst a JSon golden into a Golden object."""
167
185
  golden = [Petal_IR_Analysis.AnalysisResult() for i in range(2)]
168
186
  for i, G in enumerate(golden):
169
- G.path_length = js_golden[i]["path_length"]
170
- G.path_temp = js_golden[i]["path_temp"]
171
- G.path_spread = js_golden[i]["path_spread"]
172
- G.sensor_avg = js_golden[i]["sensor_avg"]
173
- G.sensor_std = js_golden[i]["sensor_std"]
187
+ G.path_length = np.array(js_golden[i]["path_length"])
188
+ G.path_temp = np.array(js_golden[i]["path_temp"])
189
+ G.path_spread = np.array(js_golden[i]["path_spread"])
190
+ G.sensor_avg = np.array(js_golden[i]["sensor_avg"])
191
+ G.sensor_std = np.array(js_golden[i]["sensor_std"])
192
+
193
+ return golden
194
+
195
+ def get_golden_axis(R, golden):
196
+ """Compute result on golden points."""
197
+ xvalues = [ [x for x in golden[i].path_length] for i in range(2) ]
198
+ R.golden = []
199
+ for iside in range(2):
200
+ G = Petal_IR_Analysis.AnalysisResult()
201
+ splnT = CubicSpline(R.results[iside].path_length, R.results[iside].path_temp)
202
+ splnS = CubicSpline(R.results[iside].path_length, R.results[iside].path_spread)
203
+ G.path_length = np.array(xvalues[iside])
204
+ G.path_temp = np.array([splnT(x) for x in G.path_length])
205
+ G.path_spread = np.array([splnS(x) for x in G.path_length])
206
+ G.sensor_avg = np.array(R.results[iside].sensor_avg)
207
+ G.sensor_std = np.array(R.results[iside].sensor_std)
208
+ R.golden.append(G)
209
+
210
+
211
+ def plot_profile_and_golden(golden, core, value):
212
+ """Plot petal core and golden average.
213
+
214
+ Args:
215
+ ----
216
+ resuls: results from create_golden_average
217
+ golden: golden values (from create_golgen_average)
218
+ value: value to show, ej path_temp, path_spread, sensor_avg, sensor_std
219
+
220
+ """
221
+ tick_labels = ["R0", "R1", "R2", "R3", "R3", "R4", "R4", "R5", "R5", "EoS"]
222
+ figures = []
223
+ factor = 1.0
224
+ if value.find("sensor") >= 0:
225
+ factor = 2.0
226
+
227
+ # Get acceptance band
228
+ band = get_acceptance_band()
229
+
230
+ for iside in range(2):
231
+ fig, ax = plt.subplots(2, 1, tight_layout=True, gridspec_kw={'height_ratios': (0.66, 0.34)})
232
+ figures.append(fig)
233
+ fig.suptitle("Petal core .vs. Golden for {} - side {}.".format(value, iside))
234
+ for a in ax:
235
+ a.grid()
236
+
237
+ if value.find("path") < 0:
238
+ for i in range(2):
239
+ ax[i].set_xticks(range(10), labels=tick_labels)
240
+
241
+ RS = core.results[iside]
242
+ # convert to golden X
243
+ # TODO: get X, Y from petal core. Move golden to this X axis and draw differences.
244
+ # This only happens for the "_path" values, not for the sensors.
245
+ if value.find("path") >= 0:
246
+ X = RS.path_length
247
+ Y = getattr(RS, value)
248
+ spln = CubicSpline(golden[iside].path_length, getattr(golden[iside], value))
249
+ gY = np.array([spln(x) for x in X])
250
+ else:
251
+ X = np.array([float(x) for x in range(10)])
252
+ Y = getattr(RS, value)
253
+ gY = getattr(golden[iside], value)
254
+
255
+ delta = Y - gY
256
+ ax[0].plot(X, Y, '-', label=core.aliasID, linewidth=1)
257
+ ax[1].plot(X, delta, '-', label=core.aliasID, linewidth=1)
258
+
259
+ # Draw golden line
260
+ ax[0].plot(X, gY, '-', label="Golden", linewidth=4, alpha=0.4, color="black")
261
+
262
+ Tmean = np.mean(Y)
263
+ Tband = factor*abs(Tmean)/3
264
+
265
+ ax[0].legend(ncol=3, fontsize="x-small")
266
+ ax[0].set_title("T$_{prof}$ values")
267
+ if value.find("temp") >= 0 or value.find("_avg") >= 0:
268
+ ax[0].set_ylim(Tmean-Tband, Tmean+Tband)
269
+ ax[0].fill_between(X, gY + band, gY - band,
270
+ facecolor="yellow", alpha=0.25,
271
+ label="Acceptance band")
272
+
273
+ ax[1].fill_between(X, band, -band,
274
+ facecolor="yellow", alpha=0.25,
275
+ label="Acceptance band")
276
+
277
+ ax[1].legend(ncol=4, fontsize="x-small")
278
+ ax[1].set_title("T$_{prof}$ - Golden avg.")
279
+ if value.find("temp") >= 0 or value.find("_avg") >= 0:
280
+ ax[1].set_ylim(-Tband, Tband)
281
+
282
+ return figures
174
283
 
175
284
  def show_golden_average(golden, results, value):
176
285
  """Create golden average.
@@ -202,10 +311,11 @@ def show_golden_average(golden, results, value):
202
311
  for i in range(2):
203
312
  ax[i].set_xticks(range(10), labels=tick_labels)
204
313
 
314
+ G = golden[iside]
205
315
  for R in results:
206
316
  RS = R.results[iside]
207
317
  Y = getattr(RS, value)
208
- gY = getattr(golden[iside], value)
318
+ gY = getattr(G, value)
209
319
  O = getattr(R.golden[iside], value) - gY
210
320
  if value.find("path") >= 0:
211
321
  X = RS.path_length
@@ -284,12 +394,13 @@ def analyze_petal_cores(files, golden, options):
284
394
  files (list): List of input files
285
395
  golden: the golden object
286
396
  options: other options.
287
-
397
+
288
398
  Return:
289
399
  array with JSon objects corresponding to the PDB test.
290
-
400
+
291
401
  """
292
402
  output = []
403
+ cores = []
293
404
  names = get_names(files)
294
405
  for i, ifile in enumerate(files):
295
406
  ifile = find_file(options.folder, ifile)
@@ -306,6 +417,7 @@ def analyze_petal_cores(files, golden, options):
306
417
  print("+++ File {} does not have component serial number.")
307
418
  continue
308
419
 
420
+ cores.append(core)
309
421
  out = [{}, {}]
310
422
  for iside in range(2):
311
423
  for val in ("path_temp", "sensor_avg", "sensor_std"):
@@ -371,10 +483,10 @@ def analyze_petal_cores(files, golden, options):
371
483
  json.dump(dbOut, fp, indent=3, cls=IRCore.NumpyArrayEncoder)
372
484
 
373
485
  output.append(dbOut)
374
-
375
- return output
376
486
 
377
- def analyze_IRCore(options):
487
+ return output, cores
488
+
489
+ def analyze_IRCore(options, show=True):
378
490
  """Main entry."""
379
491
  output = None
380
492
  if options.create_golden:
@@ -408,9 +520,35 @@ def analyze_IRCore(options):
408
520
  for i, Jside in enumerate(J):
409
521
  golden[i].from_json(Jside)
410
522
 
411
- output = analyze_petal_cores(options.files, golden, options)
523
+ output, cores = analyze_petal_cores(options.files, golden, options)
524
+
525
+ if show or options.report:
526
+ for C in cores:
527
+ get_golden_axis(C, golden)
528
+
529
+ if options.report:
530
+ document = docx_utils.Document()
531
+ document.add_page_numbers()
532
+ document.styles['Normal'].font.name = "Calibri"
533
+ document.add_heading("Comparing to Golden", 0)
534
+ else:
535
+ document = None
536
+
537
+ F = show_golden_average(golden, cores, "path_temp")
538
+ add_figures_to_doc(document, F, "Temperature along pipe")
539
+ F = show_golden_average(golden, cores, "path_spread")
540
+ add_figures_to_doc(document, F, "Spread along pipe")
541
+ F = show_golden_average(golden, cores, "sensor_avg")
542
+ add_figures_to_doc(document, F, "Sensor avg")
543
+ F = show_golden_average(golden, cores, "sensor_std")
544
+ add_figures_to_doc(document, F, "Sendor std")
545
+
546
+ if document:
547
+ document.save("Compare-to-Golden.docx")
548
+
549
+ if show:
550
+ plt.show()
412
551
 
413
- plt.show()
414
552
  return output
415
553
 
416
554
 
@@ -425,6 +563,8 @@ if __name__ == "__main__":
425
563
  parser.add_argument("--golden", default=None, help="The golden to compare width")
426
564
  parser.add_argument("--prefix", default="golden", help="Prefix for figures")
427
565
  parser.add_argument("--debug", action="store_true", default=False, help="Set to debug")
566
+ parser.add_argument("--report", action="store_true", default=False, help="Set to produce plots for report")
567
+
428
568
  parser.add_argument("--out", default=None, help="File to store Golden.")
429
569
  parser.add_argument("--folder", default=None, help="Folder to store output files. Superseeds folder in --out")
430
570