ararpy 0.1.35__py3-none-any.whl → 0.1.37__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 -3
- ararpy/calc/basic.py +12 -0
- ararpy/calc/raw_funcs.py +3 -3
- ararpy/calc/regression.py +207 -100
- ararpy/files/calc_file.py +35 -34
- ararpy/files/raw_file.py +97 -131
- ararpy/smp/info.py +2 -2
- ararpy/smp/initial.py +14 -11
- ararpy/smp/json.py +2 -2
- ararpy/smp/raw.py +4 -4
- ararpy/smp/sample.py +59 -70
- ararpy/smp/style.py +4 -1
- {ararpy-0.1.35.dist-info → ararpy-0.1.37.dist-info}/METADATA +1 -1
- {ararpy-0.1.35.dist-info → ararpy-0.1.37.dist-info}/RECORD +17 -17
- {ararpy-0.1.35.dist-info → ararpy-0.1.37.dist-info}/WHEEL +0 -0
- {ararpy-0.1.35.dist-info → ararpy-0.1.37.dist-info}/licenses/LICENSE +0 -0
- {ararpy-0.1.35.dist-info → ararpy-0.1.37.dist-info}/top_level.txt +0 -0
ararpy/__init__.py
CHANGED
|
@@ -16,10 +16,10 @@ from . import calc, smp, files, thermo, test
|
|
|
16
16
|
""" Information """
|
|
17
17
|
|
|
18
18
|
name = 'ararpy'
|
|
19
|
-
version = '0.1.
|
|
19
|
+
version = '0.1.37'
|
|
20
20
|
__version__ = version
|
|
21
21
|
full_version = version
|
|
22
|
-
last_update = '2025-12-
|
|
22
|
+
last_update = '2025-12-12'
|
|
23
23
|
|
|
24
24
|
""" ArArPy Functions """
|
|
25
25
|
|
|
@@ -141,6 +141,5 @@ RawData.get_sequence = smp.raw.get_sequence
|
|
|
141
141
|
RawData.to_sample = smp.initial.from_raw_data
|
|
142
142
|
RawData.get_unknown = lambda _raw: smp.raw.get_sequence(_raw, True, 'is_unknown', unique=False)
|
|
143
143
|
RawData.get_blank = lambda _raw: smp.raw.get_sequence(_raw, True, 'is_blank', unique=False)
|
|
144
|
-
RawData.get_air = lambda _raw: smp.raw.get_sequence(_raw, True, 'is_air', unique=False)
|
|
145
144
|
Sequence.get_data_df = lambda _seq: pd.DataFrame(_seq.data)
|
|
146
145
|
Sequence.get_flag_df = lambda _seq: pd.DataFrame(_seq.flag)
|
ararpy/calc/basic.py
CHANGED
|
@@ -57,6 +57,18 @@ def get_datetime(t_year: int, t_month: int, t_day: int, t_hour: int, t_min: int,
|
|
|
57
57
|
return ts - base
|
|
58
58
|
|
|
59
59
|
|
|
60
|
+
def get_timestring(timestamp: int = 0, base=None):
|
|
61
|
+
"""
|
|
62
|
+
:param timestamp: timestamp (utz)
|
|
63
|
+
:param base: base time [y, m, d, h, m]
|
|
64
|
+
:return:
|
|
65
|
+
"""
|
|
66
|
+
if base is None:
|
|
67
|
+
base = [1970, 1, 1, 0, 0]
|
|
68
|
+
ts = timestamp + datetime(*base, tzinfo=timezone.utc).timestamp()
|
|
69
|
+
return datetime.fromtimestamp(ts, tz=timezone.utc).isoformat(timespec='seconds')
|
|
70
|
+
|
|
71
|
+
|
|
60
72
|
def merge_dicts(a: dict, b: dict):
|
|
61
73
|
"""
|
|
62
74
|
a and b, two dictionary. Return updated a
|
ararpy/calc/raw_funcs.py
CHANGED
|
@@ -30,8 +30,8 @@ def get_raw_data_regression_results(points_data, unselected: list = None):
|
|
|
30
30
|
|
|
31
31
|
"""
|
|
32
32
|
def power(a0, a1):
|
|
33
|
-
return regression.power(a0, a1)
|
|
34
|
-
|
|
33
|
+
# return regression.power(a0, a1)
|
|
34
|
+
raise ValueError("Deprecated regression")
|
|
35
35
|
# if unselected is None:
|
|
36
36
|
# unselected = []
|
|
37
37
|
# linesData = []
|
|
@@ -42,9 +42,9 @@ def get_raw_data_regression_results(points_data, unselected: list = None):
|
|
|
42
42
|
power, regression.average]
|
|
43
43
|
# size = 50
|
|
44
44
|
# lines_x = [(max(x + un_x) - 0) / size * i for i in range(size + 1)]
|
|
45
|
+
x, y = transpose(points_data, ignore=False)
|
|
45
46
|
for i in range(len(reg_handler)):
|
|
46
47
|
try:
|
|
47
|
-
x, y = transpose(points_data, ignore=False)
|
|
48
48
|
res = reg_handler[i](a0=y, a1=x)
|
|
49
49
|
# line_data = transpose([lines_x, res[7](lines_x)])
|
|
50
50
|
line_results = res[0:4]
|
ararpy/calc/regression.py
CHANGED
|
@@ -16,7 +16,7 @@ import traceback
|
|
|
16
16
|
import numpy as np
|
|
17
17
|
import pandas as pd
|
|
18
18
|
from scipy.stats import distributions
|
|
19
|
-
from scipy.optimize import
|
|
19
|
+
from scipy.optimize import minimize_scalar
|
|
20
20
|
import warnings
|
|
21
21
|
from scipy.optimize import minimize
|
|
22
22
|
warnings.simplefilter(action="ignore", category=RuntimeWarning)
|
|
@@ -495,22 +495,25 @@ def linest(a0: list, a1: list, *args):
|
|
|
495
495
|
# calculate Y values base on the fitted formula
|
|
496
496
|
estimate_y = np.matmul(x, beta)
|
|
497
497
|
resid = (estimate_y - y) ** 2
|
|
498
|
-
reg = (estimate_y - np.mean(
|
|
499
|
-
ssresid = resid.sum()
|
|
500
|
-
ssreg = reg.sum()
|
|
501
|
-
sstotal =
|
|
498
|
+
reg = (estimate_y - np.mean(y)) ** 2
|
|
499
|
+
ssresid = resid.sum() # 残差平方和
|
|
500
|
+
ssreg = reg.sum() # 回归平方和
|
|
501
|
+
sstotal = ((y - np.mean(y)) ** 2).sum()
|
|
502
|
+
r2 = ssreg / sstotal if sstotal != 0 else np.inf
|
|
503
|
+
|
|
502
504
|
df = m - n
|
|
503
|
-
m_ssresid = ssresid / df
|
|
504
|
-
|
|
505
|
-
|
|
505
|
+
m_ssresid = ssresid / df # 均方残差,与加权平均中的MSWD对应
|
|
506
|
+
cov_beta = m_ssresid * inv_xtx
|
|
507
|
+
se_beta = np.diagonal(cov_beta) ** .5
|
|
508
|
+
|
|
509
|
+
beta = beta.flatten()
|
|
506
510
|
rse_beta = se_beta / beta
|
|
507
|
-
r2 = ssreg / sstotal if sstotal != 0 else np.inf
|
|
508
511
|
|
|
509
512
|
def get_adjusted_y(*args):
|
|
510
513
|
args = [[1] * len(args[0]), *args]
|
|
511
514
|
return [sum([beta[i] * args[i][j] for i in range(len(beta))]) for j in range(len(args[0]))]
|
|
512
515
|
|
|
513
|
-
return beta[0], se_beta[0], rse_beta[0] * 100, r2, m_ssresid, beta,
|
|
516
|
+
return beta[0], se_beta[0], abs(rse_beta[0]) * 100, r2, m_ssresid, beta, cov_beta, get_adjusted_y, m_ssresid
|
|
514
517
|
|
|
515
518
|
|
|
516
519
|
def average(a0: list, a1=None):
|
|
@@ -535,12 +538,12 @@ def average(a0: list, a1=None):
|
|
|
535
538
|
m_ssresid = ssresid / df
|
|
536
539
|
r2 = ssreg / sstotal if sstotal != 0 else 1 # r2 = ssreg / sstotal
|
|
537
540
|
|
|
538
|
-
|
|
539
|
-
|
|
541
|
+
k6 = [[sum([(i - k0) ** 2 for i in a0]) / df]]
|
|
542
|
+
k1 = pow(k6[0][0], 0.5) # standard deviation
|
|
543
|
+
k2 = k1 / abs(k0) * 100 if k0 != 0 else 0 # relative standard error
|
|
540
544
|
k3 = r2 # determination coefficient
|
|
541
|
-
k4 = 'MSWD'
|
|
545
|
+
k4 = m_ssresid # 'MSWD'
|
|
542
546
|
k5 = [k0]
|
|
543
|
-
k6 = [k1]
|
|
544
547
|
k8 = m_ssresid
|
|
545
548
|
|
|
546
549
|
def get_adjusted_y(x: list):
|
|
@@ -737,7 +740,7 @@ def quadratic(a0: list, a1: list):
|
|
|
737
740
|
"""
|
|
738
741
|
# y = b + m1 * x + m2 * x ^ 2
|
|
739
742
|
k = list(linest(a0, a1, [i ** 2 for i in a1]))
|
|
740
|
-
|
|
743
|
+
[b, m1, m2] = k[5]
|
|
741
744
|
|
|
742
745
|
def get_adjusted_y(x: list):
|
|
743
746
|
return [b + m1 * _x + m2 * _x ** 2 for _x in x]
|
|
@@ -756,7 +759,7 @@ def polynomial(a0: list, a1: list, degree: int = 5):
|
|
|
756
759
|
"""
|
|
757
760
|
# y = b + m1 * x + m2 * x ^ 2 + ... + m[n] * x ^ n
|
|
758
761
|
k = list(linest(a0, *[[j ** (i + 1) for j in a1] for i in range(degree)]))
|
|
759
|
-
|
|
762
|
+
beta = k[5]
|
|
760
763
|
|
|
761
764
|
def get_adjusted_y(x: list):
|
|
762
765
|
return [sum([beta[i] * _x ** i for i in range(degree + 1)]) for _x in x]
|
|
@@ -766,6 +769,7 @@ def polynomial(a0: list, a1: list, degree: int = 5):
|
|
|
766
769
|
return k
|
|
767
770
|
|
|
768
771
|
|
|
772
|
+
### Deprecated
|
|
769
773
|
def logest(a0: list, a1: list):
|
|
770
774
|
"""
|
|
771
775
|
:param a0: known_y's, y = b * m ^ x
|
|
@@ -775,15 +779,19 @@ def logest(a0: list, a1: list):
|
|
|
775
779
|
# y = b * m ^ x, Microsoft Excel LOGEST function, ln(y) = ln(b) + ln(m) * x
|
|
776
780
|
a0 = [np.log(i) for i in a0] # ln(y)
|
|
777
781
|
linest_res = linest(a0, a1)
|
|
778
|
-
lnb, selnb, rseb, r2, mswd,
|
|
782
|
+
lnb, selnb, rseb, r2, mswd, beta, cov_beta = linest_res[0:7]
|
|
783
|
+
lnb, lnm = beta
|
|
784
|
+
selnb, selnm = np.diagonal(cov_beta) ** .5
|
|
785
|
+
|
|
779
786
|
b = np.exp(lnb)
|
|
780
787
|
m = np.exp(lnm)
|
|
781
788
|
sem = np.exp(lnm) * selnm
|
|
782
789
|
seb = np.exp(lnb) * selnb # Excel.Logest function do not consider the error propagation
|
|
783
|
-
rseb = seb / b * 100
|
|
790
|
+
rseb = seb / abs(b) * 100
|
|
784
791
|
return b, seb, rseb, r2, mswd, m, sem
|
|
785
792
|
|
|
786
793
|
|
|
794
|
+
### Deprecated
|
|
787
795
|
def power(a0: list, a1: list):
|
|
788
796
|
"""
|
|
789
797
|
:param a0: known_y's, y = a * x ^ b + c
|
|
@@ -841,7 +849,9 @@ def power(a0: list, a1: list):
|
|
|
841
849
|
raise IndexError
|
|
842
850
|
|
|
843
851
|
f = linest(a0, [_x ** b for _x in a1])
|
|
844
|
-
|
|
852
|
+
beta, cov_beta = f[5:7]
|
|
853
|
+
c, a = beta
|
|
854
|
+
sec, sea = np.diagonal(cov_beta) ** .5
|
|
845
855
|
|
|
846
856
|
calculated_y = [_pow_func(i, a, b, c) for i in a1]
|
|
847
857
|
resid = [(calculated_y[i] - a0[i]) ** 2 for i in range(len(a0))]
|
|
@@ -862,104 +872,193 @@ def power(a0: list, a1: list):
|
|
|
862
872
|
errfx = pow(sum([i ** 2 for i in a1]) / (dp * sum([i ** 2 for i in a1]) - sum(a1) ** 2), 0.5)
|
|
863
873
|
# seb = errfz * sey = errfz * ssresid / df -> se_intercept = sey * errfx = seb / errfz * errfx
|
|
864
874
|
se_intercept = sec / errfz * errfx
|
|
865
|
-
rse_intercept = se_intercept / intercept * 100
|
|
875
|
+
rse_intercept = se_intercept / abs(intercept) * 100
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
exp_beta = [a, b, c]
|
|
879
|
+
exp_cov_beta = [
|
|
880
|
+
[cov_beta[1][1], 0, cov_beta[1][0]],
|
|
881
|
+
[0, 0, 0],
|
|
882
|
+
[cov_beta[0][1], 0, cov_beta[0][0]],
|
|
883
|
+
]
|
|
866
884
|
|
|
867
885
|
return intercept, se_intercept, rse_intercept, r2, 'mswd', [a, b, c], 'se', \
|
|
868
886
|
lambda x: [_pow_func(i, a, b, c) for i in x], m_ssresid
|
|
869
887
|
|
|
870
888
|
|
|
871
889
|
def exponential(a0: list, a1: list):
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
890
|
+
try:
|
|
891
|
+
k = _exponential(a0, a1, newton_minimize_1d)
|
|
892
|
+
if k[2] > 100:
|
|
893
|
+
raise ValueError
|
|
894
|
+
if abs(k[0] - min(a0)) > 5 * (max(a0) - min(a0)):
|
|
895
|
+
raise ValueError
|
|
896
|
+
except Exception as e:
|
|
897
|
+
print(f"newton_minimize_1d failed, using grad minimize")
|
|
898
|
+
k = _exponential(a0, a1, grad_minimize)
|
|
899
|
+
return k
|
|
877
900
|
|
|
878
|
-
def _exp_func(x, a, b, c):
|
|
879
|
-
return a * b ** x + c
|
|
880
901
|
|
|
881
|
-
|
|
882
|
-
a, b, c = params
|
|
883
|
-
return [_exp_func(xi, a, b, c) - yi for xi, yi in zip(a1, a0)]
|
|
902
|
+
def _exponential(a0, a1, method):
|
|
884
903
|
|
|
885
|
-
|
|
886
|
-
|
|
904
|
+
X = np.array(a1)
|
|
905
|
+
Y = np.array(a0)
|
|
906
|
+
y = np.array([a0]).transpose()
|
|
887
907
|
|
|
888
|
-
def
|
|
889
|
-
|
|
890
|
-
|
|
908
|
+
def _exp_func(xi, a, b, c):
|
|
909
|
+
return a * np.exp(b * xi) + c
|
|
910
|
+
|
|
911
|
+
@np.vectorize
|
|
912
|
+
def _get_s(b):
|
|
913
|
+
x = np.concatenate(([np.ones(len(a1))], [np.exp(b * np.array(a1))]), axis=0).transpose()
|
|
914
|
+
try:
|
|
915
|
+
inv_xtx = np.linalg.inv(np.matmul(x.transpose(), x))
|
|
916
|
+
except np.linalg.LinAlgError:
|
|
917
|
+
raise np.linalg.LinAlgError(f"The determinant of the given matrix must not be zero ")
|
|
918
|
+
beta = np.matmul(inv_xtx, np.matmul(x.transpose(), y))
|
|
919
|
+
c, a = beta.flatten()
|
|
920
|
+
reg_y = _exp_func(X, a, b, c)
|
|
921
|
+
resid = (reg_y - Y) ** 2
|
|
922
|
+
ssresid = sum(resid)
|
|
923
|
+
return ssresid
|
|
924
|
+
|
|
925
|
+
# 1阶
|
|
926
|
+
ini_f1 = linest(Y, X)
|
|
927
|
+
y_range = max(Y) - min(Y)
|
|
928
|
+
ini_b = ini_f1[5][1] / max(y_range, 1e-12)
|
|
929
|
+
# 2阶
|
|
930
|
+
ini_f2 = quadratic(Y, X)
|
|
931
|
+
ini_b *= np.sign(ini_f1[5][1]) * np.sign(ini_f2[5][2])
|
|
932
|
+
|
|
933
|
+
b, count = method(_get_s, ini_b)
|
|
934
|
+
|
|
935
|
+
x = np.concatenate(([np.ones(len(a1))], [np.exp(b * np.array(a1))]), axis=0).transpose()
|
|
936
|
+
|
|
937
|
+
m, n = x.shape # number of data, number of unknown x
|
|
938
|
+
try:
|
|
939
|
+
inv_xtx = np.linalg.inv(np.matmul(x.transpose(), x))
|
|
940
|
+
except np.linalg.LinAlgError:
|
|
941
|
+
raise np.linalg.LinAlgError(f"The determinant of the given matrix must not be zero ")
|
|
942
|
+
beta = np.matmul(inv_xtx, np.matmul(x.transpose(), y))
|
|
943
|
+
estimate_y = np.matmul(x, beta)
|
|
944
|
+
resid = (estimate_y - y) ** 2
|
|
945
|
+
reg = (estimate_y - np.mean(y)) ** 2
|
|
946
|
+
ssresid = resid.sum() # 残差平方和
|
|
947
|
+
ssreg = reg.sum() # 回归平方和
|
|
948
|
+
sstotal = ((y - np.mean(y)) ** 2).sum()
|
|
949
|
+
r2 = ssreg / sstotal if sstotal != 0 else 1
|
|
891
950
|
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
951
|
+
df = m - n
|
|
952
|
+
m_ssresid = ssresid / df # 均方残差,与加权平均中的MSWD对应
|
|
953
|
+
cov_beta = m_ssresid * inv_xtx
|
|
895
954
|
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
step = 0.01
|
|
901
|
-
while count < 100:
|
|
902
|
-
a, b, c = _get_ac(b)
|
|
903
|
-
s = _sum_squared_error([a, b, c])
|
|
904
|
-
b_left, b_right = b - step * b, b + step * b
|
|
905
|
-
s_left = _sum_squared_error(_get_ac(b_left))
|
|
906
|
-
s_right = _sum_squared_error(_get_ac(b_right))
|
|
907
|
-
if s_left > s > s_right:
|
|
908
|
-
b = b_right
|
|
909
|
-
continue
|
|
910
|
-
elif s_left < s < s_right:
|
|
911
|
-
b = b_left
|
|
912
|
-
continue
|
|
913
|
-
elif s_left < s_right:
|
|
914
|
-
b = (b + b_left) / 2
|
|
915
|
-
else:
|
|
916
|
-
b = (b + b_right) / 2
|
|
917
|
-
count += 1
|
|
918
|
-
step = step * 0.5
|
|
919
|
-
if step < 0.000001:
|
|
920
|
-
break
|
|
955
|
+
sc, sa = np.diagonal(cov_beta) ** .5
|
|
956
|
+
c, a = beta.flatten()
|
|
957
|
+
intercept = a + c
|
|
958
|
+
se_intercept = pow(sa ** 2 + sc ** 2 + 2 * cov_beta[0][1] , 0.5)
|
|
921
959
|
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
except IndexError:
|
|
929
|
-
raise IndexError
|
|
960
|
+
exp_beta = [a, b, c]
|
|
961
|
+
exp_cov_beta = [
|
|
962
|
+
[cov_beta[1][1], 0, cov_beta[1][0]],
|
|
963
|
+
[0, 0, 0],
|
|
964
|
+
[cov_beta[0][1], 0, cov_beta[0][0]],
|
|
965
|
+
]
|
|
930
966
|
|
|
931
|
-
f =
|
|
932
|
-
a, sea, c, sec = f[5][1], f[6][1], f[0], f[1]
|
|
967
|
+
# print(f"{b = }, {a = }, {c = }, {count = }, {ssresid = }, {r2 = }")
|
|
933
968
|
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
reg = [(i - sum(calculated_y) / len(calculated_y)) ** 2 for i in calculated_y]
|
|
937
|
-
ssresid = sum(resid)
|
|
938
|
-
ssreg = sum(reg)
|
|
939
|
-
sstotal = ssreg + ssresid
|
|
940
|
-
dp = len(a1)
|
|
941
|
-
df = dp - 1
|
|
942
|
-
m_ssresid = ssresid / df
|
|
943
|
-
r2 = ssreg / sstotal if sstotal != 0 else 1
|
|
969
|
+
return intercept, se_intercept, se_intercept / abs(intercept) * 100, r2, m_ssresid, exp_beta, exp_cov_beta, \
|
|
970
|
+
lambda x: [_exp_func(xi, a, b, c) for xi in x], m_ssresid
|
|
944
971
|
|
|
945
|
-
z = [b ** xi for xi in a1]
|
|
946
|
-
intercept = a + c
|
|
947
|
-
se_intercept_1 = np.sqrt(sea ** 2 + sec ** 2)
|
|
948
|
-
# calculate error of intercept
|
|
949
|
-
errfz = pow(sum([i ** 2 for i in z]) / (dp * sum([i ** 2 for i in z]) - sum(z) ** 2), 0.5)
|
|
950
|
-
errfx = pow(sum([i ** 2 for i in a1]) / (dp * sum([i ** 2 for i in a1]) - sum(a1) ** 2), 0.5)
|
|
951
|
-
# seb = errfz * sey = errfz * ssresid / df -> se_intercept = sey * errfx = seb / errfz * errfx
|
|
952
|
-
se_intercept = sec / errfz * errfx
|
|
953
|
-
rse_intercept = se_intercept / intercept * 100
|
|
954
972
|
|
|
955
|
-
|
|
956
|
-
|
|
973
|
+
def newton_minimize_1d(func, x0, h=1e-5, tol=1e-8, max_iter=30):
|
|
974
|
+
x = x0
|
|
975
|
+
for i in range(max_iter):
|
|
976
|
+
fx = func(x)
|
|
977
|
+
if not np.isfinite(fx):
|
|
978
|
+
raise ValueError("Newton Minimize: Function returned non-finite value at x={}".format(x))
|
|
979
|
+
|
|
980
|
+
# 一阶导数(中心差分)
|
|
981
|
+
f_plus = func(x + h)
|
|
982
|
+
f_minus = func(x - h)
|
|
983
|
+
if not (np.isfinite(f_plus) and np.isfinite(f_minus)):
|
|
984
|
+
raise ValueError("Newton Minimize: Non-finite values in derivative computation")
|
|
985
|
+
df = (f_plus - f_minus) / (2 * h)
|
|
986
|
+
d2f = (f_plus - 2 * fx + f_minus) / (h * h)
|
|
987
|
+
|
|
988
|
+
# 牛顿步长
|
|
989
|
+
if abs(d2f) < 1e-12: # 避免除零或平坦区域
|
|
990
|
+
raise ValueError("Newton Minimize: Second derivative too small, stopping.")
|
|
991
|
+
|
|
992
|
+
step = df / d2f
|
|
993
|
+
x_new = x - step
|
|
994
|
+
|
|
995
|
+
if abs(step) < tol:
|
|
996
|
+
x = x_new
|
|
997
|
+
break
|
|
998
|
+
|
|
999
|
+
x = x_new
|
|
1000
|
+
|
|
1001
|
+
if i + 1 == max_iter:
|
|
1002
|
+
raise ValueError("Newton Minimize: Over iteration max_iter={}".format(max_iter))
|
|
1003
|
+
|
|
1004
|
+
return x, i + 1
|
|
1005
|
+
|
|
1006
|
+
|
|
1007
|
+
def grad_minimize(func, x, lr=1e-5, tol=1e-8, max_iter=1000):
|
|
1008
|
+
|
|
1009
|
+
for i in range(max_iter):
|
|
1010
|
+
f_plus = func(x + lr)
|
|
1011
|
+
f_minus = func(x - lr)
|
|
1012
|
+
if not (np.isfinite(f_plus) and np.isfinite(f_minus)):
|
|
1013
|
+
raise ValueError("Newton Minimize: Non-finite values in derivative computation")
|
|
1014
|
+
g = (f_plus - f_minus) / (2 * lr)
|
|
1015
|
+
x_new = x - lr * g
|
|
1016
|
+
if abs(func(x_new) - func(x)) < tol:
|
|
1017
|
+
break
|
|
1018
|
+
x = x_new
|
|
1019
|
+
return x, i+1
|
|
957
1020
|
|
|
958
1021
|
|
|
959
1022
|
""" line functions """
|
|
960
1023
|
|
|
961
1024
|
|
|
962
|
-
def
|
|
1025
|
+
def linest_var(beta: list, cov: list, x: float):
|
|
1026
|
+
""" y = b0 * x^0 + b1 * x^1 + ... + bn * x^n
|
|
1027
|
+
Parameters
|
|
1028
|
+
----------
|
|
1029
|
+
|
|
1030
|
+
Returns
|
|
1031
|
+
-------
|
|
1032
|
+
|
|
1033
|
+
"""
|
|
1034
|
+
beta = np.array(beta, dtype=np.float64)
|
|
1035
|
+
cov_matrix = np.array(cov, dtype=np.float64)
|
|
1036
|
+
g = np.array([x ** k for k in range(len(beta))]).reshape(-1, 1)
|
|
1037
|
+
y = np.dot(g.T, beta.reshape(-1, 1))[0, 0]
|
|
1038
|
+
var = np.matmul(np.matmul(g.T, cov_matrix), g)[0, 0]
|
|
1039
|
+
return y, var
|
|
1040
|
+
|
|
1041
|
+
|
|
1042
|
+
def quadratic_var(beta: list, cov: list, x: float):
|
|
1043
|
+
""" y = b0 * x^0 + b1 * x^1 + b2 * x^2
|
|
1044
|
+
Parameters
|
|
1045
|
+
----------
|
|
1046
|
+
beta : coefficients
|
|
1047
|
+
x :
|
|
1048
|
+
|
|
1049
|
+
Returns
|
|
1050
|
+
-------
|
|
1051
|
+
|
|
1052
|
+
"""
|
|
1053
|
+
beta = np.array(beta, dtype=np.float64)
|
|
1054
|
+
cov_matrix = np.array(cov, dtype=np.float64)
|
|
1055
|
+
g = np.array([x ** k for k in range(len(beta))]).reshape(-1, 1)
|
|
1056
|
+
y = np.dot(g.T, beta.reshape(-1, 1))[0, 0]
|
|
1057
|
+
var = np.matmul(np.matmul(g.T, cov_matrix), g)[0, 0]
|
|
1058
|
+
return y, var
|
|
1059
|
+
|
|
1060
|
+
|
|
1061
|
+
def average_var(beta: list, cov: list, x: float):
|
|
963
1062
|
""" y = b0 * x^0 + b1 * x^1 + ... + bn * x^n
|
|
964
1063
|
Parameters
|
|
965
1064
|
----------
|
|
@@ -970,21 +1069,29 @@ def linear_eq(x: list, beta: list):
|
|
|
970
1069
|
-------
|
|
971
1070
|
|
|
972
1071
|
"""
|
|
973
|
-
|
|
1072
|
+
y, = beta
|
|
1073
|
+
var = np.array(cov, dtype=np.float64)[0, 0]
|
|
1074
|
+
return y, var
|
|
974
1075
|
|
|
975
1076
|
|
|
976
|
-
def
|
|
977
|
-
""" y = a *
|
|
1077
|
+
def exponential_var(beta: list, cov: list, x: float):
|
|
1078
|
+
""" y = a * exp(bx) + c
|
|
978
1079
|
Parameters
|
|
979
1080
|
----------
|
|
980
1081
|
beta : coefficients, [a, b, c]
|
|
981
|
-
|
|
1082
|
+
cov : covariance [[], [], []]
|
|
982
1083
|
|
|
983
1084
|
Returns
|
|
984
1085
|
-------
|
|
985
1086
|
|
|
986
1087
|
"""
|
|
987
|
-
|
|
1088
|
+
cov_matrix = np.array(cov)
|
|
1089
|
+
a, b, c = beta
|
|
1090
|
+
k = np.exp(b*x)
|
|
1091
|
+
g = np.array([k, a*x*k, 1]).reshape(-1, 1)
|
|
1092
|
+
y = a * k + c
|
|
1093
|
+
var = np.matmul(np.matmul(g.T, cov_matrix), g)[0, 0]
|
|
1094
|
+
return y, var
|
|
988
1095
|
|
|
989
1096
|
|
|
990
1097
|
def power_eq(x: list, beta: list):
|
ararpy/files/calc_file.py
CHANGED
|
@@ -493,40 +493,41 @@ def open_full_xls(file_path: str, sample_name: str = ''):
|
|
|
493
493
|
res['Inverse Isochron Table'], rows, [4, 5, 6, 7, 10])
|
|
494
494
|
total_param = arr.partial(
|
|
495
495
|
res['Sample Parameters'], rows, [
|
|
496
|
-
# 1, 2,
|
|
497
|
-
-1, -1, -1, -1, #
|
|
498
|
-
-1, -1, -1, -1, #
|
|
499
|
-
-1, -1, -1, -1, -1, -1, #
|
|
500
|
-
-1, -1, -1, -1, #
|
|
501
|
-
-1, -1, #
|
|
502
|
-
23, 24, -1, -1, -1, -1, #
|
|
503
|
-
-1, -1, #
|
|
504
|
-
22, -1, -1, -1, #
|
|
505
|
-
-1, -1, #
|
|
506
|
-
-1, -1, #
|
|
507
|
-
-1, -1, #
|
|
508
|
-
-1, -1, #
|
|
509
|
-
-1, -1, #
|
|
510
|
-
-1, -1, #
|
|
511
|
-
-1, -1, #
|
|
512
|
-
-1, -1, #
|
|
513
|
-
-1, -1, #
|
|
514
|
-
-1, -1, #
|
|
515
|
-
-1, -1, #
|
|
516
|
-
-1, -1, #
|
|
517
|
-
-1, -1, #
|
|
518
|
-
-1, -1, -1, -1, -1, -1, -1, -1, -1, #
|
|
519
|
-
10, 11, 12, 13, #
|
|
520
|
-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, #
|
|
521
|
-
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, #
|
|
522
|
-
-1, -1, -1, -1, #
|
|
523
|
-
-1, -1, -1, -1, #
|
|
524
|
-
-1, -1, -1, -1, #
|
|
525
|
-
-1, -1, -1, -1, #
|
|
526
|
-
-1, -1, -1, -1, #
|
|
527
|
-
-1, -1, -1, -1, -1, -1, -1, -1, #
|
|
528
|
-
-1, -1, -1, -1, -1, -1, -1, -1, #
|
|
529
|
-
-1, -1, -1, -1, -1, #
|
|
496
|
+
# 1, 2, -1, # 0-2
|
|
497
|
+
-1, -1, -1, -1, # 3-6
|
|
498
|
+
-1, -1, -1, -1, # 7-10
|
|
499
|
+
-1, -1, -1, -1, -1, -1, # 11-16
|
|
500
|
+
-1, -1, -1, -1, # 17-20
|
|
501
|
+
-1, -1, # 21-22
|
|
502
|
+
23, 24, -1, -1, -1, -1, # 23-28
|
|
503
|
+
-1, -1, # 29-30
|
|
504
|
+
22, -1, -1, -1, # 31-34
|
|
505
|
+
-1, -1, # 35-36
|
|
506
|
+
-1, -1, # 37-38
|
|
507
|
+
-1, -1, # 39-40
|
|
508
|
+
-1, -1, # 41-42
|
|
509
|
+
-1, -1, # 43-44
|
|
510
|
+
-1, -1, # 45-46
|
|
511
|
+
-1, -1, # 47-48
|
|
512
|
+
-1, -1, # 49-50
|
|
513
|
+
-1, -1, # 51-52
|
|
514
|
+
-1, -1, # 53-54
|
|
515
|
+
-1, -1, # 55-56
|
|
516
|
+
-1, -1, # 57-58
|
|
517
|
+
-1, -1, # 59-60
|
|
518
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, # 61-69
|
|
519
|
+
10, 11, 12, 13, # 70-73
|
|
520
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, # 74-85
|
|
521
|
+
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, # 86-95
|
|
522
|
+
-1, -1, -1, -1, # 96-99
|
|
523
|
+
-1, -1, -1, -1, # 100-103
|
|
524
|
+
-1, -1, -1, -1, # 104-107
|
|
525
|
+
-1, -1, -1, -1, # 108-111
|
|
526
|
+
-1, -1, -1, -1, # 112-115
|
|
527
|
+
-1, -1, -1, -1, -1, -1, -1, -1, # 116-123
|
|
528
|
+
-1, -1, -1, -1, -1, -1, -1, -1, # 124-131
|
|
529
|
+
-1, -1, -1, -1, -1, # 132-136
|
|
530
|
+
-1, -1, -1, -1, # 137-140
|
|
530
531
|
])
|
|
531
532
|
|
|
532
533
|
month_convert = {'Jan': '01', 'Feb': '02', 'Mar': '03', 'Apr': '04', 'May': '05', 'Jun': '06',
|
ararpy/files/raw_file.py
CHANGED
|
@@ -94,62 +94,13 @@ def open_file(file_path: str, input_filter: List[Union[str, int, bool]], name=No
|
|
|
94
94
|
"""
|
|
95
95
|
extension = str(os.path.split(file_path)[-1]).split('.')[-1]
|
|
96
96
|
try:
|
|
97
|
-
handler = {'txt': open_raw_txt, 'excel': open_raw_xls,
|
|
98
|
-
|
|
99
|
-
['txt', 'excel', 'Qtegra Exported XLS', 'Seq'][int(input_filter[1])]]
|
|
97
|
+
handler = {'txt': open_raw_txt, 'excel': open_raw_xls, 'Seq': open_raw_seq}[
|
|
98
|
+
['txt', 'excel', 'Qtegra Excel (deleted)', 'Seq'][int(input_filter[1])]]
|
|
100
99
|
except KeyError:
|
|
101
100
|
raise FileNotFoundError("Wrong File.")
|
|
102
101
|
return handler(file_path, input_filter, name)
|
|
103
102
|
|
|
104
103
|
|
|
105
|
-
def open_qtegra_exported_xls(filepath, input_filter=None, name=None):
|
|
106
|
-
if input_filter is None:
|
|
107
|
-
input_filter = []
|
|
108
|
-
try:
|
|
109
|
-
wb = open_workbook(filepath)
|
|
110
|
-
sheets = wb.sheet_names()
|
|
111
|
-
sheet = wb.sheet_by_name(sheets[0])
|
|
112
|
-
value, step_header, step_list = [], [], []
|
|
113
|
-
for row in range(sheet.nrows):
|
|
114
|
-
row_set = []
|
|
115
|
-
for col in range(sheet.ncols):
|
|
116
|
-
if sheet.cell(row, col).value == '':
|
|
117
|
-
pass
|
|
118
|
-
else:
|
|
119
|
-
row_set.append(sheet.cell(row, col).value)
|
|
120
|
-
if row_set != [] and len(row_set) > 1:
|
|
121
|
-
value.append(row_set)
|
|
122
|
-
for each_row in value:
|
|
123
|
-
# if the first item of each row is float (1.0, 2.0, ...) this row is the header of a step.
|
|
124
|
-
if isinstance(each_row[0], float):
|
|
125
|
-
each_row[0] = int(each_row[0])
|
|
126
|
-
if "M" in each_row[1].upper():
|
|
127
|
-
each_row[1] = datetime.strptime(each_row[1], '%m/%d/%Y %I:%M:%S %p').isoformat(timespec='seconds')
|
|
128
|
-
else:
|
|
129
|
-
each_row[1] = datetime.strptime(each_row[1], '%m/%d/%Y %H:%M:%S').isoformat(timespec='seconds')
|
|
130
|
-
step_header.append(each_row)
|
|
131
|
-
for step_index, each_step_header in enumerate(step_header):
|
|
132
|
-
row_start_number = value.index(each_step_header)
|
|
133
|
-
try:
|
|
134
|
-
row_stop_number = value.index(step_header[step_index + 1])
|
|
135
|
-
except IndexError:
|
|
136
|
-
row_stop_number = len(value) + 1
|
|
137
|
-
step_values = [
|
|
138
|
-
each_step_header[0:4],
|
|
139
|
-
*list(map(
|
|
140
|
-
# lambda x: [x[0], x[1], x[2], x[1], x[3], x[1], x[4], x[1], x[5], x[1], x[6]],
|
|
141
|
-
# x[1] = time, x[2] = H2:40, x[3] = H1: 39, x[4] = AX: 38, x[5] = L1: 37, x[6] = L2: 36
|
|
142
|
-
lambda x: [x[0], x[1], x[6], x[1], x[5], x[1], x[4], x[1], x[3], x[1], x[2]],
|
|
143
|
-
# in sequence: Ar36, Ar37, Ar38, Ar39, Ar40
|
|
144
|
-
[value[i] for i in range(row_start_number + 2, row_stop_number - 7, 1)]))
|
|
145
|
-
]
|
|
146
|
-
step_list.append(step_values)
|
|
147
|
-
except Exception as e:
|
|
148
|
-
raise ValueError('Error in opening the original file: %s' % str(e))
|
|
149
|
-
else:
|
|
150
|
-
return {'data': step_list}
|
|
151
|
-
|
|
152
|
-
|
|
153
104
|
def open_raw_txt(file_path, input_filter: List[Union[str, int]], name=None):
|
|
154
105
|
"""
|
|
155
106
|
Parameters
|
|
@@ -257,20 +208,34 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
257
208
|
|
|
258
209
|
"""
|
|
259
210
|
|
|
260
|
-
def datetime_parse(string, f):
|
|
211
|
+
def datetime_parse(string: str, f: str):
|
|
261
212
|
try:
|
|
262
213
|
return datetime.strptime(string, f)
|
|
263
214
|
except ValueError as v:
|
|
215
|
+
# print(traceback.format_exc())
|
|
264
216
|
if f.strip() == "":
|
|
265
217
|
return datetime_parser.parse(string)
|
|
266
218
|
elif len(v.args) > 0 and v.args[0].startswith('unconverted data remains: '):
|
|
267
|
-
|
|
268
|
-
return
|
|
219
|
+
# %f handles microseconds (6 digits), remove the remains
|
|
220
|
+
return datetime_parse(string[:-(len(v.args[0]) - 26)], f)
|
|
221
|
+
# elif f.upper()[-2:] in ['PM', 'AM']:
|
|
222
|
+
# return datetime_parse(string, f[:-2])
|
|
269
223
|
else:
|
|
270
224
|
raise
|
|
271
225
|
|
|
226
|
+
def step_num_parse(s: str):
|
|
227
|
+
try:
|
|
228
|
+
return f"{round(float(s)):02d}"
|
|
229
|
+
except (ValueError, TypeError):
|
|
230
|
+
return s
|
|
231
|
+
|
|
232
|
+
def step_type_parse(s: str):
|
|
233
|
+
if any([s.lower().__contains__(each) for each in ['blk', 'blank']]):
|
|
234
|
+
return "Blank"
|
|
235
|
+
return "Unknown"
|
|
236
|
+
|
|
272
237
|
step_list = []
|
|
273
|
-
|
|
238
|
+
step_idx = 0 # step_index rows
|
|
274
239
|
|
|
275
240
|
header = input_filter[5]
|
|
276
241
|
isotope_index = input_filter[8:28]
|
|
@@ -282,7 +247,7 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
282
247
|
while True: # measurment steps sloop
|
|
283
248
|
|
|
284
249
|
# ============ all text information ============
|
|
285
|
-
options = get_sample_info(file_contents, optional_info_index, default="", base=[1, 1 -
|
|
250
|
+
options = get_sample_info(file_contents, optional_info_index, default="", base=[1, 1 - step_idx, 1])
|
|
286
251
|
|
|
287
252
|
# ============ Step name ============
|
|
288
253
|
try:
|
|
@@ -293,13 +258,10 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
293
258
|
if res is not None and "en" in res.named.keys():
|
|
294
259
|
experiment_name = res.named.get("en")
|
|
295
260
|
if res is not None and "sn" in res.named.keys():
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
step_name = f"{experiment_name}-{step_index}"
|
|
301
|
-
if step_name == "":
|
|
302
|
-
raise ValueError(f"Step name not found")
|
|
261
|
+
step_name = res.named.get("sn")
|
|
262
|
+
if str(step_name) == "":
|
|
263
|
+
raise ValueError(f"Step name not found, break reading steps")
|
|
264
|
+
step_name = f"{experiment_name}-{step_num_parse(step_name)}"
|
|
303
265
|
except (TypeError, ValueError, IndexError):
|
|
304
266
|
# When parsing the step name fails, the end of the file has been reached
|
|
305
267
|
# raise
|
|
@@ -312,7 +274,7 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
312
274
|
# ============ Step information ============
|
|
313
275
|
try:
|
|
314
276
|
if check_box_index[2]:
|
|
315
|
-
string = get_item(file_contents, strings_index[1:4], default="", base=[1, 1 -
|
|
277
|
+
string = get_item(file_contents, strings_index[1:4], default="", base=[1, 1 - step_idx, 1])
|
|
316
278
|
res = string_parser(strings_index[4], string)
|
|
317
279
|
if res is not None:
|
|
318
280
|
options.update(dict(zip(DEFAULT_SAMPLE_INFO.keys(), [res.named.get(value, options.get(key)) for key, value in DEFAULT_SAMPLE_INFO.items()])))
|
|
@@ -347,6 +309,15 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
347
309
|
print(traceback.format_exc())
|
|
348
310
|
raise ValueError(f"Failed to parse zero datetime: {e}")
|
|
349
311
|
# zero_datetime = datetime(1970, 1, 1, 0, 0, 0).isoformat(timespec='seconds')
|
|
312
|
+
|
|
313
|
+
# ============== Step Type =============
|
|
314
|
+
step_type = step_type_parse(options.get("StepType")) # blank or unknown
|
|
315
|
+
options.update({'StepType': step_type})
|
|
316
|
+
|
|
317
|
+
# ============== Step Type =============
|
|
318
|
+
exp_type = options.get("ExpType") # crushing, laser, heating, air
|
|
319
|
+
options.update({'ExpType': exp_type})
|
|
320
|
+
|
|
350
321
|
current_step = [[step_name, zero_datetime, options]]
|
|
351
322
|
|
|
352
323
|
# ============ isotope data ============
|
|
@@ -360,9 +331,11 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
360
331
|
break_num += 1
|
|
361
332
|
continue
|
|
362
333
|
break_num = 0
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
334
|
+
try:
|
|
335
|
+
if int(data_index[2]) == 0: # == 0, vertical
|
|
336
|
+
start_row = data_index[24] * cycle_num + data_index[25] * cycle_num + header + step_idx
|
|
337
|
+
if check_box_index[0] and start_row - step_idx - header >= data_index[28]:
|
|
338
|
+
break
|
|
366
339
|
current_step.append([
|
|
367
340
|
str(cycle_num + 1),
|
|
368
341
|
# in sequence: Ar36, Ar37, Ar38, Ar39, Ar40
|
|
@@ -377,47 +350,40 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
377
350
|
float(data_content[start_row + isotope_index[ 2] - base][isotope_index[ 3] - base]),
|
|
378
351
|
float(data_content[start_row + isotope_index[ 0] - base][isotope_index[ 1] - base]) * f,
|
|
379
352
|
])
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
current_step.append([
|
|
384
|
-
str(cycle_num + 1), None, None, None, None, None, None, None, None, None, None,
|
|
385
|
-
])
|
|
386
|
-
elif int(data_index[2]) == 1: # == 1, horizontal
|
|
387
|
-
start_row = data_index[1] + idx
|
|
388
|
-
col_inc = data_index[24] * cycle_num + data_index[25] * cycle_num - base
|
|
389
|
-
try:
|
|
353
|
+
elif int(data_index[2]) == 1: # == 1, horizontal
|
|
354
|
+
start_row = data_index[1] + step_idx
|
|
355
|
+
col_inc = data_index[24] * cycle_num + data_index[25] * cycle_num
|
|
390
356
|
current_step.append([
|
|
391
357
|
str(cycle_num + 1),
|
|
392
358
|
# Ar36, Ar37, Ar38, Ar39, Ar40
|
|
393
|
-
float(data_content[start_row][isotope_index[19] + col_inc]),
|
|
394
|
-
float(data_content[start_row][isotope_index[17] + col_inc]) * f,
|
|
395
|
-
float(data_content[start_row][isotope_index[15] + col_inc]),
|
|
396
|
-
float(data_content[start_row][isotope_index[13] + col_inc]) * f,
|
|
397
|
-
float(data_content[start_row][isotope_index[11] + col_inc]),
|
|
398
|
-
float(data_content[start_row][isotope_index[ 9] + col_inc]) * f,
|
|
399
|
-
float(data_content[start_row][isotope_index[ 7] + col_inc]),
|
|
400
|
-
float(data_content[start_row][isotope_index[ 5] + col_inc]) * f,
|
|
401
|
-
float(data_content[start_row][isotope_index[ 3] + col_inc]),
|
|
402
|
-
float(data_content[start_row][isotope_index[ 1] + col_inc]) * f,
|
|
403
|
-
])
|
|
404
|
-
except (ValueError, IndexError):
|
|
405
|
-
print(f"Cannot parse isotope data")
|
|
406
|
-
print(traceback.format_exc())
|
|
407
|
-
current_step.append([
|
|
408
|
-
str(cycle_num + 1), None, None, None, None, None, None, None, None, None, None,
|
|
359
|
+
float(data_content[start_row][isotope_index[19] + col_inc - base]),
|
|
360
|
+
float(data_content[start_row][isotope_index[17] + col_inc - base]) * f,
|
|
361
|
+
float(data_content[start_row][isotope_index[15] + col_inc - base]),
|
|
362
|
+
float(data_content[start_row][isotope_index[13] + col_inc - base]) * f,
|
|
363
|
+
float(data_content[start_row][isotope_index[11] + col_inc - base]),
|
|
364
|
+
float(data_content[start_row][isotope_index[ 9] + col_inc - base]) * f,
|
|
365
|
+
float(data_content[start_row][isotope_index[ 7] + col_inc - base]),
|
|
366
|
+
float(data_content[start_row][isotope_index[ 5] + col_inc - base]) * f,
|
|
367
|
+
float(data_content[start_row][isotope_index[ 3] + col_inc - base]),
|
|
368
|
+
float(data_content[start_row][isotope_index[ 1] + col_inc - base]) * f,
|
|
409
369
|
])
|
|
410
|
-
|
|
411
|
-
|
|
370
|
+
else:
|
|
371
|
+
raise ValueError(f"{data_index[2]} not in [0, 1]")
|
|
372
|
+
except Exception as e:
|
|
373
|
+
print(f"Cannot parse isotope data")
|
|
374
|
+
# print(traceback.format_exc())
|
|
375
|
+
current_step.append([
|
|
376
|
+
str(cycle_num + 1), None, None, None, None, None, None, None, None, None, None,
|
|
377
|
+
])
|
|
412
378
|
|
|
413
379
|
cycle_num += 1
|
|
414
380
|
if cycle_num >= data_index[3]:
|
|
415
381
|
break
|
|
416
382
|
|
|
417
383
|
step_list.append(current_step)
|
|
418
|
-
|
|
384
|
+
step_idx = data_index[28] * len(step_list)
|
|
419
385
|
if not check_box_index[0] or len(step_list) >= 500: # check_box_index[0]: multiple sequences
|
|
420
|
-
print(f"Multiple Sequence = {check_box_index[0]}, Step number = {len(step_list)}")
|
|
386
|
+
# print(f"Multiple Sequence = {check_box_index[0]}, Step number = {len(step_list)}")
|
|
421
387
|
break
|
|
422
388
|
|
|
423
389
|
if not step_list:
|
|
@@ -441,39 +407,39 @@ def get_sample_info(file_contents: list, index_list: list, default="", base: Uni
|
|
|
441
407
|
"""
|
|
442
408
|
sample_info = DEFAULT_SAMPLE_INFO.copy()
|
|
443
409
|
sample_info.update({
|
|
444
|
-
"ExpName": get_item(file_contents, index_list[0:3], default=default, base=base),
|
|
445
|
-
"StepName": get_item(file_contents, index_list[3:6], default=default, base=base),
|
|
446
|
-
"StepType": get_item(file_contents, index_list[6:9], default=default, base=base),
|
|
447
|
-
"StepLabel": get_item(file_contents, index_list[9:12], default=default, base=base),
|
|
448
|
-
"ZeroYear": get_item(file_contents, index_list[12:15], default=default, base=base),
|
|
449
|
-
"ZeroHour": get_item(file_contents, index_list[15:18], default=default, base=base),
|
|
450
|
-
"ZeroMon": get_item(file_contents, index_list[18:21], default=default, base=base),
|
|
451
|
-
"ZeroMin": get_item(file_contents, index_list[21:24], default=default, base=base),
|
|
452
|
-
"ZeroDay": get_item(file_contents, index_list[24:27], default=default, base=base),
|
|
453
|
-
"ZeroSec": get_item(file_contents, index_list[27:30], default=default, base=base),
|
|
454
|
-
"SmpName": get_item(file_contents, index_list[30:33], default=default, base=base),
|
|
455
|
-
"SmpLoc": get_item(file_contents, index_list[33:36], default=default, base=base),
|
|
456
|
-
"SmpMatr": get_item(file_contents, index_list[36:39], default=default, base=base),
|
|
457
|
-
"ExpType": get_item(file_contents, index_list[39:42], default=default, base=base),
|
|
458
|
-
"SmpWeight": get_item(file_contents, index_list[42:45], default=default, base=base),
|
|
459
|
-
"Stepunit": get_item(file_contents, index_list[45:48], default=default, base=base),
|
|
460
|
-
"HeatingTime": get_item(file_contents, index_list[48:51], default=default, base=base),
|
|
461
|
-
"InstrName": get_item(file_contents, index_list[51:54], default=default, base=base),
|
|
462
|
-
"Researcher": get_item(file_contents, index_list[54:57], default=default, base=base),
|
|
463
|
-
"Analyst": get_item(file_contents, index_list[57:60], default=default, base=base),
|
|
464
|
-
"Lab": get_item(file_contents, index_list[60:63], default=default, base=base),
|
|
465
|
-
"Jv": get_item(file_contents, index_list[63:66], default=default, base=base),
|
|
466
|
-
"Jsig": get_item(file_contents, index_list[66:69], default=default, base=base),
|
|
467
|
-
"MDF": get_item(file_contents, index_list[69:72], default=default, base=base),
|
|
468
|
-
"MDFSig": get_item(file_contents, index_list[72:75], default=default, base=base),
|
|
469
|
-
"CalcName": get_item(file_contents, index_list[75:78], default=default, base=base),
|
|
470
|
-
"IrraName": get_item(file_contents, index_list[78:81], default=default, base=base),
|
|
471
|
-
"IrraLabel": get_item(file_contents, index_list[81:84], default=default, base=base),
|
|
472
|
-
"IrraPosH": get_item(file_contents, index_list[84:87], default=default, base=base),
|
|
473
|
-
"IrraPosX": get_item(file_contents, index_list[87:90], default=default, base=base),
|
|
474
|
-
"IrraPosY": get_item(file_contents, index_list[90:93], default=default, base=base),
|
|
475
|
-
"StdName": get_item(file_contents, index_list[93:96], default=default, base=base),
|
|
476
|
-
"StdAge": get_item(file_contents, index_list[96:99], default=default, base=base),
|
|
477
|
-
"StdAgeSig": get_item(file_contents, index_list[99:102], default=default, base=base),
|
|
410
|
+
"ExpName": get_item(file_contents, index_list[0:3], default=default, base=base).strip(),
|
|
411
|
+
"StepName": get_item(file_contents, index_list[3:6], default=default, base=base).strip(),
|
|
412
|
+
"StepType": get_item(file_contents, index_list[6:9], default=default, base=base).strip(),
|
|
413
|
+
"StepLabel": get_item(file_contents, index_list[9:12], default=default, base=base).strip(),
|
|
414
|
+
"ZeroYear": get_item(file_contents, index_list[12:15], default=default, base=base).strip(),
|
|
415
|
+
"ZeroHour": get_item(file_contents, index_list[15:18], default=default, base=base).strip(),
|
|
416
|
+
"ZeroMon": get_item(file_contents, index_list[18:21], default=default, base=base).strip(),
|
|
417
|
+
"ZeroMin": get_item(file_contents, index_list[21:24], default=default, base=base).strip(),
|
|
418
|
+
"ZeroDay": get_item(file_contents, index_list[24:27], default=default, base=base).strip(),
|
|
419
|
+
"ZeroSec": get_item(file_contents, index_list[27:30], default=default, base=base).strip(),
|
|
420
|
+
"SmpName": get_item(file_contents, index_list[30:33], default=default, base=base).strip(),
|
|
421
|
+
"SmpLoc": get_item(file_contents, index_list[33:36], default=default, base=base).strip(),
|
|
422
|
+
"SmpMatr": get_item(file_contents, index_list[36:39], default=default, base=base).strip(),
|
|
423
|
+
"ExpType": get_item(file_contents, index_list[39:42], default=default, base=base).strip(),
|
|
424
|
+
"SmpWeight": get_item(file_contents, index_list[42:45], default=default, base=base).strip(),
|
|
425
|
+
"Stepunit": get_item(file_contents, index_list[45:48], default=default, base=base).strip(),
|
|
426
|
+
"HeatingTime": get_item(file_contents, index_list[48:51], default=default, base=base).strip(),
|
|
427
|
+
"InstrName": get_item(file_contents, index_list[51:54], default=default, base=base).strip(),
|
|
428
|
+
"Researcher": get_item(file_contents, index_list[54:57], default=default, base=base).strip(),
|
|
429
|
+
"Analyst": get_item(file_contents, index_list[57:60], default=default, base=base).strip(),
|
|
430
|
+
"Lab": get_item(file_contents, index_list[60:63], default=default, base=base).strip(),
|
|
431
|
+
"Jv": get_item(file_contents, index_list[63:66], default=default, base=base).strip(),
|
|
432
|
+
"Jsig": get_item(file_contents, index_list[66:69], default=default, base=base).strip(),
|
|
433
|
+
"MDF": get_item(file_contents, index_list[69:72], default=default, base=base).strip(),
|
|
434
|
+
"MDFSig": get_item(file_contents, index_list[72:75], default=default, base=base).strip(),
|
|
435
|
+
"CalcName": get_item(file_contents, index_list[75:78], default=default, base=base).strip(),
|
|
436
|
+
"IrraName": get_item(file_contents, index_list[78:81], default=default, base=base).strip(),
|
|
437
|
+
"IrraLabel": get_item(file_contents, index_list[81:84], default=default, base=base).strip(),
|
|
438
|
+
"IrraPosH": get_item(file_contents, index_list[84:87], default=default, base=base).strip(),
|
|
439
|
+
"IrraPosX": get_item(file_contents, index_list[87:90], default=default, base=base).strip(),
|
|
440
|
+
"IrraPosY": get_item(file_contents, index_list[90:93], default=default, base=base).strip(),
|
|
441
|
+
"StdName": get_item(file_contents, index_list[93:96], default=default, base=base).strip(),
|
|
442
|
+
"StdAge": get_item(file_contents, index_list[96:99], default=default, base=base).strip(),
|
|
443
|
+
"StdAgeSig": get_item(file_contents, index_list[99:102], default=default, base=base).strip(),
|
|
478
444
|
})
|
|
479
445
|
return sample_info
|
ararpy/smp/info.py
CHANGED
|
@@ -15,9 +15,9 @@
|
|
|
15
15
|
|
|
16
16
|
def name(smp, n: str = None):
|
|
17
17
|
if n is None:
|
|
18
|
-
return smp.Info.
|
|
18
|
+
return smp.Info.experiment.name
|
|
19
19
|
elif isinstance(n, str):
|
|
20
|
-
smp.Info.
|
|
20
|
+
smp.Info.experiment.name = n
|
|
21
21
|
return n
|
|
22
22
|
else:
|
|
23
23
|
raise ValueError(f"{n} is not a string")
|
ararpy/smp/initial.py
CHANGED
|
@@ -140,15 +140,18 @@ def initial(smp: Sample):
|
|
|
140
140
|
# Info
|
|
141
141
|
setattr(smp, 'Info', ArArBasic(
|
|
142
142
|
id='0', name='info', attr_name='Info', arr_version=samples.VERSION,
|
|
143
|
+
experiment=ArArBasic(
|
|
144
|
+
name='', type='', instrument='', mass_spec='', collectors='', step_num=0,
|
|
145
|
+
),
|
|
143
146
|
sample=ArArBasic(
|
|
144
147
|
name='SAMPLE NAME', material='MATERIAL', location='LOCATION', type='Unknown', method='',
|
|
145
|
-
sequence_unit='', weight=''
|
|
148
|
+
sequence_unit='', weight='',
|
|
146
149
|
),
|
|
147
150
|
researcher=ArArBasic(
|
|
148
|
-
name='RESEARCHER', addr='ADDRESS', email='EMAIL'
|
|
151
|
+
name='RESEARCHER', addr='ADDRESS', email='EMAIL',
|
|
149
152
|
),
|
|
150
153
|
laboratory=ArArBasic(
|
|
151
|
-
name='LABORATORY', addr='ADDRESS', email='EMAIL', info='INFORMATION', analyst='ANALYST'
|
|
154
|
+
name='LABORATORY', addr='ADDRESS', email='EMAIL', info='INFORMATION', analyst='ANALYST',
|
|
152
155
|
),
|
|
153
156
|
results=ArArBasic(
|
|
154
157
|
name='RESULTS', plateau_F=[], plateau_age=[], total_F=[], total_age=[],
|
|
@@ -184,9 +187,9 @@ def initial(smp: Sample):
|
|
|
184
187
|
name='REFERENCE', journal='JOURNAL', doi='DOI'
|
|
185
188
|
),
|
|
186
189
|
preference=copy.deepcopy(PREFERENCE_RES),
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
)
|
|
190
|
+
irradiation= ArArBasic(
|
|
191
|
+
label='', pos_h='', pos_x='', pos_y='',
|
|
192
|
+
)
|
|
190
193
|
))
|
|
191
194
|
|
|
192
195
|
decimal_places = PREFERENCE_RES['decimalPlaces']
|
|
@@ -472,14 +475,14 @@ def from_raw_data(raw: RawData, mapping: Optional[List[dict]] = None) -> Sample:
|
|
|
472
475
|
for row in mapping:
|
|
473
476
|
row_unknown_intercept = []
|
|
474
477
|
row_blank_intercept = []
|
|
475
|
-
|
|
476
478
|
unknown: Sequence = raw.get_sequence(row['unknown'], flag='name')
|
|
477
|
-
|
|
479
|
+
try:
|
|
480
|
+
blank: Sequence = raw.get_sequence(row['blank'], flag='name')
|
|
481
|
+
if blank is None or blank == []: raise KeyError
|
|
482
|
+
except KeyError:
|
|
478
483
|
blank: Sequence = arr.filter(
|
|
479
|
-
raw.interpolated_blank, func=lambda seq: seq.datetime == unknown.datetime,
|
|
484
|
+
raw.interpolated_blank, func=lambda seq: seq.datetime == unknown.datetime and seq.name == row['blank'],
|
|
480
485
|
get=None, unique=True)
|
|
481
|
-
else:
|
|
482
|
-
blank: Sequence = raw.get_sequence(row['blank'], flag='name')
|
|
483
486
|
for i in range(5):
|
|
484
487
|
row_unknown_intercept = arr.multi_append(row_unknown_intercept, *unknown.results[i][int(unknown.fitting_method[i])][:2])
|
|
485
488
|
row_blank_intercept = arr.multi_append(row_blank_intercept, *blank.results[i][int(blank.fitting_method[i])][:2])
|
ararpy/smp/json.py
CHANGED
|
@@ -50,8 +50,8 @@ class MyEncoder(json.JSONEncoder):
|
|
|
50
50
|
Plot.Set, Plot.BasicAttr, RawData, Sequence, ArArBasic)):
|
|
51
51
|
if isinstance(obj, Sequence):
|
|
52
52
|
return dict(obj.__dict__, **{
|
|
53
|
-
'is_blank': obj.is_blank(), 'is_unknown': obj.is_unknown()
|
|
54
|
-
|
|
53
|
+
'is_blank': obj.is_blank(), 'is_unknown': obj.is_unknown()
|
|
54
|
+
})
|
|
55
55
|
return obj.__dict__
|
|
56
56
|
# Error
|
|
57
57
|
if isinstance(obj, BaseException):
|
ararpy/smp/raw.py
CHANGED
|
@@ -52,8 +52,9 @@ def to_raw(file_path: Union[str, List[str]], input_filter_path: Union[str, List[
|
|
|
52
52
|
data = res.get('data', None)
|
|
53
53
|
sequences = res.get('sequences', None)
|
|
54
54
|
sequence_num = len(data) if data is not None else len(sequences)
|
|
55
|
+
experiment_name = data[0][0][2]['ExpName'] if data is not None else file_name
|
|
55
56
|
fitting_method = [2, 0, 2, 2, 2] # 0 - linear, 1 - quadratic, 2 - exponential, 3 - power, 4 - average
|
|
56
|
-
raw = RawData(name=
|
|
57
|
+
raw = RawData(name=experiment_name, data=data, isotopic_num=10, sequence_num=sequence_num, source=[file_path],
|
|
57
58
|
sequence=sequences, unit=str(input_filter[30]), fitting_method=[*fitting_method])
|
|
58
59
|
else:
|
|
59
60
|
raise ValueError("File path and input filter should be both string or list with a same length.")
|
|
@@ -152,11 +153,10 @@ def do_regression(raw: RawData, sequence_index: Optional[List] = None, isotopic_
|
|
|
152
153
|
# unselected: list = [unselected[[isotopic_index*2 + 1, 2 * (isotopic_index + 1)]].dropna().values.tolist()
|
|
153
154
|
# for isotopic_index in list(range(5))]
|
|
154
155
|
|
|
155
|
-
for index,
|
|
156
|
+
for index, isotopic_data in enumerate(selected):
|
|
156
157
|
if hasattr(isotopic_index, '__getitem__') and index not in isotopic_index:
|
|
157
158
|
continue
|
|
158
|
-
|
|
159
|
-
res = raw_funcs.get_raw_data_regression_results(isotope)
|
|
159
|
+
res = raw_funcs.get_raw_data_regression_results(isotopic_data)
|
|
160
160
|
try:
|
|
161
161
|
sequence.results[index] = res[1]
|
|
162
162
|
sequence.coefficients[index] = res[2]
|
ararpy/smp/sample.py
CHANGED
|
@@ -109,67 +109,67 @@ ISOCHRON_TABLE_HEADERS = [
|
|
|
109
109
|
TOTAL_PARAMS_HEADERS = [
|
|
110
110
|
'Sequence', '', 'Mark', # 0-2
|
|
111
111
|
'(\u2074\u2070Ar/\u00B3\u2076Ar)t', '%1\u03C3',
|
|
112
|
-
'(\u2074\u2070Ar/\u00B3\u2076Ar)c', '%1\u03C3', #
|
|
112
|
+
'(\u2074\u2070Ar/\u00B3\u2076Ar)c', '%1\u03C3', # 3-6
|
|
113
113
|
'(\u00B3\u2078Ar/\u00B3\u2076Ar)t', '%1\u03C3',
|
|
114
|
-
'(\u00B3\u2078Ar/\u00B3\u2076Ar)c', '%1\u03C3', #
|
|
114
|
+
'(\u00B3\u2078Ar/\u00B3\u2076Ar)c', '%1\u03C3', # 7-10
|
|
115
115
|
'(\u00B3\u2079Ar/\u00B3\u2077Ar)Ca', '%1\u03C3',
|
|
116
116
|
'(\u00B3\u2078Ar/\u00B3\u2077Ar)Ca', '%1\u03C3',
|
|
117
|
-
'(\u00B3\u2076Ar/\u00B3\u2077Ar)Ca', '%1\u03C3', #
|
|
117
|
+
'(\u00B3\u2076Ar/\u00B3\u2077Ar)Ca', '%1\u03C3', # 11-16
|
|
118
118
|
'(\u2074\u2070Ar/\u00B3\u2079Ar)K', '%1\u03C3',
|
|
119
|
-
'(\u00B3\u2078Ar/\u00B3\u2079Ar)K', '%1\u03C3', #
|
|
120
|
-
'(\u00B3\u2076Ar/\u00B3\u2078Ar)Cl', '%1\u03C3', #
|
|
121
|
-
'K/Ca', '%1\u03C3', 'K/Cl', '%1\u03C3', 'Ca/Cl', '%1\u03C3', #
|
|
122
|
-
'Cycle Number', 'Irradiation Cycles', #
|
|
123
|
-
'Irradiation', 'duration', 'Irradiation Time', 'Experiment Time', #
|
|
124
|
-
'Storage Years', '', #
|
|
125
|
-
'Decay Constant \u2074\u2070K', '%1\u03C3', #
|
|
126
|
-
'Decay Constant \u2074\u2070K(EC)', '%1\u03C3', #
|
|
127
|
-
'Decay Constant \u2074\u2070K(\u03B2<sup>-</sup>)', '%1\u03C3', #
|
|
128
|
-
'Decay Constant \u2074\u2070K(\u03B2<sup>+</sup>)', '%1\u03C3', #
|
|
129
|
-
'Decay Constant \u00B3\u2079Ar', '%1\u03C3', #
|
|
130
|
-
'Decay Constant \u00B3\u2077Ar', '%1\u03C3', #
|
|
131
|
-
'Decay Constant \u00B3\u2076Cl', '%1\u03C3', #
|
|
132
|
-
'Decay Activity \u2074\u2070K', '%1\u03C3', #
|
|
133
|
-
'Decay Activity \u2074\u2070K(EC)', '%1\u03C3', #
|
|
134
|
-
'Decay Activity \u2074\u2070K(\u03B2<sup>-</sup>)', '%1\u03C3', #
|
|
135
|
-
'Decay Activity \u2074\u2070K(\u03B2<sup>+</sup>)', '%1\u03C3', #
|
|
136
|
-
'\u00B3\u2076Cl/\u00B3\u2078Cl Productivity', '%1\u03C3', #
|
|
137
|
-
'Std Name', 'Std Age', '1\u03C3', '\u2074\u2070Ar%', '1\u03C3', 'K%', '1\u03C3', #
|
|
138
|
-
'\u2074\u2070Ar<sup>*</sup>/K', '1\u03C3', #
|
|
139
|
-
'J', '%1\u03C3', 'MDF', '%1\u03C3', #
|
|
140
|
-
'Mass \u00B3\u2076Ar', '%1\u03C3', 'Mass \u00B3\u2077Ar', '%1\u03C3', #
|
|
141
|
-
'Mass \u00B3\u2078Ar', '%1\u03C3', 'Mass \u00B3\u2079Ar', '%1\u03C3', #
|
|
142
|
-
'Mass \u2074\u2070', '%1\u03C3', 'K Mass', '%1\u03C3', #
|
|
119
|
+
'(\u00B3\u2078Ar/\u00B3\u2079Ar)K', '%1\u03C3', # 17-20
|
|
120
|
+
'(\u00B3\u2076Ar/\u00B3\u2078Ar)Cl', '%1\u03C3', # 21-22
|
|
121
|
+
'K/Ca', '%1\u03C3', 'K/Cl', '%1\u03C3', 'Ca/Cl', '%1\u03C3', # 23-28
|
|
122
|
+
'Cycle Number', 'Irradiation Cycles', # 29-30
|
|
123
|
+
'Irradiation', 'duration', 'Irradiation Time', 'Experiment Time', # 31-34
|
|
124
|
+
'Storage Years', '', # 35-36
|
|
125
|
+
'Decay Constant \u2074\u2070K', '%1\u03C3', # 37-38
|
|
126
|
+
'Decay Constant \u2074\u2070K(EC)', '%1\u03C3', # 39-40
|
|
127
|
+
'Decay Constant \u2074\u2070K(\u03B2<sup>-</sup>)', '%1\u03C3', # 41-42
|
|
128
|
+
'Decay Constant \u2074\u2070K(\u03B2<sup>+</sup>)', '%1\u03C3', # 43-44
|
|
129
|
+
'Decay Constant \u00B3\u2079Ar', '%1\u03C3', # 45-46
|
|
130
|
+
'Decay Constant \u00B3\u2077Ar', '%1\u03C3', # 47-48
|
|
131
|
+
'Decay Constant \u00B3\u2076Cl', '%1\u03C3', # 49-50
|
|
132
|
+
'Decay Activity \u2074\u2070K', '%1\u03C3', # 51-52
|
|
133
|
+
'Decay Activity \u2074\u2070K(EC)', '%1\u03C3', # 53-54
|
|
134
|
+
'Decay Activity \u2074\u2070K(\u03B2<sup>-</sup>)', '%1\u03C3', # 55-56
|
|
135
|
+
'Decay Activity \u2074\u2070K(\u03B2<sup>+</sup>)', '%1\u03C3', # 57-58
|
|
136
|
+
'\u00B3\u2076Cl/\u00B3\u2078Cl Productivity', '%1\u03C3', # 59-60
|
|
137
|
+
'Std Name', 'Std Age', '1\u03C3', '\u2074\u2070Ar%', '1\u03C3', 'K%', '1\u03C3', # 61-67
|
|
138
|
+
'\u2074\u2070Ar<sup>*</sup>/K', '1\u03C3', # 68-69
|
|
139
|
+
'J', '%1\u03C3', 'MDF', '%1\u03C3', # 70-73
|
|
140
|
+
'Mass \u00B3\u2076Ar', '%1\u03C3', 'Mass \u00B3\u2077Ar', '%1\u03C3', # 74-77
|
|
141
|
+
'Mass \u00B3\u2078Ar', '%1\u03C3', 'Mass \u00B3\u2079Ar', '%1\u03C3', # 78-81
|
|
142
|
+
'Mass \u2074\u2070', '%1\u03C3', 'K Mass', '%1\u03C3', # 82-85
|
|
143
143
|
'No', '%1\u03C3', 'Year', '%1\u03C3', '\u2074\u2070K/K', '%1\u03C3',
|
|
144
|
-
'\u00B3\u2075Cl/\u00B3\u2077Cl', '%1\u03C3', 'HCl/Cl', '%1\u03C3', #
|
|
145
|
-
'\u2074\u2070Ar/\u00B3\u2076Ar air', '%1\u03C3', #
|
|
146
|
-
'\u00B3\u2078Ar/\u00B3\u2076Ar air', '%1\u03C3', #
|
|
147
|
-
'Isochron Fitting', 'Convergence', 'Iteration', 'Discrimination', #
|
|
148
|
-
'Not Zero', 'Corr Blank', 'Corr Discr', 'Corr \u00B3\u2077Ar Decay', #
|
|
149
|
-
'Corr \u00B3\u2079Ar Decay', #
|
|
150
|
-
'Ca Degassing', 'K Degassing', 'Cl Degassing', 'Trap Degassing', #
|
|
151
|
-
'Using Min Equation', #
|
|
144
|
+
'\u00B3\u2075Cl/\u00B3\u2077Cl', '%1\u03C3', 'HCl/Cl', '%1\u03C3', # 86-95
|
|
145
|
+
'\u2074\u2070Ar/\u00B3\u2076Ar air', '%1\u03C3', # 96-97
|
|
146
|
+
'\u00B3\u2078Ar/\u00B3\u2076Ar air', '%1\u03C3', # 98-99
|
|
147
|
+
'Isochron Fitting', 'Convergence', 'Iteration', 'Discrimination', # 100-103
|
|
148
|
+
'Not Zero', 'Corr Blank', 'Corr Discr', 'Corr \u00B3\u2077Ar Decay', # 104-107
|
|
149
|
+
'Corr \u00B3\u2079Ar Decay', # 108
|
|
150
|
+
'Ca Degassing', 'K Degassing', 'Cl Degassing', 'Trap Degassing', # 109-112
|
|
151
|
+
'Using Min Equation', # 113
|
|
152
152
|
# 'Recalibration', 'Using Std Age', 'Use Std Ratio', # 112-115 to be completed
|
|
153
|
-
'Apply Gain Corr to Blanks', #
|
|
154
|
-
'', '', #
|
|
155
|
-
'Auto Plateau Method', #
|
|
156
|
-
'Initial Ratio Model', #
|
|
157
|
-
'Set1 initial Ratio', #
|
|
158
|
-
'1\u03C3', #
|
|
159
|
-
'Set2 initial Ratio', #
|
|
160
|
-
'1\u03C3', #
|
|
161
|
-
'Isotopic Errors', #
|
|
162
|
-
'Parameter Errors', #
|
|
163
|
-
'Plot Errors', #
|
|
164
|
-
'Heating Time (s)', #
|
|
165
|
-
'Heating Actual Temp (C)', #
|
|
166
|
-
'Heating AT 1\u03C3', #
|
|
167
|
-
'36Ar Gain', '%1\u03C3', #
|
|
168
|
-
'37Ar Gain', '%1\u03C3', #
|
|
169
|
-
'38Ar Gain', '%1\u03C3', #
|
|
170
|
-
'39Ar Gain', '%1\u03C3', #
|
|
171
|
-
'40Ar Gain', '%1\u03C3', #
|
|
172
|
-
'Normalize Factor', '1\u03C3', #
|
|
153
|
+
'Apply Gain Corr to Blanks', # 114
|
|
154
|
+
'', '', # 115-116
|
|
155
|
+
'Auto Plateau Method', # 117 the index includes sequence name and unit
|
|
156
|
+
'Initial Ratio Model', # 118
|
|
157
|
+
'Set1 initial Ratio', # 119
|
|
158
|
+
'1\u03C3', # 120
|
|
159
|
+
'Set2 initial Ratio', # 121
|
|
160
|
+
'1\u03C3', # 122
|
|
161
|
+
'Isotopic Errors', # 123
|
|
162
|
+
'Parameter Errors', # 124
|
|
163
|
+
'Plot Errors', # 125
|
|
164
|
+
'Heating Time (s)', # 126
|
|
165
|
+
'Heating Actual Temp (C)', # 127
|
|
166
|
+
'Heating AT 1\u03C3', # 128
|
|
167
|
+
'36Ar Gain', '%1\u03C3', # 129-130
|
|
168
|
+
'37Ar Gain', '%1\u03C3', # 131-132
|
|
169
|
+
'38Ar Gain', '%1\u03C3', # 133-134
|
|
170
|
+
'39Ar Gain', '%1\u03C3', # 135-136
|
|
171
|
+
'40Ar Gain', '%1\u03C3', # 137-138
|
|
172
|
+
'Normalize Factor', '1\u03C3', # 139-140
|
|
173
173
|
]
|
|
174
174
|
|
|
175
175
|
SAMPLE_INTERCEPT_SHORT_HEADERS = [
|
|
@@ -1177,9 +1177,7 @@ class Sequence:
|
|
|
1177
1177
|
def as_type(self, type_str):
|
|
1178
1178
|
if str(type_str).lower() in ["blk", "b", "blank"]:
|
|
1179
1179
|
self.type_str = "blank"
|
|
1180
|
-
|
|
1181
|
-
self.type_str = "air"
|
|
1182
|
-
if self.type_str not in ["blank", "air"]:
|
|
1180
|
+
else:
|
|
1183
1181
|
self.type_str = "unknown"
|
|
1184
1182
|
|
|
1185
1183
|
__as_type = as_type
|
|
@@ -1188,10 +1186,7 @@ class Sequence:
|
|
|
1188
1186
|
return self.type_str == "blank"
|
|
1189
1187
|
|
|
1190
1188
|
def is_unknown(self):
|
|
1191
|
-
return self.type_str != "blank"
|
|
1192
|
-
|
|
1193
|
-
def is_air(self):
|
|
1194
|
-
return self.type_str == "air"
|
|
1189
|
+
return self.type_str != "blank"
|
|
1195
1190
|
|
|
1196
1191
|
def as_blank(self):
|
|
1197
1192
|
return self.as_type("blank")
|
|
@@ -1199,9 +1194,6 @@ class Sequence:
|
|
|
1199
1194
|
def as_unknown(self):
|
|
1200
1195
|
return self.as_type("unknown")
|
|
1201
1196
|
|
|
1202
|
-
def as_air(self):
|
|
1203
|
-
return self.as_type("air")
|
|
1204
|
-
|
|
1205
1197
|
def get_data_df(self):
|
|
1206
1198
|
...
|
|
1207
1199
|
|
|
@@ -1230,7 +1222,7 @@ class RawData:
|
|
|
1230
1222
|
self.unit = unit
|
|
1231
1223
|
self.isotopic_num = isotopic_num
|
|
1232
1224
|
self.sequence_num = sequence_num
|
|
1233
|
-
self.interpolated_blank =
|
|
1225
|
+
self.interpolated_blank = []
|
|
1234
1226
|
if sequence is not None:
|
|
1235
1227
|
self.sequence = sequence
|
|
1236
1228
|
elif data is not None:
|
|
@@ -1241,7 +1233,7 @@ class RawData:
|
|
|
1241
1233
|
data=item[1:],
|
|
1242
1234
|
datetime=item[0][1],
|
|
1243
1235
|
fitting_method=[*kwargs.get("fitting_method", [0] * 5)],
|
|
1244
|
-
options=item[0][2]
|
|
1236
|
+
options=item[0][2],
|
|
1245
1237
|
) for index, item in enumerate(data)]
|
|
1246
1238
|
else:
|
|
1247
1239
|
self.sequence: List[Sequence] = []
|
|
@@ -1275,8 +1267,5 @@ class RawData:
|
|
|
1275
1267
|
def get_blank(self) -> Union[Sequence, List]:
|
|
1276
1268
|
...
|
|
1277
1269
|
|
|
1278
|
-
def get_air(self) -> Union[Sequence, List]:
|
|
1279
|
-
...
|
|
1280
|
-
|
|
1281
1270
|
def to_sample(self, mapping: Optional[List[dict]]) -> Sample:
|
|
1282
1271
|
...
|
ararpy/smp/style.py
CHANGED
|
@@ -64,7 +64,10 @@ def set_plot_style(smp: Sample):
|
|
|
64
64
|
# Auto position and contents of texts
|
|
65
65
|
reset_text(smp)
|
|
66
66
|
# Set title, which are deleted in initializing
|
|
67
|
-
|
|
67
|
+
exp_name = smp.Info.experiment.name
|
|
68
|
+
smp_name = smp.Info.sample.name
|
|
69
|
+
name = f"{exp_name} {smp_name}" if str(exp_name).lower().strip() != str(smp_name).lower().strip() else exp_name
|
|
70
|
+
suffix = f"{name} {smp.Info.sample.material}"
|
|
68
71
|
for figure_id, figure in basic.get_components(smp).items():
|
|
69
72
|
if isinstance(figure, Plot):
|
|
70
73
|
if not hasattr(figure, 'title'):
|
|
@@ -5,20 +5,20 @@ ararpy/Example - Show MDD results.py,sha256=YFkiQual60lyCClsfvivr4REY6waSYuomf0u
|
|
|
5
5
|
ararpy/Example - Show all Kfs age spectra.py,sha256=1edPtBpFfS0lC7vLnLu34mDHt_xjbc8ptk6rZ--pf-I,12304
|
|
6
6
|
ararpy/Example - Show random walk results.py,sha256=8WWvbAI7ySiMR-XwtFe5kTQihW3mcqzL3S7EUZdoxYo,15477
|
|
7
7
|
ararpy/Example - Tc calculation.py,sha256=sD9pu3IaZ8mBV95rV2wOEhlQUexFNqBUoBqnNMdUBis,19617
|
|
8
|
-
ararpy/__init__.py,sha256=
|
|
8
|
+
ararpy/__init__.py,sha256=lguPXqCx66J1evLooyi_UF-O_dMUDWl4sH8z5VlpGns,6768
|
|
9
9
|
ararpy/test.py,sha256=4F46-JJ1Ge12HGae0qO44Qc6kiEMHBgn2MsY_5LlHDo,3973
|
|
10
10
|
ararpy/calc/__init__.py,sha256=kUjRuLE8TLuKOv3i976RnGJoEMj23QBZDu37LWs81U4,322
|
|
11
11
|
ararpy/calc/age.py,sha256=WOZs70zXiBWDIEhXJLIaNiYTOFJNk0NDbH5e5zCbCks,5435
|
|
12
12
|
ararpy/calc/arr.py,sha256=jD1Fd0Cj3xc7NqgnG4cp3VWQWxUlV0qCtPBZZokDG8o,15246
|
|
13
|
-
ararpy/calc/basic.py,sha256=
|
|
13
|
+
ararpy/calc/basic.py,sha256=2Iqk5WBMH8hiOqW2cvyPNEAbGU7hoeGTQ08Y6mlyfv8,4550
|
|
14
14
|
ararpy/calc/corr.py,sha256=QDitvLf6y5IBpHtVEJfOUVjWSlIP9qJ4Jhluk9eDEDE,18801
|
|
15
15
|
ararpy/calc/err.py,sha256=63LtprqjemlIb1QGDst4Ggcv5KMSDHdlAIL-nyQs1eA,2691
|
|
16
16
|
ararpy/calc/histogram.py,sha256=0GVbDdsjd91KQ1sa2B7NtZ4KGo0XpRIJapgIrzAwQUo,5777
|
|
17
17
|
ararpy/calc/isochron.py,sha256=ej9G2e68k6yszonWHsLcEubh3TA7eh1upTJP_X0ttAA,5726
|
|
18
18
|
ararpy/calc/jvalue.py,sha256=OL5zPYU8Pac-wOxUWPCgu3onh2n01xDnhpi2mlUsjJM,1146
|
|
19
19
|
ararpy/calc/plot.py,sha256=Hdtb-q18xYC8ZJeDKGRauCSbj4_7e6Z8HQs9aYgfvao,2139
|
|
20
|
-
ararpy/calc/raw_funcs.py,sha256=
|
|
21
|
-
ararpy/calc/regression.py,sha256=
|
|
20
|
+
ararpy/calc/raw_funcs.py,sha256=Rza1nIBQCOlJK_X0XvzmJqNG_byuaZxotNbdM84M-gI,2736
|
|
21
|
+
ararpy/calc/regression.py,sha256=m2_xJAsQ7mBIbnrmxtSPIQapJH61jkxvXskxN-8f86k,42803
|
|
22
22
|
ararpy/calc/spectra.py,sha256=_Q23eP9necHlaCoHf3_UfW1N3JmVZj5rcWFro8GS-CA,1995
|
|
23
23
|
ararpy/examples/022_VU124-M11a.ahd,sha256=3m0Gd-ZObou3KsnRNFMf77QwzT1Uz3nu3vA33Sqeyng,5414
|
|
24
24
|
ararpy/examples/20WHA0103.age,sha256=cT-a4d7Wt77aotx6v0G47vulY_TZIcZUcaVHB3pqTPM,380416
|
|
@@ -42,9 +42,9 @@ ararpy/examples/sample-default.smp,sha256=YNkoQGgPrsL_fXS7ZHxfRtLQWekCDqT9czS6vB
|
|
|
42
42
|
ararpy/files/__init__.py,sha256=l5B5ZQ01WdtvjjN0aMkyAFNgpwANdM_1I0tQbqnRuEY,69
|
|
43
43
|
ararpy/files/arr_file.py,sha256=pD5MxkAydL7cNq2wmKFUaOU4jHhc3MzTYrwbxZ3f46w,881
|
|
44
44
|
ararpy/files/basic.py,sha256=k2GXgZjhqSmKvpXQLjsXDksS_ZLvqD7AWW54fXnYvTI,1228
|
|
45
|
-
ararpy/files/calc_file.py,sha256=
|
|
45
|
+
ararpy/files/calc_file.py,sha256=bapIVd3QQBprdMdfxNbY8TJH1UkfphIUtim3ONypc3I,28779
|
|
46
46
|
ararpy/files/new_file.py,sha256=efblARIBROVLWS2w3-98BxLX5VZ8grRpiTkJFtf_rAk,214
|
|
47
|
-
ararpy/files/raw_file.py,sha256
|
|
47
|
+
ararpy/files/raw_file.py,sha256=iaM53pUHD3-sIgrRA_jXNOn5KIdKxKLEur_0DxNVPLo,20445
|
|
48
48
|
ararpy/files/xls.py,sha256=DVcZ_yRnc19p-m4leGGjt-YPDpSa2udYKmGyrM0qub0,640
|
|
49
49
|
ararpy/smp/EXPORT_TO_PDF_DATA_PROPERTIES.py,sha256=baDM437tu6hsPv0uYfod0TREXlPd6kvMBFT1S9ZZlkk,3024
|
|
50
50
|
ararpy/smp/__init__.py,sha256=k6_fa27UJsQK7K7oC5GYlwMo6l0Xd8af3QtOrZz2XJk,478
|
|
@@ -54,20 +54,20 @@ ararpy/smp/consts.py,sha256=XIdjdz8cYxspG2jMnoItdlUsxr3hKbNFJjMZJh1bpzw,393
|
|
|
54
54
|
ararpy/smp/corr.py,sha256=U5K1Vld55IHea_fZ7EEY_8dkvjp0f6OhpdSxf7b9WGY,26551
|
|
55
55
|
ararpy/smp/diffusion_funcs.py,sha256=NC5T0GYXCidgVqSy3BGmIroLWzQhyzYb5x4gg_L0dJ4,186694
|
|
56
56
|
ararpy/smp/export.py,sha256=yAUlTvFBo2U703hZ79NlAcTYC7QZGXHUn_IRP7sQuRA,120638
|
|
57
|
-
ararpy/smp/info.py,sha256=
|
|
58
|
-
ararpy/smp/initial.py,sha256=
|
|
59
|
-
ararpy/smp/json.py,sha256=
|
|
57
|
+
ararpy/smp/info.py,sha256=tpEIjrE4nR-GAYTricBk9gq0LuHh6F1Bt7HPo1rS2HM,497
|
|
58
|
+
ararpy/smp/initial.py,sha256=4-ojO-_Dmuyt-W1Ueji3FYPSSAZrOZ2ZxyGxmar3Kn8,18203
|
|
59
|
+
ararpy/smp/json.py,sha256=zfJCC_2LCDckqC8Fpu10jEA6Knl3UtKO31I5g4fvsBE,2273
|
|
60
60
|
ararpy/smp/plots.py,sha256=fFuJxoFcnvGSysjdEdrbW_ITpukt0iGs2K25gshIKNU,33594
|
|
61
|
-
ararpy/smp/raw.py,sha256=
|
|
62
|
-
ararpy/smp/sample.py,sha256=
|
|
63
|
-
ararpy/smp/style.py,sha256=
|
|
61
|
+
ararpy/smp/raw.py,sha256=77J1dEYL4ZSeftp4tyog_Cy1Y5bwHNaLqJK4i4KLOSY,6500
|
|
62
|
+
ararpy/smp/sample.py,sha256=P3lh2kOThTGrtNNgPF02y6_9ORM6mAlMSwEsPxLQAwM,58566
|
|
63
|
+
ararpy/smp/style.py,sha256=y0iQpN4jy3PGy31DG5-_P1fNFGgyUNdsJX9qlYGVMEM,7979
|
|
64
64
|
ararpy/smp/table.py,sha256=Vq3GK9aslEuBhmvlQoUHjcs71Q6raSFYqd5veB1L9mk,6887
|
|
65
65
|
ararpy/thermo/__init__.py,sha256=6VBuqTRFl403PVqOuMkVrut0nKaQsAosBmfW91X1dMg,263
|
|
66
66
|
ararpy/thermo/arrhenius.py,sha256=Ass1ichHfqIAtpv8eLlgrUc1UOb3Urh1qzr1E3gLB4U,233
|
|
67
67
|
ararpy/thermo/atomic_level_random_walk.py,sha256=ncw9DtxRfS6zlQbLVLNX7WNoO9sX_nSomwAsTH0_O3k,25910
|
|
68
68
|
ararpy/thermo/basic.py,sha256=JJRZbYmvXlpRAV2FeFPwLhrig4ZhNQmJnWqgOjo-1YQ,11508
|
|
69
|
-
ararpy-0.1.
|
|
70
|
-
ararpy-0.1.
|
|
71
|
-
ararpy-0.1.
|
|
72
|
-
ararpy-0.1.
|
|
73
|
-
ararpy-0.1.
|
|
69
|
+
ararpy-0.1.37.dist-info/licenses/LICENSE,sha256=cvG5t_C1qY_zUyJI7sNOa7gCArdngNPaOrfujl2LYuc,1085
|
|
70
|
+
ararpy-0.1.37.dist-info/METADATA,sha256=CWUoNZxPs8oUAPXtcOFXxylMCwE21PMamMv_oEm-juM,24516
|
|
71
|
+
ararpy-0.1.37.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
72
|
+
ararpy-0.1.37.dist-info/top_level.txt,sha256=9iTpsPCYuRYq09yQTk9d2lqB8JtTEOmbN-IcGB-K3vY,7
|
|
73
|
+
ararpy-0.1.37.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|