ararpy 0.1.199__py3-none-any.whl → 0.2.2__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/jvalue.py +7 -5
- 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.2.dist-info}/METADATA +10 -1
- ararpy-0.2.2.dist-info/RECORD +73 -0
- {ararpy-0.1.199.dist-info → ararpy-0.2.2.dist-info}/WHEEL +1 -1
- ararpy-0.1.199.dist-info/RECORD +0 -66
- {ararpy-0.1.199.dist-info → ararpy-0.2.2.dist-info}/licenses/LICENSE +0 -0
- {ararpy-0.1.199.dist-info → ararpy-0.2.2.dist-info}/top_level.txt +0 -0
ararpy/smp/plots.py
CHANGED
|
@@ -58,32 +58,36 @@ def set_plot_data(sample: Sample, isInit: bool = True, isIsochron: bool = True,
|
|
|
58
58
|
|
|
59
59
|
# Initialization, apply age spectra data and isochron plot data
|
|
60
60
|
if isInit:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
initial_plot_data(sample)
|
|
62
|
+
# try:
|
|
63
|
+
# initial_plot_data(sample)
|
|
64
|
+
# except (Exception, BaseException):
|
|
65
|
+
# print("initial_plot_data(sample) error:\n", traceback.format_exc())
|
|
66
|
+
# pass
|
|
66
67
|
|
|
67
68
|
# Recalculate isochron lines
|
|
68
69
|
if isIsochron:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
70
|
+
recalc_isochrons(sample, **kwargs)
|
|
71
|
+
reset_isochron_line_data(sample)
|
|
72
|
+
# try:
|
|
73
|
+
# recalc_isochrons(sample, **kwargs)
|
|
74
|
+
# except (Exception, BaseException):
|
|
75
|
+
# print("recalc_isochrons(sample, **kwargs) error:\n", traceback.format_exc())
|
|
76
|
+
# pass
|
|
77
|
+
# try:
|
|
78
|
+
# reset_isochron_line_data(sample)
|
|
79
|
+
# except (Exception, BaseException):
|
|
80
|
+
# print("reset_isochron_line_data(sample):\n", traceback.format_exc())
|
|
81
|
+
# pass
|
|
79
82
|
|
|
80
83
|
# Recalculate plateaus
|
|
81
84
|
if isPlateau:
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
85
|
+
recalc_plateaus(sample)
|
|
86
|
+
# try:
|
|
87
|
+
# recalc_plateaus(sample)
|
|
88
|
+
# except (Exception, BaseException):
|
|
89
|
+
# print("recalc_plateaus(sample) error:\n", traceback.format_exc())
|
|
90
|
+
# pass
|
|
87
91
|
|
|
88
92
|
|
|
89
93
|
# =======================
|
|
@@ -100,26 +104,42 @@ def initial_plot_data(smp: Sample):
|
|
|
100
104
|
-------
|
|
101
105
|
None
|
|
102
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
|
+
|
|
127
|
+
# Isochron plots
|
|
103
128
|
for key, val in ISOCHRON_INDEX_DICT.items():
|
|
104
129
|
figure = basic.get_component_byid(smp, key)
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
if '' not in point and None not in point:
|
|
119
|
-
ellipse_data.append(calc.isochron.get_ellipse(*point))
|
|
120
|
-
getattr(figure, 'ellipse', Set(id='ellipse')).data = ellipse_data
|
|
121
|
-
|
|
122
|
-
# Set age spectra lines
|
|
130
|
+
figure.data = [
|
|
131
|
+
*smp.IsochronValues[val['data_index'][0]:val['data_index'][1]],
|
|
132
|
+
list(range(smp.Info.experiment.step_num))
|
|
133
|
+
]
|
|
134
|
+
# Ellipse
|
|
135
|
+
if key != 'figure_7':
|
|
136
|
+
ellipse_data = []
|
|
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
|
|
123
143
|
# Try to calculate total gas age
|
|
124
144
|
try:
|
|
125
145
|
if str(smp.Info.sample.type).lower() == "unknown":
|
|
@@ -142,8 +162,6 @@ def initial_plot_data(smp: Sample):
|
|
|
142
162
|
print(traceback.format_exc())
|
|
143
163
|
total_f = [np.nan] * 2
|
|
144
164
|
total_age = [np.nan] * 4
|
|
145
|
-
print(f"{total_f = }")
|
|
146
|
-
print(f"{total_age = }")
|
|
147
165
|
smp.Info.results.age_spectra['TGA'].update(
|
|
148
166
|
{'Ar39': 100, 'F': total_f[0], 'sF': total_f[1], 'age': total_age[0],
|
|
149
167
|
's1': total_age[1], 's2': total_age[2], 's3': total_age[3], 'Num': len(smp.DegasValues[24])}
|
|
@@ -156,32 +174,10 @@ def initial_plot_data(smp: Sample):
|
|
|
156
174
|
smp.AgeSpectraPlot.data = []
|
|
157
175
|
|
|
158
176
|
# Degassing plot
|
|
159
|
-
|
|
160
|
-
if not hasattr(smp, 'DegasPatternPlot'):
|
|
161
|
-
setattr(smp, 'DegasPatternPlot', Plot(id='figure_8', name='Degas Pattern Plot'))
|
|
162
|
-
isotope_percentage = lambda l: [e / sum(l) * 100 if sum(l) != 0 else 0 for e in l]
|
|
163
|
-
smp.DegasPatternPlot.data = [
|
|
164
|
-
isotope_percentage(smp.DegasValues[0]), # Ar36a
|
|
165
|
-
isotope_percentage(smp.DegasValues[8]), # Ar37Ca
|
|
166
|
-
isotope_percentage(smp.DegasValues[10]), # Ar38Cl
|
|
167
|
-
isotope_percentage(smp.DegasValues[20]), # Ar39K
|
|
168
|
-
isotope_percentage(smp.DegasValues[24]), # Ar40r
|
|
169
|
-
isotope_percentage(smp.CorrectedValues[0]), # Ar36
|
|
170
|
-
isotope_percentage(smp.CorrectedValues[2]), # Ar37
|
|
171
|
-
isotope_percentage(smp.CorrectedValues[4]), # Ar38
|
|
172
|
-
isotope_percentage(smp.CorrectedValues[6]), # Ar39
|
|
173
|
-
isotope_percentage(smp.CorrectedValues[8]), # Ar40
|
|
174
|
-
]
|
|
175
|
-
smp.DegasPatternPlot.info = [True] * 10
|
|
176
|
-
except Exception as e:
|
|
177
|
-
print(traceback.format_exc())
|
|
178
|
-
pass
|
|
177
|
+
recalc_degassing_plot(smp)
|
|
179
178
|
|
|
180
|
-
#
|
|
181
|
-
|
|
182
|
-
recalc_agedistribution(smp)
|
|
183
|
-
except Exception as e:
|
|
184
|
-
print(traceback.format_exc())
|
|
179
|
+
# Age distribution plot
|
|
180
|
+
recalc_agedistribution(smp)
|
|
185
181
|
|
|
186
182
|
|
|
187
183
|
# =======================
|
|
@@ -249,13 +245,14 @@ def get_isochron_results(data: list, smp: Sample, sequence, figure_type: int = 0
|
|
|
249
245
|
|
|
250
246
|
if len(sequence) < 3:
|
|
251
247
|
return iso_res
|
|
252
|
-
regression_method = {
|
|
253
|
-
"york-2": calc.regression.york2, "olst": calc.regression.olst
|
|
254
|
-
}.get(smp.TotalParam[97][min(sequence)].lower(), calc.regression.york2)
|
|
255
248
|
try:
|
|
249
|
+
regression_method = {
|
|
250
|
+
"york-2": calc.regression.york2, "olst": calc.regression.olst
|
|
251
|
+
}.get(smp.TotalParam[97][min(sequence)].lower(), calc.regression.york2)
|
|
256
252
|
regression_res = regression_method(*data[:5])
|
|
257
253
|
except (Exception, BaseException):
|
|
258
|
-
# print(f"
|
|
254
|
+
# print(f"{data[:5] = }")
|
|
255
|
+
# print(f"Warning Isochron Regression: {traceback.format_exc()}")
|
|
259
256
|
return iso_res
|
|
260
257
|
else:
|
|
261
258
|
iso_res.update(dict(zip(reg_res_index, regression_res)))
|
|
@@ -348,50 +345,14 @@ def reset_isochron_line_data(smp: Sample):
|
|
|
348
345
|
for k, v in basic.get_components(smp).items():
|
|
349
346
|
if not isinstance(v, Plot):
|
|
350
347
|
continue
|
|
348
|
+
if k not in ['figure_2', 'figure_3', 'figure_4', 'figure_5', 'figure_6', ]:
|
|
349
|
+
continue
|
|
351
350
|
for index in [0, 1]:
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
setattr(getattr(v, ['text1', 'text2'][index]), 'text', "") # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
358
|
-
except Exception:
|
|
359
|
-
# print(traceback.format_exc())
|
|
360
|
-
continue
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
def set_selection(smp: Sample, index: int, mark: int):
|
|
364
|
-
"""
|
|
365
|
-
Parameters
|
|
366
|
-
----------
|
|
367
|
-
smp : sample instance
|
|
368
|
-
index : int, data point index
|
|
369
|
-
mark : int, 0 for unselected, 1 for set1, 2 for set2
|
|
370
|
-
|
|
371
|
-
Returns
|
|
372
|
-
-------
|
|
373
|
-
|
|
374
|
-
"""
|
|
375
|
-
if mark not in [1, 2, '1', '2']:
|
|
376
|
-
raise ValueError(f"{mark = }, mark must be 1 or 2.")
|
|
377
|
-
|
|
378
|
-
def seq(_i): return [smp.UnselectedSequence, smp.SelectedSequence1, smp.SelectedSequence2][_i]
|
|
379
|
-
|
|
380
|
-
if index in seq(mark):
|
|
381
|
-
seq(mark).remove(index)
|
|
382
|
-
smp.UnselectedSequence.append(index)
|
|
383
|
-
else:
|
|
384
|
-
for i in [0, [0, 2, 1][mark]]:
|
|
385
|
-
if index in seq(i):
|
|
386
|
-
seq(i).remove(index)
|
|
387
|
-
seq(mark).append(index)
|
|
388
|
-
smp.IsochronMark = [
|
|
389
|
-
'1' if i in smp.SelectedSequence1 else '2' if i in smp.SelectedSequence2 else '' for i in
|
|
390
|
-
range(len(smp.IsochronValues[2]))]
|
|
391
|
-
#
|
|
392
|
-
smp.Info.results.selection[0]['data'] = smp.SelectedSequence1
|
|
393
|
-
smp.Info.results.selection[1]['data'] = smp.SelectedSequence2
|
|
394
|
-
smp.Info.results.selection[2]['data'] = smp.UnselectedSequence
|
|
351
|
+
xscale, yscale = [v.xaxis.min, v.xaxis.max], [v.yaxis.min, v.yaxis.max]
|
|
352
|
+
coeffs = [smp.Info.results.isochron[k][index]['k'], smp.Info.results.isochron[k][index]['m1']]
|
|
353
|
+
line_point = calc.isochron.get_line_points(xscale, yscale, coeffs)
|
|
354
|
+
setattr(getattr(v, ['line1', 'line2'][index]), 'data', line_point)
|
|
355
|
+
setattr(getattr(v, ['text1', 'text2'][index]), 'text', "") # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
395
356
|
|
|
396
357
|
|
|
397
358
|
# =======================
|
|
@@ -418,7 +379,7 @@ def recalc_age_plateaus(sample: Sample, **kwargs):
|
|
|
418
379
|
-------
|
|
419
380
|
None
|
|
420
381
|
"""
|
|
421
|
-
ar39k, sar39k = calc.arr.mul(sample.DegasValues[20:22], sample.
|
|
382
|
+
ar39k, sar39k = calc.arr.mul(sample.DegasValues[20:22], sample.TotalParam[136:138])
|
|
422
383
|
ar40r, sar40r = sample.DegasValues[24:26]
|
|
423
384
|
ar40rar39k = calc.arr.div([ar40r, sar40r], [ar39k, sar39k])
|
|
424
385
|
params_initial_ratio = calc.arr.partial(sample.TotalParam, cols=list(range(115, 120)))
|
|
@@ -577,7 +538,7 @@ def recalc_mdf_plateaus(sample: Sample, **kwargs):
|
|
|
577
538
|
-------
|
|
578
539
|
None
|
|
579
540
|
"""
|
|
580
|
-
ar36a, sar36a = calc.arr.mul(sample.DegasValues[0:2], sample.
|
|
541
|
+
ar36a, sar36a = calc.arr.mul(sample.DegasValues[0:2], sample.TotalParam[136:138])
|
|
581
542
|
ar40aar36a = sample.ApparentAgeValues[0:2]
|
|
582
543
|
mdf = sample.ApparentAgeValues[2:4]
|
|
583
544
|
|
|
@@ -615,7 +576,7 @@ def calc_ar40ar39(r, sr, smp):
|
|
|
615
576
|
"""
|
|
616
577
|
try:
|
|
617
578
|
ar36a = np.array(smp.DegasValues[0:2])
|
|
618
|
-
ar39k = calc.arr.mul(smp.DegasValues[20:22], smp.
|
|
579
|
+
ar39k = calc.arr.mul(smp.DegasValues[20:22], smp.TotalParam[136:138])
|
|
619
580
|
ar40 = smp.CorrectedValues[8:10]
|
|
620
581
|
ar40k = smp.DegasValues[30:32]
|
|
621
582
|
size = ar36a.shape[-1]
|
|
@@ -677,7 +638,7 @@ def get_plateau_results(smp: Sample, sequence: list, ar40rar39k: list = None,
|
|
|
677
638
|
else:
|
|
678
639
|
raise TypeError(f"Sample type is not supported: {smp.Info.sample.type}")
|
|
679
640
|
|
|
680
|
-
age = handle(
|
|
641
|
+
age = handle(ar40rar39k, smp=smp)[0:2]
|
|
681
642
|
plot_data = calc.spectra.get_data(*age, ar39k_percentage, indices=sequence, **kwargs)
|
|
682
643
|
f_values = _get_partial(sequence, *ar40rar39k)
|
|
683
644
|
age = _get_partial(sequence, *age)
|
|
@@ -759,53 +720,72 @@ def recalc_j_plateaus(sample: Sample, **kwargs):
|
|
|
759
720
|
# =======================
|
|
760
721
|
# Age Distribution Plot
|
|
761
722
|
# =======================
|
|
762
|
-
def recalc_agedistribution(
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
)
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
break
|
|
723
|
+
def recalc_agedistribution(smp: Sample, **kwargs):
|
|
724
|
+
try:
|
|
725
|
+
ages = smp.ApparentAgeValues[2]
|
|
726
|
+
plot = smp.AgeDistributionPlot
|
|
727
|
+
# Set3: Age bars
|
|
728
|
+
plot.set3.data = calc.arr.remove(smp.ApparentAgeValues[2:4], (None, np.nan))
|
|
729
|
+
|
|
730
|
+
# Set1: Histogram data
|
|
731
|
+
s = getattr(plot.set1, 'bin_start', None)
|
|
732
|
+
w = getattr(plot.set1, 'bin_width', None)
|
|
733
|
+
c = getattr(plot.set1, 'bin_count', None)
|
|
734
|
+
r = getattr(plot.set1, 'bin_rule', None)
|
|
735
|
+
# print(f's = {s}, r = {r}, w = {w}, c = {c}')
|
|
736
|
+
histogram_data = calc.histogram.get_data(ages, s=s, r=r, w=w, c=c)
|
|
737
|
+
plot.set1.data = [histogram_data[1], histogram_data[0], histogram_data[2]] # [half_bins, counts]
|
|
738
|
+
setattr(plot.set1, 'bin_start', histogram_data[3])
|
|
739
|
+
setattr(plot.set1, 'bin_rule', histogram_data[4])
|
|
740
|
+
setattr(plot.set1, 'bin_width', histogram_data[5])
|
|
741
|
+
setattr(plot.set1, 'bin_count', histogram_data[6])
|
|
742
|
+
h = getattr(plot.set2, 'band_width', None)
|
|
743
|
+
k = getattr(plot.set2, 'band_kernel', 'normal')
|
|
744
|
+
t = getattr(plot.set2, 'band_extend', False)
|
|
745
|
+
a = getattr(plot.set2, 'auto_width', 'Scott')
|
|
746
|
+
n = getattr(plot.set2, 'band_points', 1000)
|
|
747
|
+
# print(f'h = {h}, k = {k}, a = {a}, n = {n}, extend = {t}')
|
|
748
|
+
kda_data = calc.histogram.get_kde(
|
|
749
|
+
ages, h=h, k=k, n=n, a=a,
|
|
750
|
+
s=float(getattr(plot.xaxis, 'min')) if t else histogram_data[3],
|
|
751
|
+
e=float(getattr(plot.xaxis, 'max')) if t else histogram_data[7],
|
|
752
|
+
)
|
|
753
|
+
|
|
754
|
+
# Set2: KDA data
|
|
755
|
+
plot.set2.data = kda_data[0] # [values, kda]
|
|
756
|
+
setattr(plot.set2, 'band_width', kda_data[1])
|
|
757
|
+
setattr(plot.set2, 'band_kernel', kda_data[2])
|
|
758
|
+
setattr(plot.set2, 'auto_width', kda_data[3])
|
|
759
|
+
# sorted_data = [i[0] for i in sorted(zipped_data, key=lambda x: x[1])]
|
|
760
|
+
text = f'n = {len(ages)}'
|
|
761
|
+
peaks = find_peaks(kda_data[0][1])
|
|
762
|
+
for index, peak in enumerate(peaks[0].tolist()):
|
|
763
|
+
text = text + f'\nPeak {index}: {kda_data[0][0][peak]:.2f}'
|
|
764
|
+
setattr(plot.text1, 'text', text)
|
|
765
|
+
except (Exception, BaseException):
|
|
766
|
+
print(traceback.format_exc())
|
|
767
|
+
plot.data = [[], []]
|
|
768
|
+
plot.set1.data = [[], []]
|
|
769
|
+
plot.set2.data = [[], []]
|
|
810
770
|
|
|
811
771
|
|
|
772
|
+
# =======================
|
|
773
|
+
# Age Distribution Plot
|
|
774
|
+
# =======================
|
|
775
|
+
def recalc_degassing_plot(smp: Sample, **kwargs):
|
|
776
|
+
if not hasattr(smp, 'DegasPatternPlot'):
|
|
777
|
+
setattr(smp, 'DegasPatternPlot', Plot(id='figure_8', name='Degas Pattern Plot'))
|
|
778
|
+
isotope_percentage = lambda l: [e / sum(l) * 100 if sum(l) != 0 else 0 for e in l]
|
|
779
|
+
smp.DegasPatternPlot.data = [
|
|
780
|
+
isotope_percentage(smp.DegasValues[0]), # Ar36a
|
|
781
|
+
isotope_percentage(smp.DegasValues[8]), # Ar37Ca
|
|
782
|
+
isotope_percentage(smp.DegasValues[10]), # Ar38Cl
|
|
783
|
+
isotope_percentage(smp.DegasValues[20]), # Ar39K
|
|
784
|
+
isotope_percentage(smp.DegasValues[24]), # Ar40r
|
|
785
|
+
isotope_percentage(smp.CorrectedValues[0]), # Ar36
|
|
786
|
+
isotope_percentage(smp.CorrectedValues[2]), # Ar37
|
|
787
|
+
isotope_percentage(smp.CorrectedValues[4]), # Ar38
|
|
788
|
+
isotope_percentage(smp.CorrectedValues[6]), # Ar39
|
|
789
|
+
isotope_percentage(smp.CorrectedValues[8]), # Ar40
|
|
790
|
+
]
|
|
791
|
+
smp.DegasPatternPlot.info = [True] * 10
|
ararpy/smp/raw.py
CHANGED
|
@@ -22,7 +22,7 @@ RawData = samples.RawData
|
|
|
22
22
|
Sequence = samples.Sequence
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
def to_raw(file_path: Union[str, List[str]], input_filter_path: Union[str, List[str]], **kwargs):
|
|
25
|
+
def to_raw(file_path: Union[str, List[str]], input_filter_path: Union[str, List[str]], file_name=None, **kwargs):
|
|
26
26
|
""" Read raw data from files, can create raw data instance based on the given files
|
|
27
27
|
Raw data will have the structure like:
|
|
28
28
|
[
|
|
@@ -35,6 +35,7 @@ def to_raw(file_path: Union[str, List[str]], input_filter_path: Union[str, List[
|
|
|
35
35
|
----------
|
|
36
36
|
file_path
|
|
37
37
|
input_filter_path
|
|
38
|
+
file_name
|
|
38
39
|
kwargs
|
|
39
40
|
|
|
40
41
|
Returns
|
|
@@ -42,22 +43,18 @@ def to_raw(file_path: Union[str, List[str]], input_filter_path: Union[str, List[
|
|
|
42
43
|
|
|
43
44
|
"""
|
|
44
45
|
if isinstance(file_path, list) and isinstance(input_filter_path, list):
|
|
45
|
-
raw = concatenate([to_raw(file, input_filter_path[index]
|
|
46
|
+
raw = concatenate([to_raw(file, input_filter_path[index],
|
|
47
|
+
file_name[index] if isinstance(file_name, list) else file_name) for index, file in enumerate(file_path)])
|
|
46
48
|
elif isinstance(file_path, str) and isinstance(input_filter_path, str):
|
|
47
49
|
input_filter = read_params(input_filter_path)
|
|
48
|
-
file_name = str(os.path.split(file_path)[-1]).split('.')[0]
|
|
49
|
-
res = raw_file.open_file(file_path, input_filter)
|
|
50
|
+
file_name = str(os.path.split(file_path)[-1]).split('.')[0] if file_name is None else file_name
|
|
51
|
+
res = raw_file.open_file(file_path, input_filter, file_name)
|
|
50
52
|
data = res.get('data', None)
|
|
51
53
|
sequences = res.get('sequences', None)
|
|
52
54
|
sequence_num = len(data) if data is not None else len(sequences)
|
|
53
|
-
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
# <option value=2>Exponential</option>
|
|
57
|
-
# <option value=3>Power</option>
|
|
58
|
-
# <option value=4>Average</option>
|
|
59
|
-
fitting_method = [2, 0, 2, 2, 2]
|
|
60
|
-
raw = RawData(name=file_name, data=data, isotopic_num=10, sequence_num=sequence_num, source=[file_path],
|
|
55
|
+
experiment_name = data[0][0][2]['ExpName'] if data is not None else file_name
|
|
56
|
+
fitting_method = [2, 0, 2, 2, 2] # 0 - linear, 1 - quadratic, 2 - exponential, 3 - power, 4 - average
|
|
57
|
+
raw = RawData(name=experiment_name, data=data, isotopic_num=10, sequence_num=sequence_num, source=[file_path],
|
|
61
58
|
sequence=sequences, unit=str(input_filter[30]), fitting_method=[*fitting_method])
|
|
62
59
|
else:
|
|
63
60
|
raise ValueError("File path and input filter should be both string or list with a same length.")
|
|
@@ -156,11 +153,10 @@ def do_regression(raw: RawData, sequence_index: Optional[List] = None, isotopic_
|
|
|
156
153
|
# unselected: list = [unselected[[isotopic_index*2 + 1, 2 * (isotopic_index + 1)]].dropna().values.tolist()
|
|
157
154
|
# for isotopic_index in list(range(5))]
|
|
158
155
|
|
|
159
|
-
for index,
|
|
156
|
+
for index, isotopic_data in enumerate(selected):
|
|
160
157
|
if hasattr(isotopic_index, '__getitem__') and index not in isotopic_index:
|
|
161
158
|
continue
|
|
162
|
-
|
|
163
|
-
res = raw_funcs.get_raw_data_regression_results(isotope)
|
|
159
|
+
res = raw_funcs.get_raw_data_regression_results(isotopic_data)
|
|
164
160
|
try:
|
|
165
161
|
sequence.results[index] = res[1]
|
|
166
162
|
sequence.coefficients[index] = res[2]
|