ararpy 0.1.19__py3-none-any.whl → 0.1.21__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 +4 -2
- ararpy/calc/age.py +35 -36
- ararpy/calc/arr.py +16 -6
- ararpy/calc/corr.py +9 -7
- ararpy/calc/jvalue.py +1 -1
- ararpy/calc/plot.py +5 -2
- ararpy/files/calc_file.py +2 -5
- ararpy/files/raw_file.py +3 -4
- ararpy/files/xls.py +1 -2
- ararpy/smp/basic.py +121 -71
- ararpy/smp/corr.py +69 -51
- ararpy/smp/export.py +82 -49
- ararpy/smp/initial.py +47 -17
- ararpy/smp/plots.py +126 -87
- ararpy/smp/sample.py +57 -19
- ararpy/smp/style.py +23 -16
- {ararpy-0.1.19.dist-info → ararpy-0.1.21.dist-info}/METADATA +1 -1
- {ararpy-0.1.19.dist-info → ararpy-0.1.21.dist-info}/RECORD +21 -21
- {ararpy-0.1.19.dist-info → ararpy-0.1.21.dist-info}/WHEEL +1 -1
- {ararpy-0.1.19.dist-info → ararpy-0.1.21.dist-info}/licenses/LICENSE +0 -0
- {ararpy-0.1.19.dist-info → ararpy-0.1.21.dist-info}/top_level.txt +0 -0
ararpy/smp/plots.py
CHANGED
|
@@ -89,27 +89,27 @@ def set_plot_data(sample: Sample, isInit: bool = True, isIsochron: bool = True,
|
|
|
89
89
|
# =======================
|
|
90
90
|
# Initialize plot data
|
|
91
91
|
# =======================
|
|
92
|
-
def initial_plot_data(
|
|
92
|
+
def initial_plot_data(smp: Sample):
|
|
93
93
|
"""
|
|
94
94
|
Assign initial data for plots
|
|
95
95
|
Parameters
|
|
96
96
|
----------
|
|
97
|
-
|
|
97
|
+
smp : Sample instance
|
|
98
98
|
|
|
99
99
|
Returns
|
|
100
100
|
-------
|
|
101
101
|
None
|
|
102
102
|
"""
|
|
103
103
|
for key, val in ISOCHRON_INDEX_DICT.items():
|
|
104
|
-
figure = basic.get_component_byid(
|
|
104
|
+
figure = basic.get_component_byid(smp, key)
|
|
105
105
|
try:
|
|
106
106
|
# data = [x, sx, y, sy, (z, sz,) r1, (r2, r3,), index from 1]
|
|
107
|
-
figure.data =
|
|
108
|
-
[[i + 1 for i in range(len(
|
|
107
|
+
figure.data = smp.IsochronValues[val['data_index'][0]:val['data_index'][1]] + \
|
|
108
|
+
[[i + 1 for i in range(len(smp.SequenceName))]]
|
|
109
109
|
except (Exception, BaseException):
|
|
110
110
|
print(traceback.format_exc())
|
|
111
111
|
figure.data = [[]] * (val['data_index'][1] - val['data_index'][0]) + \
|
|
112
|
-
[[i + 1 for i in range(len(
|
|
112
|
+
[[i + 1 for i in range(len(smp.SequenceName))]]
|
|
113
113
|
finally:
|
|
114
114
|
# Ellipse
|
|
115
115
|
if key != 'figure_7':
|
|
@@ -122,51 +122,62 @@ def initial_plot_data(sample: Sample):
|
|
|
122
122
|
# Set age spectra lines
|
|
123
123
|
# Try to calculate total gas age
|
|
124
124
|
try:
|
|
125
|
-
|
|
126
|
-
|
|
125
|
+
if str(smp.Info.sample.type).lower() == "unknown":
|
|
126
|
+
a0, e0 = sum(smp.DegasValues[24]), pow(sum([i ** 2 for i in smp.DegasValues[25]]), 0.5)
|
|
127
|
+
a1, e1 = sum(smp.DegasValues[20]), pow(sum([i ** 2 for i in smp.DegasValues[21]]), 0.5)
|
|
128
|
+
handle = basic.calc_age
|
|
129
|
+
elif str(smp.Info.sample.type).lower() == "standard":
|
|
130
|
+
a0, e0 = sum(smp.DegasValues[24]), pow(sum([i ** 2 for i in smp.DegasValues[25]]), 0.5)
|
|
131
|
+
a1, e1 = sum(smp.DegasValues[20]), pow(sum([i ** 2 for i in smp.DegasValues[21]]), 0.5)
|
|
132
|
+
handle = basic.calc_j
|
|
133
|
+
elif str(smp.Info.sample.type).lower() == "air":
|
|
134
|
+
a0, e0 = sum(smp.DegasValues[26]), pow(sum([i ** 2 for i in smp.DegasValues[27]]), 0.5)
|
|
135
|
+
a1, e1 = sum(smp.DegasValues[ 0]), pow(sum([i ** 2 for i in smp.DegasValues[ 1]]), 0.5)
|
|
136
|
+
handle = basic.calc_mdf
|
|
137
|
+
else:
|
|
138
|
+
raise TypeError(f"Sample type is not supported: {smp.Info.sample.type}")
|
|
127
139
|
total_f = [a0 / a1, calc.err.div((a0, e0), (a1, e1))]
|
|
128
|
-
total_age =
|
|
140
|
+
total_age = handle(total_f[:2], smp=smp)
|
|
129
141
|
except (Exception, BaseException):
|
|
130
142
|
print(traceback.format_exc())
|
|
131
143
|
total_f = [np.nan] * 2
|
|
132
144
|
total_age = [np.nan] * 4
|
|
133
|
-
|
|
145
|
+
smp.Info.results.age_spectra['TGA'].update(
|
|
134
146
|
{'Ar39': 100, 'F': total_f[0], 'sF': total_f[1], 'age': total_age[0],
|
|
135
|
-
's1': total_age[1], 's2': total_age[2], 's3': total_age[3], 'Num': len(
|
|
147
|
+
's1': total_age[1], 's2': total_age[2], 's3': total_age[3], 'Num': len(smp.DegasValues[24])}
|
|
136
148
|
)
|
|
137
149
|
try:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
sample.AgeSpectraPlot.data = calc.arr.transpose(sample.AgeSpectraPlot.data)
|
|
150
|
+
smp.AgeSpectraPlot.data = calc.spectra.get_data(*smp.ApparentAgeValues[2:4], smp.ApparentAgeValues[7])
|
|
151
|
+
smp.AgeSpectraPlot.data = calc.arr.transpose(smp.AgeSpectraPlot.data)
|
|
141
152
|
except (Exception, BaseException):
|
|
142
153
|
print(traceback.format_exc())
|
|
143
|
-
|
|
154
|
+
smp.AgeSpectraPlot.data = []
|
|
144
155
|
|
|
145
156
|
# Degassing plot
|
|
146
157
|
try:
|
|
147
|
-
if not hasattr(
|
|
148
|
-
setattr(
|
|
158
|
+
if not hasattr(smp, 'DegasPatternPlot'):
|
|
159
|
+
setattr(smp, 'DegasPatternPlot', Plot(id='figure_8', name='Degas Pattern Plot'))
|
|
149
160
|
isotope_percentage = lambda l: [e / sum(l) * 100 if sum(l) != 0 else 0 for e in l]
|
|
150
|
-
|
|
151
|
-
isotope_percentage(
|
|
152
|
-
isotope_percentage(
|
|
153
|
-
isotope_percentage(
|
|
154
|
-
isotope_percentage(
|
|
155
|
-
isotope_percentage(
|
|
156
|
-
isotope_percentage(
|
|
157
|
-
isotope_percentage(
|
|
158
|
-
isotope_percentage(
|
|
159
|
-
isotope_percentage(
|
|
160
|
-
isotope_percentage(
|
|
161
|
+
smp.DegasPatternPlot.data = [
|
|
162
|
+
isotope_percentage(smp.DegasValues[0]), # Ar36a
|
|
163
|
+
isotope_percentage(smp.DegasValues[8]), # Ar37Ca
|
|
164
|
+
isotope_percentage(smp.DegasValues[10]), # Ar38Cl
|
|
165
|
+
isotope_percentage(smp.DegasValues[20]), # Ar39K
|
|
166
|
+
isotope_percentage(smp.DegasValues[24]), # Ar40r
|
|
167
|
+
isotope_percentage(smp.CorrectedValues[0]), # Ar36
|
|
168
|
+
isotope_percentage(smp.CorrectedValues[2]), # Ar37
|
|
169
|
+
isotope_percentage(smp.CorrectedValues[4]), # Ar38
|
|
170
|
+
isotope_percentage(smp.CorrectedValues[6]), # Ar39
|
|
171
|
+
isotope_percentage(smp.CorrectedValues[8]), # Ar40
|
|
161
172
|
]
|
|
162
|
-
|
|
173
|
+
smp.DegasPatternPlot.info = [True] * 10
|
|
163
174
|
except Exception as e:
|
|
164
175
|
print(traceback.format_exc())
|
|
165
176
|
pass
|
|
166
177
|
|
|
167
178
|
# Set age distribution plot data
|
|
168
179
|
try:
|
|
169
|
-
recalc_agedistribution(
|
|
180
|
+
recalc_agedistribution(smp)
|
|
170
181
|
except Exception as e:
|
|
171
182
|
print(traceback.format_exc())
|
|
172
183
|
|
|
@@ -390,7 +401,7 @@ def recalc_plateaus(sample: Sample, **kwargs):
|
|
|
390
401
|
if sample.Info.sample.type == "Standard":
|
|
391
402
|
return recalc_j_plateaus(sample, **kwargs)
|
|
392
403
|
if sample.Info.sample.type == "Air":
|
|
393
|
-
return
|
|
404
|
+
return recalc_mdf_plateaus(sample, **kwargs)
|
|
394
405
|
|
|
395
406
|
|
|
396
407
|
def recalc_age_plateaus(sample: Sample, **kwargs):
|
|
@@ -405,6 +416,9 @@ def recalc_age_plateaus(sample: Sample, **kwargs):
|
|
|
405
416
|
-------
|
|
406
417
|
None
|
|
407
418
|
"""
|
|
419
|
+
ar39k, sar39k = calc.arr.mul(sample.DegasValues[20:22], sample.NormalizeFactor)
|
|
420
|
+
ar40r, sar40r = sample.DegasValues[24:26]
|
|
421
|
+
ar40rar39k = calc.arr.div([ar40r, sar40r], [ar39k, sar39k])
|
|
408
422
|
params_initial_ratio = calc.arr.partial(sample.TotalParam, cols=list(range(115, 120)))
|
|
409
423
|
ratio_set1 = [[], []]
|
|
410
424
|
ratio_set2 = [[], []]
|
|
@@ -430,10 +444,12 @@ def recalc_age_plateaus(sample: Sample, **kwargs):
|
|
|
430
444
|
ratio_set2[0].append(298.56)
|
|
431
445
|
ratio_set2[1].append(0.31)
|
|
432
446
|
|
|
433
|
-
#
|
|
447
|
+
# Weighted mean ages of two sets with the given initial ratios
|
|
434
448
|
try:
|
|
435
|
-
set1_res, set1_age, set1_data =
|
|
436
|
-
|
|
449
|
+
set1_res, set1_age, set1_data = get_plateau_results(
|
|
450
|
+
sample, sample.SelectedSequence1, calc_ar40ar39(*ratio_set1, smp=sample),
|
|
451
|
+
ar39k_percentage=np.array(ar39k) / np.sum(ar39k),
|
|
452
|
+
**kwargs)
|
|
437
453
|
except ValueError:
|
|
438
454
|
# print(traceback.format_exc())
|
|
439
455
|
pass
|
|
@@ -443,8 +459,10 @@ def recalc_age_plateaus(sample: Sample, **kwargs):
|
|
|
443
459
|
sample.AgeSpectraPlot.set1.data = calc.arr.transpose(set1_data)
|
|
444
460
|
sample.AgeSpectraPlot.text1.text = "" # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
445
461
|
try:
|
|
446
|
-
set2_res, set2_age, set2_data =
|
|
447
|
-
|
|
462
|
+
set2_res, set2_age, set2_data = get_plateau_results(
|
|
463
|
+
sample, sample.SelectedSequence2, calc_ar40ar39(*ratio_set2, smp=sample),
|
|
464
|
+
ar39k_percentage=np.array(ar39k) / np.sum(ar39k),
|
|
465
|
+
**kwargs)
|
|
448
466
|
except ValueError:
|
|
449
467
|
# print(traceback.format_exc())
|
|
450
468
|
pass
|
|
@@ -454,16 +472,18 @@ def recalc_age_plateaus(sample: Sample, **kwargs):
|
|
|
454
472
|
sample.AgeSpectraPlot.set2.data = calc.arr.transpose(set2_data)
|
|
455
473
|
sample.AgeSpectraPlot.text2.text = "" # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
456
474
|
|
|
457
|
-
#
|
|
475
|
+
# Weighted mean ages of two sets with 298.56 (defoult air ratio)
|
|
458
476
|
try:
|
|
459
|
-
set1_res = get_wma_results(
|
|
477
|
+
set1_res = get_wma_results(
|
|
478
|
+
sample, sample.SelectedSequence1, ar40rar39k=ar40rar39k, ar39k_percentage=np.array(ar39k) / np.sum(ar39k))
|
|
460
479
|
except ValueError:
|
|
461
480
|
pass
|
|
462
481
|
# raise ValueError(f"Set 1 WMA calculation error.")
|
|
463
482
|
else:
|
|
464
483
|
sample.Info.results.age_spectra.update({0: set1_res})
|
|
465
484
|
try:
|
|
466
|
-
set2_res = get_wma_results(
|
|
485
|
+
set2_res = get_wma_results(
|
|
486
|
+
sample, sample.SelectedSequence2, ar40rar39k=ar40rar39k, ar39k_percentage=np.array(ar39k) / np.sum(ar39k))
|
|
467
487
|
except ValueError:
|
|
468
488
|
pass
|
|
469
489
|
# raise ValueError(f"Set 2 WMA calculation error.")
|
|
@@ -543,6 +563,41 @@ def recalc_age_plateaus(sample: Sample, **kwargs):
|
|
|
543
563
|
# # """end"""
|
|
544
564
|
|
|
545
565
|
|
|
566
|
+
def recalc_mdf_plateaus(sample: Sample, **kwargs):
|
|
567
|
+
"""
|
|
568
|
+
Calculate age plateaus results
|
|
569
|
+
Parameters
|
|
570
|
+
----------
|
|
571
|
+
sample : sample instance
|
|
572
|
+
kwargs : optional args, keys in [r1, sr1, r2, sr2]
|
|
573
|
+
|
|
574
|
+
Returns
|
|
575
|
+
-------
|
|
576
|
+
None
|
|
577
|
+
"""
|
|
578
|
+
ar36a, sar36a = calc.arr.mul(sample.DegasValues[0:2], sample.NormalizeFactor)
|
|
579
|
+
ar40aar36a = sample.ApparentAgeValues[0:2]
|
|
580
|
+
mdf = sample.ApparentAgeValues[2:4]
|
|
581
|
+
|
|
582
|
+
try:
|
|
583
|
+
set1_res, _, set1_data = get_plateau_results(sample, sample.SelectedSequence1, ar40rar39k=ar40aar36a)
|
|
584
|
+
except ValueError:
|
|
585
|
+
pass
|
|
586
|
+
else:
|
|
587
|
+
sample.Info.results.age_plateau.update({0: set1_res})
|
|
588
|
+
sample.AgeSpectraPlot.set1.data = calc.arr.transpose(set1_data)
|
|
589
|
+
sample.AgeSpectraPlot.text1.text = ""
|
|
590
|
+
|
|
591
|
+
try:
|
|
592
|
+
set2_res, _, set2_data = get_plateau_results(sample, sample.SelectedSequence2, ar40rar39k=ar40aar36a)
|
|
593
|
+
except ValueError:
|
|
594
|
+
pass
|
|
595
|
+
else:
|
|
596
|
+
sample.Info.results.age_plateau.update({1: set2_res})
|
|
597
|
+
sample.AgeSpectraPlot.set2.data = calc.arr.transpose(set2_data)
|
|
598
|
+
sample.AgeSpectraPlot.text2.text = ""
|
|
599
|
+
|
|
600
|
+
|
|
546
601
|
def calc_ar40ar39(r, sr, smp):
|
|
547
602
|
"""
|
|
548
603
|
Calculate Ar40r / Ar39K based on passed initial ratio.
|
|
@@ -558,7 +613,7 @@ def calc_ar40ar39(r, sr, smp):
|
|
|
558
613
|
"""
|
|
559
614
|
try:
|
|
560
615
|
ar36a = np.array(smp.DegasValues[0:2])
|
|
561
|
-
ar39k = smp.DegasValues[20:22]
|
|
616
|
+
ar39k = calc.arr.mul(smp.DegasValues[20:22], smp.NormalizeFactor)
|
|
562
617
|
ar40 = smp.CorrectedValues[8:10]
|
|
563
618
|
ar40k = smp.DegasValues[30:32]
|
|
564
619
|
size = ar36a.shape[-1]
|
|
@@ -568,8 +623,6 @@ def calc_ar40ar39(r, sr, smp):
|
|
|
568
623
|
ratio = np.array([r, sr])
|
|
569
624
|
else:
|
|
570
625
|
raise ValueError(f"Initial ratio is unsupported.")
|
|
571
|
-
# print(f"{ratio = }")
|
|
572
|
-
# print(f"{ar36a = }")
|
|
573
626
|
ar40a = calc.arr.mul(ar36a, ratio)
|
|
574
627
|
ar40r = calc.arr.sub(ar40, ar40k, ar40a)
|
|
575
628
|
ar40rar39k: list = calc.arr.div(ar40r, ar39k)
|
|
@@ -579,20 +632,20 @@ def calc_ar40ar39(r, sr, smp):
|
|
|
579
632
|
return ar40rar39k
|
|
580
633
|
|
|
581
634
|
|
|
582
|
-
def get_plateau_results(
|
|
635
|
+
def get_plateau_results(smp: Sample, sequence: list, ar40rar39k: list = None,
|
|
583
636
|
ar39k_percentage: list = None, **kwargs):
|
|
584
637
|
"""
|
|
585
638
|
Get initial ratio re-corrected plateau results
|
|
586
639
|
Parameters
|
|
587
640
|
----------
|
|
588
|
-
|
|
641
|
+
smp : sample instance
|
|
589
642
|
sequence : data slice index
|
|
590
643
|
ar40rar39k :
|
|
591
644
|
ar39k_percentage : Ar39K released
|
|
592
645
|
|
|
593
646
|
Returns
|
|
594
647
|
-------
|
|
595
|
-
three
|
|
648
|
+
three items tuple, result dict, age, and plot data, results keys = [
|
|
596
649
|
'F', 'sF', 'Num', 'MSWD', 'Chisq', 'Pvalue',
|
|
597
650
|
'age', 's1', 's2', 's3', 'Ar39', 'rs'
|
|
598
651
|
]
|
|
@@ -609,31 +662,40 @@ def get_plateau_results(sample: Sample, sequence: list, ar40rar39k: list = None,
|
|
|
609
662
|
if len(sequence) == 0:
|
|
610
663
|
return plateau_res, [], []
|
|
611
664
|
if ar40rar39k is None:
|
|
612
|
-
ar40rar39k =
|
|
665
|
+
ar40rar39k = smp.ApparentAgeValues[0:2]
|
|
613
666
|
if ar39k_percentage is None:
|
|
614
|
-
ar39k_percentage =
|
|
667
|
+
ar39k_percentage = smp.ApparentAgeValues[7]
|
|
668
|
+
|
|
669
|
+
if str(smp.Info.sample.type).lower() == "unknown":
|
|
670
|
+
handle = basic.calc_age
|
|
671
|
+
elif str(smp.Info.sample.type).lower() == "standard":
|
|
672
|
+
handle = basic.calc_j
|
|
673
|
+
elif str(smp.Info.sample.type).lower() == "air":
|
|
674
|
+
handle = basic.calc_mdf
|
|
675
|
+
else:
|
|
676
|
+
raise TypeError(f"Sample type is not supported: {smp.Info.sample.type}")
|
|
615
677
|
|
|
616
|
-
age =
|
|
678
|
+
age = handle(ar40ar39=ar40rar39k, smp=smp)[0:2]
|
|
617
679
|
plot_data = calc.spectra.get_data(*age, ar39k_percentage, indices=sequence, **kwargs)
|
|
618
680
|
f_values = _get_partial(sequence, *ar40rar39k)
|
|
619
681
|
age = _get_partial(sequence, *age)
|
|
620
682
|
sum_ar39k = sum(_get_partial(sequence, ar39k_percentage)[0])
|
|
621
683
|
wmf = calc.arr.wtd_mean(*f_values)
|
|
622
|
-
wmage =
|
|
684
|
+
wmage = handle(wmf[0:2], smp=smp)
|
|
623
685
|
|
|
624
|
-
plateau_res.update(dict(zip(
|
|
625
|
-
plateau_res_keys, [*wmf, *wmage, sum_ar39k, np.nan]
|
|
626
|
-
)))
|
|
686
|
+
plateau_res.update(dict(zip(plateau_res_keys, [*wmf, *wmage, sum_ar39k, np.nan])))
|
|
627
687
|
return plateau_res, age, plot_data
|
|
628
688
|
|
|
629
689
|
|
|
630
|
-
def get_wma_results(sample: Sample, sequence: list):
|
|
690
|
+
def get_wma_results(sample: Sample, sequence: list, ar40rar39k: list = None, ar39k_percentage: list = None):
|
|
631
691
|
"""
|
|
632
692
|
Get initial ratio re-corrected plateau results
|
|
633
693
|
Parameters
|
|
634
694
|
----------
|
|
635
695
|
sample : sample instance
|
|
636
696
|
sequence : data slice index
|
|
697
|
+
ar40rar39k :
|
|
698
|
+
ar39k_percentage :
|
|
637
699
|
|
|
638
700
|
Returns
|
|
639
701
|
-------
|
|
@@ -642,6 +704,11 @@ def get_wma_results(sample: Sample, sequence: list):
|
|
|
642
704
|
'age', 's1', 's2', 's3', 'Ar39', 'rs'
|
|
643
705
|
]
|
|
644
706
|
"""
|
|
707
|
+
if ar40rar39k is None:
|
|
708
|
+
ar40rar39k = sample.ApparentAgeValues[0:2]
|
|
709
|
+
if ar39k_percentage is None:
|
|
710
|
+
ar39k_percentage = sample.ApparentAgeValues[7]
|
|
711
|
+
|
|
645
712
|
spectra_res = initial.SPECTRA_RES.copy()
|
|
646
713
|
# spectra_res = initial.SPECTRA_RES
|
|
647
714
|
|
|
@@ -649,9 +716,9 @@ def get_wma_results(sample: Sample, sequence: list):
|
|
|
649
716
|
return [arg[min(points): max(points) + 1] for arg in args]
|
|
650
717
|
|
|
651
718
|
if len(sequence) > 0:
|
|
652
|
-
sum_ar39k = sum(_get_partial(sequence,
|
|
653
|
-
fs = _get_partial(sequence,
|
|
654
|
-
sfs = _get_partial(sequence,
|
|
719
|
+
sum_ar39k = sum(_get_partial(sequence, ar39k_percentage)[0])
|
|
720
|
+
fs = _get_partial(sequence, ar40rar39k[0])[0]
|
|
721
|
+
sfs = _get_partial(sequence, ar40rar39k[1])[0]
|
|
655
722
|
|
|
656
723
|
wmf, swmf, num, mswd, chisq, p = calc.arr.wtd_mean(fs, sfs)
|
|
657
724
|
age, s1, s2, s3 = basic.calc_age([wmf, swmf], smp=sample)
|
|
@@ -665,13 +732,11 @@ def get_wma_results(sample: Sample, sequence: list):
|
|
|
665
732
|
|
|
666
733
|
def recalc_j_plateaus(sample: Sample, **kwargs):
|
|
667
734
|
|
|
668
|
-
|
|
669
|
-
|
|
735
|
+
ar40rar39k = sample.ApparentAgeValues[0:2]
|
|
670
736
|
j = sample.ApparentAgeValues[2:4]
|
|
671
737
|
|
|
672
738
|
try:
|
|
673
|
-
set1_res, _, set1_data =
|
|
674
|
-
get_j_plateau_results(sample, sample.SelectedSequence1, j)
|
|
739
|
+
set1_res, _, set1_data = get_plateau_results(sample, sample.SelectedSequence1, ar40rar39k=ar40rar39k)
|
|
675
740
|
except ValueError:
|
|
676
741
|
pass
|
|
677
742
|
else:
|
|
@@ -680,8 +745,7 @@ def recalc_j_plateaus(sample: Sample, **kwargs):
|
|
|
680
745
|
sample.AgeSpectraPlot.text1.text = "" # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
681
746
|
|
|
682
747
|
try:
|
|
683
|
-
set2_res, _, set2_data =
|
|
684
|
-
get_j_plateau_results(sample, sample.SelectedSequence2, j)
|
|
748
|
+
set2_res, _, set2_data = get_plateau_results(sample, sample.SelectedSequence2, ar40rar39k=ar40rar39k)
|
|
685
749
|
except ValueError:
|
|
686
750
|
pass
|
|
687
751
|
else:
|
|
@@ -690,31 +754,6 @@ def recalc_j_plateaus(sample: Sample, **kwargs):
|
|
|
690
754
|
sample.AgeSpectraPlot.text2.text = "" # 注意和js的配合,js那边根据text是否为空判断是否重新生成文字
|
|
691
755
|
|
|
692
756
|
|
|
693
|
-
def get_j_plateau_results(sample: Sample, sequence: list, j: list, ar39k_percentage: list = None):
|
|
694
|
-
|
|
695
|
-
def _get_partial(points, *args):
|
|
696
|
-
# return [arg[min(points): max(points) + 1] for arg in args]
|
|
697
|
-
return [[arg[i] for i in points] for arg in args]
|
|
698
|
-
|
|
699
|
-
if ar39k_percentage is None:
|
|
700
|
-
ar39k_percentage = sample.ApparentAgeValues[7]
|
|
701
|
-
sum_ar39k = sum(_get_partial(sequence, ar39k_percentage)[0])
|
|
702
|
-
|
|
703
|
-
j_values = _get_partial(sequence, *j)
|
|
704
|
-
wmj = calc.arr.wtd_mean(*j_values)
|
|
705
|
-
plot_data = [[sum(ar39k_percentage[:min(sequence)]), sum(ar39k_percentage[:max(sequence) + 1])],
|
|
706
|
-
[wmj[0], wmj[0]]]
|
|
707
|
-
|
|
708
|
-
plateau_res_keys = [
|
|
709
|
-
'F', 'sF', 'Num', 'MSWD', 'Chisq', 'Pvalue', 'age', 's1', 's2', 's3', 'Ar39',
|
|
710
|
-
'rs', # 'rs' means relative error of the total sum
|
|
711
|
-
]
|
|
712
|
-
plateau_res = dict(zip(plateau_res_keys, [np.nan for i in plateau_res_keys]))
|
|
713
|
-
plateau_res.update(dict(zip(plateau_res_keys, [*wmj, np.nan, np.nan, np.nan, np.nan, sum_ar39k, np.nan])))
|
|
714
|
-
|
|
715
|
-
return plateau_res, 0, plot_data
|
|
716
|
-
|
|
717
|
-
|
|
718
757
|
# =======================
|
|
719
758
|
# Age Distribution Plot
|
|
720
759
|
# =======================
|
ararpy/smp/sample.py
CHANGED
|
@@ -54,7 +54,21 @@ PUBLISH_TABLE_HEADERS = [
|
|
|
54
54
|
'Sequence', '', # 0-1
|
|
55
55
|
'\u00B3\u2076Ar[a]', '\u00B3\u2077Ar[Ca]', '\u00B3\u2078Ar[Cl]', # 2-4
|
|
56
56
|
'\u00B3\u2079Ar[K]', '\u2074\u2070Ar[r]', # 5-6
|
|
57
|
-
'Apparent Age', '1\u03C3', '\u2074\
|
|
57
|
+
'Apparent Age', '1\u03C3', '\u2074\u2070Ar[r]%', '\u00B3\u2079Ar[K]%', # 7-10
|
|
58
|
+
'Ca/K', '1\u03C3', # 11-12
|
|
59
|
+
]
|
|
60
|
+
PUBLISH_TABLE_HEADERS_AIR = [
|
|
61
|
+
'Sequence', '', # 0-1
|
|
62
|
+
'\u00B3\u2076Ar[a]', '\u00B3\u2077Ar[Ca]', '\u00B3\u2078Ar[Cl]', # 2-4
|
|
63
|
+
'\u00B3\u2079Ar[K]', '\u2074\u2070Ar[r]', # 5-6
|
|
64
|
+
'MDF', '1\u03C3', '\u2074\u2070Ar[r]%', '\u00B3\u2076Ar%', # 7-10
|
|
65
|
+
'Ca/K', '1\u03C3', # 11-12
|
|
66
|
+
]
|
|
67
|
+
PUBLISH_TABLE_HEADERS_STD = [
|
|
68
|
+
'Sequence', '', # 0-1
|
|
69
|
+
'\u00B3\u2076Ar[a]', '\u00B3\u2077Ar[Ca]', '\u00B3\u2078Ar[Cl]', # 2-4
|
|
70
|
+
'\u00B3\u2079Ar[K]', '\u2074\u2070Ar[r]', # 5-6
|
|
71
|
+
'J', '1\u03C3', '\u2074\u2070Ar[r]%', '\u00B3\u2076Ar%', # 7-10
|
|
58
72
|
'Ca/K', '1\u03C3', # 11-12
|
|
59
73
|
]
|
|
60
74
|
SPECTRUM_TABLE_HEADERS = [
|
|
@@ -63,6 +77,18 @@ SPECTRUM_TABLE_HEADERS = [
|
|
|
63
77
|
'Apparent Age', '1\u03C3', '1\u03C3', '1\u03C3', # 4-7
|
|
64
78
|
'\u2074\u2070Ar[r]%', '\u00B3\u2079Ar[K]%', # 8-9
|
|
65
79
|
]
|
|
80
|
+
SPECTRUM_TABLE_HEADERS_AIR = [
|
|
81
|
+
'Sequence', '', # 0-1
|
|
82
|
+
'\u2074\u2070Ar/\u00B3\u2076Ar', '1\u03C3', # 2-3
|
|
83
|
+
'MDF', '1\u03C3', '1\u03C3', '1\u03C3', # 4-7
|
|
84
|
+
'\u2074\u2070Ar[r]%', '\u00B3\u2076Ar%', # 8-9
|
|
85
|
+
]
|
|
86
|
+
SPECTRUM_TABLE_HEADERS_STD = [
|
|
87
|
+
'Sequence', '', # 0-1
|
|
88
|
+
'\u2074\u2070Ar/\u00B3\u2076Ar', '1\u03C3', # 2-3
|
|
89
|
+
'J', '1\u03C3', '1\u03C3', '1\u03C3', # 4-7
|
|
90
|
+
'\u2074\u2070Ar[r]%', '\u00B3\u2076Ar%', # 8-9
|
|
91
|
+
]
|
|
66
92
|
ISOCHRON_TABLE_HEADERS = [
|
|
67
93
|
'Sequence', '', 'Mark', # 0-2
|
|
68
94
|
'\u00B3\u2079Ar[K]/\u00B3\u2076Ar[a]', '1\u03C3', # 3-4
|
|
@@ -108,16 +134,16 @@ TOTAL_PARAMS_HEADERS = [
|
|
|
108
134
|
'Decay Activity \u2074\u2070K(\u03B2<sup>-</sup>)', '%1\u03C3', # 54-55
|
|
109
135
|
'Decay Activity \u2074\u2070K(\u03B2<sup>+</sup>)', '%1\u03C3', # 56-57
|
|
110
136
|
'\u00B3\u2076Cl/\u00B3\u2078Cl Productivity', '%1\u03C3', # 58-59
|
|
111
|
-
'Std Name', 'Std Age', '1\u03C3', '\u2074\u2070Ar%', '1\u03C3', 'K%', '1\u03C3',
|
|
112
|
-
'\u2074\u2070Ar<sup>*</sup>/K', '1\u03C3', #
|
|
137
|
+
'Std Name', 'Std Age', '1\u03C3', '\u2074\u2070Ar%', '1\u03C3', 'K%', '1\u03C3', # 60-66
|
|
138
|
+
'\u2074\u2070Ar<sup>*</sup>/K', '1\u03C3', # 67-68
|
|
113
139
|
'J', '%1\u03C3', 'MDF', '%1\u03C3', # 69-72
|
|
114
|
-
'Mass \u00B3\u2076Ar', '%1\u03C3', 'Mass \u00B3\u2077Ar', '%1\u03C3',
|
|
115
|
-
'Mass \u00B3\u2078Ar', '%1\u03C3', 'Mass \u00B3\u2079Ar', '%1\u03C3',
|
|
116
|
-
'Mass \u2074\u2070', '%1\u03C3', 'K Mass', '%1\u03C3', #
|
|
140
|
+
'Mass \u00B3\u2076Ar', '%1\u03C3', 'Mass \u00B3\u2077Ar', '%1\u03C3', # 73-76
|
|
141
|
+
'Mass \u00B3\u2078Ar', '%1\u03C3', 'Mass \u00B3\u2079Ar', '%1\u03C3', # 77-80
|
|
142
|
+
'Mass \u2074\u2070', '%1\u03C3', 'K Mass', '%1\u03C3', # 81-84
|
|
117
143
|
'No', '%1\u03C3', 'Year', '%1\u03C3', '\u2074\u2070K/K', '%1\u03C3',
|
|
118
|
-
'\u00B3\
|
|
119
|
-
'\u2074\u2070Ar/\u00B3\u2076Ar air', '%1\u03C3',
|
|
120
|
-
'\u00B3\u2078Ar/\u00B3\u2076Ar air', '%1\u03C3', #
|
|
144
|
+
'\u00B3\u2075Cl/\u00B3\u2077Cl', '%1\u03C3', 'HCl/Cl', '%1\u03C3', # 85-94
|
|
145
|
+
'\u2074\u2070Ar/\u00B3\u2076Ar air', '%1\u03C3', # 95-96
|
|
146
|
+
'\u00B3\u2078Ar/\u00B3\u2076Ar air', '%1\u03C3', # 97-98
|
|
121
147
|
'Isochron Fitting', 'Convergence', 'Iteration', 'Discrimination', # 99-102
|
|
122
148
|
'Not Zero', 'Corr Blank', 'Corr Discr', 'Corr \u00B3\u2077Ar Decay', # 103-106
|
|
123
149
|
'Corr \u00B3\u2079Ar Decay', # 107
|
|
@@ -222,8 +248,8 @@ TOTAL_PARAMS_SHORT_HEADERS = [
|
|
|
222
248
|
'DAb-K40', '%1s', # 54-55
|
|
223
249
|
'DAb+K40', '%1s', # 56-57
|
|
224
250
|
'Cl36/Cl38P', '%1s', # 58-59
|
|
225
|
-
'StdName', 'StdAge', '1s', 'Ar40%', '1s', 'K%', '1s',
|
|
226
|
-
'F', '1s', #
|
|
251
|
+
'StdName', 'StdAge', '1s', 'Ar40%', '1s', 'K%', '1s', # 60-66
|
|
252
|
+
'F', '1s', # 67-68
|
|
227
253
|
'J', '%1s', 'MDF', '%1s', # 69-72
|
|
228
254
|
'MassAr36', '%1s', 'MassAr37', '%1s',
|
|
229
255
|
'MassAr38', '%1s', 'MassAr39', '%1s',
|
|
@@ -259,19 +285,26 @@ TOTAL_PARAMS_SHORT_HEADERS = [
|
|
|
259
285
|
'40Gain', '%1s', # 136-137
|
|
260
286
|
]
|
|
261
287
|
|
|
262
|
-
DEFAULT_PLOT_STYLES = {
|
|
288
|
+
DEFAULT_PLOT_STYLES = lambda sample_type, age_unit: {
|
|
263
289
|
'figure_1': {
|
|
264
|
-
'id': 'figure_1', 'name': 'Age Spectra'
|
|
290
|
+
'id': 'figure_1', 'name': 'Age Spectra' if sample_type == "Unknown" else 'J Spectra' if sample_type == "Standard" else "MDF" if sample_type == "Air" else "Unkown Title",
|
|
291
|
+
'type': 'spectra', 'attr_name': 'AgeSpectraPlot',
|
|
265
292
|
'rightside_text': [],
|
|
266
|
-
'title': {'id': 'title', 'show': True,
|
|
293
|
+
'title': {'id': 'title', 'show': True,
|
|
294
|
+
'text': 'Age Spectra' if sample_type == "Unknown" else 'J Spectra' if sample_type == "Standard" else "MDF" if sample_type == "Air" else "Unkown Title",
|
|
295
|
+
'position': 'center',
|
|
267
296
|
'font_size': 18, 'color': '#333333', 'opacity': 1, 'type': 'text', 'font_weight': 'bolder',
|
|
268
297
|
'font_family': 'Microsoft Sans Serif', },
|
|
269
298
|
'xaxis': {
|
|
270
|
-
'title': {'text': 'Cumulative {sup|39}Ar Released (%)'
|
|
299
|
+
'title': {'text': 'Cumulative {sup|39}Ar Released (%)' if sample_type == "Unknown" or sample_type == "Standard" else "Cumulative {sup|36}Ar Released (%)" if sample_type == "Air" else "Unkown Title",
|
|
300
|
+
'type': 'text', }, 'type': 'axis',
|
|
271
301
|
'min': 0, 'max': 100, 'show_splitline': False, 'ticks_inside': False, 'split_number': 5, 'interval': 10,
|
|
272
302
|
},
|
|
273
303
|
'yaxis': {
|
|
274
|
-
'title': {
|
|
304
|
+
'title': {
|
|
305
|
+
'text': f'Apparent Age ({age_unit})' if sample_type == "Unknown" else 'J Values' if sample_type == "Standard" else "MDF" if sample_type == "Air" else "Unkown Title",
|
|
306
|
+
'type': 'text',
|
|
307
|
+
}, 'type': 'axis',
|
|
275
308
|
'min': 0, 'max': 100, 'show_splitline': False, 'ticks_inside': False, 'split_number': 5, 'interval': 10,
|
|
276
309
|
},
|
|
277
310
|
'set1': {'id': 'Points Set 1', 'type': 'set', },
|
|
@@ -743,7 +776,7 @@ DEFAULT_PLOT_STYLES = {
|
|
|
743
776
|
},
|
|
744
777
|
}
|
|
745
778
|
|
|
746
|
-
VERSION = '
|
|
779
|
+
VERSION = '20250404'
|
|
747
780
|
|
|
748
781
|
NAMED_DICT = {
|
|
749
782
|
"unknown": {"header": SAMPLE_INTERCEPT_HEADERS.copy()},
|
|
@@ -812,6 +845,7 @@ class Sample:
|
|
|
812
845
|
self.SelectedSequence2 = []
|
|
813
846
|
self.UnselectedSequence = []
|
|
814
847
|
self.IsochronMark = []
|
|
848
|
+
self.NormalizeFactor = [[], []]
|
|
815
849
|
|
|
816
850
|
# Tables and Plots
|
|
817
851
|
self.UnknownTable = Table()
|
|
@@ -847,8 +881,10 @@ class Sample:
|
|
|
847
881
|
# self.__version = '20240730' # change parameter table for thermo calculation
|
|
848
882
|
# self.__version = '20241028' # gain correction
|
|
849
883
|
# self.__version = '20250102' # gain correction to blanks
|
|
884
|
+
# self.__version = '20250301' # update sample info
|
|
850
885
|
# self.__version = '20250321' # error sigma adjustment
|
|
851
|
-
self.__version = '
|
|
886
|
+
# self.__version = '20250328' # Experiment info
|
|
887
|
+
self.__version = '20250404' # J normalization factor
|
|
852
888
|
|
|
853
889
|
@property
|
|
854
890
|
def version(self):
|
|
@@ -930,7 +966,7 @@ class Sample:
|
|
|
930
966
|
|
|
931
967
|
def show_data(self): ...
|
|
932
968
|
|
|
933
|
-
def set_params(self, params: Union[List, str], flag: Optional[str] = None): ...
|
|
969
|
+
def set_params(self, params: Union[List, str], flag: Optional[str] = None, rows: Optional[List] = None): ...
|
|
934
970
|
|
|
935
971
|
def set_info(self, info: dict): ...
|
|
936
972
|
|
|
@@ -938,6 +974,8 @@ class Sample:
|
|
|
938
974
|
|
|
939
975
|
def to_pdf(self, file_path: str, figure: str = "figure_3"): ...
|
|
940
976
|
|
|
977
|
+
def to_excel(self, file_path: str, *args, **kwargs): ...
|
|
978
|
+
|
|
941
979
|
|
|
942
980
|
class Table:
|
|
943
981
|
def __init__(self, id='', name='Table', colcount=None, rowcount=None, header=None,
|
ararpy/smp/style.py
CHANGED
|
@@ -19,13 +19,26 @@ Sample = samples.Sample
|
|
|
19
19
|
Table = samples.Table
|
|
20
20
|
Plot = samples.Plot
|
|
21
21
|
|
|
22
|
-
TABLEHEADER = lambda index:
|
|
23
|
-
'',
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
]
|
|
22
|
+
TABLEHEADER = lambda sample_type, index: {
|
|
23
|
+
'Unknown': ['',
|
|
24
|
+
samples.SAMPLE_INTERCEPT_HEADERS, samples.BLANK_INTERCEPT_HEADERS,
|
|
25
|
+
samples.CORRECTED_HEADERS, samples.DEGAS_HEADERS, samples.PUBLISH_TABLE_HEADERS,
|
|
26
|
+
samples.SPECTRUM_TABLE_HEADERS, samples.ISOCHRON_TABLE_HEADERS,
|
|
27
|
+
samples.TOTAL_PARAMS_HEADERS
|
|
28
|
+
],
|
|
29
|
+
'Standard': ['',
|
|
30
|
+
samples.SAMPLE_INTERCEPT_HEADERS, samples.BLANK_INTERCEPT_HEADERS,
|
|
31
|
+
samples.CORRECTED_HEADERS, samples.DEGAS_HEADERS, samples.PUBLISH_TABLE_HEADERS_STD,
|
|
32
|
+
samples.SPECTRUM_TABLE_HEADERS_STD, samples.ISOCHRON_TABLE_HEADERS,
|
|
33
|
+
samples.TOTAL_PARAMS_HEADERS
|
|
34
|
+
],
|
|
35
|
+
'Air': ['',
|
|
36
|
+
samples.SAMPLE_INTERCEPT_HEADERS, samples.BLANK_INTERCEPT_HEADERS,
|
|
37
|
+
samples.CORRECTED_HEADERS, samples.DEGAS_HEADERS, samples.PUBLISH_TABLE_HEADERS_AIR,
|
|
38
|
+
samples.SPECTRUM_TABLE_HEADERS_AIR, samples.ISOCHRON_TABLE_HEADERS,
|
|
39
|
+
samples.TOTAL_PARAMS_HEADERS
|
|
40
|
+
],
|
|
41
|
+
}[sample_type][index]
|
|
29
42
|
|
|
30
43
|
|
|
31
44
|
# =======================
|
|
@@ -58,13 +71,6 @@ def set_plot_style(smp: Sample):
|
|
|
58
71
|
setattr(figure, 'title', Plot.Text())
|
|
59
72
|
setattr(getattr(figure, 'title'), 'text', f"{suffix} {getattr(figure, 'name', '')}")
|
|
60
73
|
|
|
61
|
-
age_unit = "Undefined"
|
|
62
|
-
try:
|
|
63
|
-
age_unit = str(smp.Info.preference['ageUnit']).capitalize()
|
|
64
|
-
except:
|
|
65
|
-
print(traceback.format_exc())
|
|
66
|
-
smp.AgeSpectraPlot.yaxis.title.text = f"Apparent Age ({age_unit})"
|
|
67
|
-
|
|
68
74
|
|
|
69
75
|
def reset_plot_scale(smp: Sample, only_figure: str = None):
|
|
70
76
|
"""
|
|
@@ -160,7 +166,8 @@ def reset_text(smp: Sample, only_figure: str = None):
|
|
|
160
166
|
-------
|
|
161
167
|
None
|
|
162
168
|
"""
|
|
163
|
-
|
|
169
|
+
default_styles = initial.get_default_plot_style(smp)
|
|
170
|
+
for figure_id in list(default_styles.keys()):
|
|
164
171
|
if only_figure is not None and figure_id != only_figure:
|
|
165
172
|
continue
|
|
166
173
|
figure = basic.get_component_byid(smp, figure_id)
|
|
@@ -190,7 +197,7 @@ def set_table_style(sample: Sample):
|
|
|
190
197
|
"""
|
|
191
198
|
for key, comp in basic.get_components(sample).items():
|
|
192
199
|
if isinstance(comp, Table):
|
|
193
|
-
comp.header = TABLEHEADER(index=int(comp.id))
|
|
200
|
+
comp.header = TABLEHEADER(sample_type=sample.Info.sample.type, index=int(comp.id))
|
|
194
201
|
comp.set_coltypes()
|
|
195
202
|
# comp.colcount = len(comp.header)
|
|
196
203
|
# comp.coltypes = [{'type': 'numeric'}] * (comp.colcount)
|