ararpy 0.2.2__py3-none-any.whl → 0.2.4__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/__init__.py +2 -20
- ararpy/calc/arr.py +5 -2
- ararpy/calc/corr.py +15 -16
- ararpy/files/calc_file.py +4 -2
- ararpy/smp/basic.py +13 -7
- ararpy/smp/corr.py +28 -23
- ararpy/smp/export.py +1 -1
- ararpy/smp/initial.py +21 -4
- ararpy/smp/plots.py +248 -203
- ararpy/smp/sample.py +33 -16
- ararpy/smp/style.py +10 -4
- ararpy/smp/table.py +72 -39
- {ararpy-0.2.2.dist-info → ararpy-0.2.4.dist-info}/METADATA +1 -1
- {ararpy-0.2.2.dist-info → ararpy-0.2.4.dist-info}/RECORD +17 -17
- {ararpy-0.2.2.dist-info → ararpy-0.2.4.dist-info}/WHEEL +0 -0
- {ararpy-0.2.2.dist-info → ararpy-0.2.4.dist-info}/licenses/LICENSE +0 -0
- {ararpy-0.2.2.dist-info → ararpy-0.2.4.dist-info}/top_level.txt +0 -0
ararpy/smp/plots.py
CHANGED
|
@@ -36,182 +36,176 @@ ISOCHRON_INDEX_DICT = {
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
# Reset plot data
|
|
41
|
-
# =======================
|
|
42
|
-
def set_plot_data(sample: Sample, isInit: bool = True, isIsochron: bool = True,
|
|
43
|
-
isPlateau: bool = True, **kwargs):
|
|
39
|
+
def set_plot_data(sample: Sample, isInit: bool = True, **kwargs):
|
|
44
40
|
"""
|
|
45
41
|
Parameters
|
|
46
42
|
----------
|
|
47
43
|
sample
|
|
48
|
-
isInit
|
|
49
|
-
isIsochron
|
|
50
|
-
isPlateau
|
|
51
44
|
kwargs
|
|
52
45
|
|
|
53
46
|
Returns
|
|
54
47
|
-------
|
|
55
48
|
|
|
56
49
|
"""
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
# try:
|
|
87
|
-
# recalc_plateaus(sample)
|
|
88
|
-
# except (Exception, BaseException):
|
|
89
|
-
# print("recalc_plateaus(sample) error:\n", traceback.format_exc())
|
|
90
|
-
# pass
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
# =======================
|
|
94
|
-
# Initialize plot data
|
|
95
|
-
# =======================
|
|
96
|
-
def initial_plot_data(smp: Sample):
|
|
50
|
+
all_figures = ['figure_2', 'figure_3', 'figure_4', 'figure_5', 'figure_6', 'figure_7', 'figure_8', 'figure_9', 'figure_1', ]
|
|
51
|
+
figures = kwargs.get('figures', all_figures)
|
|
52
|
+
for idx, fig_id in enumerate(all_figures):
|
|
53
|
+
if fig_id not in figures:
|
|
54
|
+
continue
|
|
55
|
+
if fig_id == 'figure_1':
|
|
56
|
+
if isInit:
|
|
57
|
+
init_age_spec_plot(sample)
|
|
58
|
+
recalc_plateaus(sample)
|
|
59
|
+
if fig_id == 'figure_2':
|
|
60
|
+
plot_normal_iso(sample, isInit=isInit)
|
|
61
|
+
if fig_id == 'figure_3':
|
|
62
|
+
plot_inverse_iso(sample, isInit=isInit)
|
|
63
|
+
if fig_id == 'figure_4':
|
|
64
|
+
plot_cl1_iso(sample, isInit=isInit)
|
|
65
|
+
if fig_id == 'figure_5':
|
|
66
|
+
plot_cl2_iso(sample, isInit=isInit)
|
|
67
|
+
if fig_id == 'figure_6':
|
|
68
|
+
plot_cl3_iso(sample, isInit=isInit)
|
|
69
|
+
if fig_id == 'figure_7':
|
|
70
|
+
plot_3D_iso(sample, isInit=isInit)
|
|
71
|
+
if fig_id == 'figure_8':
|
|
72
|
+
recalc_degassing_plot(sample)
|
|
73
|
+
if fig_id == 'figure_9':
|
|
74
|
+
recalc_agedistribution(sample)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
# Isochrons
|
|
78
|
+
def get_iso_res(sample: Sample, figure: Plot):
|
|
97
79
|
"""
|
|
98
|
-
|
|
80
|
+
|
|
99
81
|
Parameters
|
|
100
82
|
----------
|
|
101
|
-
|
|
83
|
+
sample
|
|
84
|
+
kwargs
|
|
102
85
|
|
|
103
86
|
Returns
|
|
104
87
|
-------
|
|
105
|
-
None
|
|
106
|
-
"""
|
|
107
|
-
try:
|
|
108
|
-
params_to_check = {
|
|
109
|
-
'normal': {'data': smp.IsochronValues[0:5], 'dtype': float, 'class': 'k1', },
|
|
110
|
-
'inverse': {'data': smp.IsochronValues[6:11], 'dtype': float, 'class': 'k2', },
|
|
111
|
-
'K-Cl-Ar 1': {'data': smp.IsochronValues[12:17], 'dtype': float, 'class': 'k3', },
|
|
112
|
-
'K-Cl-Ar 2': {'data': smp.IsochronValues[18:23], 'dtype': float, 'class': 'k4', },
|
|
113
|
-
'K-Cl-Ar 3': {'data': smp.IsochronValues[24:29], 'dtype': float, 'class': 'k5', },
|
|
114
|
-
'3D': {'data': smp.IsochronValues[30:39], 'dtype': float, 'class': 'k6', },
|
|
115
|
-
'age spectra': [
|
|
116
|
-
{'data': smp.ApparentAgeValues[2:4], 'dtype': float, 'class': 'k7', },
|
|
117
|
-
{'data': smp.ApparentAgeValues[7], 'dtype': float, 'class': 'k7', },
|
|
118
|
-
],
|
|
119
|
-
'degas pattern': {'data': smp.IsochronValues[30:39], 'dtype': float, 'class': 'k8', },
|
|
120
|
-
'age distribution': {'data': smp.IsochronValues[30:39], 'dtype': float, 'class': 'k9', },
|
|
121
|
-
}
|
|
122
|
-
except (IndexError, AttributeError) as e:
|
|
123
|
-
raise
|
|
124
|
-
if not basic.validate_params(**params_to_check):
|
|
125
|
-
return
|
|
126
88
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
list(range(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
for point in calc.arr.transpose(figure.data[:5]):
|
|
138
|
-
if '' not in point and None not in point:
|
|
139
|
-
ellipse_data.append(calc.isochron.get_ellipse(*point))
|
|
140
|
-
getattr(figure, 'ellipse', Set(id='ellipse')).data = ellipse_data
|
|
141
|
-
|
|
142
|
-
# Age spectra plot
|
|
143
|
-
# Try to calculate total gas age
|
|
144
|
-
try:
|
|
145
|
-
if str(smp.Info.sample.type).lower() == "unknown":
|
|
146
|
-
a0, e0 = sum(smp.DegasValues[24]), pow(sum([i ** 2 for i in smp.DegasValues[25]]), 0.5)
|
|
147
|
-
a1, e1 = sum(smp.DegasValues[20]), pow(sum([i ** 2 for i in smp.DegasValues[21]]), 0.5)
|
|
148
|
-
handle = basic.calc_age
|
|
149
|
-
elif str(smp.Info.sample.type).lower() == "standard":
|
|
150
|
-
a0, e0 = sum(smp.DegasValues[24]), pow(sum([i ** 2 for i in smp.DegasValues[25]]), 0.5)
|
|
151
|
-
a1, e1 = sum(smp.DegasValues[20]), pow(sum([i ** 2 for i in smp.DegasValues[21]]), 0.5)
|
|
152
|
-
handle = basic.calc_j
|
|
153
|
-
elif str(smp.Info.sample.type).lower() == "air":
|
|
154
|
-
a0, e0 = sum(smp.DegasValues[26]), pow(sum([i ** 2 for i in smp.DegasValues[27]]), 0.5)
|
|
155
|
-
a1, e1 = sum(smp.DegasValues[ 0]), pow(sum([i ** 2 for i in smp.DegasValues[ 1]]), 0.5)
|
|
156
|
-
handle = basic.calc_mdf
|
|
89
|
+
"""
|
|
90
|
+
figure.set3.data, figure.set1.data, figure.set2.data = \
|
|
91
|
+
sample.UnselectedSequence.copy(), sample.SelectedSequence1.copy(), sample.SelectedSequence2.copy()
|
|
92
|
+
for index, sequence in enumerate([figure.set1.data, figure.set2.data, figure.set3.data]):
|
|
93
|
+
set_data = calc.arr.partial(
|
|
94
|
+
sample.IsochronValues, rows=sequence, cols=list(range(*ISOCHRON_INDEX_DICT[figure.id]['data_index'])))
|
|
95
|
+
if figure.id != 'figure_7':
|
|
96
|
+
iso_res = get_isochron_results(
|
|
97
|
+
set_data, figure_type=ISOCHRON_INDEX_DICT[figure.id]["figure_type"], smp=sample, sequence=sequence)
|
|
98
|
+
sample.Info.results.isochron[figure.id].update({index: iso_res})
|
|
157
99
|
else:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
total_age = handle(total_f[:2], smp=smp)
|
|
161
|
-
except (Exception, BaseException):
|
|
162
|
-
print(traceback.format_exc())
|
|
163
|
-
total_f = [np.nan] * 2
|
|
164
|
-
total_age = [np.nan] * 4
|
|
165
|
-
smp.Info.results.age_spectra['TGA'].update(
|
|
166
|
-
{'Ar39': 100, 'F': total_f[0], 'sF': total_f[1], 'age': total_age[0],
|
|
167
|
-
's1': total_age[1], 's2': total_age[2], 's3': total_age[3], 'Num': len(smp.DegasValues[24])}
|
|
168
|
-
)
|
|
169
|
-
try:
|
|
170
|
-
smp.AgeSpectraPlot.data = calc.spectra.get_data(*smp.ApparentAgeValues[2:4], smp.ApparentAgeValues[7])
|
|
171
|
-
smp.AgeSpectraPlot.data = calc.arr.transpose(smp.AgeSpectraPlot.data)
|
|
172
|
-
except (Exception, BaseException):
|
|
173
|
-
print(traceback.format_exc())
|
|
174
|
-
smp.AgeSpectraPlot.data = []
|
|
100
|
+
iso_res = get_3D_results(data=set_data, sequence=sequence, sample=sample)
|
|
101
|
+
sample.Info.results.isochron[figure.id].update({index: iso_res})
|
|
175
102
|
|
|
176
|
-
# Degassing plot
|
|
177
|
-
recalc_degassing_plot(smp)
|
|
178
103
|
|
|
179
|
-
|
|
180
|
-
recalc_agedistribution(smp)
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
# =======================
|
|
184
|
-
# Isochron results
|
|
185
|
-
# =======================
|
|
186
|
-
def recalc_isochrons(sample: Sample, **kwargs):
|
|
104
|
+
def set_iso_line_data(sample: Sample, figure: Plot):
|
|
187
105
|
"""
|
|
188
|
-
|
|
106
|
+
Set isochron regression lines
|
|
189
107
|
Parameters
|
|
190
108
|
----------
|
|
191
|
-
sample
|
|
192
|
-
kwargs
|
|
109
|
+
sample : sample instance
|
|
193
110
|
|
|
194
111
|
Returns
|
|
195
112
|
-------
|
|
196
|
-
|
|
113
|
+
None, set regression lines data to sample instance.
|
|
197
114
|
"""
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
figure
|
|
203
|
-
figure
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
115
|
+
for index in [0, 1]:
|
|
116
|
+
xscale, yscale = [figure.xaxis.min, figure.xaxis.max], [figure.yaxis.min, figure.yaxis.max]
|
|
117
|
+
coeffs = [sample.Info.results.isochron[figure.id][index]['k'], sample.Info.results.isochron[figure.id][index]['m1']]
|
|
118
|
+
line_point = calc.isochron.get_line_points(xscale, yscale, coeffs)
|
|
119
|
+
setattr(getattr(figure, ['line1', 'line2'][index]), 'data', line_point)
|
|
120
|
+
setattr(getattr(figure, ['text1', 'text2'][index]), 'text', "") # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
def get_iso_init(sample: Sample, figure: Plot):
|
|
124
|
+
# data
|
|
125
|
+
val = ISOCHRON_INDEX_DICT.get(figure.id)['data_index']
|
|
126
|
+
data = [*sample.IsochronValues[val[0]:val[1]], list(range(sample.Info.experiment.step_num))]
|
|
127
|
+
# ellipse
|
|
128
|
+
ellipse_data = []
|
|
129
|
+
if figure.id != 'figure_7':
|
|
130
|
+
for point in calc.arr.transpose(data[:5]):
|
|
131
|
+
if '' not in point and None not in point:
|
|
132
|
+
ellipse_data.append(calc.isochron.get_ellipse(*point))
|
|
133
|
+
return data, ellipse_data
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
def plot_normal_iso(sample: Sample, isInit: bool = False):
|
|
137
|
+
figure = sample.NorIsochronPlot
|
|
138
|
+
# data
|
|
139
|
+
if isInit:
|
|
140
|
+
data, ellipse_data = get_iso_init(sample, figure)
|
|
141
|
+
figure.data = data
|
|
142
|
+
getattr(figure, 'ellipse', Set(id='ellipse')).data = ellipse_data
|
|
143
|
+
# iso res
|
|
144
|
+
get_iso_res(sample, figure)
|
|
145
|
+
# line data
|
|
146
|
+
set_iso_line_data(sample, figure)
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def plot_inverse_iso(sample: Sample, isInit: bool = False):
|
|
150
|
+
figure = sample.InvIsochronPlot
|
|
151
|
+
# data
|
|
152
|
+
if isInit:
|
|
153
|
+
data, ellipse_data = get_iso_init(sample, figure)
|
|
154
|
+
figure.data = data
|
|
155
|
+
getattr(figure, 'ellipse', Set(id='ellipse')).data = ellipse_data
|
|
156
|
+
# iso res
|
|
157
|
+
get_iso_res(sample, figure)
|
|
158
|
+
# line data
|
|
159
|
+
set_iso_line_data(sample, figure)
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def plot_cl1_iso(sample: Sample, isInit: bool = False):
|
|
163
|
+
figure = sample.KClAr1IsochronPlot
|
|
164
|
+
# data
|
|
165
|
+
if isInit:
|
|
166
|
+
data, ellipse_data = get_iso_init(sample, figure)
|
|
167
|
+
figure.data = data
|
|
168
|
+
getattr(figure, 'ellipse', Set(id='ellipse')).data = ellipse_data
|
|
169
|
+
# iso res
|
|
170
|
+
get_iso_res(sample, figure)
|
|
171
|
+
# line data
|
|
172
|
+
set_iso_line_data(sample, figure)
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
def plot_cl2_iso(sample: Sample, isInit: bool = False):
|
|
176
|
+
figure = sample.KClAr2IsochronPlot
|
|
177
|
+
# data
|
|
178
|
+
if isInit:
|
|
179
|
+
data, ellipse_data = get_iso_init(sample, figure)
|
|
180
|
+
figure.data = data
|
|
181
|
+
getattr(figure, 'ellipse', Set(id='ellipse')).data = ellipse_data
|
|
182
|
+
# iso res
|
|
183
|
+
get_iso_res(sample, figure)
|
|
184
|
+
# line data
|
|
185
|
+
set_iso_line_data(sample, figure)
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
def plot_cl3_iso(sample: Sample, isInit: bool = False):
|
|
189
|
+
figure = sample.KClAr3IsochronPlot
|
|
190
|
+
# data
|
|
191
|
+
if isInit:
|
|
192
|
+
data, ellipse_data = get_iso_init(sample, figure)
|
|
193
|
+
figure.data = data
|
|
194
|
+
getattr(figure, 'ellipse', Set(id='ellipse')).data = ellipse_data
|
|
195
|
+
# iso res
|
|
196
|
+
get_iso_res(sample, figure)
|
|
197
|
+
# line data
|
|
198
|
+
set_iso_line_data(sample, figure)
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
def plot_3D_iso(sample: Sample, isInit: bool = False):
|
|
202
|
+
figure = sample.ThreeDIsochronPlot
|
|
203
|
+
# data
|
|
204
|
+
if isInit:
|
|
205
|
+
data, ellipse_data = get_iso_init(sample, figure)
|
|
206
|
+
figure.data = data
|
|
207
|
+
# iso res
|
|
208
|
+
get_iso_res(sample, figure)
|
|
215
209
|
|
|
216
210
|
|
|
217
211
|
def get_isochron_results(data: list, smp: Sample, sequence, figure_type: int = 0):
|
|
@@ -331,33 +325,55 @@ def get_3D_results(data: list, sequence: list, sample: Sample):
|
|
|
331
325
|
return iso_res
|
|
332
326
|
|
|
333
327
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
Set isochron regression lines
|
|
337
|
-
Parameters
|
|
338
|
-
----------
|
|
339
|
-
smp : sample instance
|
|
328
|
+
# Spectra
|
|
329
|
+
def init_age_spec_plot(sample: Sample):
|
|
340
330
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
331
|
+
figure = sample.AgeSpectraPlot
|
|
332
|
+
|
|
333
|
+
try:
|
|
334
|
+
params_to_check = {
|
|
335
|
+
'40Arr/39ArK': {'data': sample.ApparentAgeValues[2:4], 'dtype': float, 'func': lambda x: np.isfinite(x), 'class': 'k1', },
|
|
336
|
+
'39ArK%': {'data': sample.ApparentAgeValues[7], 'dtype': float, 'func': lambda x: np.isfinite(x), 'class': 'k1', },
|
|
337
|
+
}
|
|
338
|
+
except (IndexError, AttributeError) as e:
|
|
339
|
+
raise
|
|
340
|
+
if not basic.validate_params(fatal=False, **params_to_check):
|
|
341
|
+
return
|
|
342
|
+
|
|
343
|
+
try:
|
|
344
|
+
if str(sample.Info.sample.type).lower() == "unknown":
|
|
345
|
+
a0, e0 = sum(sample.DegasValues[24]), pow(sum([i ** 2 for i in sample.DegasValues[25]]), 0.5)
|
|
346
|
+
a1, e1 = sum(sample.DegasValues[20]), pow(sum([i ** 2 for i in sample.DegasValues[21]]), 0.5)
|
|
347
|
+
handler = basic.calc_age
|
|
348
|
+
elif str(sample.Info.sample.type).lower() == "standard":
|
|
349
|
+
a0, e0 = sum(sample.DegasValues[24]), pow(sum([i ** 2 for i in sample.DegasValues[25]]), 0.5)
|
|
350
|
+
a1, e1 = sum(sample.DegasValues[20]), pow(sum([i ** 2 for i in sample.DegasValues[21]]), 0.5)
|
|
351
|
+
handler = basic.calc_j
|
|
352
|
+
elif str(sample.Info.sample.type).lower() == "air":
|
|
353
|
+
a0, e0 = sum(sample.DegasValues[26]), pow(sum([i ** 2 for i in sample.DegasValues[27]]), 0.5)
|
|
354
|
+
a1, e1 = sum(sample.DegasValues[ 0]), pow(sum([i ** 2 for i in sample.DegasValues[ 1]]), 0.5)
|
|
355
|
+
handler = basic.calc_mdf
|
|
356
|
+
else:
|
|
357
|
+
msg = f"Sample type is not supported: {sample.Info.sample.type}"
|
|
358
|
+
context = {'names': [figure.name], 'classnames': [f'k7'], 'messages': [msg]}
|
|
359
|
+
raise basic.ParamsInvalid(400, msg, context=context, fatal=False)
|
|
360
|
+
|
|
361
|
+
total_f = [a0 / a1, calc.err.div((a0, e0), (a1, e1))]
|
|
362
|
+
total_age = handler(total_f[:2], smp=sample)
|
|
363
|
+
except (Exception, BaseException) as e:
|
|
364
|
+
total_f = [np.nan] * 2
|
|
365
|
+
total_age = [np.nan] * 4
|
|
366
|
+
|
|
367
|
+
sample.Info.results.age_spectra['TGA'].update(
|
|
368
|
+
{'Ar39': 100, 'F': total_f[0], 'sF': total_f[1], 'age': total_age[0],
|
|
369
|
+
's1': total_age[1], 's2': total_age[2], 's3': total_age[3], 'Num': len(sample.DegasValues[24])}
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
figure.data = calc.arr.transpose(
|
|
373
|
+
calc.spectra.get_data(*sample.ApparentAgeValues[2:4], sample.ApparentAgeValues[7])
|
|
374
|
+
)
|
|
356
375
|
|
|
357
376
|
|
|
358
|
-
# =======================
|
|
359
|
-
# Age spectra results
|
|
360
|
-
# =======================
|
|
361
377
|
def recalc_plateaus(sample: Sample, **kwargs):
|
|
362
378
|
if sample.Info.sample.type == "Unknown":
|
|
363
379
|
return recalc_age_plateaus(sample, **kwargs)
|
|
@@ -379,6 +395,19 @@ def recalc_age_plateaus(sample: Sample, **kwargs):
|
|
|
379
395
|
-------
|
|
380
396
|
None
|
|
381
397
|
"""
|
|
398
|
+
|
|
399
|
+
try:
|
|
400
|
+
params_to_check = {
|
|
401
|
+
'39ArK': {'data': sample.DegasValues[20:22], 'dtype': float, 'func': lambda x: np.isfinite(x), 'class': 'k1', },
|
|
402
|
+
'40Arr': {'data': sample.DegasValues[24:26], 'dtype': float, 'func': lambda x: np.isfinite(x), 'class': 'k1', },
|
|
403
|
+
'J Factor': {'data': sample.TotalParam[136], 'dtype': float, 'func': lambda x: np.isfinite(x) and x > 0, 'class': 'k1', },
|
|
404
|
+
'J Factor': {'data': sample.TotalParam[137], 'dtype': float, 'func': lambda x: np.isfinite(x), 'class': 'k1', },
|
|
405
|
+
}
|
|
406
|
+
except (IndexError, AttributeError) as e:
|
|
407
|
+
raise
|
|
408
|
+
if not basic.validate_params(fatal=False, **params_to_check):
|
|
409
|
+
return
|
|
410
|
+
|
|
382
411
|
ar39k, sar39k = calc.arr.mul(sample.DegasValues[20:22], sample.TotalParam[136:138])
|
|
383
412
|
ar40r, sar40r = sample.DegasValues[24:26]
|
|
384
413
|
ar40rar39k = calc.arr.div([ar40r, sar40r], [ar39k, sar39k])
|
|
@@ -561,6 +590,30 @@ def recalc_mdf_plateaus(sample: Sample, **kwargs):
|
|
|
561
590
|
sample.AgeSpectraPlot.text2.text = ""
|
|
562
591
|
|
|
563
592
|
|
|
593
|
+
def recalc_j_plateaus(sample: Sample, **kwargs):
|
|
594
|
+
|
|
595
|
+
ar40rar39k = sample.ApparentAgeValues[0:2]
|
|
596
|
+
j = sample.ApparentAgeValues[2:4]
|
|
597
|
+
|
|
598
|
+
try:
|
|
599
|
+
set1_res, _, set1_data = get_plateau_results(sample, sample.SelectedSequence1, ar40rar39k=ar40rar39k)
|
|
600
|
+
except ValueError:
|
|
601
|
+
pass
|
|
602
|
+
else:
|
|
603
|
+
sample.Info.results.age_plateau.update({0: set1_res})
|
|
604
|
+
sample.AgeSpectraPlot.set1.data = calc.arr.transpose(set1_data)
|
|
605
|
+
sample.AgeSpectraPlot.text1.text = "" # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
606
|
+
|
|
607
|
+
try:
|
|
608
|
+
set2_res, _, set2_data = get_plateau_results(sample, sample.SelectedSequence2, ar40rar39k=ar40rar39k)
|
|
609
|
+
except ValueError:
|
|
610
|
+
pass
|
|
611
|
+
else:
|
|
612
|
+
sample.Info.results.age_plateau.update({1: set2_res})
|
|
613
|
+
sample.AgeSpectraPlot.set2.data = calc.arr.transpose(set2_data)
|
|
614
|
+
sample.AgeSpectraPlot.text2.text = "" # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
615
|
+
|
|
616
|
+
|
|
564
617
|
def calc_ar40ar39(r, sr, smp):
|
|
565
618
|
"""
|
|
566
619
|
Calculate Ar40r / Ar39K based on passed initial ratio.
|
|
@@ -693,33 +746,7 @@ def get_wma_results(sample: Sample, sequence: list, ar40rar39k: list = None, ar3
|
|
|
693
746
|
return spectra_res
|
|
694
747
|
|
|
695
748
|
|
|
696
|
-
def recalc_j_plateaus(sample: Sample, **kwargs):
|
|
697
|
-
|
|
698
|
-
ar40rar39k = sample.ApparentAgeValues[0:2]
|
|
699
|
-
j = sample.ApparentAgeValues[2:4]
|
|
700
|
-
|
|
701
|
-
try:
|
|
702
|
-
set1_res, _, set1_data = get_plateau_results(sample, sample.SelectedSequence1, ar40rar39k=ar40rar39k)
|
|
703
|
-
except ValueError:
|
|
704
|
-
pass
|
|
705
|
-
else:
|
|
706
|
-
sample.Info.results.age_plateau.update({0: set1_res})
|
|
707
|
-
sample.AgeSpectraPlot.set1.data = calc.arr.transpose(set1_data)
|
|
708
|
-
sample.AgeSpectraPlot.text1.text = "" # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
709
|
-
|
|
710
|
-
try:
|
|
711
|
-
set2_res, _, set2_data = get_plateau_results(sample, sample.SelectedSequence2, ar40rar39k=ar40rar39k)
|
|
712
|
-
except ValueError:
|
|
713
|
-
pass
|
|
714
|
-
else:
|
|
715
|
-
sample.Info.results.age_plateau.update({1: set2_res})
|
|
716
|
-
sample.AgeSpectraPlot.set2.data = calc.arr.transpose(set2_data)
|
|
717
|
-
sample.AgeSpectraPlot.text2.text = "" # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
# =======================
|
|
721
749
|
# Age Distribution Plot
|
|
722
|
-
# =======================
|
|
723
750
|
def recalc_agedistribution(smp: Sample, **kwargs):
|
|
724
751
|
try:
|
|
725
752
|
ages = smp.ApparentAgeValues[2]
|
|
@@ -769,14 +796,32 @@ def recalc_agedistribution(smp: Sample, **kwargs):
|
|
|
769
796
|
plot.set2.data = [[], []]
|
|
770
797
|
|
|
771
798
|
|
|
772
|
-
# =======================
|
|
773
799
|
# Age Distribution Plot
|
|
774
|
-
# =======================
|
|
775
800
|
def recalc_degassing_plot(smp: Sample, **kwargs):
|
|
801
|
+
figure = smp.DegasPatternPlot
|
|
802
|
+
|
|
803
|
+
try:
|
|
804
|
+
params_to_check = {
|
|
805
|
+
'degas pattern': [
|
|
806
|
+
{'data': smp.DegasValues[0], 'dtype': float, 'class': 'k8', },
|
|
807
|
+
{'data': smp.DegasValues[8], 'dtype': float, 'class': 'k8', },
|
|
808
|
+
{'data': smp.DegasValues[10], 'dtype': float, 'class': 'k8', },
|
|
809
|
+
{'data': smp.DegasValues[20], 'dtype': float, 'class': 'k8', },
|
|
810
|
+
{'data': smp.DegasValues[24], 'dtype': float, 'class': 'k8', },
|
|
811
|
+
{'data': smp.CorrectedValues[0:10:2], 'dtype': float, 'class': 'k8', },
|
|
812
|
+
],
|
|
813
|
+
}
|
|
814
|
+
except (IndexError, AttributeError) as e:
|
|
815
|
+
context = {'names': [figure.name], 'classnames': [f'k8'], 'messages': [f"{figure.name}: {str(e)}"]}
|
|
816
|
+
raise basic.ParamsInvalid(400, f"{figure.name}: {str(e)}", context=context, fatal=False)
|
|
817
|
+
|
|
818
|
+
if not basic.validate_params(fatal=False, **params_to_check):
|
|
819
|
+
return
|
|
820
|
+
|
|
776
821
|
if not hasattr(smp, 'DegasPatternPlot'):
|
|
777
822
|
setattr(smp, 'DegasPatternPlot', Plot(id='figure_8', name='Degas Pattern Plot'))
|
|
778
823
|
isotope_percentage = lambda l: [e / sum(l) * 100 if sum(l) != 0 else 0 for e in l]
|
|
779
|
-
|
|
824
|
+
figure.data = [
|
|
780
825
|
isotope_percentage(smp.DegasValues[0]), # Ar36a
|
|
781
826
|
isotope_percentage(smp.DegasValues[8]), # Ar37Ca
|
|
782
827
|
isotope_percentage(smp.DegasValues[10]), # Ar38Cl
|
|
@@ -788,4 +833,4 @@ def recalc_degassing_plot(smp: Sample, **kwargs):
|
|
|
788
833
|
isotope_percentage(smp.CorrectedValues[6]), # Ar39
|
|
789
834
|
isotope_percentage(smp.CorrectedValues[8]), # Ar40
|
|
790
835
|
]
|
|
791
|
-
|
|
836
|
+
figure.info = [True] * 10
|
ararpy/smp/sample.py
CHANGED
|
@@ -52,24 +52,36 @@ DEGAS_HEADERS = [
|
|
|
52
52
|
]
|
|
53
53
|
PUBLISH_TABLE_HEADERS = [
|
|
54
54
|
'Sequence', '', 'Mark', # 0-2
|
|
55
|
-
'\u00B3\u2076Ar
|
|
56
|
-
'\u00B3\
|
|
57
|
-
'
|
|
58
|
-
'
|
|
55
|
+
'\u00B3\u2076Ar', '%1\u03C3',
|
|
56
|
+
'\u00B3\u2077Ar', '%1\u03C3',
|
|
57
|
+
'\u00B3\u2078Ar', '%1\u03C3',
|
|
58
|
+
'\u00B3\u2079Ar', '%1\u03C3',
|
|
59
|
+
'\u2074\u2070Ar', '%1\u03C3', # 3-12
|
|
60
|
+
'\u2074\u2070Ar/\u00B3\u2076Ar', '1\u03C3', # 13-14
|
|
61
|
+
'Apparent Age', '1\u03C3', '\u2074\u2070Ar[r]%', '\u00B3\u2079Ar[K]%', # 15-18
|
|
62
|
+
'Ca/K', '1\u03C3', # 19-20
|
|
59
63
|
]
|
|
60
64
|
PUBLISH_TABLE_HEADERS_AIR = [
|
|
61
65
|
'Sequence', '', 'Mark', # 0-2
|
|
62
|
-
'\u00B3\u2076Ar
|
|
63
|
-
'\u00B3\
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
+
'\u00B3\u2076Ar', '%1\u03C3',
|
|
67
|
+
'\u00B3\u2077Ar', '%1\u03C3',
|
|
68
|
+
'\u00B3\u2078Ar', '%1\u03C3',
|
|
69
|
+
'\u00B3\u2079Ar', '%1\u03C3',
|
|
70
|
+
'\u2074\u2070Ar', '%1\u03C3', # 3-12
|
|
71
|
+
'\u2074\u2070Ar/\u00B3\u2076Ar', '1\u03C3', # 13-14
|
|
72
|
+
'MDF', '1\u03C3', '\u2074\u2070Ar[r]%', '\u00B3\u2076Ar%', # 15-18
|
|
73
|
+
'Ca/K', '1\u03C3', # 19-20
|
|
66
74
|
]
|
|
67
75
|
PUBLISH_TABLE_HEADERS_STD = [
|
|
68
76
|
'Sequence', '', 'Mark', # 0-2
|
|
69
|
-
'\u00B3\u2076Ar
|
|
70
|
-
'\u00B3\
|
|
71
|
-
'
|
|
72
|
-
'
|
|
77
|
+
'\u00B3\u2076Ar', '%1\u03C3',
|
|
78
|
+
'\u00B3\u2077Ar', '%1\u03C3',
|
|
79
|
+
'\u00B3\u2078Ar', '%1\u03C3',
|
|
80
|
+
'\u00B3\u2079Ar', '%1\u03C3',
|
|
81
|
+
'\u2074\u2070Ar', '%1\u03C3', # 3-12
|
|
82
|
+
'\u2074\u2070Ar/\u00B3\u2076Ar', '1\u03C3', # 13-14
|
|
83
|
+
'J', '1\u03C3', '\u2074\u2070Ar[r]%', '\u00B3\u2076Ar%', # 15-18
|
|
84
|
+
'Ca/K', '1\u03C3', # 19-20
|
|
73
85
|
]
|
|
74
86
|
SPECTRUM_TABLE_HEADERS = [
|
|
75
87
|
'Sequence', '', 'Mark', # 0-2
|
|
@@ -200,9 +212,13 @@ DEGAS_SHORT_HEADERS = [
|
|
|
200
212
|
]
|
|
201
213
|
PUBLISH_TABLE_SHORT_HEADERS = [
|
|
202
214
|
'Seq', 'Label', 'Mark', # 0-2
|
|
203
|
-
'Ar36
|
|
204
|
-
'
|
|
205
|
-
'
|
|
215
|
+
'Ar36', '%1s',
|
|
216
|
+
'Ar37', '%1s',
|
|
217
|
+
'Ar38', '%1s',
|
|
218
|
+
'Ar39', '%1s',
|
|
219
|
+
'Ar40', '%1s',
|
|
220
|
+
'Apparent Age', '1s', 'Ar40r%', 'Ar39K%',
|
|
221
|
+
'Ca/K', '1s'
|
|
206
222
|
]
|
|
207
223
|
SPECTRUM_TABLE_SHORT_HEADERS = [
|
|
208
224
|
'Seq', 'Label', 'Mark', # 0-2
|
|
@@ -839,7 +855,8 @@ class Sample:
|
|
|
839
855
|
# self.__version = '20250328' # Experiment info
|
|
840
856
|
# self.__version = '20250404' # J normalization factor
|
|
841
857
|
# self.__version = '20251001' # add marker col for all tables
|
|
842
|
-
self.__version = '20251231' # move montecarlo to params-112
|
|
858
|
+
# self.__version = '20251231' # move montecarlo to params-112
|
|
859
|
+
self.__version = '20260101' #
|
|
843
860
|
|
|
844
861
|
self.Doi = ""
|
|
845
862
|
self.RawData = RawData()
|
ararpy/smp/style.py
CHANGED
|
@@ -60,8 +60,6 @@ def set_plot_style(smp: Sample):
|
|
|
60
60
|
initial.initial_plot_styles(smp, except_attrs=['data'])
|
|
61
61
|
# Auto scale
|
|
62
62
|
reset_plot_scale(smp)
|
|
63
|
-
# Reset isochron data
|
|
64
|
-
plots.reset_isochron_line_data(smp)
|
|
65
63
|
# Auto position and contents of texts
|
|
66
64
|
reset_text(smp)
|
|
67
65
|
# Set title, which are deleted in initializing
|
|
@@ -69,8 +67,16 @@ def set_plot_style(smp: Sample):
|
|
|
69
67
|
smp_name = smp.Info.sample.name
|
|
70
68
|
name = f"{exp_name} {smp_name}" if str(exp_name).lower().strip() != str(smp_name).lower().strip() else exp_name
|
|
71
69
|
suffix = f"{name} {smp.Info.sample.material}"
|
|
70
|
+
|
|
72
71
|
for figure_id, figure in basic.get_components(smp).items():
|
|
72
|
+
if not isinstance(figure, Plot):
|
|
73
|
+
continue
|
|
74
|
+
|
|
73
75
|
if isinstance(figure, Plot):
|
|
76
|
+
# Reset isochron line
|
|
77
|
+
if figure_id in ['figure_2', 'figure_3', 'figure_4', 'figure_5', 'figure_6', ]:
|
|
78
|
+
plots.set_iso_line_data(smp, figure)
|
|
79
|
+
# name and title
|
|
74
80
|
if not hasattr(figure, 'title'):
|
|
75
81
|
setattr(figure, 'title', Plot.Text())
|
|
76
82
|
setattr(getattr(figure, 'title'), 'text', f"{suffix} {getattr(figure, 'name', '')}")
|
|
@@ -111,8 +117,8 @@ def reset_plot_scale(smp: Sample, only_figure: str = None):
|
|
|
111
117
|
if k == 'figure_1':
|
|
112
118
|
try:
|
|
113
119
|
k0 = calc.arr.transpose(v.data)
|
|
114
|
-
k1 = calc.arr.transpose(v.set1.data) if len(v.set1.data) != 0 else [[]
|
|
115
|
-
k2 = calc.arr.transpose(v.set2.data) if len(v.set2.data) != 0 else [[]
|
|
120
|
+
k1 = calc.arr.transpose(v.set1.data) if len(v.set1.data) != 0 else [[] for i in range(3)]
|
|
121
|
+
k2 = calc.arr.transpose(v.set2.data) if len(v.set2.data) != 0 else [[] for i in range(3)]
|
|
116
122
|
data = np.concatenate([k0, k1, k2], axis=1)
|
|
117
123
|
ylist = np.concatenate([data[1], data[2]])
|
|
118
124
|
yscale = calc.plot.get_axis_scale(ylist, min_interval=5, extra_count=1)
|