ararpy 0.1.35__py3-none-any.whl → 0.1.36__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 -2
- ararpy/calc/raw_funcs.py +3 -3
- ararpy/calc/regression.py +94 -82
- ararpy/files/calc_file.py +35 -34
- ararpy/files/raw_file.py +20 -63
- ararpy/smp/sample.py +55 -55
- {ararpy-0.1.35.dist-info → ararpy-0.1.36.dist-info}/METADATA +1 -1
- {ararpy-0.1.35.dist-info → ararpy-0.1.36.dist-info}/RECORD +11 -11
- {ararpy-0.1.35.dist-info → ararpy-0.1.36.dist-info}/WHEEL +0 -0
- {ararpy-0.1.35.dist-info → ararpy-0.1.36.dist-info}/licenses/LICENSE +0 -0
- {ararpy-0.1.35.dist-info → ararpy-0.1.36.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.36'
|
|
20
20
|
__version__ = version
|
|
21
21
|
full_version = version
|
|
22
|
-
last_update = '2025-12-
|
|
22
|
+
last_update = '2025-12-08'
|
|
23
23
|
|
|
24
24
|
""" ArArPy Functions """
|
|
25
25
|
|
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,16 +495,19 @@ 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]
|
|
@@ -538,7 +541,7 @@ def average(a0: list, a1=None):
|
|
|
538
541
|
k1 = pow(sum([(i - k0) ** 2 for i in a0]) / df, 0.5) # standard deviation
|
|
539
542
|
k2 = k1 / k0 * 100 if k0 != 0 else 0 # relative standard error
|
|
540
543
|
k3 = r2 # determination coefficient
|
|
541
|
-
k4 = 'MSWD'
|
|
544
|
+
k4 = m_ssresid # 'MSWD'
|
|
542
545
|
k5 = [k0]
|
|
543
546
|
k6 = [k1]
|
|
544
547
|
k8 = m_ssresid
|
|
@@ -869,92 +872,101 @@ def power(a0: list, a1: list):
|
|
|
869
872
|
|
|
870
873
|
|
|
871
874
|
def exponential(a0: list, a1: list):
|
|
872
|
-
"""
|
|
873
|
-
:param a0: known_y's, y = a * b ^ x + c
|
|
874
|
-
:param a1: known_x's
|
|
875
|
-
:return: intercept | standard error of intercept | relative error | R2 | MSWD | [m, c, b] | [sem, sec, seb]
|
|
876
|
-
"""
|
|
877
875
|
|
|
878
|
-
|
|
879
|
-
|
|
876
|
+
X = np.array(a1)
|
|
877
|
+
Y = np.array(a0)
|
|
878
|
+
y = np.array([a0]).transpose()
|
|
880
879
|
|
|
881
|
-
def
|
|
882
|
-
a
|
|
883
|
-
return [_exp_func(xi, a, b, c) - yi for xi, yi in zip(a1, a0)]
|
|
880
|
+
def _exp_func(xi, a, b, c):
|
|
881
|
+
return a * np.exp(b * xi) + c
|
|
884
882
|
|
|
885
|
-
|
|
886
|
-
|
|
883
|
+
@np.vectorize
|
|
884
|
+
def _get_s(b):
|
|
885
|
+
x = np.concatenate(([np.ones(len(a1))], [np.exp(b * np.array(a1))]), axis=0).transpose()
|
|
886
|
+
try:
|
|
887
|
+
inv_xtx = np.linalg.inv(np.matmul(x.transpose(), x))
|
|
888
|
+
except np.linalg.LinAlgError:
|
|
889
|
+
raise np.linalg.LinAlgError(f"The determinant of the given matrix must not be zero ")
|
|
890
|
+
beta = np.matmul(inv_xtx, np.matmul(x.transpose(), y))
|
|
891
|
+
c, a = beta.flatten()
|
|
892
|
+
reg_y = _exp_func(X, a, b, c)
|
|
893
|
+
resid = (reg_y - Y) ** 2
|
|
894
|
+
ssresid = sum(resid)
|
|
895
|
+
return ssresid
|
|
887
896
|
|
|
888
|
-
def _get_ac(b):
|
|
889
|
-
f = linest(a0, [b ** xi for xi in a1])
|
|
890
|
-
return f[5][1], b, f[0]
|
|
891
897
|
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
return np.exp(f[0]), np.exp(f[5][1]), 0
|
|
898
|
+
ini_f = linest(np.log(Y), X)
|
|
899
|
+
ini_b = ini_f[5][1]
|
|
895
900
|
|
|
901
|
+
# 替换原来的 minimize_scalar 部分
|
|
896
902
|
try:
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
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
|
|
903
|
+
b, count = newton_minimize_1d(_get_s, x0=ini_b, h=1e-5, tol=1e-8, max_iter=30)
|
|
904
|
+
except Exception as e:
|
|
905
|
+
# 使用 scipy 一维优化
|
|
906
|
+
res = minimize_scalar(_get_s, bounds=(-2, 2), method='bounded', options={'xatol': 1e-8})
|
|
907
|
+
b, count = res.x, res.nfev
|
|
921
908
|
|
|
922
|
-
|
|
923
|
-
raise RuntimeError
|
|
924
|
-
except np.linalg.LinAlgError:
|
|
925
|
-
raise np.linalg.LinAlgError
|
|
926
|
-
except TypeError:
|
|
927
|
-
raise TypeError
|
|
928
|
-
except IndexError:
|
|
929
|
-
raise IndexError
|
|
930
|
-
|
|
931
|
-
f = linest(a0, [b ** xi for xi in a1])
|
|
932
|
-
a, sea, c, sec = f[5][1], f[6][1], f[0], f[1]
|
|
909
|
+
# print(f"{b = }, {count = }")
|
|
933
910
|
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
911
|
+
x = np.concatenate(([np.ones(len(a1))], [np.exp(b * np.array(a1))]), axis=0).transpose()
|
|
912
|
+
m, n = x.shape # number of data, number of unknown x
|
|
913
|
+
try:
|
|
914
|
+
inv_xtx = np.linalg.inv(np.matmul(x.transpose(), x))
|
|
915
|
+
except np.linalg.LinAlgError:
|
|
916
|
+
raise np.linalg.LinAlgError(f"The determinant of the given matrix must not be zero ")
|
|
917
|
+
beta = np.matmul(inv_xtx, np.matmul(x.transpose(), y))
|
|
918
|
+
estimate_y = np.matmul(x, beta)
|
|
919
|
+
resid = (estimate_y - y) ** 2
|
|
920
|
+
reg = (estimate_y - np.mean(y)) ** 2
|
|
921
|
+
ssresid = resid.sum() # 残差平方和
|
|
922
|
+
ssreg = reg.sum() # 回归平方和
|
|
923
|
+
sstotal = ((y - np.mean(y)) ** 2).sum()
|
|
943
924
|
r2 = ssreg / sstotal if sstotal != 0 else 1
|
|
944
925
|
|
|
945
|
-
|
|
926
|
+
df = m - n
|
|
927
|
+
m_ssresid = ssresid / df # 均方残差,与加权平均中的MSWD对应
|
|
928
|
+
cov_beta = m_ssresid * inv_xtx
|
|
929
|
+
|
|
930
|
+
sc, sa = np.diagonal(cov_beta) ** .5
|
|
931
|
+
c, a = beta.flatten()
|
|
946
932
|
intercept = a + c
|
|
947
|
-
|
|
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
|
|
933
|
+
se_intercept = pow(sa ** 2 + sc ** 2 + 2 * cov_beta[0][1] , 0.5)
|
|
954
934
|
|
|
955
|
-
return intercept, se_intercept,
|
|
956
|
-
lambda x: [_exp_func(
|
|
935
|
+
return intercept, se_intercept, se_intercept / intercept * 100, r2, m_ssresid, [a, b, c], 'se', \
|
|
936
|
+
lambda x: [_exp_func(xi, a, b, c) for xi in x], m_ssresid
|
|
937
|
+
|
|
938
|
+
|
|
939
|
+
def newton_minimize_1d(func, x0, h=1e-5, tol=1e-8, max_iter=20):
|
|
940
|
+
x = x0
|
|
941
|
+
for i in range(max_iter):
|
|
942
|
+
fx = func(x)
|
|
943
|
+
if not np.isfinite(fx):
|
|
944
|
+
raise ValueError("Newton Minimize: Function returned non-finite value at x={}".format(x))
|
|
945
|
+
|
|
946
|
+
# 一阶导数(中心差分)
|
|
947
|
+
f_plus = func(x + h)
|
|
948
|
+
f_minus = func(x - h)
|
|
949
|
+
if not (np.isfinite(f_plus) and np.isfinite(f_minus)):
|
|
950
|
+
raise ValueError("Newton Minimize: Non-finite values in derivative computation")
|
|
951
|
+
|
|
952
|
+
df = (f_plus - f_minus) / (2 * h)
|
|
953
|
+
d2f = (f_plus - 2 * fx + f_minus) / (h * h)
|
|
954
|
+
|
|
955
|
+
# 牛顿步长
|
|
956
|
+
if abs(d2f) < 1e-12: # 避免除零或平坦区域
|
|
957
|
+
print("Newton Minimize: Second derivative too small, stopping.")
|
|
958
|
+
break
|
|
959
|
+
|
|
960
|
+
step = df / d2f
|
|
961
|
+
x_new = x - step
|
|
962
|
+
|
|
963
|
+
if abs(step) < tol:
|
|
964
|
+
x = x_new
|
|
965
|
+
break
|
|
966
|
+
|
|
967
|
+
x = x_new
|
|
957
968
|
|
|
969
|
+
return x, i + 1
|
|
958
970
|
|
|
959
971
|
""" line functions """
|
|
960
972
|
|
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,29 @@ 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
|
+
|
|
272
232
|
step_list = []
|
|
273
|
-
idx = step_index
|
|
233
|
+
idx = 0 # step_index
|
|
274
234
|
|
|
275
235
|
header = input_filter[5]
|
|
276
236
|
isotope_index = input_filter[8:28]
|
|
@@ -293,13 +253,10 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
293
253
|
if res is not None and "en" in res.named.keys():
|
|
294
254
|
experiment_name = res.named.get("en")
|
|
295
255
|
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")
|
|
256
|
+
step_name = res.named.get("sn")
|
|
257
|
+
if str(step_name) == "":
|
|
258
|
+
raise ValueError(f"Step name not found, break reading steps")
|
|
259
|
+
step_name = f"{experiment_name}-{step_num_parse(step_name)}"
|
|
303
260
|
except (TypeError, ValueError, IndexError):
|
|
304
261
|
# When parsing the step name fails, the end of the file has been reached
|
|
305
262
|
# raise
|
|
@@ -417,7 +374,7 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
417
374
|
step_list.append(current_step)
|
|
418
375
|
idx = data_index[28] * len(step_list)
|
|
419
376
|
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)}")
|
|
377
|
+
# print(f"Multiple Sequence = {check_box_index[0]}, Step number = {len(step_list)}")
|
|
421
378
|
break
|
|
422
379
|
|
|
423
380
|
if not step_list:
|
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 = [
|
|
@@ -5,7 +5,7 @@ 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=mVCcRD0R0FoAL0Q6u9paujSfaQ8YBP8A_FXELRXO5AI,6857
|
|
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
|
|
@@ -17,8 +17,8 @@ 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=3L6caRhAptWY7o3EGGk5sfB_C471crSUcwOQRrkLS7Q,40255
|
|
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=IwU_1Urrk0FjOt3kUuOaYjBBFozhCVAdsP6STxRia-o,19778
|
|
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
|
|
@@ -59,15 +59,15 @@ ararpy/smp/initial.py,sha256=QGk7vh7JyVqalwnpd9VudQoX2Z9tyWzfIIw_cL5Sok0,18031
|
|
|
59
59
|
ararpy/smp/json.py,sha256=BTZCjVN0aj9epc700nwkYEYMKN2lHBYo-pLmtnz5oHY,2300
|
|
60
60
|
ararpy/smp/plots.py,sha256=fFuJxoFcnvGSysjdEdrbW_ITpukt0iGs2K25gshIKNU,33594
|
|
61
61
|
ararpy/smp/raw.py,sha256=SeKaNZZRWjiE_7fMHwn1IgQxX17t8mNFYMnRiimMLRU,6474
|
|
62
|
-
ararpy/smp/sample.py,sha256=
|
|
62
|
+
ararpy/smp/sample.py,sha256=HW2JIZZcNslYVQupAqlfLEKXBWdYol5Xpx0PDdPG44o,58905
|
|
63
63
|
ararpy/smp/style.py,sha256=Q8f6SsqnxmzocxpZUyGDiNanVW0ijCZpxHKh19UIeoM,7800
|
|
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.36.dist-info/licenses/LICENSE,sha256=cvG5t_C1qY_zUyJI7sNOa7gCArdngNPaOrfujl2LYuc,1085
|
|
70
|
+
ararpy-0.1.36.dist-info/METADATA,sha256=z82ivzCqiDnDN8TjnGAk1EmL4-C_YLhhY99WFbLnw3Y,24516
|
|
71
|
+
ararpy-0.1.36.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
72
|
+
ararpy-0.1.36.dist-info/top_level.txt,sha256=9iTpsPCYuRYq09yQTk9d2lqB8JtTEOmbN-IcGB-K3vY,7
|
|
73
|
+
ararpy-0.1.36.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|