ararpy 0.1.11__py3-none-any.whl → 0.1.12__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/calc/arr.py +2 -0
- ararpy/calc/corr.py +12 -0
- ararpy/calc/isochron.py +4 -2
- ararpy/examples/WHA.pdf +2863 -0
- ararpy/smp/basic.py +3 -2
- ararpy/smp/calculation.py +4 -0
- ararpy/smp/corr.py +26 -0
- ararpy/smp/diffusion_funcs.py +67 -43
- ararpy/smp/export.py +46 -0
- ararpy/smp/json.py +12 -1
- ararpy/smp/plots.py +10 -6
- ararpy/smp/sample.py +14 -4
- ararpy/smp/table.py +8 -0
- ararpy/test.py +63 -0
- {ararpy-0.1.11.dist-info → ararpy-0.1.12.dist-info}/METADATA +1 -1
- {ararpy-0.1.11.dist-info → ararpy-0.1.12.dist-info}/RECORD +19 -18
- {ararpy-0.1.11.dist-info → ararpy-0.1.12.dist-info}/LICENSE +0 -0
- {ararpy-0.1.11.dist-info → ararpy-0.1.12.dist-info}/WHEEL +0 -0
- {ararpy-0.1.11.dist-info → ararpy-0.1.12.dist-info}/top_level.txt +0 -0
ararpy/smp/basic.py
CHANGED
|
@@ -534,10 +534,11 @@ def set_params(smp: Sample, params: Union[List, str], flag: Optional[str] = None
|
|
|
534
534
|
smp.TotalParam[58:67] = remove_none(smp.TotalParam[58:67], params[4:13], n, 67 - 58)
|
|
535
535
|
smp.TotalParam[97:100] = remove_none(smp.TotalParam[97:100], params[13:16], n, 100 - 97)
|
|
536
536
|
smp.TotalParam[115:120] = remove_none(smp.TotalParam[115:120], params[16:21], n, 120 - 115)
|
|
537
|
-
smp.TotalParam[
|
|
537
|
+
smp.TotalParam[126:136] = remove_none(smp.TotalParam[126:136], params[21:31], n, 136 - 126)
|
|
538
|
+
smp.TotalParam[120:123] = remove_none(smp.TotalParam[120:123], params[31:34], n, 123 - 120)
|
|
538
539
|
smp.TotalParam[100:114] = remove_none(
|
|
539
540
|
smp.TotalParam[100:114],
|
|
540
|
-
[['Linear', 'Exponential', 'Power'][params[
|
|
541
|
+
[['Linear', 'Exponential', 'Power'][params[34:37].index(True)] if True in params[34:37] else '', *params[37:]], n, 114 - 100)
|
|
541
542
|
else:
|
|
542
543
|
raise KeyError(f"{flag = } is not supported. It must be 'calc' for Calc Params, "
|
|
543
544
|
f"'irra' for Irradiation Params, or 'smp' for Sample Params.")
|
ararpy/smp/calculation.py
CHANGED
|
@@ -47,6 +47,7 @@ def recalculate(
|
|
|
47
47
|
re_plot_style
|
|
48
48
|
re_set_table
|
|
49
49
|
re_table_style
|
|
50
|
+
re_corr_gain
|
|
50
51
|
kwargs
|
|
51
52
|
|
|
52
53
|
Returns
|
|
@@ -59,11 +60,14 @@ def recalculate(
|
|
|
59
60
|
# print(f"{sample.SelectedSequence1 = }")
|
|
60
61
|
# print(f"{sample.SelectedSequence2 = }")
|
|
61
62
|
# --- initializing ---
|
|
63
|
+
re_corr_gain = re_corr_blank
|
|
62
64
|
if re_initial: # 1
|
|
63
65
|
initial.re_set_smp(sample)
|
|
64
66
|
# --- calculating ---
|
|
65
67
|
if re_corr_blank: # 2
|
|
66
68
|
corr.corr_blank(sample)
|
|
69
|
+
if re_corr_gain: # 2 2024-10-04 add
|
|
70
|
+
corr.corr_gain(sample)
|
|
67
71
|
if re_corr_massdiscr: # 3
|
|
68
72
|
corr.corr_massdiscr(sample)
|
|
69
73
|
if re_corr_decay: # 4
|
ararpy/smp/corr.py
CHANGED
|
@@ -45,6 +45,32 @@ def corr_blank(sample: Sample):
|
|
|
45
45
|
sample.CorrectedValues = copy.deepcopy(sample.BlankCorrected)
|
|
46
46
|
|
|
47
47
|
|
|
48
|
+
# =======================
|
|
49
|
+
# Corr Blank
|
|
50
|
+
# =======================
|
|
51
|
+
def corr_gain(sample: Sample):
|
|
52
|
+
"""Blank Correction"""
|
|
53
|
+
corrGain = True
|
|
54
|
+
# if not corrBlank:
|
|
55
|
+
# sample.BlankCorrected = copy.deepcopy(sample.SampleIntercept)
|
|
56
|
+
# sample.CorrectedValues = copy.deepcopy(sample.BlankCorrected)
|
|
57
|
+
# return
|
|
58
|
+
gain_corrected = [[]] * 10
|
|
59
|
+
try:
|
|
60
|
+
for i in range(5):
|
|
61
|
+
gain_corrected[i * 2:2 + i * 2] = calc.corr.gain(
|
|
62
|
+
*sample.BlankCorrected[i * 2:2 + i * 2], *sample.TotalParam[126 + i * 2:128 + i * 2])
|
|
63
|
+
except Exception as e:
|
|
64
|
+
print(f"Gain correction failed")
|
|
65
|
+
print(traceback.format_exc())
|
|
66
|
+
return
|
|
67
|
+
for i in range(0, 10, 2):
|
|
68
|
+
gain_corrected[i] = [gain_corrected[i][index] if corrGain else j for index, j in enumerate(sample.BlankCorrected[i])]
|
|
69
|
+
gain_corrected[i + 1] = [gain_corrected[i + 1][index] if corrGain else j for index, j in enumerate(sample.BlankCorrected[i + 1])]
|
|
70
|
+
sample.BlankCorrected = copy.deepcopy(gain_corrected)
|
|
71
|
+
sample.CorrectedValues = copy.deepcopy(sample.BlankCorrected)
|
|
72
|
+
|
|
73
|
+
|
|
48
74
|
# =======================
|
|
49
75
|
# Mass Discrimination
|
|
50
76
|
# =======================
|
ararpy/smp/diffusion_funcs.py
CHANGED
|
@@ -167,7 +167,7 @@ class DiffArrmultiFunc(DiffSample):
|
|
|
167
167
|
print(f"{self.telab = }")
|
|
168
168
|
print(f"{self.tilab = }")
|
|
169
169
|
|
|
170
|
-
def main(self):
|
|
170
|
+
def main(self, **params):
|
|
171
171
|
|
|
172
172
|
print(f"\n======================================")
|
|
173
173
|
print(f"Run Arrmulti Main | ")
|
|
@@ -1436,7 +1436,7 @@ class DiffArrmultiFunc(DiffSample):
|
|
|
1436
1436
|
return xran, yran
|
|
1437
1437
|
|
|
1438
1438
|
def arr(self, e, ord, dzx, fmod, f, telab, tilab, xlogd,
|
|
1439
|
-
ns=200, r=1.987e-3, pi=3.141592654, ee=0.4342944879, acut=0, b=
|
|
1439
|
+
ns=200, r=1.987e-3, pi=3.141592654, ee=0.4342944879, acut=0.5, b=8, imp=2):
|
|
1440
1440
|
|
|
1441
1441
|
# print(f"{e = }")
|
|
1442
1442
|
# print(f"{ord = }")
|
|
@@ -3677,13 +3677,10 @@ class InsideTemperatureCalibration:
|
|
|
3677
3677
|
|
|
3678
3678
|
|
|
3679
3679
|
class SmpTemperatureCalibration:
|
|
3680
|
-
def __init__(self,
|
|
3680
|
+
def __init__(self, helix_log_path="", libano_log_path=None,
|
|
3681
3681
|
name="smp_example", loc=r'D:\DjangoProjects\webarar\static\settings'):
|
|
3682
3682
|
|
|
3683
3683
|
self.name = name
|
|
3684
|
-
self.smp = ap.from_arr(file_path=arr_path)
|
|
3685
|
-
if isinstance(self.smp, Sample):
|
|
3686
|
-
self.name = self.smp.name()
|
|
3687
3684
|
|
|
3688
3685
|
self.loc = loc
|
|
3689
3686
|
|
|
@@ -3858,27 +3855,28 @@ class SmpTemperatureCalibration:
|
|
|
3858
3855
|
|
|
3859
3856
|
file_out.close()
|
|
3860
3857
|
|
|
3858
|
+
np.savetxt(os.path.join(self.loc, f"{self.name}-temp.txt"), libano_log, delimiter=',')
|
|
3859
|
+
heating_out = open(os.path.join(self.loc, f"{self.name}-heated-index.txt"), "w")
|
|
3860
|
+
heating_out.writelines([f'{min(i)},{max(i)}\n' for i in yellow_data_index])
|
|
3861
|
+
heating_out.close()
|
|
3861
3862
|
|
|
3862
|
-
|
|
3863
|
-
|
|
3863
|
+
plt_plot = False
|
|
3864
|
+
if plt_plot:
|
|
3864
3865
|
|
|
3865
|
-
|
|
3866
|
-
|
|
3867
|
-
ax.plot(libano_log[0], libano_log[4], c='red')
|
|
3868
|
-
ax.plot(libano_log[0], libano_log[5], c='red')
|
|
3869
|
-
for i in range(nstep):
|
|
3870
|
-
_index = yellow_data_index[i]
|
|
3871
|
-
ax.plot(libano_log[0, _index], libano_log[4, _index], c='yellow')
|
|
3872
|
-
ax.plot(libano_log[0, _index], libano_log[5, _index], c='yellow')
|
|
3866
|
+
fig, ax = plt.subplots()
|
|
3867
|
+
fig.set_size_inches(w=12, h=10)
|
|
3873
3868
|
|
|
3874
|
-
|
|
3875
|
-
|
|
3869
|
+
ax.plot(libano_log[0], libano_log[1], c='green')
|
|
3870
|
+
ax.plot(libano_log[0], libano_log[2], c='blue')
|
|
3871
|
+
ax.plot(libano_log[0], libano_log[4], c='red')
|
|
3872
|
+
ax.plot(libano_log[0], libano_log[5], c='red')
|
|
3873
|
+
for i in range(nstep):
|
|
3874
|
+
_index = yellow_data_index[i]
|
|
3875
|
+
ax.plot(libano_log[0, _index], libano_log[4, _index], c='yellow')
|
|
3876
|
+
ax.plot(libano_log[0, _index], libano_log[5, _index], c='yellow')
|
|
3876
3877
|
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
heating_out = open(os.path.join(self.loc, f"{self.name}-heated-index.txt"), "w")
|
|
3880
|
-
heating_out.writelines([','.join([str(j) for j in i]) for i in yellow_data_index])
|
|
3881
|
-
heating_out.close()
|
|
3878
|
+
fig.tight_layout()
|
|
3879
|
+
plt.show()
|
|
3882
3880
|
|
|
3883
3881
|
|
|
3884
3882
|
#
|
|
@@ -4613,15 +4611,15 @@ def dr2_lovera(f, ti, ar, sar):
|
|
|
4613
4611
|
# Lovera
|
|
4614
4612
|
f = np.array(f)
|
|
4615
4613
|
ti = np.array(ti)
|
|
4616
|
-
ar = np.array(ar)
|
|
4617
|
-
sar = np.array(sar)
|
|
4614
|
+
# ar = np.array(ar)
|
|
4615
|
+
# sar = np.array(sar)
|
|
4618
4616
|
ti = ti * 60 # in seconds
|
|
4619
4617
|
pi = math.pi
|
|
4620
4618
|
pi = 3.141592654
|
|
4621
4619
|
|
|
4622
4620
|
# sf = sqrt(b ** 2 * siga ** 2 + a ** 2 * sigb ** 2) / (a + b) ** 2
|
|
4623
|
-
sf = [math.sqrt(sar[i + 1:].sum() ** 2 * (sar[:i + 1] ** 2).sum() + ar[:i + 1].sum() ** 2 * (sar[i + 1:] ** 2).sum()) / ar.sum() ** 2 for i in range(len(ar) - 1)]
|
|
4624
|
-
sf.append(0)
|
|
4621
|
+
# sf = [math.sqrt(sar[i + 1:].sum() ** 2 * (sar[:i + 1] ** 2).sum() + ar[:i + 1].sum() ** 2 * (sar[i + 1:] ** 2).sum()) / ar.sum() ** 2 for i in range(len(ar) - 1)]
|
|
4622
|
+
# sf.append(0)
|
|
4625
4623
|
|
|
4626
4624
|
f = np.where(f >= 1, 0.9999999999999999, f)
|
|
4627
4625
|
|
|
@@ -4631,41 +4629,67 @@ def dr2_lovera(f, ti, ar, sar):
|
|
|
4631
4629
|
dr2 = [(dtr2[i] - (dtr2[i - 1] if i > 0 else 0)) / ti[i] * imp ** 2 for i in range(len(dtr2))]
|
|
4632
4630
|
xlogd = [np.log10(i) for i in dr2]
|
|
4633
4631
|
|
|
4634
|
-
wt = errcal(f, ti,
|
|
4632
|
+
wt = errcal(f, ti, ar, sar)
|
|
4635
4633
|
|
|
4636
4634
|
return dr2, xlogd, wt
|
|
4637
4635
|
|
|
4638
4636
|
|
|
4639
|
-
def dr2_yang(f, ti):
|
|
4637
|
+
def dr2_yang(f, ti, ar, sar):
|
|
4638
|
+
"""
|
|
4639
|
+
|
|
4640
|
+
if i == 0:
|
|
4641
|
+
dr2[i] = _dr2(f[i]) / ti[i]
|
|
4642
|
+
else:
|
|
4643
|
+
dr2[i] = _dr2((f[i] - f[i - 1]) / (1 - f[i - 1])) / ti[i]
|
|
4644
|
+
|
|
4645
|
+
Parameters
|
|
4646
|
+
----------
|
|
4647
|
+
f: array NOTE:这里的 f 既不是释放百分数也不是累积百分数,而是各个阶段释放量占其及后续所有气体的分数,即占释放前的比例
|
|
4648
|
+
ti
|
|
4649
|
+
|
|
4650
|
+
Returns
|
|
4651
|
+
-------
|
|
4652
|
+
|
|
4653
|
+
"""
|
|
4640
4654
|
f = np.array(f)
|
|
4641
4655
|
ti = np.array(ti)
|
|
4642
4656
|
n = min(len(f), len(ti))
|
|
4643
4657
|
ti = ti * 60 # in seconds
|
|
4658
|
+
sti = 5.
|
|
4644
4659
|
pi = math.pi
|
|
4645
4660
|
pi = 3.141592654
|
|
4661
|
+
ee = 0.4342944819
|
|
4646
4662
|
dr2 = np.zeros(n)
|
|
4663
|
+
sdr2 = np.zeros(n)
|
|
4647
4664
|
|
|
4648
|
-
|
|
4649
|
-
f[-1] = 0.99999999
|
|
4665
|
+
f = np.where(f >= 1, 0.9999999999999999, f)
|
|
4650
4666
|
|
|
4651
4667
|
def _dr2(_fi):
|
|
4668
|
+
# return: dr2, dy/df
|
|
4652
4669
|
if _fi <= 0.85:
|
|
4653
|
-
return (1 - math.sqrt(1 - pi * _fi / 3)) ** 2 / pi
|
|
4670
|
+
return (1 - math.sqrt(1 - pi * _fi / 3)) ** 2 / pi, 1 / (3 * math.sqrt(1 - pi * _fi / 3)) - 1 / 3
|
|
4654
4671
|
else:
|
|
4655
|
-
return math.log((1 - _fi) / (6 / pi ** 2)) / - (pi ** 2)
|
|
4672
|
+
return math.log((1 - _fi) / (6 / pi ** 2)) / - (pi ** 2), 1 / (pi ** 2 * (1 - _fi))
|
|
4656
4673
|
|
|
4657
|
-
for i in range(
|
|
4658
|
-
if i
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4674
|
+
for i in range(n):
|
|
4675
|
+
dtr2, d = _dr2((f[i] - (f[i-1] if i > 0 else 0)) / (1 - (f[i-1] if i > 0 else 0)))
|
|
4676
|
+
# sf 中 f = (f[i] - f[i - 1]) / (1 - f[i - 1])
|
|
4677
|
+
sf = sum([ar[i] ** 2 * sar[j] ** 2 / sum(ar[i:]) ** 4 for j in range(i+1, n)]) + sum(ar[i+1:]) ** 2 * sar[i] ** 2 / sum(ar[i:]) ** 4
|
|
4678
|
+
sdtr2 = math.sqrt(d ** 2 * sf)
|
|
4679
|
+
dr2[i] = dtr2 / ti[i]
|
|
4680
|
+
sdr2[i] = ap.calc.err.div((dtr2, sdtr2), (ti[i], sti))
|
|
4681
|
+
|
|
4682
|
+
xlogd = np.log(dr2)
|
|
4683
|
+
sxlogd = np.abs(sdr2 / dr2)
|
|
4662
4684
|
|
|
4663
4685
|
print(f"yang {dr2 = }")
|
|
4686
|
+
print(f"yang {xlogd = }")
|
|
4687
|
+
print(f"yang {sxlogd = }")
|
|
4664
4688
|
|
|
4665
|
-
return dr2,
|
|
4689
|
+
return dr2, xlogd, sxlogd
|
|
4666
4690
|
|
|
4667
4691
|
|
|
4668
|
-
def errcal(f, ti,
|
|
4692
|
+
def errcal(f, ti, ar, sar):
|
|
4669
4693
|
|
|
4670
4694
|
# ns = 200
|
|
4671
4695
|
# r = 1.987E-3
|
|
@@ -4681,9 +4705,9 @@ def errcal(f, ti, a39, sig39):
|
|
|
4681
4705
|
sigt0 = 90.
|
|
4682
4706
|
|
|
4683
4707
|
ni = len(f)
|
|
4684
|
-
sumat = sum(
|
|
4685
|
-
sigsm = [i / sumat for i in
|
|
4686
|
-
siga = [
|
|
4708
|
+
sumat = sum(ar)
|
|
4709
|
+
sigsm = [i / sumat for i in sar]
|
|
4710
|
+
siga = [sar[i] / ar[i] for i in range(ni)]
|
|
4687
4711
|
|
|
4688
4712
|
an1 = math.pi ** 2
|
|
4689
4713
|
sigat = 0.
|
ararpy/smp/export.py
CHANGED
|
@@ -41,6 +41,52 @@ def to_pdf(file_path: str, figure: str, smp: Sample):
|
|
|
41
41
|
pdf.save(figure=figure)
|
|
42
42
|
|
|
43
43
|
|
|
44
|
+
def export_chart_to_pdf(data: dict):
|
|
45
|
+
# create a canvas
|
|
46
|
+
cv = pm.Canvas(width=17, height=12, unit="cm", show_frame=True, clip_outside_plot_areas=False)
|
|
47
|
+
# change frame outline style
|
|
48
|
+
cv.show_frame(color="grey", line_width=0.5)
|
|
49
|
+
sc = (*data['xAxis'][0]['extent'], *data['yAxis'][0]['extent'])
|
|
50
|
+
pt = cv.add_plot_area(name="Plot1", plot_area=(0.15, 0.15, 0.8, 0.8), plot_scale=sc, show_frame=True)
|
|
51
|
+
# draw axis
|
|
52
|
+
for stick in data['xAxis'][0]['interval']:
|
|
53
|
+
start = pt.scale_to_points(stick, sc[2])
|
|
54
|
+
end = pt.scale_to_points(stick, sc[2])
|
|
55
|
+
end = (end[0], end[1] - 5)
|
|
56
|
+
pt.line(start=start, end=end, width=1, line_style="solid", y_clip=False, coordinate="pt", z_index=100)
|
|
57
|
+
pt.text(x=start[0], y=end[1] - 15, text=f"{stick}", clip=False,
|
|
58
|
+
coordinate="pt", h_align="middle", z_index=150)
|
|
59
|
+
for stick in data['yAxis'][0]['interval']:
|
|
60
|
+
start = pt.scale_to_points(sc[0], stick)
|
|
61
|
+
end = pt.scale_to_points(sc[0], stick)
|
|
62
|
+
end = (end[0] - 5, end[1])
|
|
63
|
+
pt.line(start=start, end=end, width=1, line_style="solid", x_clip=False, coordinate="pt", z_index=100)
|
|
64
|
+
pt.text(x=end[0] - 5, y=end[1], text=f"{stick}", clip=False,
|
|
65
|
+
coordinate="pt", h_align="right", v_align="center", z_index=150)
|
|
66
|
+
# axis titles
|
|
67
|
+
nameLocation = pt.scale_to_points(sum(sc[:2]) / 2, sc[2])
|
|
68
|
+
pt.text(x=nameLocation[0], y=nameLocation[1] - 30, text=data['xAxis'][0]['title'], clip=False, coordinate="pt",
|
|
69
|
+
h_align="middle", v_align="top", z_index=150)
|
|
70
|
+
nameLocation = pt.scale_to_points(sc[0], sum(sc[2:4]) / 2)
|
|
71
|
+
pt.text(x=nameLocation[0] - 50, y=nameLocation[1], text=data['yAxis'][0]['title'], clip=False, coordinate="pt",
|
|
72
|
+
h_align="middle", v_align="bottom", rotate=90, z_index=150)
|
|
73
|
+
# draw series
|
|
74
|
+
for se in data['series']:
|
|
75
|
+
data = se.get('data', [])
|
|
76
|
+
if 'line' in se['type']:
|
|
77
|
+
for index in range(1, len(data)):
|
|
78
|
+
pt.line(start=data[index - 1], end=data[index], width=1, line_style='solid', name=se['name'],
|
|
79
|
+
color=se.get('color', 'black'), clip=True, line_caps=se.get('line_caps', 'none'), z_index=9)
|
|
80
|
+
if 'scatter' in se['type'] and se['name'] != 'Text':
|
|
81
|
+
for each in data:
|
|
82
|
+
pt.scatter(each[0], each[1], fill_color=se.get('color', 'black'), size=2)
|
|
83
|
+
if 'scatter' in se['type'] and se['name'] == 'Text' or 'text' in se['type']:
|
|
84
|
+
for each in data:
|
|
85
|
+
pt.text(*each[:2], **se)
|
|
86
|
+
|
|
87
|
+
return cv
|
|
88
|
+
|
|
89
|
+
|
|
44
90
|
class ExcelTemplate:
|
|
45
91
|
def __init__(self, **kwargs):
|
|
46
92
|
self.name = ""
|
ararpy/smp/json.py
CHANGED
|
@@ -22,7 +22,8 @@ def dumps(a):
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def loads(a):
|
|
25
|
-
|
|
25
|
+
# null will be converted to None by default, replace None with np.nan
|
|
26
|
+
return json.loads(a, object_hook=myHook)
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
class MyEncoder(json.JSONEncoder):
|
|
@@ -51,3 +52,13 @@ class MyEncoder(json.JSONEncoder):
|
|
|
51
52
|
if not isinstance(obj, (int, str, list, dict, tuple, float)):
|
|
52
53
|
print(f"Special type, {type(obj) = }, {obj = }")
|
|
53
54
|
return super(MyEncoder, self).default(obj)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
def myHook(obj):
|
|
58
|
+
if isinstance(obj, dict):
|
|
59
|
+
return {k: myHook(v) for k, v in obj.items()}
|
|
60
|
+
elif isinstance(obj, list):
|
|
61
|
+
return [myHook(v) for v in obj]
|
|
62
|
+
elif obj is None:
|
|
63
|
+
return np.nan
|
|
64
|
+
return obj
|
ararpy/smp/plots.py
CHANGED
|
@@ -61,16 +61,20 @@ def set_plot_data(sample: Sample, isInit: bool = True, isIsochron: bool = True,
|
|
|
61
61
|
try:
|
|
62
62
|
initial_plot_data(sample)
|
|
63
63
|
except (Exception, BaseException):
|
|
64
|
-
print(traceback.format_exc())
|
|
64
|
+
# print(traceback.format_exc())
|
|
65
65
|
pass
|
|
66
66
|
|
|
67
67
|
# Recalculate isochron lines
|
|
68
68
|
if isIsochron:
|
|
69
69
|
try:
|
|
70
70
|
recalc_isochrons(sample, **kwargs)
|
|
71
|
+
except (Exception, BaseException):
|
|
72
|
+
# print(traceback.format_exc())
|
|
73
|
+
pass
|
|
74
|
+
try:
|
|
71
75
|
reset_isochron_line_data(sample)
|
|
72
76
|
except (Exception, BaseException):
|
|
73
|
-
print(traceback.format_exc())
|
|
77
|
+
# print(traceback.format_exc())
|
|
74
78
|
pass
|
|
75
79
|
|
|
76
80
|
# Recalculate plateaus
|
|
@@ -78,7 +82,7 @@ def set_plot_data(sample: Sample, isInit: bool = True, isIsochron: bool = True,
|
|
|
78
82
|
try:
|
|
79
83
|
recalc_plateaus(sample)
|
|
80
84
|
except (Exception, BaseException):
|
|
81
|
-
print(traceback.format_exc())
|
|
85
|
+
# print(traceback.format_exc())
|
|
82
86
|
pass
|
|
83
87
|
|
|
84
88
|
|
|
@@ -237,7 +241,7 @@ def get_isochron_results(data: list, smp: Sample, sequence, figure_type: int = 0
|
|
|
237
241
|
try:
|
|
238
242
|
regression_res = regression_method(*data[:5])
|
|
239
243
|
except (Exception, BaseException):
|
|
240
|
-
print(f"Warning: {traceback.format_exc()}")
|
|
244
|
+
# print(f"Warning: {traceback.format_exc()}")
|
|
241
245
|
return iso_res
|
|
242
246
|
else:
|
|
243
247
|
iso_res.update(dict(zip(reg_res_index, regression_res)))
|
|
@@ -305,11 +309,11 @@ def get_3D_results(data: list, sequence: list, sample: Sample):
|
|
|
305
309
|
Q = 1 - np.exp(-1 * sample.TotalParam[46][0] * sum(sample.TotalParam[32]) / len(sample.TotalParam[32]))
|
|
306
310
|
P = PQ / Q
|
|
307
311
|
except:
|
|
308
|
-
print(f"Warning: {traceback.format_exc()}")
|
|
312
|
+
# print(f"Warning: {traceback.format_exc()}")
|
|
309
313
|
P = 0
|
|
310
314
|
age = basic.calc_age([f, sf], smp=sample)
|
|
311
315
|
except:
|
|
312
|
-
print(f"Warning: {traceback.format_exc()}")
|
|
316
|
+
# print(f"Warning: {traceback.format_exc()}")
|
|
313
317
|
k = [0] * 15
|
|
314
318
|
age = [0] * 4
|
|
315
319
|
ar40ar36, sar40ar36, P = 0, 0, 0
|
ararpy/smp/sample.py
CHANGED
|
@@ -119,8 +119,8 @@ TOTAL_PARAMS_HEADERS = [
|
|
|
119
119
|
'\u2074\u2070Ar/\u00B3\u2076Ar air', '%1\u03C3',
|
|
120
120
|
'\u00B3\u2078Ar/\u00B3\u2076Ar air', '%1\u03C3', # 95-98
|
|
121
121
|
'Isochron Fitting', 'Convergence', 'Iteration', 'Discrimination', # 99-102
|
|
122
|
-
'Not Zero', 'Corr Blank', 'Corr Discr', 'Corr \u00B3\u2077Ar Decay',
|
|
123
|
-
'Corr \u00B3\u2079Ar Decay', #
|
|
122
|
+
'Not Zero', 'Corr Blank', 'Corr Discr', 'Corr \u00B3\u2077Ar Decay', # 103-106
|
|
123
|
+
'Corr \u00B3\u2079Ar Decay', # 107
|
|
124
124
|
'Ca Degassing', 'K Degassing', 'Cl Degassing', 'Trap Degassing', # 108-111
|
|
125
125
|
'Using Min Equation',
|
|
126
126
|
# 'Recalibration', 'Using Std Age', 'Use Std Ratio', # 112-115 to be completed
|
|
@@ -137,6 +137,11 @@ TOTAL_PARAMS_HEADERS = [
|
|
|
137
137
|
'Heating Time (s)', # 125
|
|
138
138
|
'Heating Actual Temp (C)', # 126
|
|
139
139
|
'Heating AT 1\u03C3', # 127
|
|
140
|
+
'36Ar Gain', '1\u03C3', # 128-129
|
|
141
|
+
'37Ar Gain', '1\u03C3', # 130-131
|
|
142
|
+
'38Ar Gain', '1\u03C3', # 132-133
|
|
143
|
+
'39Ar Gain', '1\u03C3', # 134-135
|
|
144
|
+
'40Ar Gain', '1\u03C3', # 136-137
|
|
140
145
|
]
|
|
141
146
|
|
|
142
147
|
SAMPLE_INTERCEPT_SHORT_HEADERS = [
|
|
@@ -245,6 +250,11 @@ TOTAL_PARAMS_SHORT_HEADERS = [
|
|
|
245
250
|
'HeatingTime', # 125
|
|
246
251
|
'HeatingActualTemp', # 126
|
|
247
252
|
'HeatingActualTempError', # 127
|
|
253
|
+
'36Gain', '1s', # 128-129
|
|
254
|
+
'37Gain', '1s', # 130-131
|
|
255
|
+
'38Gain', '1s', # 132-133
|
|
256
|
+
'39Gain', '1s', # 134-135
|
|
257
|
+
'40Gain', '1s', # 136-137
|
|
248
258
|
]
|
|
249
259
|
|
|
250
260
|
DEFAULT_PLOT_STYLES = {
|
|
@@ -731,7 +741,7 @@ DEFAULT_PLOT_STYLES = {
|
|
|
731
741
|
},
|
|
732
742
|
}
|
|
733
743
|
|
|
734
|
-
VERSION = '
|
|
744
|
+
VERSION = '20240930'
|
|
735
745
|
|
|
736
746
|
NAMED_DICT = {
|
|
737
747
|
"unknown": {"header": SAMPLE_INTERCEPT_HEADERS.copy()},
|
|
@@ -854,7 +864,7 @@ class Sample:
|
|
|
854
864
|
|
|
855
865
|
def sequence(self) -> ArArBasic: ...
|
|
856
866
|
|
|
857
|
-
def recalculate(self, *args): ...
|
|
867
|
+
def recalculate(self, *args, **kwargs): ...
|
|
858
868
|
|
|
859
869
|
def plot_age_plateau(self): ...
|
|
860
870
|
|
ararpy/smp/table.py
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
#
|
|
10
10
|
#
|
|
11
11
|
"""
|
|
12
|
+
import copy
|
|
12
13
|
from .. import calc
|
|
13
14
|
from . import (sample as samples, basic)
|
|
14
15
|
|
|
@@ -47,6 +48,13 @@ def update_table_data(smp: Sample, only_table: str = None):
|
|
|
47
48
|
data = calc.arr.merge(
|
|
48
49
|
smp.SequenceName, smp.SequenceValue, *smp.DegasValues)
|
|
49
50
|
elif key == '5':
|
|
51
|
+
smp.PublishValues[0] = copy.deepcopy(smp.DegasValues[ 0])
|
|
52
|
+
smp.PublishValues[1] = copy.deepcopy(smp.DegasValues[ 8])
|
|
53
|
+
smp.PublishValues[2] = copy.deepcopy(smp.DegasValues[10])
|
|
54
|
+
smp.PublishValues[3] = copy.deepcopy(smp.DegasValues[20])
|
|
55
|
+
smp.PublishValues[4] = copy.deepcopy(smp.DegasValues[24])
|
|
56
|
+
smp.PublishValues[5:7] = copy.deepcopy(smp.ApparentAgeValues[2:4])
|
|
57
|
+
smp.PublishValues[7:9] = copy.deepcopy(smp.ApparentAgeValues[6:8])
|
|
50
58
|
data = calc.arr.merge(
|
|
51
59
|
smp.SequenceName, smp.SequenceValue, *smp.PublishValues)
|
|
52
60
|
elif key == '6':
|
ararpy/test.py
CHANGED
|
@@ -33,5 +33,68 @@ def test():
|
|
|
33
33
|
print(sample.blank().to_df().iloc[:, [1, 2, 3]])
|
|
34
34
|
|
|
35
35
|
|
|
36
|
+
def export_pdf_demo():
|
|
37
|
+
import numpy as np
|
|
38
|
+
import pdf_maker as pm
|
|
39
|
+
|
|
40
|
+
example_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), r'examples')
|
|
41
|
+
|
|
42
|
+
# ------ 将以下五个样品的年龄谱图组合到一起 -------
|
|
43
|
+
arr_files = [
|
|
44
|
+
os.path.join(example_dir, r'22WHA0433.arr'),
|
|
45
|
+
os.path.join(example_dir, r'20WHA0103.age'),
|
|
46
|
+
]
|
|
47
|
+
colors = ['#1f3c40', '#e35000', '#e1ae0f', '#3d8ebf']
|
|
48
|
+
series = []
|
|
49
|
+
|
|
50
|
+
# ------ 构建数据 -------
|
|
51
|
+
for index, file in enumerate(arr_files):
|
|
52
|
+
smp = ap.from_arr(file_path=file) if file.endswith('.arr') else ap.from_age(file_path=file)
|
|
53
|
+
age = smp.ApparentAgeValues[2:4]
|
|
54
|
+
ar = smp.DegasValues[20]
|
|
55
|
+
data = ap.calc.spectra.get_data(*age, ar, cumulative=False)
|
|
56
|
+
series.append({
|
|
57
|
+
'type': 'series.line', 'id': f'line{index * 2 + 0}', 'name': f'line{index * 2 + 0}', 'color': colors[index],
|
|
58
|
+
'data': np.transpose([data[0], data[1]]).tolist(), 'line_caps': 'square',
|
|
59
|
+
})
|
|
60
|
+
series.append({
|
|
61
|
+
'type': 'series.line', 'id': f'line{index * 2 + 1}', 'name': f'line{index * 2 + 1}', 'color': colors[index],
|
|
62
|
+
'data': np.transpose([data[0], data[2]]).tolist(), 'line_caps': 'square',
|
|
63
|
+
})
|
|
64
|
+
series.append({
|
|
65
|
+
'type': 'text', 'id': f'text{index * 2 + 0}', 'name': f'text{index * 2 + 0}', 'color': colors[index],
|
|
66
|
+
'text': f'{smp.name()}<r>{round(smp.Info.results.age_plateau[0]["age"], 2)}',
|
|
67
|
+
'size': 10, 'data': [[index * 15 + 5, 23]],
|
|
68
|
+
})
|
|
69
|
+
data = {
|
|
70
|
+
"data": [
|
|
71
|
+
{
|
|
72
|
+
'xAxis': [{'extent': [0, 100], 'interval': [0, 20, 40, 60, 80, 100],
|
|
73
|
+
'title': 'Cumulative <sup>39</sup>Ar Released (%)', 'nameLocation': 'middle', }],
|
|
74
|
+
'yAxis': [{'extent': [0, 250], 'interval': [0, 50, 100, 150, 200, 250],
|
|
75
|
+
'title': 'Apparent Age (Ma)', 'nameLocation': 'middle', }],
|
|
76
|
+
'series': series
|
|
77
|
+
}
|
|
78
|
+
],
|
|
79
|
+
"file_name": "WHA",
|
|
80
|
+
"plot_names": ["all age plateaus"],
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
# write pdf
|
|
84
|
+
file = pm.NewPDF(filepath=os.path.join(example_dir, f"{data['file_name']}.pdf"))
|
|
85
|
+
for index, each in enumerate(data['data']):
|
|
86
|
+
# rich text tags should follow this priority: color > script > break
|
|
87
|
+
file.text(page=index, x=50, y=780, line_space=1.2, size=12, base=0, h_align="left",
|
|
88
|
+
text=f"The PDF can be edited with Adobe Acrobat, Illustrator and CorelDRAW")
|
|
89
|
+
cv = ap.smp.export.export_chart_to_pdf(each)
|
|
90
|
+
file.canvas(page=index, base=0, margin_top=5, canvas=cv, unit="cm", h_align="middle")
|
|
91
|
+
if index + 1 < len(data['data']):
|
|
92
|
+
file.add_page()
|
|
93
|
+
|
|
94
|
+
# save pdf
|
|
95
|
+
file.save()
|
|
96
|
+
|
|
97
|
+
|
|
36
98
|
if __name__ == "__main__":
|
|
37
99
|
test()
|
|
100
|
+
# export_pdf_demo()
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
ararpy/__init__.py,sha256=XKlsgklkzGfvqQkt59y-UST9aVhgCf-eXpEDiaZaynQ,6725
|
|
2
|
-
ararpy/test.py,sha256=
|
|
2
|
+
ararpy/test.py,sha256=4F46-JJ1Ge12HGae0qO44Qc6kiEMHBgn2MsY_5LlHDo,3973
|
|
3
3
|
ararpy/calc/__init__.py,sha256=kUjRuLE8TLuKOv3i976RnGJoEMj23QBZDu37LWs81U4,322
|
|
4
4
|
ararpy/calc/age.py,sha256=CUex9UxZbYinl9ypd7o86R3VRQFzahku3gW__fBeoss,5811
|
|
5
|
-
ararpy/calc/arr.py,sha256=
|
|
5
|
+
ararpy/calc/arr.py,sha256=P0DdYMXXnN69tNGL9NpB0hftNN03EEB_KFmfmZdIy-A,14922
|
|
6
6
|
ararpy/calc/basic.py,sha256=wPzUXmrHAXdFkvd53JsH9Vae-o7O3LxYWztGQ5OpDhw,2871
|
|
7
|
-
ararpy/calc/corr.py,sha256=
|
|
7
|
+
ararpy/calc/corr.py,sha256=mQd5_CfDP2aBQrkQHKTV5R-zKbNOjXh8a21zHNrRNmU,19102
|
|
8
8
|
ararpy/calc/err.py,sha256=63LtprqjemlIb1QGDst4Ggcv5KMSDHdlAIL-nyQs1eA,2691
|
|
9
9
|
ararpy/calc/histogram.py,sha256=0GVbDdsjd91KQ1sa2B7NtZ4KGo0XpRIJapgIrzAwQUo,5777
|
|
10
|
-
ararpy/calc/isochron.py,sha256=
|
|
10
|
+
ararpy/calc/isochron.py,sha256=ej9G2e68k6yszonWHsLcEubh3TA7eh1upTJP_X0ttAA,5726
|
|
11
11
|
ararpy/calc/jvalue.py,sha256=zHUhJ1iYe5mPrY95mGYxoUPAp7hwu4coUgiHKiruKfM,1138
|
|
12
12
|
ararpy/calc/plot.py,sha256=v-vJwciJIhKrdXKWAUZbYslez0zBrIa6awI-DopmRZg,1956
|
|
13
13
|
ararpy/calc/raw_funcs.py,sha256=fhAmqpvTvWUegbLi2PNbFRIbKgbDmycDIWNic3z25hU,2536
|
|
@@ -29,6 +29,7 @@ ararpy/examples/NGX-XLS.input-filter,sha256=iyfTLsLHf0h58ePOsNQoBtG6UBLIf7V-zTGi
|
|
|
29
29
|
ararpy/examples/Qtegra-exported-xls.input-filter,sha256=KuD3Dey82ecuKnqNMQqOcY3VXHgKbpE9Yxfl1ZC4_so,441
|
|
30
30
|
ararpy/examples/S01-239.csv,sha256=J_PHT85XCxPd3TEGzBARGwKSkiAzz1nzNbrKUf00GBU,39566
|
|
31
31
|
ararpy/examples/WH01.irra,sha256=Ws78m5p3fD4oybtkOWoAtvFyuLPxpL_A_ueIg2tnhnw,365
|
|
32
|
+
ararpy/examples/WHA.pdf,sha256=iopbptHkWPmYdgihEVDDfv2nm2XE-Q-e7fFnkR44Xh0,178692
|
|
32
33
|
ararpy/examples/raw_example.xls,sha256=ftcSiXRx_7nYnbqJVma1Yl3Yr_iuceAWlEjhJwlAvFM,1929895
|
|
33
34
|
ararpy/examples/sample-default.smp,sha256=YNkoQGgPrsL_fXS7ZHxfRtLQWekCDqT9czS6vBScImk,432
|
|
34
35
|
ararpy/files/__init__.py,sha256=l5B5ZQ01WdtvjjN0aMkyAFNgpwANdM_1I0tQbqnRuEY,69
|
|
@@ -39,22 +40,22 @@ ararpy/files/new_file.py,sha256=efblARIBROVLWS2w3-98BxLX5VZ8grRpiTkJFtf_rAk,214
|
|
|
39
40
|
ararpy/files/raw_file.py,sha256=B2k4RjAp4EViwHKv6CbI5400Liaa7OW_eBjGSPlN9Ek,22768
|
|
40
41
|
ararpy/files/xls.py,sha256=8ibT4ZRY2grK34ikKm1pDmlWFlVTgDL7vSMO6mphzrY,702
|
|
41
42
|
ararpy/smp/__init__.py,sha256=k6_fa27UJsQK7K7oC5GYlwMo6l0Xd8af3QtOrZz2XJk,478
|
|
42
|
-
ararpy/smp/basic.py,sha256=
|
|
43
|
-
ararpy/smp/calculation.py,sha256=
|
|
43
|
+
ararpy/smp/basic.py,sha256=DrwU4ApXOkxYNMwax7B-ErBndJnUwG5n64fLU6zR63Y,21506
|
|
44
|
+
ararpy/smp/calculation.py,sha256=1dUKYbq83j0YpZ9Nbb5rM0wbaEXezDKqcbUCc9TRKng,2919
|
|
44
45
|
ararpy/smp/consts.py,sha256=XIdjdz8cYxspG2jMnoItdlUsxr3hKbNFJjMZJh1bpzw,393
|
|
45
|
-
ararpy/smp/corr.py,sha256=
|
|
46
|
-
ararpy/smp/diffusion_funcs.py,sha256=
|
|
47
|
-
ararpy/smp/export.py,sha256=
|
|
46
|
+
ararpy/smp/corr.py,sha256=MXF04dLYGcZN7JHFq8OJqawkZ-yUjN45qG0NJX_kBB0,24528
|
|
47
|
+
ararpy/smp/diffusion_funcs.py,sha256=5yDlyVVcaKQDMPLd7ZvyCetyiQNBR57XtrJkLT_Hsww,168544
|
|
48
|
+
ararpy/smp/export.py,sha256=SEUySwBnDm6ao0Ujc93y98FamUx_UmEsqnd3cmFgKPA,80817
|
|
48
49
|
ararpy/smp/info.py,sha256=iKUELm-BuUduDlJKC1d8tKKNHbwwbNmhUg2pi6bcBvA,489
|
|
49
50
|
ararpy/smp/initial.py,sha256=nZNrV4fv_PlNXYfqqIOOOkcQjnSOTLymVpJyJ9d_QtM,15359
|
|
50
|
-
ararpy/smp/json.py,sha256=
|
|
51
|
-
ararpy/smp/plots.py,sha256=
|
|
51
|
+
ararpy/smp/json.py,sha256=Y7xoTZczSTrvVHlhfLmpu-zoxgLw9MFn2lgRYkjgHTY,2079
|
|
52
|
+
ararpy/smp/plots.py,sha256=bM4ofS12NedBUXXleEy7-xcK9C8svVuSrTXYmeiMY3k,31495
|
|
52
53
|
ararpy/smp/raw.py,sha256=KtAmzTAwCDK4x1dRgvwj2TbOzHRv7LFwaU2hHCknF3c,6173
|
|
53
|
-
ararpy/smp/sample.py,sha256=
|
|
54
|
+
ararpy/smp/sample.py,sha256=KPysezU7avqUBu6ykIEtP3_2wa5a16n0gC0iF_kqSoU,54988
|
|
54
55
|
ararpy/smp/style.py,sha256=NZwTeodhtHBBdCyjvupF64nh2B5EDdMHzlT8oE360zg,6746
|
|
55
|
-
ararpy/smp/table.py,sha256=
|
|
56
|
-
ararpy-0.1.
|
|
57
|
-
ararpy-0.1.
|
|
58
|
-
ararpy-0.1.
|
|
59
|
-
ararpy-0.1.
|
|
60
|
-
ararpy-0.1.
|
|
56
|
+
ararpy/smp/table.py,sha256=yNr4PLxbH4ezeUXpKBxLjRfq4RuYiW-G3sMWFDtjlVM,6802
|
|
57
|
+
ararpy-0.1.12.dist-info/LICENSE,sha256=cvG5t_C1qY_zUyJI7sNOa7gCArdngNPaOrfujl2LYuc,1085
|
|
58
|
+
ararpy-0.1.12.dist-info/METADATA,sha256=BiPSBAkyiLpDd-5VsJm14TqeH58VkFf1G1mpQh3Xx4E,24331
|
|
59
|
+
ararpy-0.1.12.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
|
|
60
|
+
ararpy-0.1.12.dist-info/top_level.txt,sha256=9iTpsPCYuRYq09yQTk9d2lqB8JtTEOmbN-IcGB-K3vY,7
|
|
61
|
+
ararpy-0.1.12.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|