ararpy 0.1.199__py3-none-any.whl → 0.2.1__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/Example - Check arr.py +52 -0
- ararpy/Example - Granite Cooling History.py +411 -0
- ararpy/Example - Plot temperature calibration.py +291 -0
- ararpy/Example - Show MDD results.py +561 -0
- ararpy/Example - Show all Kfs age spectra.py +344 -0
- ararpy/Example - Show random walk results.py +363 -0
- ararpy/Example - Tc calculation.py +437 -0
- ararpy/__init__.py +3 -4
- ararpy/calc/age.py +34 -36
- ararpy/calc/arr.py +0 -20
- ararpy/calc/basic.py +26 -3
- ararpy/calc/corr.py +131 -85
- ararpy/calc/plot.py +1 -2
- ararpy/calc/raw_funcs.py +41 -2
- ararpy/calc/regression.py +224 -132
- ararpy/files/arr_file.py +2 -1
- ararpy/files/basic.py +0 -22
- ararpy/files/calc_file.py +107 -84
- ararpy/files/raw_file.py +242 -229
- ararpy/smp/basic.py +133 -34
- ararpy/smp/calculation.py +6 -6
- ararpy/smp/corr.py +339 -153
- ararpy/smp/diffusion_funcs.py +345 -36
- ararpy/smp/export.py +247 -129
- ararpy/smp/info.py +2 -2
- ararpy/smp/initial.py +93 -45
- ararpy/smp/json.py +2 -2
- ararpy/smp/plots.py +144 -164
- ararpy/smp/raw.py +11 -15
- ararpy/smp/sample.py +222 -181
- ararpy/smp/style.py +26 -7
- ararpy/smp/table.py +42 -33
- ararpy/thermo/atomic_level_random_walk.py +56 -48
- ararpy/thermo/basic.py +2 -2
- {ararpy-0.1.199.dist-info → ararpy-0.2.1.dist-info}/METADATA +1 -1
- ararpy-0.2.1.dist-info/RECORD +73 -0
- {ararpy-0.1.199.dist-info → ararpy-0.2.1.dist-info}/WHEEL +1 -1
- ararpy-0.1.199.dist-info/RECORD +0 -66
- {ararpy-0.1.199.dist-info → ararpy-0.2.1.dist-info}/licenses/LICENSE +0 -0
- {ararpy-0.1.199.dist-info → ararpy-0.2.1.dist-info}/top_level.txt +0 -0
ararpy/smp/export.py
CHANGED
|
@@ -19,18 +19,26 @@ import pickle
|
|
|
19
19
|
import traceback
|
|
20
20
|
import pdf_maker as pm
|
|
21
21
|
import numpy as np
|
|
22
|
+
from math import log
|
|
22
23
|
from decimal import Decimal
|
|
23
24
|
|
|
24
25
|
from ..calc import arr, isochron, spectra, err
|
|
25
|
-
from ..calc.basic import
|
|
26
|
+
from ..calc.basic import random_choice, merge_dicts
|
|
26
27
|
from ..calc.plot import get_axis_scale
|
|
27
28
|
from . import basic, sample, consts
|
|
28
29
|
|
|
29
30
|
Sample = sample.Sample
|
|
30
31
|
Plot = sample.Plot
|
|
31
32
|
|
|
32
|
-
title_size =
|
|
33
|
-
label_size =
|
|
33
|
+
title_size = 8
|
|
34
|
+
label_size = 8
|
|
35
|
+
|
|
36
|
+
colors_map = {
|
|
37
|
+
'red': "#EF661B",
|
|
38
|
+
'blue': "#189CCA",
|
|
39
|
+
'red80': "#FFB593",
|
|
40
|
+
'blue80': "#6BD2FF",
|
|
41
|
+
}
|
|
34
42
|
|
|
35
43
|
try:
|
|
36
44
|
from webarar.settings import SETTINGS_ROOT
|
|
@@ -53,8 +61,12 @@ def get_cv_from_dict(data: dict, **kwargs):
|
|
|
53
61
|
cv = pm.Canvas(width=kwargs.get("width", 17), height=kwargs.get("height", 12),
|
|
54
62
|
unit="cm", show_frame=False, clip_outside_plot_areas=False)
|
|
55
63
|
# change frame outline style
|
|
56
|
-
if kwargs.get("show_frame",
|
|
64
|
+
if kwargs.get("show_frame", False):
|
|
57
65
|
cv.show_frame(color="grey", line_width=0.5)
|
|
66
|
+
# stick length
|
|
67
|
+
stick_length = kwargs.get("stick_length", 3)
|
|
68
|
+
ylabel_offset = kwargs.get("ylabel_offset", 2)
|
|
69
|
+
xlabel_offset = kwargs.get("xlabel_offset", 8)
|
|
58
70
|
axis_num = min([len(data['xAxis']), len(data['yAxis'])])
|
|
59
71
|
# draw axis
|
|
60
72
|
plots = []
|
|
@@ -63,28 +75,28 @@ def get_cv_from_dict(data: dict, **kwargs):
|
|
|
63
75
|
scale = (float(scale[0]), float(scale[1]), float(scale[2]), float(scale[3]))
|
|
64
76
|
# create plot area based on axis scale
|
|
65
77
|
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))
|
|
66
|
-
pt = cv.add_plot_area(name=f"PlotArea{i}", plot_area=plot_area, plot_scale=scale,
|
|
78
|
+
pt = cv.add_plot_area(name=f"PlotArea{i}", plot_area=plot_area, plot_scale=scale, **data['xAxis'][i])
|
|
67
79
|
for stick in data['xAxis'][i]['interval']:
|
|
68
80
|
start = pt.scale_to_points(float(stick), scale[2])
|
|
69
81
|
end = pt.scale_to_points(float(stick), scale[2])
|
|
70
|
-
end = (end[0], end[1] -
|
|
71
|
-
if pt.line(start=start, end=end, width=1, line_style="solid", y_clip=False, coordinate="pt", z_index=100):
|
|
72
|
-
pt.text(x=start[0], y=end[1] -
|
|
82
|
+
end = (end[0], end[1] - stick_length)
|
|
83
|
+
if pt.line(start=start, end=end, width=data['xAxis'][i].get('line_width', 1), line_style="solid", y_clip=False, coordinate="pt", z_index=100):
|
|
84
|
+
pt.text(x=start[0], y=end[1] - xlabel_offset, text=f"{stick}", clip=False, size=int(data['xAxis'][i].get('label_size', 8)),
|
|
73
85
|
coordinate="pt", h_align="middle", z_index=150)
|
|
74
86
|
for stick in data['yAxis'][i]['interval']:
|
|
75
87
|
start = pt.scale_to_points(scale[0], float(stick))
|
|
76
88
|
end = pt.scale_to_points(scale[0], float(stick))
|
|
77
|
-
end = (end[0] -
|
|
78
|
-
if pt.line(start=start, end=end, width=1, line_style="solid", x_clip=False, coordinate="pt", z_index=100):
|
|
79
|
-
pt.text(x=end[0] -
|
|
89
|
+
end = (end[0] - stick_length, end[1])
|
|
90
|
+
if pt.line(start=start, end=end, width=data['xAxis'][i].get('line_width', 1), line_style="solid", x_clip=False, coordinate="pt", z_index=100):
|
|
91
|
+
pt.text(x=end[0] - ylabel_offset, y=end[1], text=f"{stick}", clip=False, size=int(data['yAxis'][i].get('label_size', 8)),
|
|
80
92
|
coordinate="pt", h_align="right", v_align="center", z_index=150)
|
|
81
93
|
# axis titles
|
|
82
94
|
nloc = pt.scale_to_points(sum(scale[:2]) / 2, scale[2])
|
|
83
|
-
pt.text(x=nloc[0], y=nloc[1] - kwargs.get("offset_bottom", 30), text=data['xAxis'][i]
|
|
84
|
-
h_align="middle", v_align="center", z_index=150, size=int(data['xAxis'][i]
|
|
95
|
+
pt.text(x=nloc[0], y=nloc[1] - kwargs.get("offset_bottom", 30), text=data['xAxis'][i].get('title', 'title'), clip=False, coordinate="pt",
|
|
96
|
+
h_align="middle", v_align="center", z_index=150, size=int(data['xAxis'][i].get('title_size', 8)))
|
|
85
97
|
nloc = pt.scale_to_points(scale[0], sum(scale[2:4]) / 2)
|
|
86
|
-
pt.text(x=nloc[0] - kwargs.get("offset_left", 50), y=nloc[1], text=data['yAxis'][i]
|
|
87
|
-
h_align="middle", v_align="center", rotate=90, z_index=150, size=int(data['yAxis'][i]
|
|
98
|
+
pt.text(x=nloc[0] - kwargs.get("offset_left", 50), y=nloc[1], text=data['yAxis'][i].get('title', 'title'), clip=False, coordinate="pt",
|
|
99
|
+
h_align="middle", v_align="center", rotate=90, z_index=150, size=int(data['yAxis'][i].get('title_size', 8)))
|
|
88
100
|
plots.append(pt)
|
|
89
101
|
# draw series
|
|
90
102
|
for se in data['series']:
|
|
@@ -102,20 +114,23 @@ def get_cv_from_dict(data: dict, **kwargs):
|
|
|
102
114
|
except IndexError:
|
|
103
115
|
continue
|
|
104
116
|
if 'line' in se['type']:
|
|
117
|
+
se['width'] = se.get('line_width', 1)
|
|
118
|
+
se['line_style'] = se.get('line_style', 'solid')
|
|
119
|
+
se['color'] = se.get('color', 'black')
|
|
120
|
+
se['line_caps'] = se.get('line_caps', 'none')
|
|
121
|
+
se['z_index'] = int(se.get('z_index', 9))
|
|
105
122
|
for index in range(1, len(data)):
|
|
106
|
-
pt.line(
|
|
107
|
-
start=data[index - 1], end=data[index], width=se.get('line_width', 1),
|
|
108
|
-
line_style=se.get('line_style', 'solid'), name=se['name'],
|
|
109
|
-
color=se.get('color', 'black'), clip=True, line_caps=se.get('line_caps', 'none'),
|
|
110
|
-
z_index=se.get('z_index', 9))
|
|
123
|
+
pt.line(start=data[index - 1], end=data[index], **se)
|
|
111
124
|
if 'scatter' in se['type'] and se['name'] != 'Text':
|
|
125
|
+
se['fill_color'] = se.get('fill_color', 'black')
|
|
126
|
+
se['size'] = se.get('size', 5)
|
|
127
|
+
se['stroke_color'] = se.get('stroke_color', se.get('color', 'black'))
|
|
128
|
+
se['z_index'] = int(se.get('z_index', 9))
|
|
129
|
+
se['marker'] = se.get('marker', 'rec')
|
|
112
130
|
for each in data:
|
|
113
|
-
pt.scatter(
|
|
114
|
-
each[0], each[1], fill_color=se.get('fill_color', 'black'), size=se.get('size', 5),
|
|
115
|
-
stroke_color=se.get('stroke_color', se.get('color', 'black')),
|
|
116
|
-
z_index=se.get('z_index', 9)
|
|
117
|
-
)
|
|
131
|
+
pt.scatter(each[0], each[1], **se)
|
|
118
132
|
if 'scatter' in se['type'] and se['name'] == 'Text' or 'text' in se['type']:
|
|
133
|
+
se.update({'size': 10})
|
|
119
134
|
for each in data:
|
|
120
135
|
pt.text(*each[:2], **se)
|
|
121
136
|
if 'rect' in se['type']:
|
|
@@ -181,6 +196,12 @@ def export_chart_to_pdf(cvs, file_name: str = "", file_path: str = "", **kwargs)
|
|
|
181
196
|
-------
|
|
182
197
|
|
|
183
198
|
"""
|
|
199
|
+
# capital letter for label
|
|
200
|
+
def get_label(l="", num=0):
|
|
201
|
+
if num // 26 > 0:
|
|
202
|
+
return get_label(get_label(l, num // 26 - 1), num % 26)
|
|
203
|
+
return l + chr(num % 26 + 65)
|
|
204
|
+
|
|
184
205
|
# write pdf
|
|
185
206
|
show_label = kwargs.get('show_label', False)
|
|
186
207
|
num_cols = kwargs.get('num_columns', 2)
|
|
@@ -195,21 +216,12 @@ def export_chart_to_pdf(cvs, file_name: str = "", file_path: str = "", **kwargs)
|
|
|
195
216
|
file.del_obj(i)
|
|
196
217
|
file.add_page(size=page_size[kwargs.get('page_size', 'a4').lower()], unit='mm')
|
|
197
218
|
for page_index, page in enumerate(cvs):
|
|
198
|
-
|
|
199
|
-
# for x in range(0, 600, 10):
|
|
200
|
-
# file.line(page_index, start=(x, 0), end=(x, 900), style='dash', color='grey')
|
|
201
|
-
# for y in range(0, 900, 10):
|
|
202
|
-
# file.line(page_index, start=(0, y), end=(800, y), style='dash', color='grey')
|
|
203
|
-
|
|
204
|
-
numbers = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N']
|
|
205
|
-
|
|
206
219
|
for cv_index, cv in enumerate(page):
|
|
207
220
|
left = 10 + cv_index % num_cols * cv.width()
|
|
208
221
|
top = 20 + cv_index // num_cols * cv.height()
|
|
209
222
|
if show_label:
|
|
210
|
-
# file.text(page=page_index, x=left + 65, y=810 - top, text=numbers[cv_index])
|
|
211
223
|
cv._plot_areas[1].text(
|
|
212
|
-
x=5, y=95, text=
|
|
224
|
+
x=5, y=95, text=f"({str(get_label(num=cv_index)).lower()})",
|
|
213
225
|
id=f'text-label-{page_index}-{cv_index}',
|
|
214
226
|
name=f'text-label-{page_index}-{cv_index}',
|
|
215
227
|
color='black', size=title_size, axis_index=1, h_align='middle', v_align='center'
|
|
@@ -312,13 +324,13 @@ def getRectFromSpectra(data):
|
|
|
312
324
|
|
|
313
325
|
"""
|
|
314
326
|
data = np.array(data)
|
|
315
|
-
return list(map(lambda index: [data[index,0], min(data[index,[1,2]]),
|
|
327
|
+
return list(filter(lambda rect: rect[2] != 0 and rect[3] != 0, map(lambda index: [data[index,0], min(data[index,[1,2]]), abs(data[index+1,0] - data[index,0]), abs(data[index,1] - data[index,2])], list(range(len(data) - 1)))))
|
|
316
328
|
|
|
317
329
|
|
|
318
330
|
def _get_additional_text_series(name):
|
|
319
331
|
return {
|
|
320
|
-
'type': 'text', 'id': f'text-{name}-{
|
|
321
|
-
'name': f'text-{name}-{
|
|
332
|
+
'type': 'text', 'id': f'text-{name}-{random_choice()}',
|
|
333
|
+
'name': f'text-{name}-{random_choice()}', 'color': 'black',
|
|
322
334
|
'text': "", 'size': title_size,
|
|
323
335
|
'data': [[50, 50]], 'axis_index': 1,
|
|
324
336
|
'h_align': "middle", 'v_align': "center",
|
|
@@ -327,28 +339,30 @@ def _get_additional_text_series(name):
|
|
|
327
339
|
|
|
328
340
|
def _get_plot_data_age_spectra_series(smp: sample, **options):
|
|
329
341
|
color = options.get('color', 'black')
|
|
330
|
-
sigma = options.get('sigma',
|
|
342
|
+
sigma = options.get('sigma', smp.Info.preference.confidence_level)
|
|
343
|
+
unit = options.get('unit', smp.Info.preference.age_unit)
|
|
331
344
|
xAxis = options.get('xAxis', [{}])
|
|
332
345
|
yAxis = options.get('yAxis', [{}])
|
|
346
|
+
line_width = options.get('line_width', 1)
|
|
347
|
+
line_caps = options.get('line_caps', 'none')
|
|
333
348
|
series = []
|
|
349
|
+
# apparent spectra lines
|
|
334
350
|
age = smp.ApparentAgeValues[2:4]
|
|
335
351
|
ar = smp.DegasValues[20]
|
|
336
|
-
|
|
352
|
+
x, y1, y2 = spectra.get_data(*age, ar, cumulative=False, sigma=sigma)
|
|
353
|
+
X = x + list(reversed(x))
|
|
354
|
+
Y = y1 + list(reversed(y2))
|
|
337
355
|
series.append({
|
|
338
|
-
'type': 'series.line', 'id': f'line-{smp.name()}-{
|
|
339
|
-
'color': color, 'fill_color': color, 'line_width':
|
|
340
|
-
'data': np.transpose([
|
|
341
|
-
'
|
|
342
|
-
|
|
343
|
-
series.append({
|
|
344
|
-
'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
|
|
345
|
-
'color': color, 'fill_color': color, 'line_width': 1, 'line_style': 'solid', 'z_index': 9,
|
|
346
|
-
'data': np.transpose([data[0], data[2]]).tolist(), 'line_caps': 'square',
|
|
356
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{random_choice()}', 'name': f'line-{smp.name()}-{random_choice()}',
|
|
357
|
+
'color': color, 'fill_color': color, 'line_width': line_width, 'line_style': 'solid', 'z_index': 19,
|
|
358
|
+
'data': np.transpose([X, Y]).tolist(),
|
|
359
|
+
'line_caps': line_caps,
|
|
360
|
+
# 'line_caps': 'none',
|
|
347
361
|
'axis_index': 0,
|
|
348
362
|
})
|
|
363
|
+
# initial values corrected spectra lines and rect
|
|
349
364
|
text1 = smp.AgeSpectraPlot.text1
|
|
350
365
|
text2 = smp.AgeSpectraPlot.text2
|
|
351
|
-
sigma = 1
|
|
352
366
|
set_data = [spectraData2Sgima(smp.AgeSpectraPlot.set1.data, sigma),
|
|
353
367
|
spectraData2Sgima(smp.AgeSpectraPlot.set2.data, sigma)]
|
|
354
368
|
for index, text in enumerate([text1, text2]):
|
|
@@ -359,55 +373,133 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
|
|
|
359
373
|
# spectra_fill_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))
|
|
360
374
|
spectra_fill_data = getRectFromSpectra(plateau_data)
|
|
361
375
|
series.append({
|
|
362
|
-
'type': 'series.rect', 'id': f'rect-{smp.name()}-{
|
|
363
|
-
'color': ['red', 'blue'][index], 'fill_color': ['red', 'blue'][index],
|
|
364
|
-
'data': spectra_fill_data, 'line_caps': '
|
|
376
|
+
'type': 'series.rect', 'id': f'rect-{smp.name()}-{random_choice()}', 'name': f'rect-{smp.name()}-{random_choice()}',
|
|
377
|
+
'color': [colors_map['red'], colors_map['blue']][index], 'fill_color': [colors_map['red'], colors_map['blue']][index], 'line_style': 'none', 'z_index': 9,
|
|
378
|
+
'data': spectra_fill_data, 'line_caps': 'none', 'fill': True,
|
|
365
379
|
'axis_index': 0,
|
|
366
380
|
})
|
|
381
|
+
x, y1, y2 = np.transpose(plateau_data).tolist()[:3]
|
|
382
|
+
X = x + list(reversed(x))
|
|
383
|
+
Y = y1 + list(reversed(y2))
|
|
367
384
|
series.append({
|
|
368
|
-
'type': 'series.line', 'id': f'line-{smp.name()}-{
|
|
369
|
-
'name': f'line-{smp.name()}-{
|
|
370
|
-
'color': ['red', 'blue'][index], 'line_width':
|
|
371
|
-
'data':
|
|
385
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{random_choice()}',
|
|
386
|
+
'name': f'line-{smp.name()}-{random_choice()}',
|
|
387
|
+
'color': [colors_map['red'], colors_map['blue']][index], 'line_width': line_width, 'line_style': 'solid', 'z_index': 9,
|
|
388
|
+
'data': np.transpose([X, Y]).tolist(),
|
|
389
|
+
'line_caps': line_caps,
|
|
390
|
+
# 'line_caps': 'none',
|
|
372
391
|
'axis_index': 0,
|
|
373
392
|
})
|
|
393
|
+
# plateau line
|
|
374
394
|
series.append({
|
|
375
|
-
'type': 'series.line', 'id': f'line-{smp.name()}-{
|
|
376
|
-
'name': f'line-{smp.name()}-{
|
|
377
|
-
'color':
|
|
378
|
-
'data':
|
|
395
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{random_choice()}',
|
|
396
|
+
'name': f'line-{smp.name()}-{random_choice()}',
|
|
397
|
+
'color': '#A9A9A9', 'line_width': line_width, 'line_style': 'solid', 'z_index': 9,
|
|
398
|
+
'data': [[0, res['age']], [100, res['age']]],
|
|
399
|
+
'line_caps': line_caps,
|
|
400
|
+
# 'line_caps': 'none',
|
|
379
401
|
'axis_index': 0,
|
|
380
402
|
})
|
|
381
403
|
series.append({
|
|
382
|
-
'type': 'text', 'id': f'text-{smp.name()}-{
|
|
383
|
-
'color': ['red', 'blue'][index], 'fill_color': ['red', 'blue'][index],
|
|
384
|
-
'text': f"
|
|
404
|
+
'type': 'text', 'id': f'text-{smp.name()}-{random_choice()}', 'name': f'text-{smp.name()}-{random_choice()}',
|
|
405
|
+
'color': [colors_map['red'], colors_map['blue']][index], 'fill_color': [colors_map['red'], colors_map['blue']][index],
|
|
406
|
+
'text': f"Corrected = {res['age']:.2f} ± {(sigma * res['s2']):.2f} {unit} ({sigma}s)<r>"
|
|
385
407
|
f"MSWD = {res['MSWD']:.2f}, n = {res['Num']:.0f}<r>"
|
|
386
408
|
f"<sup>39</sup>Ar = {res['Ar39']:.2f}%",
|
|
387
409
|
'size': title_size,
|
|
388
|
-
'data': [text.pos],
|
|
389
|
-
'
|
|
410
|
+
# 'data': [text.pos],
|
|
411
|
+
'data': [[50, 50]],
|
|
412
|
+
'axis_index': 1, 'z_index': 29,
|
|
390
413
|
'h_align': "middle",
|
|
391
414
|
'v_align': "center",
|
|
392
415
|
})
|
|
416
|
+
spe = smp.Info.results.age_spectra[index]
|
|
417
|
+
if not np.isnan(res['age']):
|
|
418
|
+
series.append({
|
|
419
|
+
'type': 'text', 'id': f'text-{smp.name()}-{random_choice()}',
|
|
420
|
+
'name': f'text-{smp.name()}-{random_choice()}',
|
|
421
|
+
'color': color, 'fill_color': color,
|
|
422
|
+
'text': f"WMPA = {spe['age']:.2f} ± {(sigma * spe['s2']):.2f} {unit} ({sigma}s)",
|
|
423
|
+
'size': title_size,
|
|
424
|
+
'data': [[50, 10+10*index]],
|
|
425
|
+
'axis_index': 1,
|
|
426
|
+
'h_align': "middle",
|
|
427
|
+
'v_align': "bottom",
|
|
428
|
+
})
|
|
429
|
+
|
|
430
|
+
# TGA
|
|
393
431
|
tga = smp.Info.results.age_spectra['TGA']
|
|
394
432
|
if not np.isnan(tga['age']):
|
|
395
433
|
series.append({
|
|
396
|
-
'type': 'text', 'id': f'text-{smp.name()}-{
|
|
434
|
+
'type': 'text', 'id': f'text-{smp.name()}-{random_choice()}', 'name': f'text-{smp.name()}-{random_choice()}',
|
|
397
435
|
'color': color, 'fill_color': color,
|
|
398
|
-
'text': f"TGA = {tga['age']:.2f} ± {(sigma * tga['
|
|
436
|
+
'text': f"TGA = {tga['age']:.2f} ± {(sigma * tga['s2']):.2f} {unit} ({sigma}s)",
|
|
399
437
|
'size': title_size,
|
|
400
438
|
'data': [[50, 3]],
|
|
401
439
|
'axis_index': 1,
|
|
402
440
|
'h_align': "middle",
|
|
403
441
|
'v_align': "bottom",
|
|
404
442
|
})
|
|
443
|
+
# Max
|
|
444
|
+
age = np.array(smp.ApparentAgeValues[2:8]).transpose()
|
|
445
|
+
age = np.where(age is None, np.nan, age)
|
|
446
|
+
valid_mask = np.isfinite(age[:, 0])
|
|
447
|
+
age = age[valid_mask]
|
|
448
|
+
age = age[age[:, 5] >= 0.1]
|
|
449
|
+
try:
|
|
450
|
+
max_index = np.argmax(age[20:, 0]) + 20
|
|
451
|
+
except ValueError:
|
|
452
|
+
max_index = np.argmax(age[10:, 0]) + 10
|
|
453
|
+
min_index = np.argmin(age[:20, 0])
|
|
454
|
+
# print(f"{max_index = }")
|
|
455
|
+
# print(f"{min_index = }")
|
|
405
456
|
|
|
406
457
|
series.append({
|
|
407
|
-
'type': 'text', 'id': f'text-{smp.name()}-{
|
|
408
|
-
'
|
|
458
|
+
'type': 'text', 'id': f'text-{smp.name()}-{random_choice()}', 'name': f'text-{smp.name()}-{random_choice()}',
|
|
459
|
+
'color': color, 'fill_color': color,
|
|
460
|
+
'text': f"Max. = {age[max_index, 0]:.2f} ± {(sigma * age[max_index, 2]):.2f} {unit}",
|
|
461
|
+
'size': title_size,
|
|
462
|
+
'data': [[50, 70]],
|
|
463
|
+
'axis_index': 1,
|
|
464
|
+
'h_align': "middle",
|
|
465
|
+
'v_align': "bottom",
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
series.append({
|
|
469
|
+
'type': 'text', 'id': f'text-{smp.name()}-{random_choice()}', 'name': f'text-{smp.name()}-{random_choice()}',
|
|
470
|
+
'color': color, 'fill_color': color,
|
|
471
|
+
'text': f"Min. = {age[min_index, 0]:.2f} ± {(sigma * age[min_index, 2]):.2f} {unit}",
|
|
472
|
+
'size': title_size,
|
|
473
|
+
'data': [[50, 75]],
|
|
474
|
+
'axis_index': 1,
|
|
475
|
+
'h_align': "middle",
|
|
476
|
+
'v_align': "bottom",
|
|
477
|
+
})
|
|
478
|
+
|
|
479
|
+
series.append({
|
|
480
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{random_choice()}',
|
|
481
|
+
'name': f'line-{smp.name()}-{random_choice()}',
|
|
482
|
+
'color': '#A9A9A9', 'line_width': line_width, 'line_style': 'solid', 'z_index': 9,
|
|
483
|
+
'data': [[0, age[max_index, 0]], [100, age[max_index, 0]]],
|
|
484
|
+
'line_caps': line_caps,
|
|
485
|
+
# 'line_caps': 'none',
|
|
486
|
+
'axis_index': 0,
|
|
487
|
+
})
|
|
488
|
+
series.append({
|
|
489
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{random_choice()}',
|
|
490
|
+
'name': f'line-{smp.name()}-{random_choice()}',
|
|
491
|
+
'color': '#A9A9A9', 'line_width': line_width, 'line_style': 'solid', 'z_index': 9,
|
|
492
|
+
'data': [[0, age[min_index, 0]], [100, age[min_index, 0]]],
|
|
493
|
+
'line_caps': line_caps,
|
|
494
|
+
# 'line_caps': 'none',
|
|
495
|
+
'axis_index': 0,
|
|
496
|
+
})
|
|
497
|
+
# title
|
|
498
|
+
series.append({
|
|
499
|
+
'type': 'text', 'id': f'text-{smp.name()}-{random_choice()}',
|
|
500
|
+
'name': f'text-{smp.name()}-{random_choice()}', 'color': color,
|
|
409
501
|
'text': smp.name(), 'size': title_size,
|
|
410
|
-
'data': [[50, 95]], 'axis_index': 1,
|
|
502
|
+
'data': [[50, 95]], 'axis_index': 1, 'z_index': 29,
|
|
411
503
|
'h_align': "middle", 'v_align': "center",
|
|
412
504
|
})
|
|
413
505
|
|
|
@@ -416,50 +508,60 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
|
|
|
416
508
|
|
|
417
509
|
def _get_plot_data_age_spectra_axis(smp: sample, **options):
|
|
418
510
|
color = options.get('color', 'black')
|
|
511
|
+
line_width = options.get('line_width', 1)
|
|
419
512
|
xAxis, yAxis = [], []
|
|
420
513
|
age = smp.ApparentAgeValues[2:4]
|
|
421
514
|
ar = smp.DegasValues[20]
|
|
422
515
|
data = spectra.get_data(*age, ar, cumulative=False)
|
|
423
516
|
|
|
424
|
-
y_low_limit, y_up_limit, stick_num, inc = get_axis_scale(np.array(data[1:3]).flatten())
|
|
425
|
-
y_extent = [y_low_limit, y_up_limit]
|
|
426
|
-
y_interval = [y_low_limit + i * inc for i in range(stick_num + 1)]
|
|
427
|
-
y_interval.extend([y_up_limit * 10] * 3)
|
|
428
|
-
dp = int(np.log10(abs(y_up_limit - y_low_limit)) - 1)
|
|
429
|
-
dp = 0 if dp >= 0 else abs(dp)
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
517
|
+
# y_low_limit, y_up_limit, stick_num, inc = get_axis_scale(np.array(data[1:3]).flatten())
|
|
518
|
+
# y_extent = [y_low_limit, y_up_limit]
|
|
519
|
+
# y_interval = [y_low_limit + i * inc for i in range(stick_num + 1)]
|
|
520
|
+
# y_interval.extend([y_up_limit * 10] * 3)
|
|
521
|
+
# dp = int(np.log10(abs(y_up_limit - y_low_limit)) - 1)
|
|
522
|
+
# dp = 0 if dp >= 0 else abs(dp)
|
|
523
|
+
# y_interval = [f"{i:.{dp}f}" for i in y_interval]
|
|
524
|
+
try:
|
|
525
|
+
y_low_limit = float(smp.AgeSpectraPlot.yaxis.min)
|
|
526
|
+
y_up_limit = float(smp.AgeSpectraPlot.yaxis.max)
|
|
527
|
+
y_extent = [y_low_limit, y_up_limit]
|
|
528
|
+
stick_num = int(smp.AgeSpectraPlot.yaxis.split_number)
|
|
529
|
+
inc = float(smp.AgeSpectraPlot.yaxis.interval)
|
|
530
|
+
y_interval = [y_low_limit + i * inc for i in range(stick_num + 1)]
|
|
531
|
+
dp = int(np.log10(abs(y_up_limit - y_low_limit)) - 1)
|
|
532
|
+
dp = 0 if dp >= 0 else abs(dp)
|
|
533
|
+
y_interval = [f"{i:.{dp}f}" for i in y_interval]
|
|
534
|
+
except (BaseException, Exception):
|
|
535
|
+
y_extent = [0, 250]
|
|
536
|
+
y_interval = ['0', '50', '100', '150', '200', '250', '600', '700', '800', '900', '1000']
|
|
436
537
|
|
|
437
538
|
xAxis.append({
|
|
438
539
|
'extent': [0, 100], 'interval': [0, 20, 40, 60, 80, 100], 'id': 0, 'show_frame': True,
|
|
439
|
-
'title': 'Cumulative <sup>39</sup>Ar
|
|
440
|
-
'line_width':
|
|
540
|
+
'title': 'Cumulative <sup>39</sup>Ar released (%)', 'name_location': 'middle',
|
|
541
|
+
'line_width': line_width, 'line_style': 'solid', 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
441
542
|
})
|
|
442
543
|
xAxis.append({
|
|
443
544
|
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
444
545
|
'title': '', 'name_location': 'middle',
|
|
445
|
-
'line_width':
|
|
546
|
+
'line_width': 0, 'line_style': 'none', 'z_index': 0, 'label_size': label_size, 'title_size': title_size,
|
|
446
547
|
})
|
|
447
548
|
yAxis.append({
|
|
448
549
|
'extent': y_extent, 'interval': y_interval,
|
|
449
550
|
'id': 0, 'show_frame': True,
|
|
450
|
-
'title': 'Apparent
|
|
451
|
-
'line_width':
|
|
551
|
+
'title': 'Apparent age (Ma)', 'name_location': 'middle',
|
|
552
|
+
'line_width': line_width, 'line_style': 'solid', 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
452
553
|
})
|
|
453
554
|
yAxis.append({
|
|
454
555
|
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
455
556
|
'title': '', 'name_location': 'middle',
|
|
456
|
-
'line_width':
|
|
557
|
+
'line_width': 0, 'line_style': 'none', 'z_index': 0, 'label_size': label_size, 'title_size': title_size,
|
|
457
558
|
})
|
|
458
559
|
return xAxis, yAxis
|
|
459
560
|
|
|
460
561
|
|
|
461
562
|
def _get_plot_data_inv_isochron_axis(smp: sample, **options):
|
|
462
563
|
color = options.get('color', 'black')
|
|
564
|
+
line_width = options.get('line_width', 1)
|
|
463
565
|
xAxis, yAxis = [], []
|
|
464
566
|
data = np.array(smp.InvIsochronPlot.data)
|
|
465
567
|
set1 = smp.InvIsochronPlot.set1.data
|
|
@@ -478,10 +580,12 @@ def _get_plot_data_inv_isochron_axis(smp: sample, **options):
|
|
|
478
580
|
'interval': interval,
|
|
479
581
|
'id': 0, 'show_frame': True, 'z_index': 9, 'label_size': label_size, 'title_size': title_size,
|
|
480
582
|
'title': '<sup>39</sup>Ar<sub>K</sub> / <sup>40</sup>Ar<sup>*</sup>', 'name_location': 'middle',
|
|
583
|
+
'line_width': line_width,
|
|
481
584
|
})
|
|
482
585
|
xAxis.append({
|
|
483
586
|
'extent': [0, 100], 'interval': [], 'id': 1, 'show_frame': False,
|
|
484
587
|
'title': '', 'name_location': 'middle', 'z_index': 0, 'label_size': label_size, 'title_size': title_size,
|
|
588
|
+
'line_width': 0,
|
|
485
589
|
})
|
|
486
590
|
|
|
487
591
|
low_limit, up_limit, stick_num, inc = get_axis_scale(data[2])
|
|
@@ -507,9 +611,10 @@ def _get_plot_data_inv_isochron_axis(smp: sample, **options):
|
|
|
507
611
|
|
|
508
612
|
def _get_plot_data_inv_isochron_series(smp: sample, **options):
|
|
509
613
|
color = options.get('color', 'black')
|
|
614
|
+
marker_size = options.get('marker_szie', 2)
|
|
510
615
|
xAxis = options.get('xAxis', [{}])
|
|
511
616
|
yAxis = options.get('yAxis', [{}])
|
|
512
|
-
sigma = options.get('sigma',
|
|
617
|
+
sigma = options.get('sigma', 2)
|
|
513
618
|
series = []
|
|
514
619
|
age = smp.ApparentAgeValues[2:4]
|
|
515
620
|
ar = smp.DegasValues[20]
|
|
@@ -519,22 +624,22 @@ def _get_plot_data_inv_isochron_series(smp: sample, **options):
|
|
|
519
624
|
set3 = smp.InvIsochronPlot.set3.data
|
|
520
625
|
# set 1
|
|
521
626
|
series.append({
|
|
522
|
-
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{
|
|
523
|
-
'stroke_color': 'red', 'fill_color': '
|
|
627
|
+
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{random_choice()}', 'name': f'scatter-{smp.name()}-{random_choice()}',
|
|
628
|
+
'stroke_color': colors_map['red'], 'fill_color': colors_map['red80'], 'myType': 'scatter', 'size': marker_size, 'line_width': 0,
|
|
524
629
|
'data': (data[[0, 2], :][:, set1]).transpose().tolist(),
|
|
525
630
|
'axis_index': 0, 'z_index': 99
|
|
526
631
|
})
|
|
527
632
|
# set 2
|
|
528
633
|
series.append({
|
|
529
|
-
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{
|
|
530
|
-
'stroke_color': 'blue', 'fill_color': '
|
|
634
|
+
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{random_choice()}', 'name': f'scatter-{smp.name()}-{random_choice()}',
|
|
635
|
+
'stroke_color': colors_map['blue'], 'fill_color': colors_map['blue80'], 'myType': 'scatter', 'size': marker_size, 'line_width': 0,
|
|
531
636
|
'data': (data[[0, 2], :][:, set2]).transpose().tolist(),
|
|
532
637
|
'axis_index': 0, 'z_index': 99
|
|
533
638
|
})
|
|
534
639
|
# set 3
|
|
535
640
|
series.append({
|
|
536
|
-
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{
|
|
537
|
-
'stroke_color': 'black', 'fill_color': 'white', 'myType': 'scatter', 'size':
|
|
641
|
+
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{random_choice()}', 'name': f'scatter-{smp.name()}-{random_choice()}',
|
|
642
|
+
'stroke_color': 'black', 'fill_color': 'white', 'myType': 'scatter', 'size': marker_size, 'line_width': 0,
|
|
538
643
|
'data': (data[[0, 2], :][:, set3]).transpose().tolist(),
|
|
539
644
|
'axis_index': 0, 'z_index': 0
|
|
540
645
|
})
|
|
@@ -548,18 +653,18 @@ def _get_plot_data_inv_isochron_series(smp: sample, **options):
|
|
|
548
653
|
(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']),
|
|
549
654
|
]
|
|
550
655
|
series.append({
|
|
551
|
-
'type': 'series.line', 'id': f'line-{smp.name()}-{
|
|
552
|
-
'color': ['red', 'blue'][index], 'fill_color': ['red', 'blue'][index],
|
|
553
|
-
'line_width': 1
|
|
656
|
+
'type': 'series.line', 'id': f'line-{smp.name()}-{random_choice()}', 'name': f'line-{smp.name()}-{random_choice()}',
|
|
657
|
+
'color': [colors_map['red'], colors_map['blue']][index], 'fill_color': [colors_map['red'], colors_map['blue']][index],
|
|
658
|
+
'line_width': 1, 'line_style': 'solid',
|
|
554
659
|
'data': isochron_data,
|
|
555
660
|
'axis_index': 0,
|
|
556
661
|
})
|
|
557
662
|
series.append({
|
|
558
|
-
'type': 'text', 'id': f'text-{smp.name()}-{
|
|
559
|
-
'color': ['red', 'blue'][index], 'fill_color': ['red', 'blue'][index],
|
|
560
|
-
'text': f"IIA = {smp.Info.results.isochron['figure_3'][index]['age']:.2f} ± {(sigma * smp.Info.results.isochron['figure_3'][index]['
|
|
561
|
-
f"
|
|
562
|
-
f"MSWD = {smp.Info.results.isochron['figure_3'][index]['MSWD']:.2f}
|
|
663
|
+
'type': 'text', 'id': f'text-{smp.name()}-{random_choice()}', 'name': f'text-{smp.name()}-{random_choice()}',
|
|
664
|
+
'color': [colors_map['red'], colors_map['blue']][index], 'fill_color': [colors_map['red'], colors_map['blue']][index],
|
|
665
|
+
'text': f"IIA = {smp.Info.results.isochron['figure_3'][index]['age']:.2f} ± {(sigma * smp.Info.results.isochron['figure_3'][index]['s2']):.2f} Ma ({sigma}s)<r>"
|
|
666
|
+
f"(40Ar/36Ar)0 = {smp.Info.results.isochron['figure_3'][index]['initial']:.2f} ± {(sigma * smp.Info.results.isochron['figure_3'][index]['sinitial']):.2f}<r>"
|
|
667
|
+
f"MSWD = {smp.Info.results.isochron['figure_3'][index]['MSWD']:.2f}<r>",
|
|
563
668
|
'size': title_size,
|
|
564
669
|
'data': [text.pos],
|
|
565
670
|
'axis_index': 1,
|
|
@@ -568,8 +673,8 @@ def _get_plot_data_inv_isochron_series(smp: sample, **options):
|
|
|
568
673
|
})
|
|
569
674
|
|
|
570
675
|
series.append({
|
|
571
|
-
'type': 'text', 'id': f'text-{smp.name()}-{
|
|
572
|
-
'name': f'text-{smp.name()}-{
|
|
676
|
+
'type': 'text', 'id': f'text-{smp.name()}-{random_choice()}',
|
|
677
|
+
'name': f'text-{smp.name()}-{random_choice()}', 'color': color,
|
|
573
678
|
'text': smp.name(), 'size': title_size,
|
|
574
679
|
'data': [[50, 95]], 'axis_index': 1,
|
|
575
680
|
'h_align': "middle", 'v_align': "center",
|
|
@@ -590,7 +695,7 @@ def _get_plot_data_degas_pattern(smp: sample, **options):
|
|
|
590
695
|
data = np.array([x, y])
|
|
591
696
|
# set 1
|
|
592
697
|
series.append({
|
|
593
|
-
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{
|
|
698
|
+
'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{random_choice()}', 'name': f'scatter-{smp.name()}-{random_choice()}',
|
|
594
699
|
'stroke_color': color, 'fill_color': 'white', 'myType': 'scatter', 'size': 4, 'line_width': 1,
|
|
595
700
|
'data': data.transpose().tolist(), 'axis_index': 0, 'z_index': 99
|
|
596
701
|
})
|
|
@@ -682,7 +787,7 @@ def _get_plot_data_degas_spectra_series(smp: sample, **options):
|
|
|
682
787
|
|
|
683
788
|
# set 1
|
|
684
789
|
series.append({
|
|
685
|
-
'type': 'rect', 'id': f'rect-{smp.name()}-{
|
|
790
|
+
'type': 'rect', 'id': f'rect-{smp.name()}-{random_choice()}', 'name': f'rect-{smp.name()}-{random_choice()}',
|
|
686
791
|
'color': color, 'myType': 'rect', 'line_width': 1,
|
|
687
792
|
'data': data.transpose().tolist(),
|
|
688
793
|
'axis_index': 0, 'z_index': 99
|
|
@@ -739,13 +844,13 @@ def _get_plot_data_degas_curve_series(smp: sample, **options):
|
|
|
739
844
|
|
|
740
845
|
# line
|
|
741
846
|
series.append({
|
|
742
|
-
'type': 'line', 'id': f'line-{smp.name()}-{
|
|
847
|
+
'type': 'line', 'id': f'line-{smp.name()}-{random_choice()}', 'name': f'line-{smp.name()}-{random_choice()}',
|
|
743
848
|
'color': color, 'myType': 'line', 'line_width': 1, 'line_style': 'solid',
|
|
744
849
|
'data': np.array([x, released]).transpose().tolist(),
|
|
745
850
|
'axis_index': 0, 'z_index': 99
|
|
746
851
|
})
|
|
747
852
|
series.append({
|
|
748
|
-
'type': 'line', 'id': f'line-{smp.name()}-{
|
|
853
|
+
'type': 'line', 'id': f'line-{smp.name()}-{random_choice()}', 'name': f'line-{smp.name()}-{random_choice()}',
|
|
749
854
|
'color': color, 'myType': 'line', 'line_width': 1, 'line_style': 'solid',
|
|
750
855
|
'data': np.array([x, remained]).transpose().tolist(),
|
|
751
856
|
'axis_index': 0, 'z_index': 99
|
|
@@ -816,7 +921,7 @@ class WritingWorkbook:
|
|
|
816
921
|
|
|
817
922
|
style = xls.add_format(self.default_fmt_prop)
|
|
818
923
|
|
|
819
|
-
sigma = int(self.sample.Info.preference
|
|
924
|
+
sigma = int(self.sample.Info.preference.confidence_level)
|
|
820
925
|
|
|
821
926
|
sht_reference = xls.add_worksheet("Reference") # Data used to plot
|
|
822
927
|
sht_reference.hide_gridlines(2) # 0 = show grids, 1 = hide print grid, else = hide print and screen grids
|
|
@@ -1070,10 +1175,10 @@ class WritingWorkbook:
|
|
|
1070
1175
|
weight = self.sample.Info.sample.weight
|
|
1071
1176
|
J_value = self.sample.TotalParam[67][0]
|
|
1072
1177
|
J_error = self.sample.TotalParam[68][0] * self.sample.TotalParam[67][0] / 100
|
|
1073
|
-
sigma = self.sample.Info.preference
|
|
1178
|
+
sigma = self.sample.Info.preference.confidence_level
|
|
1074
1179
|
sequence_type = {"StepLaser": "Laser", "StepFurnace": "Temperature", "StepCrusher": "Drop", }.get(method, "Step Value")
|
|
1075
1180
|
sequence_unit = self.sample.Info.sample.sequence_unit if self.sample.Info.sample.sequence_unit != "" else "Unit"
|
|
1076
|
-
age_unit = self.sample.Info.preference
|
|
1181
|
+
age_unit = self.sample.Info.preference.age_unit
|
|
1077
1182
|
num_step = len(self.sample.SequenceName)
|
|
1078
1183
|
set1_ratio = [self.sample.Info.results.isochron['figure_3'][0]['initial'], self.sample.Info.results.isochron['figure_2'][0]['initial'], self.sample.TotalParam[116][0]][int(self.sample.TotalParam[115][0])]
|
|
1079
1184
|
set2_ratio = [self.sample.Info.results.isochron['figure_3'][1]['initial'], self.sample.Info.results.isochron['figure_2'][1]['initial'], self.sample.TotalParam[118][0]][int(self.sample.TotalParam[115][0])]
|
|
@@ -1144,7 +1249,7 @@ class WritingWorkbook:
|
|
|
1144
1249
|
tga_res = self.sample.Info.results.age_spectra['TGA']
|
|
1145
1250
|
content.extend([
|
|
1146
1251
|
[(9 + num_step, 1, 10 + num_step, 1), tga_res['F'], {'num_format': '0.00000'}],
|
|
1147
|
-
[(9 + num_step, 2, 10 + num_step, 2), tga_res['sF'], {'num_format': '0.00000'}],
|
|
1252
|
+
[(9 + num_step, 2, 10 + num_step, 2), tga_res['sF'] * sigma, {'num_format': '0.00000'}],
|
|
1148
1253
|
[(9 + num_step, 3, 10 + num_step, 3), tga_res['age'], {'num_format': '0.00'}],
|
|
1149
1254
|
[(9 + num_step, 4), tga_res['s1'] * sigma, {'num_format': '± 0.00', 'align': 'left'}],
|
|
1150
1255
|
[(9 + num_step, 5), tga_res['s2'] * sigma, {'num_format': '± 0.00', 'align': 'left'}],
|
|
@@ -1164,7 +1269,6 @@ class WritingWorkbook:
|
|
|
1164
1269
|
]:
|
|
1165
1270
|
for index, _ in enumerate(['Set 1', 'Set 2']):
|
|
1166
1271
|
ar39[index] = res[index].get('Ar39', ar39[index] * 100) / 100
|
|
1167
|
-
print(res[index])
|
|
1168
1272
|
try:
|
|
1169
1273
|
content.extend([
|
|
1170
1274
|
[(row + num_step, 0, row + 1 + num_step, 0), _, {'bold': 1, 'align': 'center'}],
|
|
@@ -1205,20 +1309,36 @@ class WritingWorkbook:
|
|
|
1205
1309
|
|
|
1206
1310
|
def write_sht_table(self, sht_name, prop_name, sht_type, row, col, _, smp_attr_name, header_name, style, xls, sigma=1):
|
|
1207
1311
|
sht = xls.add_worksheet(sht_name)
|
|
1312
|
+
num_step = len(self.sample.SequenceName)
|
|
1208
1313
|
data = arr.transpose(getattr(self.sample, smp_attr_name, None).data)
|
|
1209
1314
|
sht.hide_gridlines(2) # 0 = show grids, 1 = hide print grid, else = hide print and screen grids
|
|
1210
1315
|
sht.hide() # default hidden table sheet
|
|
1211
1316
|
sht.set_column(0, len(data), width=12) # column width
|
|
1212
1317
|
header = getattr(sample, header_name)
|
|
1213
1318
|
header = list(map(lambda each: each if "σ" not in each else each.replace('1', str(sigma)) if str(sigma) not in each else each.replace('2', str(sigma)), header))
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1319
|
+
|
|
1320
|
+
content = [
|
|
1321
|
+
[(0, 0), f"{sht_name}", {'bold': 1, 'top': 1, 'align': 'left'}],
|
|
1322
|
+
*[[(1, col, 2, col), each, {'bold': 1, 'top': 1, 'bottom': 6}] for col, each in enumerate(header)],
|
|
1323
|
+
*[[(3, col, 1), each if "σ" not in header[col] else list(map(lambda _: _ * sigma, each)), {}] for col, each in enumerate(data)],
|
|
1324
|
+
[(3 + num_step, 0, 0), [''] * len(data), {'bold': 1, 'top': 1}],
|
|
1325
|
+
]
|
|
1326
|
+
|
|
1327
|
+
for pos, value, _prop in content:
|
|
1328
|
+
prop = self.default_fmt_prop.copy()
|
|
1329
|
+
prop.update(_prop)
|
|
1330
|
+
fmt = Format(prop, xls.xf_format_indices, xls.dxf_format_indices)
|
|
1331
|
+
xls.formats.append(fmt)
|
|
1332
|
+
if isinstance(value, (list, np.ndarray)) and len(pos) == 3:
|
|
1333
|
+
value = [None if isinstance(v, (float, int)) and np.isnan(v) else v for v in value]
|
|
1334
|
+
[sht.write_row, sht.write_column][pos[2]](*pos[:2], value, fmt)
|
|
1335
|
+
elif len(pos) == 2:
|
|
1336
|
+
isnumeric = isinstance(value, (float, int)) and not np.isnan(value) and not np.isinf(value)
|
|
1337
|
+
[sht.write_string, sht.write_number][isnumeric](*pos, value if isnumeric else str(value), fmt)
|
|
1338
|
+
elif len(pos) == 4:
|
|
1339
|
+
isnumeric = isinstance(value, (float, int)) and not np.isnan(value) and not np.isinf(value)
|
|
1340
|
+
sht.merge_range(*pos, value if isnumeric else str(value), fmt)
|
|
1341
|
+
|
|
1222
1342
|
|
|
1223
1343
|
def write_sht_chart(self, sht_name, prop_name, sht_type, row, col, _, smp_attr_name, header_name, style, xls, start_row, total_rows):
|
|
1224
1344
|
sht = xls.add_chartsheet(sht_name)
|
|
@@ -1243,7 +1363,7 @@ class WritingWorkbook:
|
|
|
1243
1363
|
f"I{start_row}:I{(total_rows + 1) * 2 + start_row - 1}",
|
|
1244
1364
|
]
|
|
1245
1365
|
axis_range = [figure.xaxis.min, figure.xaxis.max, figure.yaxis.min, figure.yaxis.max]
|
|
1246
|
-
self.get_chart_age_spectra(xls, sht, data_area, axis_range, age_unit=self.sample.Info.preference
|
|
1366
|
+
self.get_chart_age_spectra(xls, sht, data_area, axis_range, age_unit=self.sample.Info.preference.age_unit)
|
|
1247
1367
|
elif "normal_isochron" in prop_name.lower():
|
|
1248
1368
|
data_area = [
|
|
1249
1369
|
f"O{start_row}:O{num_set1 + start_row - 1}", f"P{start_row}:P{num_set1 + start_row - 1}",
|
|
@@ -1839,7 +1959,7 @@ class CreatePDF:
|
|
|
1839
1959
|
yaxis_max = float(yaxis.max)
|
|
1840
1960
|
|
|
1841
1961
|
plot_scale = (xaxis_min, xaxis_max, yaxis_min, yaxis_max)
|
|
1842
|
-
colors = ['red', 'color']
|
|
1962
|
+
colors = [colors_map['red'], 'color']
|
|
1843
1963
|
|
|
1844
1964
|
# create a canvas
|
|
1845
1965
|
cv = pm.Canvas(width=17, height=12, unit="cm", show_frame=True, clip_outside_plot_areas=False)
|
|
@@ -1978,10 +2098,10 @@ class CreatePDF:
|
|
|
1978
2098
|
for index in range(len(data) - 1):
|
|
1979
2099
|
pt.line(start=(data[index][0], data[index][1]), end=(data[index + 1][0], data[index + 1][1]),
|
|
1980
2100
|
width=widths[0], line_style=styles[0], color=colors[0],
|
|
1981
|
-
clip=True, line_caps="
|
|
2101
|
+
clip=True, line_caps="none", z_index=9)
|
|
1982
2102
|
pt.line(start=(data[index][0], data[index][2]), end=(data[index + 1][0], data[index + 1][2]),
|
|
1983
2103
|
width=widths[1], line_style=styles[1], color=colors[1],
|
|
1984
|
-
clip=True, line_caps="
|
|
2104
|
+
clip=True, line_caps="none", z_index=9)
|
|
1985
2105
|
|
|
1986
2106
|
colors = [
|
|
1987
2107
|
[self.color_rgb_normalized(self.color_hex_to_rgb(plot.line3.color)),
|
|
@@ -2075,8 +2195,6 @@ class CreatePDF:
|
|
|
2075
2195
|
yaxis_max = float(yaxis.max)
|
|
2076
2196
|
plot_scale = (xaxis_min, xaxis_max, yaxis_min, yaxis_max)
|
|
2077
2197
|
|
|
2078
|
-
colors = ['red', 'color']
|
|
2079
|
-
|
|
2080
2198
|
# data
|
|
2081
2199
|
data = plot.data # 36a, 37ca, 38cl, 39k, 40r, 36, 37, 38, 39, 40
|
|
2082
2200
|
|