ararpy 0.1.12__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/arr.py +2 -1
- ararpy/calc/basic.py +36 -14
- ararpy/calc/corr.py +7 -34
- ararpy/calc/plot.py +3 -3
- ararpy/calc/raw_funcs.py +4 -2
- ararpy/calc/regression.py +3 -6
- ararpy/calc/spectra.py +3 -1
- ararpy/files/calc_file.py +1 -1
- ararpy/files/raw_file.py +84 -82
- ararpy/smp/EXPORT_TO_PDF_DATA_PROPERTIES.py +95 -0
- ararpy/smp/basic.py +6 -5
- ararpy/smp/calculation.py +2 -2
- ararpy/smp/corr.py +107 -77
- ararpy/smp/diffusion_funcs.py +282 -123
- ararpy/smp/export.py +927 -264
- ararpy/smp/json.py +7 -0
- ararpy/smp/plots.py +10 -8
- ararpy/smp/raw.py +9 -2
- ararpy/smp/sample.py +32 -23
- {ararpy-0.1.12.dist-info → ararpy-0.1.14.dist-info}/METADATA +10 -2
- {ararpy-0.1.12.dist-info → ararpy-0.1.14.dist-info}/RECORD +26 -23
- {ararpy-0.1.12.dist-info → ararpy-0.1.14.dist-info}/WHEEL +1 -1
- {ararpy-0.1.12.dist-info → ararpy-0.1.14.dist-info}/LICENSE +0 -0
- {ararpy-0.1.12.dist-info → ararpy-0.1.14.dist-info}/top_level.txt +0 -0
ararpy/smp/export.py
CHANGED
|
@@ -17,14 +17,20 @@ import sys
|
|
|
17
17
|
import pickle
|
|
18
18
|
import traceback
|
|
19
19
|
import pdf_maker as pm
|
|
20
|
+
import numpy as np
|
|
20
21
|
from decimal import Decimal
|
|
21
22
|
|
|
22
|
-
from ..calc import arr, isochron
|
|
23
|
+
from ..calc import arr, isochron, spectra
|
|
24
|
+
from ..calc.basic import get_random_digits
|
|
25
|
+
from ..calc.plot import get_axis_scale
|
|
23
26
|
from . import basic, sample, consts
|
|
24
27
|
|
|
25
28
|
Sample = sample.Sample
|
|
26
29
|
Plot = sample.Plot
|
|
27
30
|
|
|
31
|
+
title_size = 11
|
|
32
|
+
label_size = 11
|
|
33
|
+
|
|
28
34
|
try:
|
|
29
35
|
from webarar.settings import SETTINGS_ROOT
|
|
30
36
|
except ModuleNotFoundError:
|
|
@@ -41,52 +47,669 @@ def to_pdf(file_path: str, figure: str, smp: Sample):
|
|
|
41
47
|
pdf.save(figure=figure)
|
|
42
48
|
|
|
43
49
|
|
|
44
|
-
def
|
|
50
|
+
def get_cv_from_dict(data: dict, **kwargs):
|
|
45
51
|
# create a canvas
|
|
46
|
-
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)
|
|
47
54
|
# change frame outline style
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
55
|
+
if kwargs.get("show_frame", True):
|
|
56
|
+
cv.show_frame(color="grey", line_width=0.5)
|
|
57
|
+
axis_num = min([len(data['xAxis']), len(data['yAxis'])])
|
|
51
58
|
# draw axis
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
59
|
+
plots = []
|
|
60
|
+
for i in range(axis_num):
|
|
61
|
+
scale = [*data['xAxis'][i]['extent'], *data['yAxis'][i]['extent']]
|
|
62
|
+
scale = (float(scale[0]), float(scale[1]), float(scale[2]), float(scale[3]))
|
|
63
|
+
# create plot area based on axis scale
|
|
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)
|
|
66
|
+
for stick in data['xAxis'][i]['interval']:
|
|
67
|
+
start = pt.scale_to_points(float(stick), scale[2])
|
|
68
|
+
end = pt.scale_to_points(float(stick), scale[2])
|
|
69
|
+
end = (end[0], end[1] - 5)
|
|
70
|
+
if pt.line(start=start, end=end, width=1, line_style="solid", y_clip=False, coordinate="pt", z_index=100):
|
|
71
|
+
pt.text(x=start[0], y=end[1] - 15, text=f"{stick}", clip=False, size=int(data['xAxis'][i]['label_size']),
|
|
72
|
+
coordinate="pt", h_align="middle", z_index=150)
|
|
73
|
+
for stick in data['yAxis'][i]['interval']:
|
|
74
|
+
start = pt.scale_to_points(scale[0], float(stick))
|
|
75
|
+
end = pt.scale_to_points(scale[0], float(stick))
|
|
76
|
+
end = (end[0] - 5, end[1])
|
|
77
|
+
if pt.line(start=start, end=end, width=1, line_style="solid", x_clip=False, coordinate="pt", z_index=100):
|
|
78
|
+
pt.text(x=end[0] - 5, y=end[1], text=f"{stick}", clip=False, size=int(data['yAxis'][i]['label_size']),
|
|
79
|
+
coordinate="pt", h_align="right", v_align="center", z_index=150)
|
|
80
|
+
# axis titles
|
|
81
|
+
nloc = pt.scale_to_points(sum(scale[:2]) / 2, scale[2])
|
|
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']))
|
|
84
|
+
nloc = pt.scale_to_points(scale[0], sum(scale[2:4]) / 2)
|
|
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']))
|
|
87
|
+
plots.append(pt)
|
|
73
88
|
# draw series
|
|
74
89
|
for se in data['series']:
|
|
75
|
-
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
|
|
99
|
+
try:
|
|
100
|
+
pt = plots[se.get('axis_index', 0)]
|
|
101
|
+
except IndexError:
|
|
102
|
+
continue
|
|
76
103
|
if 'line' in se['type']:
|
|
77
104
|
for index in range(1, len(data)):
|
|
78
|
-
pt.line(
|
|
79
|
-
|
|
105
|
+
pt.line(
|
|
106
|
+
start=data[index - 1], end=data[index], width=se.get('line_width', 1),
|
|
107
|
+
line_style=se.get('line_style', 'solid'), name=se['name'],
|
|
108
|
+
color=se.get('color', 'black'), clip=True, line_caps=se.get('line_caps', 'none'),
|
|
109
|
+
z_index=se.get('z_index', 9))
|
|
80
110
|
if 'scatter' in se['type'] and se['name'] != 'Text':
|
|
81
111
|
for each in data:
|
|
82
|
-
pt.scatter(
|
|
112
|
+
pt.scatter(
|
|
113
|
+
each[0], each[1], fill_color=se.get('fill_color', 'black'), size=se.get('size', 5),
|
|
114
|
+
stroke_color=se.get('stroke_color', se.get('color', 'black')),
|
|
115
|
+
z_index=se.get('z_index', 9)
|
|
116
|
+
)
|
|
83
117
|
if 'scatter' in se['type'] and se['name'] == 'Text' or 'text' in se['type']:
|
|
84
118
|
for each in data:
|
|
85
119
|
pt.text(*each[:2], **se)
|
|
120
|
+
if 'rect' in se['type']:
|
|
121
|
+
for each in data:
|
|
122
|
+
lb = each[:2]; width, height = each[2:4]
|
|
123
|
+
pt.rect(lb, width, height, **se)
|
|
86
124
|
|
|
87
125
|
return cv
|
|
88
126
|
|
|
89
127
|
|
|
128
|
+
def export_chart_to_pdf(cvs, file_name: str = "", file_path: str = "", **kwargs):
|
|
129
|
+
"""
|
|
130
|
+
|
|
131
|
+
Parameters
|
|
132
|
+
----------
|
|
133
|
+
file_path: str
|
|
134
|
+
data: dict
|
|
135
|
+
- file_name: string
|
|
136
|
+
file name, like "24WHA0001"
|
|
137
|
+
- data: list of dicts
|
|
138
|
+
properties:
|
|
139
|
+
- name: string
|
|
140
|
+
diagram name, like "Age spectra"
|
|
141
|
+
|
|
142
|
+
- xAxis: list
|
|
143
|
+
properties:
|
|
144
|
+
- extend: list
|
|
145
|
+
limits of values of axis, like [0, 100]
|
|
146
|
+
- interval: list
|
|
147
|
+
sticks location, like [0, 20, 40, 60, 80, 100]
|
|
148
|
+
- title: string
|
|
149
|
+
- name_location: string
|
|
150
|
+
axis title location, 'middle'
|
|
151
|
+
|
|
152
|
+
- yAxis: same as xAxis
|
|
153
|
+
|
|
154
|
+
- series: list
|
|
155
|
+
properties:
|
|
156
|
+
- type: string
|
|
157
|
+
series type, 'line', 'scatter', 'text', and any string contains these characters
|
|
158
|
+
- id: string
|
|
159
|
+
- name: string
|
|
160
|
+
- color: string or list
|
|
161
|
+
color for outlines, color name | RGB triplet | Hex color code
|
|
162
|
+
- fill_color: string or list
|
|
163
|
+
color for filling markers, format is similar to that of color
|
|
164
|
+
- data: 2-dimensional array
|
|
165
|
+
[[x1, y1], [x2, y2], ...]
|
|
166
|
+
- axis_index: int
|
|
167
|
+
index of axis to combine with, which is useful for plotting on different scales.
|
|
168
|
+
|
|
169
|
+
optional:
|
|
170
|
+
- line_caps: string
|
|
171
|
+
for lines only, 'square', 'none', 'butt'
|
|
172
|
+
- text: string
|
|
173
|
+
for texts only
|
|
174
|
+
- size: int
|
|
175
|
+
for scatters only
|
|
176
|
+
**kwargs:
|
|
177
|
+
author, producer, creator, page_size, ppi, ...
|
|
178
|
+
|
|
179
|
+
Returns
|
|
180
|
+
-------
|
|
181
|
+
|
|
182
|
+
"""
|
|
183
|
+
# write pdf
|
|
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):
|
|
218
|
+
file.add_page()
|
|
219
|
+
|
|
220
|
+
# save pdf
|
|
221
|
+
file.save()
|
|
222
|
+
|
|
223
|
+
return file_path
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def get_plot_data(smp: Sample, diagram: str = 'age spectra', **options):
|
|
227
|
+
"""
|
|
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
|
+
|
|
247
|
+
Parameters
|
|
248
|
+
----------
|
|
249
|
+
smp
|
|
250
|
+
diagram
|
|
251
|
+
color
|
|
252
|
+
options
|
|
253
|
+
|
|
254
|
+
Returns
|
|
255
|
+
-------
|
|
256
|
+
|
|
257
|
+
"""
|
|
258
|
+
if diagram.lower() == "age spectra":
|
|
259
|
+
xAxis, yAxis = _get_plot_data_age_spectra_axis(smp, **options)
|
|
260
|
+
elif diagram.lower() == "inverse isochron":
|
|
261
|
+
xAxis, yAxis = _get_plot_data_inv_isochron_axis(smp, **options)
|
|
262
|
+
elif "degas spectra" in diagram.lower():
|
|
263
|
+
xAxis, yAxis = _get_plot_data_degas_spectra_axis(smp, diagram_name = diagram.lower(), **options)
|
|
264
|
+
elif "degas curve" in diagram.lower():
|
|
265
|
+
xAxis, yAxis = _get_plot_data_degas_curve_axis(smp, diagram_name = diagram.lower(), **options)
|
|
266
|
+
else:
|
|
267
|
+
raise KeyError
|
|
268
|
+
return xAxis, yAxis
|
|
269
|
+
|
|
270
|
+
|
|
271
|
+
def get_plot_series_data(smp: Sample, diagram: str = 'age spectra', **options):
|
|
272
|
+
"""
|
|
273
|
+
|
|
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
|
|
297
|
+
|
|
298
|
+
|
|
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):
|
|
310
|
+
color = options.get('color', 'black')
|
|
311
|
+
sigma = options.get('sigma', 1)
|
|
312
|
+
xAxis = options.get('xAxis', [{}])
|
|
313
|
+
yAxis = options.get('yAxis', [{}])
|
|
314
|
+
series = []
|
|
315
|
+
age = smp.ApparentAgeValues[2:4]
|
|
316
|
+
ar = smp.DegasValues[20]
|
|
317
|
+
data = spectra.get_data(*age, ar, cumulative=False)
|
|
318
|
+
series.append({
|
|
319
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
|
|
320
|
+
'color': color, 'fill_color': color, 'line_width': 1, 'line_style': 'solid', 'z_index': 9,
|
|
321
|
+
'data': np.transpose([data[0], data[1]]).tolist(), 'line_caps': 'square',
|
|
322
|
+
'axis_index': 0,
|
|
323
|
+
})
|
|
324
|
+
series.append({
|
|
325
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
|
|
326
|
+
'color': color, 'fill_color': color, 'line_width': 1, 'line_style': 'solid', 'z_index': 9,
|
|
327
|
+
'data': np.transpose([data[0], data[2]]).tolist(), 'line_caps': 'square',
|
|
328
|
+
'axis_index': 0,
|
|
329
|
+
})
|
|
330
|
+
text1 = smp.AgeSpectraPlot.text1
|
|
331
|
+
text2 = smp.AgeSpectraPlot.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']):
|
|
356
|
+
series.append({
|
|
357
|
+
'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}', 'name': f'text-{smp.name()}-{get_random_digits()}',
|
|
358
|
+
'color': color, 'fill_color': color,
|
|
359
|
+
'text': f"TGA = {tga['age']:.2f} ± {(sigma * tga['s3']):.2f} Ma",
|
|
360
|
+
'size': title_size,
|
|
361
|
+
'data': [[50, 3]],
|
|
362
|
+
'axis_index': 1,
|
|
363
|
+
'h_align': "middle",
|
|
364
|
+
'v_align': "bottom",
|
|
365
|
+
})
|
|
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
|
+
|
|
393
|
+
xAxis.append({
|
|
394
|
+
'extent': [0, 100], 'interval': [0, 20, 40, 60, 80, 100], 'id': 0, 'show_frame': True,
|
|
395
|
+
'title': 'Cumulative <sup>39</sup>Ar Released (%)', 'name_location': 'middle',
|
|
396
|
+
'line_width': 1, 'line_style': 'solid', 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
397
|
+
})
|
|
398
|
+
xAxis.append({
|
|
399
|
+
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
400
|
+
'title': '', 'name_location': 'middle',
|
|
401
|
+
'line_width': 1, 'line_style': 'solid', 'z_index': 0, 'label_size': label_size, 'title_size': title_size,
|
|
402
|
+
})
|
|
403
|
+
yAxis.append({
|
|
404
|
+
'extent': y_extent, 'interval': y_interval,
|
|
405
|
+
'id': 0, 'show_frame': True,
|
|
406
|
+
'title': 'Apparent Age (Ma)', 'name_location': 'middle',
|
|
407
|
+
'line_width': 1, 'line_style': 'solid', 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
408
|
+
})
|
|
409
|
+
yAxis.append({
|
|
410
|
+
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
411
|
+
'title': '', 'name_location': 'middle',
|
|
412
|
+
'line_width': 1, 'line_style': 'solid', 'z_index': 0, 'label_size': label_size, 'title_size': title_size,
|
|
413
|
+
})
|
|
414
|
+
return xAxis, yAxis
|
|
415
|
+
|
|
416
|
+
|
|
417
|
+
def _get_plot_data_inv_isochron_axis(smp: sample, **options):
|
|
418
|
+
color = options.get('color', 'black')
|
|
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 = []
|
|
470
|
+
age = smp.ApparentAgeValues[2:4]
|
|
471
|
+
ar = smp.DegasValues[20]
|
|
472
|
+
data = np.array(smp.InvIsochronPlot.data)
|
|
473
|
+
set1 = smp.InvIsochronPlot.set1.data
|
|
474
|
+
set2 = smp.InvIsochronPlot.set2.data
|
|
475
|
+
set3 = smp.InvIsochronPlot.set3.data
|
|
476
|
+
# set 1
|
|
477
|
+
series.append({
|
|
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,
|
|
480
|
+
'data': (data[[0, 2], :][:, set1]).transpose().tolist(),
|
|
481
|
+
'axis_index': 0, 'z_index': 99
|
|
482
|
+
})
|
|
483
|
+
# set 2
|
|
484
|
+
series.append({
|
|
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,
|
|
487
|
+
'data': (data[[0, 2], :][:, set2]).transpose().tolist(),
|
|
488
|
+
'axis_index': 0, 'z_index': 99
|
|
489
|
+
})
|
|
490
|
+
# set 3
|
|
491
|
+
series.append({
|
|
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,
|
|
494
|
+
'data': (data[[0, 2], :][:, set3]).transpose().tolist(),
|
|
495
|
+
'axis_index': 0, 'z_index': 0
|
|
496
|
+
})
|
|
497
|
+
|
|
498
|
+
text1 = smp.InvIsochronPlot.text1
|
|
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
|
+
})
|
|
525
|
+
|
|
526
|
+
series.append({
|
|
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",
|
|
532
|
+
})
|
|
533
|
+
|
|
534
|
+
return series
|
|
535
|
+
|
|
536
|
+
|
|
537
|
+
def _get_plot_data_degas_pattern(smp: sample, **options):
|
|
538
|
+
color = options.get('color', 'black')
|
|
539
|
+
plot = smp.DegasPatternPlot
|
|
540
|
+
xAxis, yAxis, series = [], [], []
|
|
541
|
+
argon = smp.DegasValues[20] # Ar39K as default
|
|
542
|
+
while argon[-1] == 0:
|
|
543
|
+
argon = argon[:-1]
|
|
544
|
+
y = [argon[i] / sum(argon[i:]) * 100 for i in range(len(argon))]
|
|
545
|
+
x = list(range(1, len(argon) + 1))
|
|
546
|
+
data = np.array([x, y])
|
|
547
|
+
# set 1
|
|
548
|
+
series.append({
|
|
549
|
+
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_digits()}', 'name': f'scatter-{smp.name()}-{get_random_digits()}',
|
|
550
|
+
'stroke_color': color, 'fill_color': 'white', 'myType': 'scatter', 'size': 4, 'line_width': 1,
|
|
551
|
+
'data': data.transpose().tolist(), 'axis_index': 0, 'z_index': 99
|
|
552
|
+
})
|
|
553
|
+
|
|
554
|
+
xaxis = plot.xaxis
|
|
555
|
+
yaxis = plot.yaxis
|
|
556
|
+
|
|
557
|
+
xaxis.min = 0
|
|
558
|
+
xaxis.max = 100
|
|
559
|
+
xaxis.interval = 20
|
|
560
|
+
xaxis.split_number = 5
|
|
561
|
+
yaxis.min = 0
|
|
562
|
+
yaxis.max = 20
|
|
563
|
+
yaxis.interval = 5
|
|
564
|
+
yaxis.split_number = 4
|
|
565
|
+
|
|
566
|
+
xAxis.append({
|
|
567
|
+
'extent': [float(xaxis.min), float(xaxis.max)],
|
|
568
|
+
'interval': [float("{:g}".format(float(xaxis.min) + i * float(xaxis.interval))) for i in range(int(xaxis.split_number) + 1)],
|
|
569
|
+
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
570
|
+
'title': 'XXXX', 'name_location': 'middle',
|
|
571
|
+
})
|
|
572
|
+
yAxis.append({
|
|
573
|
+
'extent': [float(yaxis.min), float(yaxis.max)],
|
|
574
|
+
'interval': [float("{:g}".format(float(yaxis.min) + i * float(yaxis.interval))) for i in range(int(yaxis.split_number) + 1)],
|
|
575
|
+
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
576
|
+
'title': 'YYYY', 'name_location': 'middle',
|
|
577
|
+
})
|
|
578
|
+
return xAxis, yAxis, series
|
|
579
|
+
|
|
580
|
+
|
|
581
|
+
def _get_plot_data_degas_spectra_axis(smp: sample, **options):
|
|
582
|
+
name = options.get('diagram_name', '39Ar')
|
|
583
|
+
color = options.get('color', 'black')
|
|
584
|
+
plot = smp.DegasPatternPlot
|
|
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 = []
|
|
620
|
+
nindex = {"40": 24, "39": 20, "38": 10, "37": 8, "36": 0}
|
|
621
|
+
if name[:2] in list(nindex.keys()):
|
|
622
|
+
ar = np.array(smp.DegasValues[nindex[name[:2]]], dtype=np.float64) # 20-21 Ar39
|
|
623
|
+
sar = np.array(smp.DegasValues[nindex[name[:2]] + 1], dtype=np.float64)
|
|
624
|
+
elif 'total' in name:
|
|
625
|
+
all_ar = np.array(smp.CorrectedValues, dtype=np.float64) # 20-21 Ar39
|
|
626
|
+
ar, sar = arr.add(*all_ar.reshape(5, 2, len(all_ar[0])))
|
|
627
|
+
ar = np.array(ar); sar = np.array(sar)
|
|
628
|
+
else:
|
|
629
|
+
raise KeyError
|
|
630
|
+
|
|
631
|
+
while ar[-1] == 0:
|
|
632
|
+
ar = ar[:-1]
|
|
633
|
+
x = list(range(0, len(ar)))
|
|
634
|
+
y = [0 for i in range(len(ar))]
|
|
635
|
+
width = [1 for i in range(len(ar))]
|
|
636
|
+
height = [ar[i] / sum(ar) * 100 for i in range(len(ar))]
|
|
637
|
+
data = np.array([x, y, width, height])
|
|
638
|
+
|
|
639
|
+
# set 1
|
|
640
|
+
series.append({
|
|
641
|
+
'type': 'rect', 'id': f'rect-{smp.name()}-{get_random_digits()}', 'name': f'rect-{smp.name()}-{get_random_digits()}',
|
|
642
|
+
'color': color, 'myType': 'rect', 'line_width': 1,
|
|
643
|
+
'data': data.transpose().tolist(),
|
|
644
|
+
'axis_index': 0, 'z_index': 99
|
|
645
|
+
})
|
|
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 = [], []
|
|
654
|
+
xAxis.append({
|
|
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,
|
|
658
|
+
'title': 'Steps [n]', 'name_location': 'middle',
|
|
659
|
+
})
|
|
660
|
+
yAxis.append({
|
|
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',
|
|
665
|
+
})
|
|
666
|
+
return xAxis, yAxis
|
|
667
|
+
|
|
668
|
+
|
|
669
|
+
def _get_plot_data_degas_curve_series(smp: sample, **options):
|
|
670
|
+
name = options.get('diagram_name', '39Ar')
|
|
671
|
+
color = options.get('color', 'black')
|
|
672
|
+
xAxis = options.get('xAxis', [{}])
|
|
673
|
+
yAxis = options.get('yAxis', [{}])
|
|
674
|
+
series = []
|
|
675
|
+
nindex = {"40": 24, "39": 20, "38": 10, "37": 8, "36": 0}
|
|
676
|
+
if name[:2] in list(nindex.keys()):
|
|
677
|
+
ar = np.array(smp.DegasValues[nindex[name[:2]]], dtype=np.float64) # 20-21 Ar39
|
|
678
|
+
sar = np.array(smp.DegasValues[nindex[name[:2]] + 1], dtype=np.float64)
|
|
679
|
+
elif 'total' in name:
|
|
680
|
+
all_ar = np.array(smp.CorrectedValues, dtype=np.float64) # 20-21 Ar39
|
|
681
|
+
ar, sar = arr.add(*all_ar.reshape(5, 2, len(all_ar[0])))
|
|
682
|
+
ar = np.array(ar); sar = np.array(sar)
|
|
683
|
+
else:
|
|
684
|
+
raise KeyError
|
|
685
|
+
|
|
686
|
+
while ar[-1] == 0:
|
|
687
|
+
ar = ar[:-1]
|
|
688
|
+
x = list(range(0, len(ar) + 1))
|
|
689
|
+
f = ar / sum(ar) * 100
|
|
690
|
+
released = np.zeros(len(ar) + 1)
|
|
691
|
+
remained = np.zeros(len(ar) + 1) + 100
|
|
692
|
+
for i in range(1, len(ar) + 1):
|
|
693
|
+
released[i] = sum(f[:i])
|
|
694
|
+
remained[i] = 100 - released[i]
|
|
695
|
+
|
|
696
|
+
# line
|
|
697
|
+
series.append({
|
|
698
|
+
'type': 'line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
|
|
699
|
+
'color': color, 'myType': 'line', 'line_width': 1, 'line_style': 'solid',
|
|
700
|
+
'data': np.array([x, released]).transpose().tolist(),
|
|
701
|
+
'axis_index': 0, 'z_index': 99
|
|
702
|
+
})
|
|
703
|
+
series.append({
|
|
704
|
+
'type': 'line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
|
|
705
|
+
'color': color, 'myType': 'line', 'line_width': 1, 'line_style': 'solid',
|
|
706
|
+
'data': np.array([x, remained]).transpose().tolist(),
|
|
707
|
+
'axis_index': 0, 'z_index': 99
|
|
708
|
+
})
|
|
709
|
+
|
|
710
|
+
return series
|
|
711
|
+
|
|
712
|
+
|
|
90
713
|
class ExcelTemplate:
|
|
91
714
|
def __init__(self, **kwargs):
|
|
92
715
|
self.name = ""
|
|
@@ -168,31 +791,42 @@ class WritingWorkbook:
|
|
|
168
791
|
]
|
|
169
792
|
# writing header
|
|
170
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
|
+
|
|
171
798
|
# Data for age spectra
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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
|
+
|
|
186
817
|
# Data for normal isochron
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
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
|
|
196
830
|
try:
|
|
197
831
|
sht_reference.write_column(f"U{start_row}", self.sample.NorIsochronPlot.line1.data[0], style)
|
|
198
832
|
except IndexError:
|
|
@@ -209,16 +843,20 @@ class WritingWorkbook:
|
|
|
209
843
|
sht_reference.write_column(f"X{start_row}", self.sample.NorIsochronPlot.line2.data[1], style)
|
|
210
844
|
except IndexError:
|
|
211
845
|
pass
|
|
846
|
+
|
|
212
847
|
# Data for inverse isochron
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
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
|
|
222
860
|
try:
|
|
223
861
|
sht_reference.write_column(f"AE{start_row}", self.sample.InvIsochronPlot.line1.data[0], style)
|
|
224
862
|
except IndexError:
|
|
@@ -235,16 +873,20 @@ class WritingWorkbook:
|
|
|
235
873
|
sht_reference.write_column(f"AH{start_row}", self.sample.InvIsochronPlot.line2.data[1], style)
|
|
236
874
|
except IndexError:
|
|
237
875
|
pass
|
|
876
|
+
|
|
238
877
|
# Data for Cl 1 isochron
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
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
|
|
248
890
|
try:
|
|
249
891
|
sht_reference.write_column(f"AO{start_row}", self.sample.KClAr1IsochronPlot.line1.data[0], style)
|
|
250
892
|
except IndexError:
|
|
@@ -261,16 +903,20 @@ class WritingWorkbook:
|
|
|
261
903
|
sht_reference.write_column(f"AR{start_row}", self.sample.KClAr1IsochronPlot.line2.data[1], style)
|
|
262
904
|
except IndexError:
|
|
263
905
|
pass
|
|
906
|
+
|
|
264
907
|
# Data for Cl 2 isochron
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
|
274
920
|
try:
|
|
275
921
|
sht_reference.write_column(f"AY{start_row}", self.sample.KClAr2IsochronPlot.line1.data[0], style)
|
|
276
922
|
except IndexError:
|
|
@@ -287,16 +933,20 @@ class WritingWorkbook:
|
|
|
287
933
|
sht_reference.write_column(f"BB{start_row}", self.sample.KClAr2IsochronPlot.line2.data[1], style)
|
|
288
934
|
except IndexError:
|
|
289
935
|
pass
|
|
936
|
+
|
|
290
937
|
# Data for Cl 3 isochron
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
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
|
|
300
950
|
try:
|
|
301
951
|
sht_reference.write_column(f"BI{start_row}", self.sample.KClAr3IsochronPlot.line1.data[0], style)
|
|
302
952
|
except IndexError:
|
|
@@ -313,19 +963,23 @@ class WritingWorkbook:
|
|
|
313
963
|
sht_reference.write_column(f"BL{start_row}", self.sample.KClAr3IsochronPlot.line2.data[1], style)
|
|
314
964
|
except IndexError:
|
|
315
965
|
pass
|
|
966
|
+
|
|
316
967
|
# Data for degas pattern
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
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
|
|
329
983
|
|
|
330
984
|
sht_result = xls.add_worksheet('Results')
|
|
331
985
|
title_style = xls.add_format({
|
|
@@ -430,165 +1084,17 @@ class WritingWorkbook:
|
|
|
430
1084
|
continue
|
|
431
1085
|
|
|
432
1086
|
for sht_name, [prop_name, sht_type, row, col, _, smp_attr_name, header_name] in self.template.sheet():
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
xls.close()
|
|
445
|
-
return None
|
|
446
|
-
col += 1
|
|
447
|
-
elif sht_type == "chart":
|
|
448
|
-
sht = xls.add_chartsheet(sht_name)
|
|
449
|
-
sht.set_paper(1) # US letter = 1, A4 = 9, letter is more rectangular
|
|
450
|
-
num_unselected = len(self.sample.UnselectedSequence)
|
|
451
|
-
num_set1 = len(self.sample.SelectedSequence1)
|
|
452
|
-
num_set2 = len(self.sample.SelectedSequence2)
|
|
453
|
-
if "spectra" in prop_name.lower():
|
|
454
|
-
figure = self.sample.AgeSpectraPlot
|
|
455
|
-
data_area = [
|
|
456
|
-
# Spectra lines
|
|
457
|
-
f"A{start_row}:A{len(spectra_data[0]) + start_row - 1}",
|
|
458
|
-
f"B{start_row}:B{len(spectra_data[0]) + start_row - 1}",
|
|
459
|
-
f"C{start_row}:C{len(spectra_data[0]) + start_row - 1}",
|
|
460
|
-
# set 1
|
|
461
|
-
f"D{start_row}:D{len(spectra_data[0]) + start_row - 1}",
|
|
462
|
-
f"E{start_row}:E{len(spectra_data[0]) + start_row - 1}",
|
|
463
|
-
f"F{start_row}:F{len(spectra_data[0]) + start_row - 1}",
|
|
464
|
-
# set 2
|
|
465
|
-
f"G{start_row}:G{len(spectra_data[0]) + start_row - 1}",
|
|
466
|
-
f"H{start_row}:H{len(spectra_data[0]) + start_row - 1}",
|
|
467
|
-
f"I{start_row}:I{len(spectra_data[0]) + start_row - 1}",
|
|
468
|
-
]
|
|
469
|
-
axis_range = [figure.xaxis.min, figure.xaxis.max, figure.yaxis.min, figure.yaxis.max]
|
|
470
|
-
self.get_chart_age_spectra(xls, sht, data_area, axis_range)
|
|
471
|
-
elif "normal_isochron" in prop_name.lower():
|
|
472
|
-
data_area = [
|
|
473
|
-
f"O{start_row}:O{num_set1 + start_row - 1}", f"P{start_row}:P{num_set1 + start_row - 1}",
|
|
474
|
-
f"Q{start_row}:Q{num_set2 + start_row - 1}", f"R{start_row}:R{num_set2 + start_row - 1}",
|
|
475
|
-
f"S{start_row}:S{num_unselected + start_row - 1}",
|
|
476
|
-
f"T{start_row}:T{num_unselected + start_row - 1}",
|
|
477
|
-
f"U{start_row}:V{start_row}", f"U{start_row + 1}:V{start_row + 1}",
|
|
478
|
-
f"W{start_row}:X{start_row}", f"W{start_row + 1}:X{start_row + 1}",
|
|
479
|
-
]
|
|
480
|
-
axis_range = [
|
|
481
|
-
basic.get_component_byid(self.sample, 'figure_2').xaxis.min,
|
|
482
|
-
basic.get_component_byid(self.sample, 'figure_2').xaxis.max,
|
|
483
|
-
basic.get_component_byid(self.sample, 'figure_2').yaxis.min,
|
|
484
|
-
basic.get_component_byid(self.sample, 'figure_2').yaxis.max,
|
|
485
|
-
]
|
|
486
|
-
self.get_chart_isochron(
|
|
487
|
-
xls, sht, data_area, axis_range, title_name="Normal Isochron",
|
|
488
|
-
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_36}Ar",
|
|
489
|
-
y_axis_name=f"{consts.sup_40}Ar / {consts.sup_36}Ar")
|
|
490
|
-
elif "inverse_isochron" in prop_name.lower():
|
|
491
|
-
data_area = [
|
|
492
|
-
f"Y{start_row}:Y{num_set1 + start_row - 1}", f"Z{start_row}:Z{num_set1 + start_row - 1}",
|
|
493
|
-
f"AA{start_row}:AA{num_set2 + start_row - 1}", f"AB{start_row}:AB{num_set2 + start_row - 1}",
|
|
494
|
-
f"AC{start_row}:AC{num_unselected + start_row - 1}",
|
|
495
|
-
f"AD{start_row}:AD{num_unselected + start_row - 1}",
|
|
496
|
-
f"AE{start_row}:AF{start_row}", f"AE{start_row + 1}:AF{start_row + 1}",
|
|
497
|
-
f"AG{start_row}:AH{start_row}", f"AG{start_row + 1}:AH{start_row + 1}",
|
|
498
|
-
]
|
|
499
|
-
axis_range = [
|
|
500
|
-
basic.get_component_byid(self.sample, 'figure_3').xaxis.min,
|
|
501
|
-
basic.get_component_byid(self.sample, 'figure_3').xaxis.max,
|
|
502
|
-
basic.get_component_byid(self.sample, 'figure_3').yaxis.min,
|
|
503
|
-
basic.get_component_byid(self.sample, 'figure_3').yaxis.max,
|
|
504
|
-
]
|
|
505
|
-
self.get_chart_isochron(
|
|
506
|
-
xls, sht, data_area, axis_range, title_name="Inverse Isochron",
|
|
507
|
-
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_40}Ar",
|
|
508
|
-
y_axis_name=f"{consts.sup_36}Ar / {consts.sup_40}Ar")
|
|
509
|
-
elif "k-cl-ar_1_isochron" in prop_name.lower():
|
|
510
|
-
data_area = [
|
|
511
|
-
f"AI{start_row}:AI{num_set1 + start_row - 1}", f"AJ{start_row}:AJ{num_set1 + start_row - 1}",
|
|
512
|
-
f"AK{start_row}:AK{num_set2 + start_row - 1}", f"AL{start_row}:AL{num_set2 + start_row - 1}",
|
|
513
|
-
f"AM{start_row}:AM{num_unselected + start_row - 1}",
|
|
514
|
-
f"AN{start_row}:AN{num_unselected + start_row - 1}",
|
|
515
|
-
f"AO{start_row}:AP{start_row}", f"AO{start_row + 1}:AP{start_row + 1}",
|
|
516
|
-
f"AQ{start_row}:AR{start_row}", f"AQ{start_row + 1}:AR{start_row + 1}",
|
|
517
|
-
]
|
|
518
|
-
axis_range = [
|
|
519
|
-
basic.get_component_byid(self.sample, 'figure_4').xaxis.min,
|
|
520
|
-
basic.get_component_byid(self.sample, 'figure_4').xaxis.max,
|
|
521
|
-
basic.get_component_byid(self.sample, 'figure_4').yaxis.min,
|
|
522
|
-
basic.get_component_byid(self.sample, 'figure_4').yaxis.max,
|
|
523
|
-
]
|
|
524
|
-
self.get_chart_isochron(
|
|
525
|
-
xls, sht, data_area, axis_range, title_name="K-Cl-Ar 1 Isochron",
|
|
526
|
-
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_38}Ar",
|
|
527
|
-
y_axis_name=f"{consts.sup_40}Ar / {consts.sup_38}Ar")
|
|
528
|
-
elif "k-cl-ar_2_isochron" in prop_name.lower():
|
|
529
|
-
data_area = [
|
|
530
|
-
f"AS{start_row}:AS{num_set1 + start_row - 1}", f"AT{start_row}:AT{num_set1 + start_row - 1}",
|
|
531
|
-
f"AU{start_row}:AU{num_set2 + start_row - 1}", f"AV{start_row}:AV{num_set2 + start_row - 1}",
|
|
532
|
-
f"AW{start_row}:AW{num_unselected + start_row - 1}",
|
|
533
|
-
f"AX{start_row}:AX{num_unselected + start_row - 1}",
|
|
534
|
-
f"AY{start_row}:AZ{start_row}", f"AY{start_row + 1}:AZ{start_row + 1}",
|
|
535
|
-
f"BA{start_row}:BB{start_row}", f"BA{start_row + 1}:BB{start_row + 1}",
|
|
536
|
-
]
|
|
537
|
-
axis_range = [
|
|
538
|
-
basic.get_component_byid(self.sample, 'figure_5').xaxis.min,
|
|
539
|
-
basic.get_component_byid(self.sample, 'figure_5').xaxis.max,
|
|
540
|
-
basic.get_component_byid(self.sample, 'figure_5').yaxis.min,
|
|
541
|
-
basic.get_component_byid(self.sample, 'figure_5').yaxis.max,
|
|
542
|
-
]
|
|
543
|
-
self.get_chart_isochron(
|
|
544
|
-
xls, sht, data_area, axis_range, title_name="K-Cl-Ar 2 Isochron",
|
|
545
|
-
x_axis_name=f"{consts.sup_39}Ar / {consts.sup_40}Ar",
|
|
546
|
-
y_axis_name=f"{consts.sup_38}Ar / {consts.sup_40}Ar")
|
|
547
|
-
elif "k-cl-ar_3_isochron" in prop_name.lower():
|
|
548
|
-
data_area = [
|
|
549
|
-
f"BC{start_row}:BC{num_set1 + start_row - 1}", f"BD{start_row}:BD{num_set1 + start_row - 1}",
|
|
550
|
-
f"BE{start_row}:BE{num_set2 + start_row - 1}", f"BF{start_row}:BF{num_set2 + start_row - 1}",
|
|
551
|
-
f"BG{start_row}:BG{num_unselected + start_row - 1}",
|
|
552
|
-
f"BH{start_row}:BH{num_unselected + start_row - 1}",
|
|
553
|
-
f"BI{start_row}:BJ{start_row}", f"BI{start_row + 1}:BJ{start_row + 1}",
|
|
554
|
-
f"BK{start_row}:BL{start_row}", f"BK{start_row + 1}:BL{start_row + 1}",
|
|
555
|
-
]
|
|
556
|
-
axis_range = [
|
|
557
|
-
basic.get_component_byid(self.sample, 'figure_6').xaxis.min,
|
|
558
|
-
basic.get_component_byid(self.sample, 'figure_6').xaxis.max,
|
|
559
|
-
basic.get_component_byid(self.sample, 'figure_6').yaxis.min,
|
|
560
|
-
basic.get_component_byid(self.sample, 'figure_6').yaxis.max,
|
|
561
|
-
]
|
|
562
|
-
self.get_chart_isochron(
|
|
563
|
-
xls, sht, data_area, axis_range, title_name="K-Cl-Ar 3 Isochron",
|
|
564
|
-
x_axis_name=f"{consts.sup_38}Ar / {consts.sup_39}Ar",
|
|
565
|
-
y_axis_name=f"{consts.sup_40}Ar / {consts.sup_39}Ar")
|
|
566
|
-
elif "degas_pattern" in prop_name.lower():
|
|
567
|
-
data_area = [
|
|
568
|
-
f"BM{start_row}:BM{len(degas_data[0]) + start_row - 1}",
|
|
569
|
-
f"BN{start_row}:BN{len(degas_data[1]) + start_row - 1}",
|
|
570
|
-
f"BO{start_row}:BO{len(degas_data[2]) + start_row - 1}",
|
|
571
|
-
f"BP{start_row}:BP{len(degas_data[3]) + start_row - 1}",
|
|
572
|
-
f"BQ{start_row}:BQ{len(degas_data[4]) + start_row - 1}",
|
|
573
|
-
f"BR{start_row}:BR{len(degas_data[5]) + start_row - 1}",
|
|
574
|
-
f"BS{start_row}:BS{len(degas_data[6]) + start_row - 1}",
|
|
575
|
-
f"BT{start_row}:BT{len(degas_data[7]) + start_row - 1}",
|
|
576
|
-
f"BU{start_row}:BU{len(degas_data[8]) + start_row - 1}",
|
|
577
|
-
f"BV{start_row}:BV{len(degas_data[9]) + start_row - 1}",
|
|
578
|
-
f"BW{start_row}:BW{len(degas_data[9]) + start_row - 1}",
|
|
579
|
-
]
|
|
580
|
-
axis_range = [
|
|
581
|
-
basic.get_component_byid(self.sample, 'figure_8').xaxis.min,
|
|
582
|
-
basic.get_component_byid(self.sample, 'figure_8').xaxis.max,
|
|
583
|
-
basic.get_component_byid(self.sample, 'figure_8').yaxis.min,
|
|
584
|
-
basic.get_component_byid(self.sample, 'figure_8').yaxis.max,
|
|
585
|
-
]
|
|
586
|
-
self.get_chart_degas_pattern(
|
|
587
|
-
xls, sht, data_area, axis_range,
|
|
588
|
-
title_name="Degas Pattern", x_axis_name=f"Sequence",
|
|
589
|
-
y_axis_name=f"Argon Isotopes (%)")
|
|
590
|
-
else:
|
|
591
|
-
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())
|
|
592
1098
|
return None
|
|
593
1099
|
xls.get_worksheet_by_name("Reference").hide()
|
|
594
1100
|
xls.get_worksheet_by_name("Isochrons").hidden = 0 # unhiden isochrons worksheet
|
|
@@ -597,6 +1103,163 @@ class WritingWorkbook:
|
|
|
597
1103
|
print('导出完毕,文件路径:%s' % self.filepath)
|
|
598
1104
|
return True
|
|
599
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
|
+
|
|
600
1263
|
def create_initial_chart(self, xls: Workbook, chart_type: str = 'scatter'):
|
|
601
1264
|
# chartarea
|
|
602
1265
|
chartarea_dict = {'border': {'none': True}, 'fill': {'color': self.chartarea_color}}
|
|
@@ -775,8 +1438,8 @@ class WritingWorkbook:
|
|
|
775
1438
|
# chart.title_name = title_name
|
|
776
1439
|
for each in series:
|
|
777
1440
|
chart.add_series(each)
|
|
778
|
-
|
|
779
|
-
|
|
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]})
|
|
780
1443
|
|
|
781
1444
|
chart.set_legend({'none': False, 'position': 'top'})
|
|
782
1445
|
|
|
@@ -1163,7 +1826,7 @@ class CreatePDF:
|
|
|
1163
1826
|
y=(yaxis_max - yaxis_min) * pos[1] + yaxis_min,
|
|
1164
1827
|
text=f"Age ={age} {chr(0xb1)} {sage} Ma<r>F = {F} {chr(0xb1)} {sF}<r>"
|
|
1165
1828
|
f"R<sub>0</sub> = {R0} {chr(0xb1)} {sR0}<r>"
|
|
1166
|
-
f"{MSWD = },
|
|
1829
|
+
f"{MSWD = }, r<sup>2</sup> = {R2}<r>"
|
|
1167
1830
|
f"{Chisq = }, {p = }",
|
|
1168
1831
|
size=10, clip=True, coordinate="scale", h_align="left", v_align="bottom",
|
|
1169
1832
|
color=color, rotate=0, z_index=150)
|