ararpy 0.1.13__py3-none-any.whl → 0.1.14__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.
- ararpy/argon_diffusion_simulator/__init__.py +12 -0
- ararpy/argon_diffusion_simulator/main.py +542 -0
- ararpy/calc/corr.py +4 -4
- ararpy/calc/plot.py +3 -3
- ararpy/calc/raw_funcs.py +2 -0
- ararpy/calc/regression.py +0 -5
- ararpy/calc/spectra.py +3 -1
- ararpy/smp/corr.py +9 -1
- ararpy/smp/diffusion_funcs.py +34 -12
- ararpy/smp/export.py +620 -374
- ararpy/smp/json.py +7 -0
- ararpy/smp/plots.py +10 -8
- ararpy/smp/sample.py +9 -6
- {ararpy-0.1.13.dist-info → ararpy-0.1.14.dist-info}/METADATA +10 -2
- {ararpy-0.1.13.dist-info → ararpy-0.1.14.dist-info}/RECORD +18 -16
- {ararpy-0.1.13.dist-info → ararpy-0.1.14.dist-info}/WHEEL +1 -1
- {ararpy-0.1.13.dist-info → ararpy-0.1.14.dist-info}/LICENSE +0 -0
- {ararpy-0.1.13.dist-info → ararpy-0.1.14.dist-info}/top_level.txt +0 -0
ararpy/smp/export.py
CHANGED
|
@@ -22,11 +22,15 @@ from decimal import Decimal
|
|
|
22
22
|
|
|
23
23
|
from ..calc import arr, isochron, spectra
|
|
24
24
|
from ..calc.basic import get_random_digits
|
|
25
|
+
from ..calc.plot import get_axis_scale
|
|
25
26
|
from . import basic, sample, consts
|
|
26
27
|
|
|
27
28
|
Sample = sample.Sample
|
|
28
29
|
Plot = sample.Plot
|
|
29
30
|
|
|
31
|
+
title_size = 11
|
|
32
|
+
label_size = 11
|
|
33
|
+
|
|
30
34
|
try:
|
|
31
35
|
from webarar.settings import SETTINGS_ROOT
|
|
32
36
|
except ModuleNotFoundError:
|
|
@@ -43,44 +47,55 @@ def to_pdf(file_path: str, figure: str, smp: Sample):
|
|
|
43
47
|
pdf.save(figure=figure)
|
|
44
48
|
|
|
45
49
|
|
|
46
|
-
def get_cv_from_dict(data: dict):
|
|
50
|
+
def get_cv_from_dict(data: dict, **kwargs):
|
|
47
51
|
# create a canvas
|
|
48
|
-
cv = pm.Canvas(width=17, height=
|
|
52
|
+
cv = pm.Canvas(width=kwargs.get("width", 17), height=kwargs.get("height", 12),
|
|
53
|
+
unit="cm", show_frame=False, clip_outside_plot_areas=False)
|
|
49
54
|
# change frame outline style
|
|
50
|
-
|
|
55
|
+
if kwargs.get("show_frame", True):
|
|
56
|
+
cv.show_frame(color="grey", line_width=0.5)
|
|
51
57
|
axis_num = min([len(data['xAxis']), len(data['yAxis'])])
|
|
52
58
|
# draw axis
|
|
53
59
|
plots = []
|
|
54
60
|
for i in range(axis_num):
|
|
55
61
|
scale = [*data['xAxis'][i]['extent'], *data['yAxis'][i]['extent']]
|
|
56
|
-
scale = (
|
|
62
|
+
scale = (float(scale[0]), float(scale[1]), float(scale[2]), float(scale[3]))
|
|
57
63
|
# create plot area based on axis scale
|
|
58
|
-
|
|
64
|
+
plot_area = (kwargs.get("pt_left", 0.15), kwargs.get("pt_bottom", 0.15), kwargs.get("pt_width", 0.8), kwargs.get("pt_height", 0.8))
|
|
65
|
+
pt = cv.add_plot_area(name=f"PlotArea{i}", plot_area=plot_area, plot_scale=scale, show_frame=True)
|
|
59
66
|
for stick in data['xAxis'][i]['interval']:
|
|
60
|
-
start = pt.scale_to_points(stick, scale[2])
|
|
61
|
-
end = pt.scale_to_points(stick, scale[2])
|
|
67
|
+
start = pt.scale_to_points(float(stick), scale[2])
|
|
68
|
+
end = pt.scale_to_points(float(stick), scale[2])
|
|
62
69
|
end = (end[0], end[1] - 5)
|
|
63
70
|
if pt.line(start=start, end=end, width=1, line_style="solid", y_clip=False, coordinate="pt", z_index=100):
|
|
64
|
-
pt.text(x=start[0], y=end[1] - 15, text=f"{stick}", clip=False,
|
|
71
|
+
pt.text(x=start[0], y=end[1] - 15, text=f"{stick}", clip=False, size=int(data['xAxis'][i]['label_size']),
|
|
65
72
|
coordinate="pt", h_align="middle", z_index=150)
|
|
66
73
|
for stick in data['yAxis'][i]['interval']:
|
|
67
|
-
start = pt.scale_to_points(scale[0], stick)
|
|
68
|
-
end = pt.scale_to_points(scale[0], stick)
|
|
74
|
+
start = pt.scale_to_points(scale[0], float(stick))
|
|
75
|
+
end = pt.scale_to_points(scale[0], float(stick))
|
|
69
76
|
end = (end[0] - 5, end[1])
|
|
70
77
|
if pt.line(start=start, end=end, width=1, line_style="solid", x_clip=False, coordinate="pt", z_index=100):
|
|
71
|
-
pt.text(x=end[0] - 5, y=end[1], text=f"{stick}", clip=False,
|
|
78
|
+
pt.text(x=end[0] - 5, y=end[1], text=f"{stick}", clip=False, size=int(data['yAxis'][i]['label_size']),
|
|
72
79
|
coordinate="pt", h_align="right", v_align="center", z_index=150)
|
|
73
80
|
# axis titles
|
|
74
81
|
nloc = pt.scale_to_points(sum(scale[:2]) / 2, scale[2])
|
|
75
|
-
pt.text(x=nloc[0], y=nloc[1] - 30, text=data['xAxis'][i]['title'], clip=False, coordinate="pt",
|
|
76
|
-
h_align="middle", v_align="
|
|
82
|
+
pt.text(x=nloc[0], y=nloc[1] - kwargs.get("offset_bottom", 30), text=data['xAxis'][i]['title'], clip=False, coordinate="pt",
|
|
83
|
+
h_align="middle", v_align="center", z_index=150, size=int(data['xAxis'][i]['title_size']))
|
|
77
84
|
nloc = pt.scale_to_points(scale[0], sum(scale[2:4]) / 2)
|
|
78
|
-
pt.text(x=nloc[0] - 50, y=nloc[1], text=data['yAxis'][i]['title'], clip=False, coordinate="pt",
|
|
79
|
-
h_align="middle", v_align="
|
|
85
|
+
pt.text(x=nloc[0] - kwargs.get("offset_left", 50), y=nloc[1], text=data['yAxis'][i]['title'], clip=False, coordinate="pt",
|
|
86
|
+
h_align="middle", v_align="center", rotate=90, z_index=150, size=int(data['yAxis'][i]['title_size']))
|
|
80
87
|
plots.append(pt)
|
|
81
88
|
# draw series
|
|
82
89
|
for se in data['series']:
|
|
83
|
-
data = se.get('data', [])
|
|
90
|
+
data = np.array(se.get('data', []), dtype=np.float64)
|
|
91
|
+
for key, val in se.items():
|
|
92
|
+
if str(val).isnumeric():
|
|
93
|
+
se[key] = int(val)
|
|
94
|
+
else:
|
|
95
|
+
try:
|
|
96
|
+
se[key] = float(val)
|
|
97
|
+
except (ValueError, TypeError):
|
|
98
|
+
pass
|
|
84
99
|
try:
|
|
85
100
|
pt = plots[se.get('axis_index', 0)]
|
|
86
101
|
except IndexError:
|
|
@@ -110,12 +125,12 @@ def get_cv_from_dict(data: dict):
|
|
|
110
125
|
return cv
|
|
111
126
|
|
|
112
127
|
|
|
113
|
-
def export_chart_to_pdf(
|
|
128
|
+
def export_chart_to_pdf(cvs, file_name: str = "", file_path: str = "", **kwargs):
|
|
114
129
|
"""
|
|
115
130
|
|
|
116
131
|
Parameters
|
|
117
132
|
----------
|
|
118
|
-
|
|
133
|
+
file_path: str
|
|
119
134
|
data: dict
|
|
120
135
|
- file_name: string
|
|
121
136
|
file name, like "24WHA0001"
|
|
@@ -165,30 +180,70 @@ def export_chart_to_pdf(data: dict, filepath: str = "", **kwargs):
|
|
|
165
180
|
-------
|
|
166
181
|
|
|
167
182
|
"""
|
|
168
|
-
title = data.get('file_name', '')
|
|
169
183
|
# write pdf
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
)
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
184
|
+
show_label = kwargs.get('show_label', False)
|
|
185
|
+
num_cols = kwargs.get('num_columns', 2)
|
|
186
|
+
file = pm.NewPDF(filepath=file_path, title=f"{file_name}", **kwargs)
|
|
187
|
+
page_size = {
|
|
188
|
+
"a3": (297, 420),
|
|
189
|
+
"a4": (210, 297),
|
|
190
|
+
"b5": (176, 250),
|
|
191
|
+
"a5": (148, 210),
|
|
192
|
+
}
|
|
193
|
+
for i in file.get_page_indexes():
|
|
194
|
+
file.del_obj(i)
|
|
195
|
+
file.add_page(size=page_size[kwargs.get('page_size', 'a4').lower()], unit='mm')
|
|
196
|
+
for page_index, page in enumerate(cvs):
|
|
197
|
+
|
|
198
|
+
# for x in range(0, 600, 10):
|
|
199
|
+
# file.line(page_index, start=(x, 0), end=(x, 900), style='dash', color='grey')
|
|
200
|
+
# for y in range(0, 900, 10):
|
|
201
|
+
# file.line(page_index, start=(0, y), end=(800, y), style='dash', color='grey')
|
|
202
|
+
|
|
203
|
+
numbers = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N']
|
|
204
|
+
|
|
205
|
+
for cv_index, cv in enumerate(page):
|
|
206
|
+
left = 10 + cv_index % num_cols * cv.width()
|
|
207
|
+
top = 20 + cv_index // num_cols * cv.height()
|
|
208
|
+
if show_label:
|
|
209
|
+
# file.text(page=page_index, x=left + 65, y=810 - top, text=numbers[cv_index])
|
|
210
|
+
cv._plot_areas[1].text(
|
|
211
|
+
x=5, y=95, text=numbers[cv_index],
|
|
212
|
+
id=f'text-label-{page_index}-{cv_index}',
|
|
213
|
+
name=f'text-label-{page_index}-{cv_index}',
|
|
214
|
+
color='black', size=title_size, axis_index=1, h_align='middle', v_align='center'
|
|
215
|
+
)
|
|
216
|
+
file.canvas(page=page_index, base=0, margin_left=left, margin_top=top, canvas=cv, unit="pt")
|
|
217
|
+
if page_index + 1 < len(cvs):
|
|
181
218
|
file.add_page()
|
|
182
219
|
|
|
183
220
|
# save pdf
|
|
184
221
|
file.save()
|
|
185
222
|
|
|
186
|
-
return
|
|
223
|
+
return file_path
|
|
187
224
|
|
|
188
225
|
|
|
189
226
|
def get_plot_data(smp: Sample, diagram: str = 'age spectra', **options):
|
|
190
227
|
"""
|
|
191
228
|
|
|
229
|
+
Parameters
|
|
230
|
+
----------
|
|
231
|
+
smp
|
|
232
|
+
diagram
|
|
233
|
+
options
|
|
234
|
+
|
|
235
|
+
Returns
|
|
236
|
+
-------
|
|
237
|
+
|
|
238
|
+
"""
|
|
239
|
+
xAxis, yAxis = get_plot_axis_data(smp, diagram=diagram.lower(), **options)
|
|
240
|
+
series = get_plot_series_data(smp, diagram=diagram.lower(), xAxis=xAxis, yAxis=yAxis, **options)
|
|
241
|
+
return {'name': smp.name(), 'xAxis': xAxis, 'yAxis': yAxis, 'series': series}
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def get_plot_axis_data(smp: Sample, diagram: str = 'age spectra', **options):
|
|
245
|
+
"""
|
|
246
|
+
|
|
192
247
|
Parameters
|
|
193
248
|
----------
|
|
194
249
|
smp
|
|
@@ -201,80 +256,217 @@ def get_plot_data(smp: Sample, diagram: str = 'age spectra', **options):
|
|
|
201
256
|
|
|
202
257
|
"""
|
|
203
258
|
if diagram.lower() == "age spectra":
|
|
204
|
-
xAxis, yAxis
|
|
259
|
+
xAxis, yAxis = _get_plot_data_age_spectra_axis(smp, **options)
|
|
205
260
|
elif diagram.lower() == "inverse isochron":
|
|
206
|
-
xAxis, yAxis
|
|
261
|
+
xAxis, yAxis = _get_plot_data_inv_isochron_axis(smp, **options)
|
|
207
262
|
elif "degas spectra" in diagram.lower():
|
|
208
|
-
xAxis, yAxis
|
|
263
|
+
xAxis, yAxis = _get_plot_data_degas_spectra_axis(smp, diagram_name = diagram.lower(), **options)
|
|
209
264
|
elif "degas curve" in diagram.lower():
|
|
210
|
-
xAxis, yAxis
|
|
265
|
+
xAxis, yAxis = _get_plot_data_degas_curve_axis(smp, diagram_name = diagram.lower(), **options)
|
|
211
266
|
else:
|
|
212
267
|
raise KeyError
|
|
268
|
+
return xAxis, yAxis
|
|
213
269
|
|
|
214
|
-
data = {
|
|
215
|
-
'name': smp.name(), 'xAxis': xAxis, 'yAxis': yAxis, 'series': series
|
|
216
|
-
}
|
|
217
270
|
|
|
218
|
-
|
|
271
|
+
def get_plot_series_data(smp: Sample, diagram: str = 'age spectra', **options):
|
|
272
|
+
"""
|
|
219
273
|
|
|
220
|
-
|
|
274
|
+
Parameters
|
|
275
|
+
----------
|
|
276
|
+
smp
|
|
277
|
+
diagram
|
|
278
|
+
color
|
|
279
|
+
options
|
|
280
|
+
|
|
281
|
+
Returns
|
|
282
|
+
-------
|
|
283
|
+
|
|
284
|
+
"""
|
|
285
|
+
if diagram.lower() == "age spectra":
|
|
286
|
+
series = _get_plot_data_age_spectra_series(smp, **options)
|
|
287
|
+
elif diagram.lower() == "inverse isochron":
|
|
288
|
+
series = _get_plot_data_inv_isochron_series(smp, **options)
|
|
289
|
+
elif "degas spectra" in diagram.lower():
|
|
290
|
+
series = _get_plot_data_degas_spectra_series(smp, diagram_name=diagram.lower(), **options)
|
|
291
|
+
elif "degas curve" in diagram.lower():
|
|
292
|
+
series = _get_plot_data_degas_curve_series(smp, diagram_name=diagram.lower(), **options)
|
|
293
|
+
else:
|
|
294
|
+
raise KeyError
|
|
295
|
+
series.append(_get_additional_text_series(smp.name()))
|
|
296
|
+
return series
|
|
221
297
|
|
|
222
298
|
|
|
223
|
-
def
|
|
299
|
+
def _get_additional_text_series(name):
|
|
300
|
+
return {
|
|
301
|
+
'type': 'text', 'id': f'text-{name}-{get_random_digits()}',
|
|
302
|
+
'name': f'text-{name}-{get_random_digits()}', 'color': 'black',
|
|
303
|
+
'text': "", 'size': title_size,
|
|
304
|
+
'data': [[50, 50]], 'axis_index': 1,
|
|
305
|
+
'h_align': "middle", 'v_align': "center",
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
def _get_plot_data_age_spectra_series(smp: sample, **options):
|
|
224
310
|
color = options.get('color', 'black')
|
|
225
|
-
|
|
311
|
+
sigma = options.get('sigma', 1)
|
|
312
|
+
xAxis = options.get('xAxis', [{}])
|
|
313
|
+
yAxis = options.get('yAxis', [{}])
|
|
314
|
+
series = []
|
|
226
315
|
age = smp.ApparentAgeValues[2:4]
|
|
227
316
|
ar = smp.DegasValues[20]
|
|
228
317
|
data = spectra.get_data(*age, ar, cumulative=False)
|
|
229
318
|
series.append({
|
|
230
|
-
'type': 'series.line', 'id': f'line-{get_random_digits()}', 'name': f'line-{get_random_digits()}',
|
|
319
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
|
|
231
320
|
'color': color, 'fill_color': color, 'line_width': 1, 'line_style': 'solid', 'z_index': 9,
|
|
232
321
|
'data': np.transpose([data[0], data[1]]).tolist(), 'line_caps': 'square',
|
|
233
322
|
'axis_index': 0,
|
|
234
323
|
})
|
|
235
324
|
series.append({
|
|
236
|
-
'type': 'series.line', 'id': f'line-{get_random_digits()}', 'name': f'line-{get_random_digits()}',
|
|
325
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
|
|
237
326
|
'color': color, 'fill_color': color, 'line_width': 1, 'line_style': 'solid', 'z_index': 9,
|
|
238
327
|
'data': np.transpose([data[0], data[2]]).tolist(), 'line_caps': 'square',
|
|
239
328
|
'axis_index': 0,
|
|
240
329
|
})
|
|
241
330
|
text1 = smp.AgeSpectraPlot.text1
|
|
242
331
|
text2 = smp.AgeSpectraPlot.text2
|
|
243
|
-
for text in [text1, text2]:
|
|
332
|
+
for index, text in enumerate([text1, text2]):
|
|
333
|
+
if not np.isnan(smp.Info.results.age_spectra[index]['age']):
|
|
334
|
+
selection = np.array(smp.Info.results.selection[index]['data']) * 2 + 1
|
|
335
|
+
set_data = list(map(lambda each: [data[0][each - 1], min(data[1][each], data[2][each]), data[0][each + 1] - data[0][each], sigma * abs(data[1][each] - data[2][each])], selection))
|
|
336
|
+
series.append({
|
|
337
|
+
'type': 'series.rect', 'id': f'rect-{smp.name()}-{get_random_digits()}', 'name': f'rect-{smp.name()}-{get_random_digits()}',
|
|
338
|
+
'color': 'none', 'fill_color': ['red', 'blue'][index], 'line_width': 1, 'line_style': 'solid', 'z_index': 9,
|
|
339
|
+
'data': set_data, 'line_caps': 'square', 'fill': True,
|
|
340
|
+
'axis_index': 0,
|
|
341
|
+
})
|
|
342
|
+
series.append({
|
|
343
|
+
'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}', 'name': f'text-{smp.name()}-{get_random_digits()}',
|
|
344
|
+
'color': ['red', 'blue'][index], 'fill_color': ['red', 'blue'][index],
|
|
345
|
+
'text': f"WMPA = {smp.Info.results.age_spectra[index]['age']:.2f} ± {(sigma * smp.Info.results.age_spectra[index]['s3']):.2f} Ma<r>"
|
|
346
|
+
f"MSWD = {smp.Info.results.age_spectra[index]['MSWD']:.2f}, n = {smp.Info.results.age_spectra[index]['Num']:.0f}<r>"
|
|
347
|
+
f"<sup>39</sup>Ar = {smp.Info.results.age_spectra[index]['Ar39']:.2f}%",
|
|
348
|
+
'size': title_size,
|
|
349
|
+
'data': [text.pos],
|
|
350
|
+
'axis_index': 1,
|
|
351
|
+
'h_align': "middle",
|
|
352
|
+
'v_align': "center",
|
|
353
|
+
})
|
|
354
|
+
tga = smp.Info.results.age_spectra['TGA']
|
|
355
|
+
if not np.isnan(tga['age']):
|
|
244
356
|
series.append({
|
|
245
|
-
'type': 'text', 'id': f'text-{get_random_digits()}', 'name': f'text-{get_random_digits()}',
|
|
357
|
+
'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}', 'name': f'text-{smp.name()}-{get_random_digits()}',
|
|
246
358
|
'color': color, 'fill_color': color,
|
|
247
|
-
'text':
|
|
248
|
-
'
|
|
359
|
+
'text': f"TGA = {tga['age']:.2f} ± {(sigma * tga['s3']):.2f} Ma",
|
|
360
|
+
'size': title_size,
|
|
361
|
+
'data': [[50, 3]],
|
|
249
362
|
'axis_index': 1,
|
|
363
|
+
'h_align': "middle",
|
|
364
|
+
'v_align': "bottom",
|
|
250
365
|
})
|
|
251
366
|
|
|
367
|
+
series.append({
|
|
368
|
+
'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}',
|
|
369
|
+
'name': f'text-{smp.name()}-{get_random_digits()}', 'color': color,
|
|
370
|
+
'text': smp.name(), 'size': title_size,
|
|
371
|
+
'data': [[50, 95]], 'axis_index': 1,
|
|
372
|
+
'h_align': "middle", 'v_align': "center",
|
|
373
|
+
})
|
|
374
|
+
|
|
375
|
+
return series
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
def _get_plot_data_age_spectra_axis(smp: sample, **options):
|
|
379
|
+
color = options.get('color', 'black')
|
|
380
|
+
xAxis, yAxis = [], []
|
|
381
|
+
age = smp.ApparentAgeValues[2:4]
|
|
382
|
+
ar = smp.DegasValues[20]
|
|
383
|
+
data = spectra.get_data(*age, ar, cumulative=False)
|
|
384
|
+
|
|
385
|
+
y_low_limit, y_up_limit, stick_num, inc = get_axis_scale(np.array(data[1:3]).flatten())
|
|
386
|
+
y_extent = [y_low_limit, y_up_limit]
|
|
387
|
+
y_interval = [y_low_limit + i * inc for i in range(stick_num + 1)]
|
|
388
|
+
|
|
389
|
+
y_extent = [4, 12]
|
|
390
|
+
y_interval = ['0', '10', '20', '30', '40', '50', '60', '70', '80', '90', '100']
|
|
391
|
+
y_interval = ['0', '4', '6', '8', '10', '12', '60', '70', '80', '90', '100']
|
|
392
|
+
|
|
252
393
|
xAxis.append({
|
|
253
394
|
'extent': [0, 100], 'interval': [0, 20, 40, 60, 80, 100], 'id': 0, 'show_frame': True,
|
|
254
395
|
'title': 'Cumulative <sup>39</sup>Ar Released (%)', 'name_location': 'middle',
|
|
255
|
-
'line_width': 1, 'line_style': 'solid', 'z_index': 9,
|
|
396
|
+
'line_width': 1, 'line_style': 'solid', 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
256
397
|
})
|
|
257
398
|
xAxis.append({
|
|
258
399
|
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
259
400
|
'title': '', 'name_location': 'middle',
|
|
260
|
-
'line_width': 1, 'line_style': 'solid', 'z_index': 0,
|
|
401
|
+
'line_width': 1, 'line_style': 'solid', 'z_index': 0, 'label_size': label_size, 'title_size': title_size,
|
|
261
402
|
})
|
|
262
403
|
yAxis.append({
|
|
263
|
-
'extent':
|
|
404
|
+
'extent': y_extent, 'interval': y_interval,
|
|
405
|
+
'id': 0, 'show_frame': True,
|
|
264
406
|
'title': 'Apparent Age (Ma)', 'name_location': 'middle',
|
|
265
|
-
'line_width': 1, 'line_style': 'solid', 'z_index': 9,
|
|
407
|
+
'line_width': 1, 'line_style': 'solid', 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
266
408
|
})
|
|
267
409
|
yAxis.append({
|
|
268
410
|
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
269
411
|
'title': '', 'name_location': 'middle',
|
|
270
|
-
'line_width': 1, 'line_style': 'solid', 'z_index': 0,
|
|
412
|
+
'line_width': 1, 'line_style': 'solid', 'z_index': 0, 'label_size': label_size, 'title_size': title_size,
|
|
271
413
|
})
|
|
272
|
-
return xAxis, yAxis
|
|
414
|
+
return xAxis, yAxis
|
|
273
415
|
|
|
274
416
|
|
|
275
|
-
def
|
|
417
|
+
def _get_plot_data_inv_isochron_axis(smp: sample, **options):
|
|
276
418
|
color = options.get('color', 'black')
|
|
277
|
-
xAxis, yAxis
|
|
419
|
+
xAxis, yAxis = [], []
|
|
420
|
+
data = np.array(smp.InvIsochronPlot.data)
|
|
421
|
+
set1 = smp.InvIsochronPlot.set1.data
|
|
422
|
+
set2 = smp.InvIsochronPlot.set2.data
|
|
423
|
+
set3 = smp.InvIsochronPlot.set3.data
|
|
424
|
+
|
|
425
|
+
low_limit, up_limit, stick_num, inc = get_axis_scale(data[0])
|
|
426
|
+
x_extent = [low_limit, up_limit]
|
|
427
|
+
interval = [float("{:g}".format(low_limit + i * inc)) for i in range(stick_num + 1)]
|
|
428
|
+
|
|
429
|
+
x_extent = [0, 1]
|
|
430
|
+
interval = ['0', '0.2', '0.4', '0.6', '0.8', '1', '6', '7', '8']
|
|
431
|
+
|
|
432
|
+
xAxis.append({
|
|
433
|
+
'extent': x_extent,
|
|
434
|
+
'interval': interval,
|
|
435
|
+
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
436
|
+
'title': '<sup>39</sup>Ar<sub>K</sub> / <sup>40</sup>Ar<sup>*</sup>', 'name_location': 'middle',
|
|
437
|
+
})
|
|
438
|
+
xAxis.append({
|
|
439
|
+
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
440
|
+
'title': '', 'name_location': 'middle', 'z_index': 0, 'label_size': label_size, 'title_size': title_size,
|
|
441
|
+
})
|
|
442
|
+
|
|
443
|
+
low_limit, up_limit, stick_num, inc = get_axis_scale(data[2])
|
|
444
|
+
y_extent = [low_limit, up_limit]
|
|
445
|
+
interval = [float("{:g}".format(low_limit + i * inc)) for i in range(stick_num + 1)]
|
|
446
|
+
|
|
447
|
+
y_extent = [0, 0.004]
|
|
448
|
+
interval = ['0', '0.001', '0.002', '0.003', '0.004', '0.005', '0.006', '0.007', '0.008']
|
|
449
|
+
|
|
450
|
+
yAxis.append({
|
|
451
|
+
'extent': y_extent,
|
|
452
|
+
'interval': interval,
|
|
453
|
+
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
454
|
+
'title': '<sup>36</sup>Ar<sub>a</sub> / <sup>40</sup>Ar<sup>*</sup>', 'name_location': 'middle',
|
|
455
|
+
})
|
|
456
|
+
yAxis.append({
|
|
457
|
+
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
458
|
+
'title': '', 'name_location': 'middle', 'z_index': 0, 'label_size': label_size, 'title_size': title_size,
|
|
459
|
+
})
|
|
460
|
+
|
|
461
|
+
return xAxis, yAxis
|
|
462
|
+
|
|
463
|
+
|
|
464
|
+
def _get_plot_data_inv_isochron_series(smp: sample, **options):
|
|
465
|
+
color = options.get('color', 'black')
|
|
466
|
+
xAxis = options.get('xAxis', [{}])
|
|
467
|
+
yAxis = options.get('yAxis', [{}])
|
|
468
|
+
sigma = options.get('sigma', 1)
|
|
469
|
+
series = []
|
|
278
470
|
age = smp.ApparentAgeValues[2:4]
|
|
279
471
|
ar = smp.DegasValues[20]
|
|
280
472
|
data = np.array(smp.InvIsochronPlot.data)
|
|
@@ -283,68 +475,63 @@ def _get_plot_data_inv_isochron(smp: sample, **options):
|
|
|
283
475
|
set3 = smp.InvIsochronPlot.set3.data
|
|
284
476
|
# set 1
|
|
285
477
|
series.append({
|
|
286
|
-
'type': 'series.scatter', 'id': f'scatter-{get_random_digits()}', 'name': f'
|
|
287
|
-
'stroke_color': 'red', 'fill_color': 'red', 'myType': 'scatter', 'size':
|
|
478
|
+
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_digits()}', 'name': f'scatter-{smp.name()}-{get_random_digits()}',
|
|
479
|
+
'stroke_color': 'red', 'fill_color': 'red', 'myType': 'scatter', 'size': 3, 'line_width': 0,
|
|
288
480
|
'data': (data[[0, 2], :][:, set1]).transpose().tolist(),
|
|
289
481
|
'axis_index': 0, 'z_index': 99
|
|
290
482
|
})
|
|
291
483
|
# set 2
|
|
292
484
|
series.append({
|
|
293
|
-
'type': 'series.scatter', 'id': f'scatter-{get_random_digits()}', 'name': f'
|
|
294
|
-
'stroke_color': 'blue', 'fill_color': 'blue', 'myType': 'scatter', 'size':
|
|
485
|
+
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_digits()}', 'name': f'scatter-{smp.name()}-{get_random_digits()}',
|
|
486
|
+
'stroke_color': 'blue', 'fill_color': 'blue', 'myType': 'scatter', 'size': 3, 'line_width': 0,
|
|
295
487
|
'data': (data[[0, 2], :][:, set2]).transpose().tolist(),
|
|
296
488
|
'axis_index': 0, 'z_index': 99
|
|
297
489
|
})
|
|
298
490
|
# set 3
|
|
299
491
|
series.append({
|
|
300
|
-
'type': 'series.scatter', 'id': f'scatter-{get_random_digits()}', 'name': f'
|
|
301
|
-
'stroke_color': 'black', 'fill_color': '
|
|
492
|
+
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_digits()}', 'name': f'scatter-{smp.name()}-{get_random_digits()}',
|
|
493
|
+
'stroke_color': 'black', 'fill_color': 'white', 'myType': 'scatter', 'size': 3, 'line_width': 0,
|
|
302
494
|
'data': (data[[0, 2], :][:, set3]).transpose().tolist(),
|
|
303
495
|
'axis_index': 0, 'z_index': 0
|
|
304
496
|
})
|
|
305
497
|
|
|
306
498
|
text1 = smp.InvIsochronPlot.text1
|
|
307
499
|
text2 = smp.InvIsochronPlot.text2
|
|
500
|
+
for index, text in enumerate([text1, text2]):
|
|
501
|
+
if not np.isnan(smp.Info.results.isochron['figure_3'][index]['age']):
|
|
502
|
+
isochron_data = [
|
|
503
|
+
(float(xAxis[0]['extent'][0]), float(xAxis[0]['extent'][0]) * smp.Info.results.isochron['figure_3'][index]['m1'] + smp.Info.results.isochron['figure_3'][index]['k']),
|
|
504
|
+
(float(xAxis[0]['extent'][1]), float(xAxis[0]['extent'][1]) * smp.Info.results.isochron['figure_3'][index]['m1'] + smp.Info.results.isochron['figure_3'][index]['k']),
|
|
505
|
+
]
|
|
506
|
+
series.append({
|
|
507
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
|
|
508
|
+
'color': ['red', 'blue'][index], 'fill_color': ['red', 'blue'][index],
|
|
509
|
+
'line_width': 1.5, 'line_style': 'solid',
|
|
510
|
+
'data': isochron_data,
|
|
511
|
+
'axis_index': 0,
|
|
512
|
+
})
|
|
513
|
+
series.append({
|
|
514
|
+
'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}', 'name': f'text-{smp.name()}-{get_random_digits()}',
|
|
515
|
+
'color': ['red', 'blue'][index], 'fill_color': ['red', 'blue'][index],
|
|
516
|
+
'text': f"IIA = {smp.Info.results.isochron['figure_3'][index]['age']:.2f} ± {(sigma * smp.Info.results.isochron['figure_3'][index]['s3']):.2f} Ma<r>"
|
|
517
|
+
f"[<sup>40</sup>Ar/<sup>36</sup>Ar]<sub>i</sub> = {smp.Info.results.isochron['figure_3'][index]['initial']:.2f} ± {(sigma * smp.Info.results.isochron['figure_3'][index]['sinitial']):.2f}<r>"
|
|
518
|
+
f"MSWD = {smp.Info.results.isochron['figure_3'][index]['MSWD']:.2f}, r<sup>2</sup> = {smp.Info.results.isochron['figure_3'][index]['R2']:.4f}<r>",
|
|
519
|
+
'size': title_size,
|
|
520
|
+
'data': [text.pos],
|
|
521
|
+
'axis_index': 1,
|
|
522
|
+
'h_align': "middle",
|
|
523
|
+
'v_align': "center",
|
|
524
|
+
})
|
|
308
525
|
|
|
309
526
|
series.append({
|
|
310
|
-
'type': 'text', 'id': f'text-{
|
|
311
|
-
'
|
|
312
|
-
'text': smp.name()
|
|
313
|
-
'data': [
|
|
314
|
-
'
|
|
315
|
-
})
|
|
316
|
-
series.append({
|
|
317
|
-
'type': 'text', 'id': f'text-{get_random_digits()}', 'name': f'text-{get_random_digits()}',
|
|
318
|
-
'color': 'blue', 'fill_color': 'blue',
|
|
319
|
-
'text': smp.name() + '<r>' + text2.text.replace("\n", "<r>"), 'size': int(text2.font_size / 1.5),
|
|
320
|
-
'data': [text2.pos],
|
|
321
|
-
'axis_index': 1,
|
|
527
|
+
'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}',
|
|
528
|
+
'name': f'text-{smp.name()}-{get_random_digits()}', 'color': color,
|
|
529
|
+
'text': smp.name(), 'size': title_size,
|
|
530
|
+
'data': [[50, 95]], 'axis_index': 1,
|
|
531
|
+
'h_align': "middle", 'v_align': "center",
|
|
322
532
|
})
|
|
323
533
|
|
|
324
|
-
|
|
325
|
-
yaxis = smp.InvIsochronPlot.yaxis
|
|
326
|
-
|
|
327
|
-
xAxis.append({
|
|
328
|
-
'extent': [float(xaxis.min), float(xaxis.max)],
|
|
329
|
-
'interval': [float("{:g}".format(float(xaxis.min) + i * float(xaxis.interval))) for i in range(int(xaxis.split_number) + 1)],
|
|
330
|
-
'id': 0, 'show_frame': True, 'z_index': 9,
|
|
331
|
-
'title': 'XXXX', 'name_location': 'middle',
|
|
332
|
-
})
|
|
333
|
-
xAxis.append({
|
|
334
|
-
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
335
|
-
'title': '', 'name_location': 'middle', 'z_index': 0,
|
|
336
|
-
})
|
|
337
|
-
yAxis.append({
|
|
338
|
-
'extent': [float(yaxis.min), float(yaxis.max)],
|
|
339
|
-
'interval': [float("{:g}".format(float(yaxis.min) + i * float(yaxis.interval))) for i in range(int(yaxis.split_number) + 1)],
|
|
340
|
-
'id': 0, 'show_frame': True, 'z_index': 9,
|
|
341
|
-
'title': 'YYYY', 'name_location': 'middle',
|
|
342
|
-
})
|
|
343
|
-
yAxis.append({
|
|
344
|
-
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
345
|
-
'title': '', 'name_location': 'middle', 'z_index': 0,
|
|
346
|
-
})
|
|
347
|
-
return xAxis, yAxis, series
|
|
534
|
+
return series
|
|
348
535
|
|
|
349
536
|
|
|
350
537
|
def _get_plot_data_degas_pattern(smp: sample, **options):
|
|
@@ -359,7 +546,7 @@ def _get_plot_data_degas_pattern(smp: sample, **options):
|
|
|
359
546
|
data = np.array([x, y])
|
|
360
547
|
# set 1
|
|
361
548
|
series.append({
|
|
362
|
-
'type': 'series.scatter', 'id': f'scatter-{get_random_digits()}', 'name': f'
|
|
549
|
+
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_digits()}', 'name': f'scatter-{smp.name()}-{get_random_digits()}',
|
|
363
550
|
'stroke_color': color, 'fill_color': 'white', 'myType': 'scatter', 'size': 4, 'line_width': 1,
|
|
364
551
|
'data': data.transpose().tolist(), 'axis_index': 0, 'z_index': 99
|
|
365
552
|
})
|
|
@@ -379,23 +566,57 @@ def _get_plot_data_degas_pattern(smp: sample, **options):
|
|
|
379
566
|
xAxis.append({
|
|
380
567
|
'extent': [float(xaxis.min), float(xaxis.max)],
|
|
381
568
|
'interval': [float("{:g}".format(float(xaxis.min) + i * float(xaxis.interval))) for i in range(int(xaxis.split_number) + 1)],
|
|
382
|
-
'id': 0, 'show_frame': True, 'z_index': 9,
|
|
569
|
+
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
383
570
|
'title': 'XXXX', 'name_location': 'middle',
|
|
384
571
|
})
|
|
385
572
|
yAxis.append({
|
|
386
573
|
'extent': [float(yaxis.min), float(yaxis.max)],
|
|
387
574
|
'interval': [float("{:g}".format(float(yaxis.min) + i * float(yaxis.interval))) for i in range(int(yaxis.split_number) + 1)],
|
|
388
|
-
'id': 0, 'show_frame': True, 'z_index': 9,
|
|
575
|
+
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
389
576
|
'title': 'YYYY', 'name_location': 'middle',
|
|
390
577
|
})
|
|
391
578
|
return xAxis, yAxis, series
|
|
392
579
|
|
|
393
580
|
|
|
394
|
-
def
|
|
581
|
+
def _get_plot_data_degas_spectra_axis(smp: sample, **options):
|
|
395
582
|
name = options.get('diagram_name', '39Ar')
|
|
396
583
|
color = options.get('color', 'black')
|
|
397
584
|
plot = smp.DegasPatternPlot
|
|
398
|
-
xAxis, yAxis
|
|
585
|
+
xAxis, yAxis = [], []
|
|
586
|
+
|
|
587
|
+
xaxis = plot.xaxis
|
|
588
|
+
yaxis = plot.yaxis
|
|
589
|
+
xaxis.min = 0
|
|
590
|
+
xaxis.max = 100
|
|
591
|
+
xaxis.interval = 20
|
|
592
|
+
xaxis.split_number = 5
|
|
593
|
+
yaxis.min = 0
|
|
594
|
+
yaxis.max = 20
|
|
595
|
+
yaxis.interval = 5
|
|
596
|
+
yaxis.split_number = 4
|
|
597
|
+
|
|
598
|
+
xAxis.append({
|
|
599
|
+
'extent': [float(xaxis.min), float(xaxis.max)],
|
|
600
|
+
'interval': [float("{:g}".format(float(xaxis.min) + i * float(xaxis.interval))) for i in range(int(xaxis.split_number) + 1)],
|
|
601
|
+
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
602
|
+
'title': 'Steps [n]', 'name_location': 'middle',
|
|
603
|
+
})
|
|
604
|
+
yAxis.append({
|
|
605
|
+
'extent': [float(yaxis.min), float(yaxis.max)],
|
|
606
|
+
'interval': [float("{:g}".format(float(yaxis.min) + i * float(yaxis.interval))) for i in range(int(yaxis.split_number) + 1)],
|
|
607
|
+
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
608
|
+
'title': 'Argon Released [%]', 'name_location': 'middle',
|
|
609
|
+
})
|
|
610
|
+
return xAxis, yAxis
|
|
611
|
+
|
|
612
|
+
|
|
613
|
+
def _get_plot_data_degas_spectra_series(smp: sample, **options):
|
|
614
|
+
name = options.get('diagram_name', '39Ar')
|
|
615
|
+
color = options.get('color', 'black')
|
|
616
|
+
plot = smp.DegasPatternPlot
|
|
617
|
+
xAxis = options.get('xAxis', [{}])
|
|
618
|
+
yAxis = options.get('yAxis', [{}])
|
|
619
|
+
series = []
|
|
399
620
|
nindex = {"40": 24, "39": 20, "38": 10, "37": 8, "36": 0}
|
|
400
621
|
if name[:2] in list(nindex.keys()):
|
|
401
622
|
ar = np.array(smp.DegasValues[nindex[name[:2]]], dtype=np.float64) # 20-21 Ar39
|
|
@@ -415,45 +636,42 @@ def _get_plot_data_degas_spectra(smp: sample, **options):
|
|
|
415
636
|
height = [ar[i] / sum(ar) * 100 for i in range(len(ar))]
|
|
416
637
|
data = np.array([x, y, width, height])
|
|
417
638
|
|
|
418
|
-
xaxis = plot.xaxis
|
|
419
|
-
yaxis = plot.yaxis
|
|
420
|
-
|
|
421
|
-
xaxis.min = 0
|
|
422
|
-
xaxis.max = 100
|
|
423
|
-
xaxis.interval = 20
|
|
424
|
-
xaxis.split_number = 5
|
|
425
|
-
yaxis.min = 0
|
|
426
|
-
yaxis.max = 20
|
|
427
|
-
yaxis.interval = 5
|
|
428
|
-
yaxis.split_number = 4
|
|
429
|
-
|
|
430
639
|
# set 1
|
|
431
640
|
series.append({
|
|
432
|
-
'type': 'rect', 'id': f'rect-{get_random_digits()}', 'name': f'rect-{get_random_digits()}',
|
|
641
|
+
'type': 'rect', 'id': f'rect-{smp.name()}-{get_random_digits()}', 'name': f'rect-{smp.name()}-{get_random_digits()}',
|
|
433
642
|
'color': color, 'myType': 'rect', 'line_width': 1,
|
|
434
643
|
'data': data.transpose().tolist(),
|
|
435
644
|
'axis_index': 0, 'z_index': 99
|
|
436
645
|
})
|
|
437
646
|
|
|
647
|
+
return series
|
|
648
|
+
|
|
649
|
+
|
|
650
|
+
def _get_plot_data_degas_curve_axis(smp: sample, **options):
|
|
651
|
+
name = options.get('diagram_name', '39Ar')
|
|
652
|
+
color = options.get('color', 'black')
|
|
653
|
+
xAxis, yAxis = [], []
|
|
438
654
|
xAxis.append({
|
|
439
|
-
'extent': [
|
|
440
|
-
'interval': [
|
|
441
|
-
'id': 0, 'show_frame': True, 'z_index': 9,
|
|
655
|
+
'extent': [0, 100],
|
|
656
|
+
'interval': [0, 20, 40, 60, 80, 100],
|
|
657
|
+
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
442
658
|
'title': 'Steps [n]', 'name_location': 'middle',
|
|
443
659
|
})
|
|
444
660
|
yAxis.append({
|
|
445
|
-
'extent': [
|
|
446
|
-
'interval': [
|
|
447
|
-
'id': 0, 'show_frame': True, 'z_index': 9,
|
|
448
|
-
'title': 'Argon
|
|
661
|
+
'extent': [0, 100],
|
|
662
|
+
'interval': [0, 20, 40, 60, 80, 100],
|
|
663
|
+
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
664
|
+
'title': 'Argon [%]', 'name_location': 'middle',
|
|
449
665
|
})
|
|
450
|
-
return xAxis, yAxis
|
|
666
|
+
return xAxis, yAxis
|
|
451
667
|
|
|
452
668
|
|
|
453
|
-
def
|
|
669
|
+
def _get_plot_data_degas_curve_series(smp: sample, **options):
|
|
454
670
|
name = options.get('diagram_name', '39Ar')
|
|
455
671
|
color = options.get('color', 'black')
|
|
456
|
-
xAxis
|
|
672
|
+
xAxis = options.get('xAxis', [{}])
|
|
673
|
+
yAxis = options.get('yAxis', [{}])
|
|
674
|
+
series = []
|
|
457
675
|
nindex = {"40": 24, "39": 20, "38": 10, "37": 8, "36": 0}
|
|
458
676
|
if name[:2] in list(nindex.keys()):
|
|
459
677
|
ar = np.array(smp.DegasValues[nindex[name[:2]]], dtype=np.float64) # 20-21 Ar39
|
|
@@ -477,31 +695,19 @@ def _get_plot_data_degas_curve(smp: sample, **options):
|
|
|
477
695
|
|
|
478
696
|
# line
|
|
479
697
|
series.append({
|
|
480
|
-
'type': 'line', 'id': f'line-{get_random_digits()}', 'name': f'line-{get_random_digits()}',
|
|
698
|
+
'type': 'line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
|
|
481
699
|
'color': color, 'myType': 'line', 'line_width': 1, 'line_style': 'solid',
|
|
482
700
|
'data': np.array([x, released]).transpose().tolist(),
|
|
483
701
|
'axis_index': 0, 'z_index': 99
|
|
484
702
|
})
|
|
485
703
|
series.append({
|
|
486
|
-
'type': 'line', 'id': f'line-{get_random_digits()}', 'name': f'line-{get_random_digits()}',
|
|
704
|
+
'type': 'line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
|
|
487
705
|
'color': color, 'myType': 'line', 'line_width': 1, 'line_style': 'solid',
|
|
488
706
|
'data': np.array([x, remained]).transpose().tolist(),
|
|
489
707
|
'axis_index': 0, 'z_index': 99
|
|
490
708
|
})
|
|
491
709
|
|
|
492
|
-
|
|
493
|
-
'extent': [0, 100],
|
|
494
|
-
'interval': [0, 20, 40, 60, 80, 100],
|
|
495
|
-
'id': 0, 'show_frame': True, 'z_index': 9,
|
|
496
|
-
'title': 'Steps [n]', 'name_location': 'middle',
|
|
497
|
-
})
|
|
498
|
-
yAxis.append({
|
|
499
|
-
'extent': [0, 100],
|
|
500
|
-
'interval': [0, 20, 40, 60, 80, 100],
|
|
501
|
-
'id': 0, 'show_frame': True, 'z_index': 9,
|
|
502
|
-
'title': 'Argon [%]', 'name_location': 'middle',
|
|
503
|
-
})
|
|
504
|
-
return xAxis, yAxis, series
|
|
710
|
+
return series
|
|
505
711
|
|
|
506
712
|
|
|
507
713
|
class ExcelTemplate:
|
|
@@ -585,31 +791,42 @@ class WritingWorkbook:
|
|
|
585
791
|
]
|
|
586
792
|
# writing header
|
|
587
793
|
sht_reference.write_row(row=start_row - 3, col=0, data=reference_header, cell_format=style)
|
|
794
|
+
|
|
795
|
+
# total rows, sequence number
|
|
796
|
+
total_rows = len(self.sample.SequenceName)
|
|
797
|
+
|
|
588
798
|
# Data for age spectra
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
799
|
+
try:
|
|
800
|
+
spectra_data = arr.transpose(self.sample.AgeSpectraPlot.data)
|
|
801
|
+
spectra_set1_data = arr.transpose(self.sample.AgeSpectraPlot.set1.data) or [[]] * 3
|
|
802
|
+
spectra_set2_data = arr.transpose(self.sample.AgeSpectraPlot.set2.data) or [[]] * 3
|
|
803
|
+
sht_reference.write_column(f"A{start_row}", spectra_data[0], style)
|
|
804
|
+
sht_reference.write_column(f"B{start_row}", spectra_data[1], style)
|
|
805
|
+
sht_reference.write_column(f"C{start_row}", spectra_data[2], style)
|
|
806
|
+
sht_reference.write_column(f"D{start_row}", spectra_set1_data[0], style)
|
|
807
|
+
sht_reference.write_column(f"E{start_row}", spectra_set1_data[1], style)
|
|
808
|
+
sht_reference.write_column(f"F{start_row}", spectra_set1_data[2], style)
|
|
809
|
+
sht_reference.write_column(f"G{start_row}", spectra_set2_data[0], style)
|
|
810
|
+
sht_reference.write_column(f"H{start_row}", spectra_set2_data[1], style)
|
|
811
|
+
sht_reference.write_column(f"I{start_row}", spectra_set2_data[2], style)
|
|
812
|
+
sht_reference.write_column(f"J{start_row}", [], style)
|
|
813
|
+
sht_reference.write_column(f"K{start_row}", [], style)
|
|
814
|
+
except IndexError:
|
|
815
|
+
pass
|
|
816
|
+
|
|
603
817
|
# Data for normal isochron
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
818
|
+
try:
|
|
819
|
+
set_data = [set1_data, set2_data, set3_data] = isochron.get_set_data(
|
|
820
|
+
self.sample.NorIsochronPlot.data, self.sample.SelectedSequence1, self.sample.SelectedSequence2,
|
|
821
|
+
self.sample.UnselectedSequence)
|
|
822
|
+
sht_reference.write_column(f"O{start_row}", set1_data[0], style)
|
|
823
|
+
sht_reference.write_column(f"P{start_row}", set1_data[2], style)
|
|
824
|
+
sht_reference.write_column(f"Q{start_row}", set2_data[0], style)
|
|
825
|
+
sht_reference.write_column(f"R{start_row}", set2_data[2], style)
|
|
826
|
+
sht_reference.write_column(f"S{start_row}", set3_data[0], style)
|
|
827
|
+
sht_reference.write_column(f"T{start_row}", set3_data[2], style)
|
|
828
|
+
except IndexError:
|
|
829
|
+
pass
|
|
613
830
|
try:
|
|
614
831
|
sht_reference.write_column(f"U{start_row}", self.sample.NorIsochronPlot.line1.data[0], style)
|
|
615
832
|
except IndexError:
|
|
@@ -626,16 +843,20 @@ class WritingWorkbook:
|
|
|
626
843
|
sht_reference.write_column(f"X{start_row}", self.sample.NorIsochronPlot.line2.data[1], style)
|
|
627
844
|
except IndexError:
|
|
628
845
|
pass
|
|
846
|
+
|
|
629
847
|
# Data for inverse isochron
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
848
|
+
try:
|
|
849
|
+
set_data = [set1_data, set2_data, set3_data] = isochron.get_set_data(
|
|
850
|
+
self.sample.InvIsochronPlot.data, self.sample.SelectedSequence1, self.sample.SelectedSequence2,
|
|
851
|
+
self.sample.UnselectedSequence)
|
|
852
|
+
sht_reference.write_column(f"Y{start_row}", set1_data[0], style)
|
|
853
|
+
sht_reference.write_column(f"Z{start_row}", set1_data[2], style)
|
|
854
|
+
sht_reference.write_column(f"AA{start_row}", set2_data[0], style)
|
|
855
|
+
sht_reference.write_column(f"AB{start_row}", set2_data[2], style)
|
|
856
|
+
sht_reference.write_column(f"AC{start_row}", set3_data[0], style)
|
|
857
|
+
sht_reference.write_column(f"AD{start_row}", set3_data[2], style)
|
|
858
|
+
except IndexError:
|
|
859
|
+
pass
|
|
639
860
|
try:
|
|
640
861
|
sht_reference.write_column(f"AE{start_row}", self.sample.InvIsochronPlot.line1.data[0], style)
|
|
641
862
|
except IndexError:
|
|
@@ -652,16 +873,20 @@ class WritingWorkbook:
|
|
|
652
873
|
sht_reference.write_column(f"AH{start_row}", self.sample.InvIsochronPlot.line2.data[1], style)
|
|
653
874
|
except IndexError:
|
|
654
875
|
pass
|
|
876
|
+
|
|
655
877
|
# Data for Cl 1 isochron
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
878
|
+
try:
|
|
879
|
+
set_data = [set1_data, set2_data, set3_data] = isochron.get_set_data(
|
|
880
|
+
self.sample.KClAr1IsochronPlot.data, self.sample.SelectedSequence1, self.sample.SelectedSequence2,
|
|
881
|
+
self.sample.UnselectedSequence)
|
|
882
|
+
sht_reference.write_column(f"AI{start_row}", set1_data[0], style)
|
|
883
|
+
sht_reference.write_column(f"AJ{start_row}", set1_data[2], style)
|
|
884
|
+
sht_reference.write_column(f"AK{start_row}", set2_data[0], style)
|
|
885
|
+
sht_reference.write_column(f"AL{start_row}", set2_data[2], style)
|
|
886
|
+
sht_reference.write_column(f"AM{start_row}", set3_data[0], style)
|
|
887
|
+
sht_reference.write_column(f"AN{start_row}", set3_data[2], style)
|
|
888
|
+
except IndexError:
|
|
889
|
+
pass
|
|
665
890
|
try:
|
|
666
891
|
sht_reference.write_column(f"AO{start_row}", self.sample.KClAr1IsochronPlot.line1.data[0], style)
|
|
667
892
|
except IndexError:
|
|
@@ -678,16 +903,20 @@ class WritingWorkbook:
|
|
|
678
903
|
sht_reference.write_column(f"AR{start_row}", self.sample.KClAr1IsochronPlot.line2.data[1], style)
|
|
679
904
|
except IndexError:
|
|
680
905
|
pass
|
|
906
|
+
|
|
681
907
|
# Data for Cl 2 isochron
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
908
|
+
try:
|
|
909
|
+
set_data = [set1_data, set2_data, set3_data] = isochron.get_set_data(
|
|
910
|
+
self.sample.KClAr2IsochronPlot.data, self.sample.SelectedSequence1, self.sample.SelectedSequence2,
|
|
911
|
+
self.sample.UnselectedSequence)
|
|
912
|
+
sht_reference.write_column(f"AS{start_row}", set1_data[0], style)
|
|
913
|
+
sht_reference.write_column(f"AT{start_row}", set1_data[2], style)
|
|
914
|
+
sht_reference.write_column(f"AU{start_row}", set2_data[0], style)
|
|
915
|
+
sht_reference.write_column(f"AV{start_row}", set2_data[2], style)
|
|
916
|
+
sht_reference.write_column(f"AW{start_row}", set3_data[0], style)
|
|
917
|
+
sht_reference.write_column(f"AX{start_row}", set3_data[2], style)
|
|
918
|
+
except IndexError:
|
|
919
|
+
pass
|
|
691
920
|
try:
|
|
692
921
|
sht_reference.write_column(f"AY{start_row}", self.sample.KClAr2IsochronPlot.line1.data[0], style)
|
|
693
922
|
except IndexError:
|
|
@@ -704,16 +933,20 @@ class WritingWorkbook:
|
|
|
704
933
|
sht_reference.write_column(f"BB{start_row}", self.sample.KClAr2IsochronPlot.line2.data[1], style)
|
|
705
934
|
except IndexError:
|
|
706
935
|
pass
|
|
936
|
+
|
|
707
937
|
# Data for Cl 3 isochron
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
938
|
+
try:
|
|
939
|
+
set_data = [set1_data, set2_data, set3_data] = isochron.get_set_data(
|
|
940
|
+
self.sample.KClAr3IsochronPlot.data, self.sample.SelectedSequence1, self.sample.SelectedSequence2,
|
|
941
|
+
self.sample.UnselectedSequence)
|
|
942
|
+
sht_reference.write_column(f"BC{start_row}", set1_data[0], style)
|
|
943
|
+
sht_reference.write_column(f"BD{start_row}", set1_data[2], style)
|
|
944
|
+
sht_reference.write_column(f"BE{start_row}", set2_data[0], style)
|
|
945
|
+
sht_reference.write_column(f"BF{start_row}", set2_data[2], style)
|
|
946
|
+
sht_reference.write_column(f"BG{start_row}", set3_data[0], style)
|
|
947
|
+
sht_reference.write_column(f"BH{start_row}", set3_data[2], style)
|
|
948
|
+
except IndexError:
|
|
949
|
+
pass
|
|
717
950
|
try:
|
|
718
951
|
sht_reference.write_column(f"BI{start_row}", self.sample.KClAr3IsochronPlot.line1.data[0], style)
|
|
719
952
|
except IndexError:
|
|
@@ -730,19 +963,23 @@ class WritingWorkbook:
|
|
|
730
963
|
sht_reference.write_column(f"BL{start_row}", self.sample.KClAr3IsochronPlot.line2.data[1], style)
|
|
731
964
|
except IndexError:
|
|
732
965
|
pass
|
|
966
|
+
|
|
733
967
|
# Data for degas pattern
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
968
|
+
try:
|
|
969
|
+
degas_data = self.sample.DegasPatternPlot.data
|
|
970
|
+
sht_reference.write_column(f"BM{start_row}", degas_data[0], style)
|
|
971
|
+
sht_reference.write_column(f"BN{start_row}", degas_data[1], style)
|
|
972
|
+
sht_reference.write_column(f"BO{start_row}", degas_data[2], style)
|
|
973
|
+
sht_reference.write_column(f"BP{start_row}", degas_data[3], style)
|
|
974
|
+
sht_reference.write_column(f"BQ{start_row}", degas_data[4], style)
|
|
975
|
+
sht_reference.write_column(f"BR{start_row}", degas_data[5], style)
|
|
976
|
+
sht_reference.write_column(f"BS{start_row}", degas_data[6], style)
|
|
977
|
+
sht_reference.write_column(f"BT{start_row}", degas_data[7], style)
|
|
978
|
+
sht_reference.write_column(f"BU{start_row}", degas_data[8], style)
|
|
979
|
+
sht_reference.write_column(f"BV{start_row}", degas_data[9], style)
|
|
980
|
+
sht_reference.write_column(f"BW{start_row}", [i+1 for i in range(len(self.sample.SequenceName))], style)
|
|
981
|
+
except IndexError:
|
|
982
|
+
pass
|
|
746
983
|
|
|
747
984
|
sht_result = xls.add_worksheet('Results')
|
|
748
985
|
title_style = xls.add_format({
|
|
@@ -847,165 +1084,17 @@ class WritingWorkbook:
|
|
|
847
1084
|
continue
|
|
848
1085
|
|
|
849
1086
|
for sht_name, [prop_name, sht_type, row, col, _, smp_attr_name, header_name] in self.template.sheet():
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
xls.close()
|
|
862
|
-
return None
|
|
863
|
-
col += 1
|
|
864
|
-
elif sht_type == "chart":
|
|
865
|
-
sht = xls.add_chartsheet(sht_name)
|
|
866
|
-
sht.set_paper(1) # US letter = 1, A4 = 9, letter is more rectangular
|
|
867
|
-
num_unselected = len(self.sample.UnselectedSequence)
|
|
868
|
-
num_set1 = len(self.sample.SelectedSequence1)
|
|
869
|
-
num_set2 = len(self.sample.SelectedSequence2)
|
|
870
|
-
if "spectra" in prop_name.lower():
|
|
871
|
-
figure = self.sample.AgeSpectraPlot
|
|
872
|
-
data_area = [
|
|
873
|
-
# Spectra lines
|
|
874
|
-
f"A{start_row}:A{len(spectra_data[0]) + start_row - 1}",
|
|
875
|
-
f"B{start_row}:B{len(spectra_data[0]) + start_row - 1}",
|
|
876
|
-
f"C{start_row}:C{len(spectra_data[0]) + start_row - 1}",
|
|
877
|
-
# set 1
|
|
878
|
-
f"D{start_row}:D{len(spectra_data[0]) + start_row - 1}",
|
|
879
|
-
f"E{start_row}:E{len(spectra_data[0]) + start_row - 1}",
|
|
880
|
-
f"F{start_row}:F{len(spectra_data[0]) + start_row - 1}",
|
|
881
|
-
# set 2
|
|
882
|
-
f"G{start_row}:G{len(spectra_data[0]) + start_row - 1}",
|
|
883
|
-
f"H{start_row}:H{len(spectra_data[0]) + start_row - 1}",
|
|
884
|
-
f"I{start_row}:I{len(spectra_data[0]) + start_row - 1}",
|
|
885
|
-
]
|
|
886
|
-
axis_range = [figure.xaxis.min, figure.xaxis.max, figure.yaxis.min, figure.yaxis.max]
|
|
887
|
-
self.get_chart_age_spectra(xls, sht, data_area, axis_range)
|
|
888
|
-
elif "normal_isochron" in prop_name.lower():
|
|
889
|
-
data_area = [
|
|
890
|
-
f"O{start_row}:O{num_set1 + start_row - 1}", f"P{start_row}:P{num_set1 + start_row - 1}",
|
|
891
|
-
f"Q{start_row}:Q{num_set2 + start_row - 1}", f"R{start_row}:R{num_set2 + start_row - 1}",
|
|
892
|
-
f"S{start_row}:S{num_unselected + start_row - 1}",
|
|
893
|
-
f"T{start_row}:T{num_unselected + start_row - 1}",
|
|
894
|
-
f"U{start_row}:V{start_row}", f"U{start_row + 1}:V{start_row + 1}",
|
|
895
|
-
f"W{start_row}:X{start_row}", f"W{start_row + 1}:X{start_row + 1}",
|
|
896
|
-
]
|
|
897
|
-
axis_range = [
|
|
898
|
-
basic.get_component_byid(self.sample, 'figure_2').xaxis.min,
|
|
899
|
-
basic.get_component_byid(self.sample, 'figure_2').xaxis.max,
|
|
900
|
-
basic.get_component_byid(self.sample, 'figure_2').yaxis.min,
|
|
901
|
-
basic.get_component_byid(self.sample, 'figure_2').yaxis.max,
|
|
902
|
-
]
|
|
903
|
-
self.get_chart_isochron(
|
|
904
|
-
xls, sht, data_area, axis_range, title_name="Normal Isochron",
|
|
905
|
-
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_36}Ar",
|
|
906
|
-
y_axis_name=f"{consts.sup_40}Ar / {consts.sup_36}Ar")
|
|
907
|
-
elif "inverse_isochron" in prop_name.lower():
|
|
908
|
-
data_area = [
|
|
909
|
-
f"Y{start_row}:Y{num_set1 + start_row - 1}", f"Z{start_row}:Z{num_set1 + start_row - 1}",
|
|
910
|
-
f"AA{start_row}:AA{num_set2 + start_row - 1}", f"AB{start_row}:AB{num_set2 + start_row - 1}",
|
|
911
|
-
f"AC{start_row}:AC{num_unselected + start_row - 1}",
|
|
912
|
-
f"AD{start_row}:AD{num_unselected + start_row - 1}",
|
|
913
|
-
f"AE{start_row}:AF{start_row}", f"AE{start_row + 1}:AF{start_row + 1}",
|
|
914
|
-
f"AG{start_row}:AH{start_row}", f"AG{start_row + 1}:AH{start_row + 1}",
|
|
915
|
-
]
|
|
916
|
-
axis_range = [
|
|
917
|
-
basic.get_component_byid(self.sample, 'figure_3').xaxis.min,
|
|
918
|
-
basic.get_component_byid(self.sample, 'figure_3').xaxis.max,
|
|
919
|
-
basic.get_component_byid(self.sample, 'figure_3').yaxis.min,
|
|
920
|
-
basic.get_component_byid(self.sample, 'figure_3').yaxis.max,
|
|
921
|
-
]
|
|
922
|
-
self.get_chart_isochron(
|
|
923
|
-
xls, sht, data_area, axis_range, title_name="Inverse Isochron",
|
|
924
|
-
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_40}Ar",
|
|
925
|
-
y_axis_name=f"{consts.sup_36}Ar / {consts.sup_40}Ar")
|
|
926
|
-
elif "k-cl-ar_1_isochron" in prop_name.lower():
|
|
927
|
-
data_area = [
|
|
928
|
-
f"AI{start_row}:AI{num_set1 + start_row - 1}", f"AJ{start_row}:AJ{num_set1 + start_row - 1}",
|
|
929
|
-
f"AK{start_row}:AK{num_set2 + start_row - 1}", f"AL{start_row}:AL{num_set2 + start_row - 1}",
|
|
930
|
-
f"AM{start_row}:AM{num_unselected + start_row - 1}",
|
|
931
|
-
f"AN{start_row}:AN{num_unselected + start_row - 1}",
|
|
932
|
-
f"AO{start_row}:AP{start_row}", f"AO{start_row + 1}:AP{start_row + 1}",
|
|
933
|
-
f"AQ{start_row}:AR{start_row}", f"AQ{start_row + 1}:AR{start_row + 1}",
|
|
934
|
-
]
|
|
935
|
-
axis_range = [
|
|
936
|
-
basic.get_component_byid(self.sample, 'figure_4').xaxis.min,
|
|
937
|
-
basic.get_component_byid(self.sample, 'figure_4').xaxis.max,
|
|
938
|
-
basic.get_component_byid(self.sample, 'figure_4').yaxis.min,
|
|
939
|
-
basic.get_component_byid(self.sample, 'figure_4').yaxis.max,
|
|
940
|
-
]
|
|
941
|
-
self.get_chart_isochron(
|
|
942
|
-
xls, sht, data_area, axis_range, title_name="K-Cl-Ar 1 Isochron",
|
|
943
|
-
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_38}Ar",
|
|
944
|
-
y_axis_name=f"{consts.sup_40}Ar / {consts.sup_38}Ar")
|
|
945
|
-
elif "k-cl-ar_2_isochron" in prop_name.lower():
|
|
946
|
-
data_area = [
|
|
947
|
-
f"AS{start_row}:AS{num_set1 + start_row - 1}", f"AT{start_row}:AT{num_set1 + start_row - 1}",
|
|
948
|
-
f"AU{start_row}:AU{num_set2 + start_row - 1}", f"AV{start_row}:AV{num_set2 + start_row - 1}",
|
|
949
|
-
f"AW{start_row}:AW{num_unselected + start_row - 1}",
|
|
950
|
-
f"AX{start_row}:AX{num_unselected + start_row - 1}",
|
|
951
|
-
f"AY{start_row}:AZ{start_row}", f"AY{start_row + 1}:AZ{start_row + 1}",
|
|
952
|
-
f"BA{start_row}:BB{start_row}", f"BA{start_row + 1}:BB{start_row + 1}",
|
|
953
|
-
]
|
|
954
|
-
axis_range = [
|
|
955
|
-
basic.get_component_byid(self.sample, 'figure_5').xaxis.min,
|
|
956
|
-
basic.get_component_byid(self.sample, 'figure_5').xaxis.max,
|
|
957
|
-
basic.get_component_byid(self.sample, 'figure_5').yaxis.min,
|
|
958
|
-
basic.get_component_byid(self.sample, 'figure_5').yaxis.max,
|
|
959
|
-
]
|
|
960
|
-
self.get_chart_isochron(
|
|
961
|
-
xls, sht, data_area, axis_range, title_name="K-Cl-Ar 2 Isochron",
|
|
962
|
-
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_40}Ar",
|
|
963
|
-
y_axis_name=f"{consts.sup_38}Ar / {consts.sup_40}Ar")
|
|
964
|
-
elif "k-cl-ar_3_isochron" in prop_name.lower():
|
|
965
|
-
data_area = [
|
|
966
|
-
f"BC{start_row}:BC{num_set1 + start_row - 1}", f"BD{start_row}:BD{num_set1 + start_row - 1}",
|
|
967
|
-
f"BE{start_row}:BE{num_set2 + start_row - 1}", f"BF{start_row}:BF{num_set2 + start_row - 1}",
|
|
968
|
-
f"BG{start_row}:BG{num_unselected + start_row - 1}",
|
|
969
|
-
f"BH{start_row}:BH{num_unselected + start_row - 1}",
|
|
970
|
-
f"BI{start_row}:BJ{start_row}", f"BI{start_row + 1}:BJ{start_row + 1}",
|
|
971
|
-
f"BK{start_row}:BL{start_row}", f"BK{start_row + 1}:BL{start_row + 1}",
|
|
972
|
-
]
|
|
973
|
-
axis_range = [
|
|
974
|
-
basic.get_component_byid(self.sample, 'figure_6').xaxis.min,
|
|
975
|
-
basic.get_component_byid(self.sample, 'figure_6').xaxis.max,
|
|
976
|
-
basic.get_component_byid(self.sample, 'figure_6').yaxis.min,
|
|
977
|
-
basic.get_component_byid(self.sample, 'figure_6').yaxis.max,
|
|
978
|
-
]
|
|
979
|
-
self.get_chart_isochron(
|
|
980
|
-
xls, sht, data_area, axis_range, title_name="K-Cl-Ar 3 Isochron",
|
|
981
|
-
x_axis_name=f"{consts.sup_38}Ar / {consts.sup_39}Ar",
|
|
982
|
-
y_axis_name=f"{consts.sup_40}Ar / {consts.sup_39}Ar")
|
|
983
|
-
elif "degas_pattern" in prop_name.lower():
|
|
984
|
-
data_area = [
|
|
985
|
-
f"BM{start_row}:BM{len(degas_data[0]) + start_row - 1}",
|
|
986
|
-
f"BN{start_row}:BN{len(degas_data[1]) + start_row - 1}",
|
|
987
|
-
f"BO{start_row}:BO{len(degas_data[2]) + start_row - 1}",
|
|
988
|
-
f"BP{start_row}:BP{len(degas_data[3]) + start_row - 1}",
|
|
989
|
-
f"BQ{start_row}:BQ{len(degas_data[4]) + start_row - 1}",
|
|
990
|
-
f"BR{start_row}:BR{len(degas_data[5]) + start_row - 1}",
|
|
991
|
-
f"BS{start_row}:BS{len(degas_data[6]) + start_row - 1}",
|
|
992
|
-
f"BT{start_row}:BT{len(degas_data[7]) + start_row - 1}",
|
|
993
|
-
f"BU{start_row}:BU{len(degas_data[8]) + start_row - 1}",
|
|
994
|
-
f"BV{start_row}:BV{len(degas_data[9]) + start_row - 1}",
|
|
995
|
-
f"BW{start_row}:BW{len(degas_data[9]) + start_row - 1}",
|
|
996
|
-
]
|
|
997
|
-
axis_range = [
|
|
998
|
-
basic.get_component_byid(self.sample, 'figure_8').xaxis.min,
|
|
999
|
-
basic.get_component_byid(self.sample, 'figure_8').xaxis.max,
|
|
1000
|
-
basic.get_component_byid(self.sample, 'figure_8').yaxis.min,
|
|
1001
|
-
basic.get_component_byid(self.sample, 'figure_8').yaxis.max,
|
|
1002
|
-
]
|
|
1003
|
-
self.get_chart_degas_pattern(
|
|
1004
|
-
xls, sht, data_area, axis_range,
|
|
1005
|
-
title_name="Degas Pattern", x_axis_name=f"Sequence",
|
|
1006
|
-
y_axis_name=f"Argon Isotopes (%)")
|
|
1007
|
-
else:
|
|
1008
|
-
xls.close()
|
|
1087
|
+
try:
|
|
1088
|
+
if sht_type == "table":
|
|
1089
|
+
self.write_sht_table(sht_name, prop_name, sht_type, row, col, _, smp_attr_name, header_name,
|
|
1090
|
+
style, xls)
|
|
1091
|
+
elif sht_type == "chart":
|
|
1092
|
+
self.write_sht_chart(sht_name, prop_name, sht_type, row, col, _, smp_attr_name, header_name,
|
|
1093
|
+
style, xls, start_row, total_rows)
|
|
1094
|
+
else:
|
|
1095
|
+
raise ValueError
|
|
1096
|
+
except (BaseException, Exception):
|
|
1097
|
+
print(traceback.format_exc())
|
|
1009
1098
|
return None
|
|
1010
1099
|
xls.get_worksheet_by_name("Reference").hide()
|
|
1011
1100
|
xls.get_worksheet_by_name("Isochrons").hidden = 0 # unhiden isochrons worksheet
|
|
@@ -1014,6 +1103,163 @@ class WritingWorkbook:
|
|
|
1014
1103
|
print('导出完毕,文件路径:%s' % self.filepath)
|
|
1015
1104
|
return True
|
|
1016
1105
|
|
|
1106
|
+
def write_sht_table(self, sht_name, prop_name, sht_type, row, col, _, smp_attr_name, header_name, style, xls):
|
|
1107
|
+
sht = xls.add_worksheet(sht_name)
|
|
1108
|
+
data = arr.transpose(getattr(self.sample, smp_attr_name, None).data)
|
|
1109
|
+
sht.hide_gridlines(2) # 0 = show grids, 1 = hide print grid, else = hide print and screen grids
|
|
1110
|
+
sht.hide() # default hidden table sheet
|
|
1111
|
+
sht.set_column(0, len(data), width=12) # column width
|
|
1112
|
+
header = getattr(sample, header_name)
|
|
1113
|
+
sht.write_row(row=row - 1, col=col, data=header, cell_format=style)
|
|
1114
|
+
for each_col in data:
|
|
1115
|
+
res = sht.write_column(row=row, col=col, data=each_col, cell_format=style)
|
|
1116
|
+
if res:
|
|
1117
|
+
raise ValueError(res)
|
|
1118
|
+
col += 1
|
|
1119
|
+
|
|
1120
|
+
def write_sht_chart(self, sht_name, prop_name, sht_type, row, col, _, smp_attr_name, header_name, style, xls, start_row, total_rows):
|
|
1121
|
+
sht = xls.add_chartsheet(sht_name)
|
|
1122
|
+
sht.set_paper(1) # US letter = 1, A4 = 9, letter is more rectangular
|
|
1123
|
+
num_unselected = len(self.sample.UnselectedSequence)
|
|
1124
|
+
num_set1 = len(self.sample.SelectedSequence1)
|
|
1125
|
+
num_set2 = len(self.sample.SelectedSequence2)
|
|
1126
|
+
if "spectra" in prop_name.lower():
|
|
1127
|
+
figure = self.sample.AgeSpectraPlot
|
|
1128
|
+
data_area = [
|
|
1129
|
+
# Spectra lines
|
|
1130
|
+
f"A{start_row}:A{total_rows + start_row - 1}",
|
|
1131
|
+
f"B{start_row}:B{total_rows + start_row - 1}",
|
|
1132
|
+
f"C{start_row}:C{total_rows + start_row - 1}",
|
|
1133
|
+
# set 1
|
|
1134
|
+
f"D{start_row}:D{total_rows + start_row - 1}",
|
|
1135
|
+
f"E{start_row}:E{total_rows + start_row - 1}",
|
|
1136
|
+
f"F{start_row}:F{total_rows + start_row - 1}",
|
|
1137
|
+
# set 2
|
|
1138
|
+
f"G{start_row}:G{total_rows + start_row - 1}",
|
|
1139
|
+
f"H{start_row}:H{total_rows + start_row - 1}",
|
|
1140
|
+
f"I{start_row}:I{total_rows + start_row - 1}",
|
|
1141
|
+
]
|
|
1142
|
+
axis_range = [figure.xaxis.min, figure.xaxis.max, figure.yaxis.min, figure.yaxis.max]
|
|
1143
|
+
self.get_chart_age_spectra(xls, sht, data_area, axis_range)
|
|
1144
|
+
elif "normal_isochron" in prop_name.lower():
|
|
1145
|
+
data_area = [
|
|
1146
|
+
f"O{start_row}:O{num_set1 + start_row - 1}", f"P{start_row}:P{num_set1 + start_row - 1}",
|
|
1147
|
+
f"Q{start_row}:Q{num_set2 + start_row - 1}", f"R{start_row}:R{num_set2 + start_row - 1}",
|
|
1148
|
+
f"S{start_row}:S{num_unselected + start_row - 1}",
|
|
1149
|
+
f"T{start_row}:T{num_unselected + start_row - 1}",
|
|
1150
|
+
f"U{start_row}:V{start_row}", f"U{start_row + 1}:V{start_row + 1}",
|
|
1151
|
+
f"W{start_row}:X{start_row}", f"W{start_row + 1}:X{start_row + 1}",
|
|
1152
|
+
]
|
|
1153
|
+
axis_range = [
|
|
1154
|
+
basic.get_component_byid(self.sample, 'figure_2').xaxis.min,
|
|
1155
|
+
basic.get_component_byid(self.sample, 'figure_2').xaxis.max,
|
|
1156
|
+
basic.get_component_byid(self.sample, 'figure_2').yaxis.min,
|
|
1157
|
+
basic.get_component_byid(self.sample, 'figure_2').yaxis.max,
|
|
1158
|
+
]
|
|
1159
|
+
self.get_chart_isochron(
|
|
1160
|
+
xls, sht, data_area, axis_range, title_name="Normal Isochron",
|
|
1161
|
+
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_36}Ar",
|
|
1162
|
+
y_axis_name=f"{consts.sup_40}Ar / {consts.sup_36}Ar")
|
|
1163
|
+
elif "inverse_isochron" in prop_name.lower():
|
|
1164
|
+
data_area = [
|
|
1165
|
+
f"Y{start_row}:Y{num_set1 + start_row - 1}", f"Z{start_row}:Z{num_set1 + start_row - 1}",
|
|
1166
|
+
f"AA{start_row}:AA{num_set2 + start_row - 1}", f"AB{start_row}:AB{num_set2 + start_row - 1}",
|
|
1167
|
+
f"AC{start_row}:AC{num_unselected + start_row - 1}",
|
|
1168
|
+
f"AD{start_row}:AD{num_unselected + start_row - 1}",
|
|
1169
|
+
f"AE{start_row}:AF{start_row}", f"AE{start_row + 1}:AF{start_row + 1}",
|
|
1170
|
+
f"AG{start_row}:AH{start_row}", f"AG{start_row + 1}:AH{start_row + 1}",
|
|
1171
|
+
]
|
|
1172
|
+
axis_range = [
|
|
1173
|
+
basic.get_component_byid(self.sample, 'figure_3').xaxis.min,
|
|
1174
|
+
basic.get_component_byid(self.sample, 'figure_3').xaxis.max,
|
|
1175
|
+
basic.get_component_byid(self.sample, 'figure_3').yaxis.min,
|
|
1176
|
+
basic.get_component_byid(self.sample, 'figure_3').yaxis.max,
|
|
1177
|
+
]
|
|
1178
|
+
self.get_chart_isochron(
|
|
1179
|
+
xls, sht, data_area, axis_range, title_name="Inverse Isochron",
|
|
1180
|
+
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_40}Ar",
|
|
1181
|
+
y_axis_name=f"{consts.sup_36}Ar / {consts.sup_40}Ar")
|
|
1182
|
+
elif "k-cl-ar_1_isochron" in prop_name.lower():
|
|
1183
|
+
data_area = [
|
|
1184
|
+
f"AI{start_row}:AI{num_set1 + start_row - 1}", f"AJ{start_row}:AJ{num_set1 + start_row - 1}",
|
|
1185
|
+
f"AK{start_row}:AK{num_set2 + start_row - 1}", f"AL{start_row}:AL{num_set2 + start_row - 1}",
|
|
1186
|
+
f"AM{start_row}:AM{num_unselected + start_row - 1}",
|
|
1187
|
+
f"AN{start_row}:AN{num_unselected + start_row - 1}",
|
|
1188
|
+
f"AO{start_row}:AP{start_row}", f"AO{start_row + 1}:AP{start_row + 1}",
|
|
1189
|
+
f"AQ{start_row}:AR{start_row}", f"AQ{start_row + 1}:AR{start_row + 1}",
|
|
1190
|
+
]
|
|
1191
|
+
axis_range = [
|
|
1192
|
+
basic.get_component_byid(self.sample, 'figure_4').xaxis.min,
|
|
1193
|
+
basic.get_component_byid(self.sample, 'figure_4').xaxis.max,
|
|
1194
|
+
basic.get_component_byid(self.sample, 'figure_4').yaxis.min,
|
|
1195
|
+
basic.get_component_byid(self.sample, 'figure_4').yaxis.max,
|
|
1196
|
+
]
|
|
1197
|
+
self.get_chart_isochron(
|
|
1198
|
+
xls, sht, data_area, axis_range, title_name="K-Cl-Ar 1 Isochron",
|
|
1199
|
+
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_38}Ar",
|
|
1200
|
+
y_axis_name=f"{consts.sup_40}Ar / {consts.sup_38}Ar")
|
|
1201
|
+
elif "k-cl-ar_2_isochron" in prop_name.lower():
|
|
1202
|
+
data_area = [
|
|
1203
|
+
f"AS{start_row}:AS{num_set1 + start_row - 1}", f"AT{start_row}:AT{num_set1 + start_row - 1}",
|
|
1204
|
+
f"AU{start_row}:AU{num_set2 + start_row - 1}", f"AV{start_row}:AV{num_set2 + start_row - 1}",
|
|
1205
|
+
f"AW{start_row}:AW{num_unselected + start_row - 1}",
|
|
1206
|
+
f"AX{start_row}:AX{num_unselected + start_row - 1}",
|
|
1207
|
+
f"AY{start_row}:AZ{start_row}", f"AY{start_row + 1}:AZ{start_row + 1}",
|
|
1208
|
+
f"BA{start_row}:BB{start_row}", f"BA{start_row + 1}:BB{start_row + 1}",
|
|
1209
|
+
]
|
|
1210
|
+
axis_range = [
|
|
1211
|
+
basic.get_component_byid(self.sample, 'figure_5').xaxis.min,
|
|
1212
|
+
basic.get_component_byid(self.sample, 'figure_5').xaxis.max,
|
|
1213
|
+
basic.get_component_byid(self.sample, 'figure_5').yaxis.min,
|
|
1214
|
+
basic.get_component_byid(self.sample, 'figure_5').yaxis.max,
|
|
1215
|
+
]
|
|
1216
|
+
self.get_chart_isochron(
|
|
1217
|
+
xls, sht, data_area, axis_range, title_name="K-Cl-Ar 2 Isochron",
|
|
1218
|
+
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_40}Ar",
|
|
1219
|
+
y_axis_name=f"{consts.sup_38}Ar / {consts.sup_40}Ar")
|
|
1220
|
+
elif "k-cl-ar_3_isochron" in prop_name.lower():
|
|
1221
|
+
data_area = [
|
|
1222
|
+
f"BC{start_row}:BC{num_set1 + start_row - 1}", f"BD{start_row}:BD{num_set1 + start_row - 1}",
|
|
1223
|
+
f"BE{start_row}:BE{num_set2 + start_row - 1}", f"BF{start_row}:BF{num_set2 + start_row - 1}",
|
|
1224
|
+
f"BG{start_row}:BG{num_unselected + start_row - 1}",
|
|
1225
|
+
f"BH{start_row}:BH{num_unselected + start_row - 1}",
|
|
1226
|
+
f"BI{start_row}:BJ{start_row}", f"BI{start_row + 1}:BJ{start_row + 1}",
|
|
1227
|
+
f"BK{start_row}:BL{start_row}", f"BK{start_row + 1}:BL{start_row + 1}",
|
|
1228
|
+
]
|
|
1229
|
+
axis_range = [
|
|
1230
|
+
basic.get_component_byid(self.sample, 'figure_6').xaxis.min,
|
|
1231
|
+
basic.get_component_byid(self.sample, 'figure_6').xaxis.max,
|
|
1232
|
+
basic.get_component_byid(self.sample, 'figure_6').yaxis.min,
|
|
1233
|
+
basic.get_component_byid(self.sample, 'figure_6').yaxis.max,
|
|
1234
|
+
]
|
|
1235
|
+
self.get_chart_isochron(
|
|
1236
|
+
xls, sht, data_area, axis_range, title_name="K-Cl-Ar 3 Isochron",
|
|
1237
|
+
x_axis_name=f"{consts.sup_38}Ar / {consts.sup_39}Ar",
|
|
1238
|
+
y_axis_name=f"{consts.sup_40}Ar / {consts.sup_39}Ar")
|
|
1239
|
+
elif "degas_pattern" in prop_name.lower():
|
|
1240
|
+
data_area = [
|
|
1241
|
+
f"BM{start_row}:BM{total_rows + start_row - 1}",
|
|
1242
|
+
f"BN{start_row}:BN{total_rows + start_row - 1}",
|
|
1243
|
+
f"BO{start_row}:BO{total_rows + start_row - 1}",
|
|
1244
|
+
f"BP{start_row}:BP{total_rows + start_row - 1}",
|
|
1245
|
+
f"BQ{start_row}:BQ{total_rows + start_row - 1}",
|
|
1246
|
+
f"BR{start_row}:BR{total_rows + start_row - 1}",
|
|
1247
|
+
f"BS{start_row}:BS{total_rows + start_row - 1}",
|
|
1248
|
+
f"BT{start_row}:BT{total_rows + start_row - 1}",
|
|
1249
|
+
f"BU{start_row}:BU{total_rows + start_row - 1}",
|
|
1250
|
+
f"BV{start_row}:BV{total_rows + start_row - 1}",
|
|
1251
|
+
f"BW{start_row}:BW{total_rows + start_row - 1}",
|
|
1252
|
+
]
|
|
1253
|
+
axis_range = [
|
|
1254
|
+
basic.get_component_byid(self.sample, 'figure_8').xaxis.min,
|
|
1255
|
+
basic.get_component_byid(self.sample, 'figure_8').xaxis.max,
|
|
1256
|
+
basic.get_component_byid(self.sample, 'figure_8').yaxis.min,
|
|
1257
|
+
basic.get_component_byid(self.sample, 'figure_8').yaxis.max,
|
|
1258
|
+
]
|
|
1259
|
+
self.get_chart_degas_pattern(
|
|
1260
|
+
xls, sht, data_area, axis_range,
|
|
1261
|
+
title_name="Degas Pattern", x_axis_name=f"Sequence", y_axis_name=f"Argon Isotopes (%)")
|
|
1262
|
+
|
|
1017
1263
|
def create_initial_chart(self, xls: Workbook, chart_type: str = 'scatter'):
|
|
1018
1264
|
# chartarea
|
|
1019
1265
|
chartarea_dict = {'border': {'none': True}, 'fill': {'color': self.chartarea_color}}
|
|
@@ -1192,8 +1438,8 @@ class WritingWorkbook:
|
|
|
1192
1438
|
# chart.title_name = title_name
|
|
1193
1439
|
for each in series:
|
|
1194
1440
|
chart.add_series(each)
|
|
1195
|
-
|
|
1196
|
-
|
|
1441
|
+
chart.x_axis.update({'name': x_axis_name, 'min': axis_range[0], 'max': axis_range[1]})
|
|
1442
|
+
chart.y_axis.update({'name': y_axis_name, 'min': axis_range[2], 'max': axis_range[3]})
|
|
1197
1443
|
|
|
1198
1444
|
chart.set_legend({'none': False, 'position': 'top'})
|
|
1199
1445
|
|
|
@@ -1580,7 +1826,7 @@ class CreatePDF:
|
|
|
1580
1826
|
y=(yaxis_max - yaxis_min) * pos[1] + yaxis_min,
|
|
1581
1827
|
text=f"Age ={age} {chr(0xb1)} {sage} Ma<r>F = {F} {chr(0xb1)} {sF}<r>"
|
|
1582
1828
|
f"R<sub>0</sub> = {R0} {chr(0xb1)} {sR0}<r>"
|
|
1583
|
-
f"{MSWD = },
|
|
1829
|
+
f"{MSWD = }, r<sup>2</sup> = {R2}<r>"
|
|
1584
1830
|
f"{Chisq = }, {p = }",
|
|
1585
1831
|
size=10, clip=True, coordinate="scale", h_align="left", v_align="bottom",
|
|
1586
1832
|
color=color, rotate=0, z_index=150)
|