ararpy 0.1.1__py3-none-any.whl → 0.1.11__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/smp/__init__.py CHANGED
@@ -1,6 +1,6 @@
1
1
 
2
2
  from . import (
3
- sample as samples, consts, json, basic, corr, raw, initial,
3
+ sample as samples, info, consts, json, basic, corr, raw, initial,
4
4
  plots, style, table, calculation, export, diffusion_funcs
5
5
  )
6
6
 
ararpy/smp/info.py ADDED
@@ -0,0 +1,23 @@
1
+ # Copyright (C) 2024 Yang. - All Rights Reserved
2
+
3
+ # !/usr/bin/env python
4
+ # -*- coding: UTF-8 -*-
5
+ """
6
+ # ==========================================
7
+ # Copyright 2024 Yang
8
+ # ararpy - info
9
+ # ==========================================
10
+ #
11
+ #
12
+ #
13
+ """
14
+
15
+
16
+ def name(smp, n: str = None):
17
+ if n is None:
18
+ return smp.Info.sample.name
19
+ elif isinstance(n, str):
20
+ smp.Info.sample.name = n
21
+ return n
22
+ else:
23
+ raise ValueError(f"{n} is not a string")
ararpy/smp/sample.py CHANGED
@@ -839,7 +839,7 @@ class Sample:
839
839
  return self.__version
840
840
 
841
841
  def help(self) -> str: ...
842
-
842
+
843
843
  def name(self) -> str: ...
844
844
 
845
845
  def doi(self) -> str: ...
ararpy/test.py CHANGED
@@ -10,287 +10,28 @@
10
10
  """
11
11
  import ararpy as ap
12
12
  import os
13
- import ctypes
14
- import numpy as np
15
- import time
16
-
17
- def is_number(s):
18
- try:
19
- float(s)
20
- return True
21
- except ValueError:
22
- return False
23
-
24
-
25
- class DiffSample:
26
- def __init__(self, smp = None, name: str = None):
27
-
28
- if smp is not None:
29
- self.smp = smp
30
- self.sname = self.smp.name()
31
-
32
- self.sequence = self.smp.sequence()
33
- self.ni = self.sequence.size # sequence number
34
-
35
- # self.telab = np.linspace(600, 1500, self.ni, dtype=np.float64)
36
- self.telab = np.array(self.smp.TotalParam[124], dtype=np.float64)
37
-
38
- ### 这里用真实的加热温度之后 a1 > 0,导致后面无法计算
39
- ### 原因:telab不能为 0
40
-
41
-
42
- self.telab = self.telab + 275.13
43
- # self.tilab = np.array([15*60 for i in range(self.ni)], dtype=np.float64)
44
- self.tilab = np.array(self.smp.TotalParam[123], dtype=np.float64)
45
- self.a39 = np.array(self.smp.DegasValues[20], dtype=np.float64)
46
- self.sig39 = np.array(self.smp.DegasValues[21], dtype=np.float64)
47
- self.f = np.cumsum(self.a39) / self.a39.sum()
48
- self.f[-1] = 0.999999999
49
- # self.f = np.insert(self.f, 0, 0)
50
- self.ya = np.array(self.smp.ApparentAgeValues[2], dtype=np.float64)
51
- self.sig = np.array(self.smp.ApparentAgeValues[3], dtype=np.float64)
52
-
53
- loc = "D:\\PythonProjects\\ararpy_package\\ararpy\\examples"
54
- self.file_age_in = open(os.path.join(loc, f"{self.sname}_age.in"), "w")
55
- self.file_sig_in = open(os.path.join(loc, f"{self.sname}_sig.in"), "w")
56
- self.file_tmp_in = open(os.path.join(loc, f"{self.sname}_tmp.in"), "w")
57
- self.file_fj_in = open(os.path.join(loc, f"{self.sname}_fj.in"), "w")
58
- self.file_a39_in = open(os.path.join(loc, f"{self.sname}_a39.in"), "w")
59
-
60
- self.file_age_in.writelines("\n".join([f" {self.f[i] * 100} {self.ya[i]}" for i in range(self.ni)]))
61
- self.file_sig_in.writelines("\n".join([f"{self.sig[i]}" for i in range(self.ni)]))
62
- self.file_tmp_in.writelines(f"{str(self.ni)}\n")
63
- self.file_tmp_in.writelines("\n".join([f"{self.telab[i]}\n{self.tilab[i]}" for i in range(self.ni)]))
64
- self.file_fj_in.writelines("\n".join([f"{self.f[i]}" for i in range(self.ni)]))
65
- self.file_a39_in.writelines("\n".join([f" {self.a39[i]} {self.sig39[i]}" for i in range(self.ni)]))
66
-
67
- self.file_age_in.close()
68
- self.file_sig_in.close()
69
- self.file_tmp_in.close()
70
- self.file_fj_in.close()
71
- self.file_a39_in.close()
72
-
73
-
74
- elif name is not None:
75
- self.sname = name
76
- else:
77
- raise ValueError("Sample not found")
78
-
79
- self.pi = 3.141592654
80
- self.nloop = 1
81
- self.ngauss = 10
82
- self.zi = [0.]
83
- self.b = 8
84
- self.imp = 2
85
- self.acut = 0.5
86
- self.dchmin = 0.01
87
- self.ncons = 0
88
- self.ndom = 8
89
- self.mdom = 8
90
- self.iset = 0
91
- self.gset = 0
92
- self.wt = []
93
-
94
-
95
- class DiffAgemonFuncs(DiffSample):
96
-
97
- def __init__(self, ni=10, mmax=100, ochisq=0, **kwargs):
98
-
99
- self.ni = ni
100
- self.mmax = mmax
101
- self.ochisq = ochisq
102
-
103
- super().__init__(**kwargs)
104
-
105
- self.nca = 200
106
- self.da = np.zeros(self.ni, dtype=np.float64)
107
- self.beta = np.zeros(self.mmax, dtype=np.float64)
108
- self.atry = np.zeros(self.mmax, dtype=np.float64)
109
-
110
- # constants
111
- self.nwcy = 10
112
- self.ncyc = 1
113
- self.ntst = 1001
114
- self.ns = 200
115
- self.nmaxi = np.zeros(self.nwcy, dtype=int)
116
- self.nmaxo = np.zeros(self.nwcy, dtype=int)
117
- self.tti = np.zeros([self.nwcy, 2, self.ntst], dtype=np.float64)
118
- self.tto = np.zeros([self.nwcy, 2, self.ntst], dtype=np.float64)
119
- self.agei = np.zeros([self.nwcy, 2, self.ns], dtype=np.float64)
120
- self.ageo = np.zeros([self.nwcy, 2, self.ns], dtype=np.float64)
121
-
122
- self.loc = "D:\\PythonProjects\\ararpy_package\\ararpy\\examples"
123
-
124
- self.file_ame_in = open(os.path.join(self.loc, f"{self.sname}.ame"), "r") # from arrmulti
125
- self.file_age_in = open(os.path.join(self.loc, f"{self.sname}_age.in"), "r")
126
- self.file_sig_in = open(os.path.join(self.loc, f"{self.sname}_sig.in"), "r")
127
- self.file_tmp_in = open(os.path.join(self.loc, f"{self.sname}_tmp.in"), "r")
128
-
129
- self.file_output_mch = open(os.path.join(self.loc, f"{self.sname}_mch-out.dat"), "w")
130
- self.file_output_mages = open(os.path.join(self.loc, f"{self.sname}_mages-out.dat"), "w")
131
- self.file_output_agesd = open(os.path.join(self.loc, f"{self.sname}_ages-sd.samp"), "w")
132
-
133
- self.file_output_mch.close()
134
- self.file_output_mages.close()
135
- self.file_output_agesd.close()
136
-
137
- # parameters
138
- self.ns = 200
139
- self.nc = 100
140
- self.ntst = 1001
141
- self.mxi = 350
142
- self.nn = 319
143
- self.mfit = 10
144
- self.nwcy = 10
145
- self.nd = 10
146
- self.xlambd = 0.0005543
147
- self.a = 0
148
- self.perc = 0.01
149
- self.cht0 = 1.0e-4
150
- self.nrun = 5
151
- self.maxrun = 15
152
- self.nemax = 10
153
-
154
- # 读取加热温度和时间
155
- self.ni = int(self.file_tmp_in.readline())
156
- self.nit = self.ni
157
- self.r39 = np.zeros(self.ni, dtype=np.float64)
158
- self.telab = np.zeros(self.ni, dtype=np.float64)
159
- self.tilab = np.zeros(self.ni, dtype=np.float64)
160
- for i in range(self.ni):
161
- self.telab[i] = float(self.file_tmp_in.readline())
162
- self.tilab[i] = float(self.file_tmp_in.readline())
163
- if self.telab[i] > 1373:
164
- # go to 11
165
- self.ni = i
166
- break
167
- self.tilab[i] /= 5.256E+11 # 1 Ma = 525600000000 minutes
168
-
169
- # 读取
170
- nemax = 0
171
- self.nst_arr = np.zeros(100, dtype=int)
172
- self.e_arr = np.zeros(100, dtype=np.float64)
173
- self.d0_arr = np.zeros([100, 20], dtype=np.float64)
174
- self.vc_arr = np.zeros([100, 20], dtype=np.float64)
175
- self.e = 0
176
- self.d0 = np.zeros(self.nd, dtype=np.float64)
177
- self.vc = np.zeros(self.nd, dtype=np.float64)
178
- kk = 0
179
- while True:
180
- try:
181
- self.nst_arr[kk] = int(self.file_ame_in.readline()) # sequence number
182
- # self.nst = int(self.file_ame_in.readline()) # sequence number
183
- for i in range(self.nst_arr[kk]):
184
- self.e_arr[kk] = float(self.file_ame_in.readline())
185
- self.d0_arr[kk, i] = 10 ** float(self.file_ame_in.readline()) / 4 * (24 * 3600 * 365e+6)
186
- self.vc_arr[kk, i] = float(self.file_ame_in.readline())
187
- # self.e = float(self.file_ame_in.readline())
188
- # self.d0[i] = float(self.file_ame_in.readline())
189
- # self.vc[i] = float(self.file_ame_in.readline())
190
- # self.d0[i] = 10 ** self.d0[i] / 4 * (24 * 3600 * 365e+6)
191
- nemax += 1
192
- self.atmp = self.file_ame_in.readline()
193
- self.atmp = self.file_ame_in.readline()
194
- self.atmp = self.file_ame_in.readline()
195
- kk += 1
196
- except ValueError:
197
- break
198
- self.kk = kk
199
- print(f"{self.kk = }")
200
-
201
- # 读取sig
202
- self.sig = np.zeros(self.ns, dtype=np.float64)
203
- self.xs = np.zeros(self.ns + 1, dtype=np.float64)
204
- self.ya = np.zeros(self.ns + 1, dtype=np.float64)
205
- for i in range(self.nit + 1):
206
- try:
207
- self.sig[i] = float(self.file_sig_in.readline())
208
- if self.sig[i] <= 0:
209
- raise ValueError("Sigma less than 0")
210
- self.xs[i + 1], self.ya[i + 1] = [float(j) for j in filter(lambda x: is_number(x),
211
- self.file_age_in.readline().split(' '))]
212
- self.xs[i + 1] /= 100
213
- if self.ya[i] < 0:
214
- self.ya[i] = 0
215
- except ValueError:
216
- print(f"{i = } error in reading sig file")
217
- continue
218
-
219
- self.max_plateau_age = 30
220
-
221
- self.file_ame_in.close()
222
- self.file_tmp_in.close()
223
- self.file_age_in.close()
224
- self.file_sig_in.close()
225
-
226
-
227
-
228
-
229
13
 
230
14
 
231
15
  def test():
232
16
  example_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), r'examples')
233
17
  print(f"Running: ararpy.test()")
234
18
  print(f"============= Open an example .arr file =============")
235
- # file_path = os.path.join(example_dir, r'22WHA0433.arr')
236
- # sample = ap.from_arr(file_path=file_path)
237
- # # file_path = os.path.join(example_dir, r'22WHA0433.age')
238
- # # sample = ap.from_age(file_path=file_path)
239
- # print(f"{file_path = }")
240
- # print(f"sample = from_arr(file_path=file_path)")
241
- # print(f"{sample.name() = }")
242
- # print(f"{sample.help = }")
243
- # print(f"sample.parameters() = {sample.parameters()}")
244
- # print(f"sample.parameters().to_df() = \n{sample.parameters().to_df()}")
245
- # print(sample.show_data())
246
- # print(sample.sample())
247
- # print(sample.blank().to_df().iloc[:, [1, 2, 3]])
248
-
249
- # diff_smp = ap.calc.diffusion_funcs.DiffArrmultiFunc(smp=sample)
250
- # diff_smp = ap.calc.diffusion_funcs.DiffArrmultiFunc(name='12h')
251
- # e, sige, ordi, sigo = diff_smp.main()
252
- # diff_smp = ap.calc.diffusion_funcs.DiffAgemonFuncs(smp=sample)
253
- # diff_smp = ap.calc.diffusion_funcs.DiffAgemonFuncs(name='12h')
254
- # diff_smp.main()
255
- # diff_smp = ap.calc.diffusion_funcs.DiffDraw(name='12h')
256
- # diff_smp.main()
257
-
258
-
259
- # diff_smp = ap.calc.diffusion_funcs.InsideTemperatureCalibration()
260
- #
261
- # # k1, k2 = diff_smp.get_calibrated_temp(45 * 60, 600)
262
- # # print(round((k1 + k2) / 2, 2), round(abs(k2 - k1) / 2, 2))
263
- #
264
- # ## 显示每个设定温度的所有空载加热测试结果,红蓝线为上下95%置信区间
265
- # diff_smp.plot()
266
- #
267
- # ## 显示用于校正的温度曲线
268
- # diff_smp.plot_confidence()
269
-
270
- ## 显示实际样品的 libano 记录,并给出校正的温度曲线
271
- # diff_smp.plot_libano_log(r"C:\Users\Young\OneDrive\Documents\Libano Data\2024-03-26\202403260941-libano.log")
272
- # diff_smp.plot_libano_log(r"C:\Users\Young\OneDrive\00-Projects\【2】个人项目\2022-05论文课题\【3】分析测试\ArAr\01-VU实验数据和记录\20240717-Y53\202407171832-libano.log")
273
- # diff_smp.plot_libano_log(r"C:\Users\Young\OneDrive\00-Projects\【2】个人项目\2022-05论文课题\【3】分析测试\ArAr\01-VU实验数据和记录\20240714-Y52\202407142127-libano.log")
274
-
275
- name = "20240909-Y86"
276
- arr_name = "20240909_24BY86"
277
-
278
- libano_log_path = f"C:\\Users\\Young\\OneDrive\\00-Projects\\【2】个人项目\\2022-05论文课题\\【3】分析测试\\ArAr\\01-VU实验数据和记录\\{name}\\Libano-log"
279
- # libano_log_path = r"C:\Users\Young\OneDrive\00-Projects\【2】个人项目\2022-05论文课题\【3】分析测试\ArAr\01-VU实验数据和记录\20240705-Y50\Libano-log"
280
- libano_log_path = [os.path.join(libano_log_path, i) for i in os.listdir(libano_log_path)]
281
- print(libano_log_path)
282
- helix_log_path = f"C:\\Users\\Young\\OneDrive\\00-Projects\\【2】个人项目\\2022-05论文课题\\【3】分析测试\\ArAr\\01-VU实验数据和记录\\{name}\\LogFiles"
283
- # helix_log_path = r"C:\Users\Young\OneDrive\00-Projects\【2】个人项目\2022-05论文课题\【3】分析测试\ArAr\01-VU实验数据和记录\20240621-Y56\LogFiles-20240621"
284
- helix_log_path = [os.path.join(helix_log_path, i) for i in os.listdir(helix_log_path)]
285
- print(helix_log_path)
286
-
287
- loc = f"C:\\Users\\Young\\OneDrive\\00-Projects\\【2】个人项目\\2022-05论文课题\\【3】分析测试\\ArAr\\01-VU实验数据和记录\\{name}"
288
- arr_path = f"C:\\Users\\Young\\OneDrive\\00-Projects\\【2】个人项目\\2022-05论文课题\\【3】分析测试\\ArAr\\01-VU实验数据和记录\\Arr Data\\{arr_name}.arr"
289
- diff_smp = ap.calc.diffusion_funcs.SmpTemperatureCalibration(libano_log_path=libano_log_path, helix_log_path=helix_log_path, arr_path=arr_path, loc=loc)
290
-
291
-
19
+ file_path = os.path.join(example_dir, r'22WHA0433.arr')
20
+ sample = ap.from_arr(file_path=file_path)
21
+ # file_path = os.path.join(example_dir, r'22WHA0433.age')
22
+ # sample = ap.from_age(file_path=file_path)
23
+ print(f"{file_path = }")
24
+ print(f"sample = from_arr(file_path=file_path)")
25
+ print(f"{sample.name() = }")
26
+ sample.name("new name")
27
+ print(f"{sample.name() = }")
28
+ print(f"{sample.help() = }")
29
+ print(f"{sample.parameters() = }")
30
+ print(f"{sample.parameters().to_df() = }")
31
+ print(sample.show_data())
32
+ print(sample.sample())
33
+ print(sample.blank().to_df().iloc[:, [1, 2, 3]])
292
34
 
293
- ### 梳理这些函数 用numba加速
294
35
 
295
36
  if __name__ == "__main__":
296
37
  test()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ararpy
3
- Version: 0.1.1
3
+ Version: 0.1.11
4
4
  Summary: A project for Ar-Ar geochronology
5
5
  Home-page: https://github.com/wuyangchn/ararpy.git
6
6
  Author: Yang Wu
@@ -1,5 +1,5 @@
1
1
  ararpy/__init__.py,sha256=XKlsgklkzGfvqQkt59y-UST9aVhgCf-eXpEDiaZaynQ,6725
2
- ararpy/test.py,sha256=wrXLWejJ7HEBIEy3Eq1Xt5LFd4r_5VM3gf9HtR_BTzo,12805
2
+ ararpy/test.py,sha256=jdHhBvMbvDlxi0o2eRVG99nsUBNDA-0s2bbGbnXweo8,1130
3
3
  ararpy/calc/__init__.py,sha256=kUjRuLE8TLuKOv3i976RnGJoEMj23QBZDu37LWs81U4,322
4
4
  ararpy/calc/age.py,sha256=CUex9UxZbYinl9ypd7o86R3VRQFzahku3gW__fBeoss,5811
5
5
  ararpy/calc/arr.py,sha256=ntu6p3lUcF654SxLnFNrToLubXRWl101LRNFVJFulTQ,14871
@@ -38,22 +38,23 @@ ararpy/files/calc_file.py,sha256=b4bzPsoVD9y5wDqFw-2HmhK6Rd7qwufnEjaYz_FLxos,278
38
38
  ararpy/files/new_file.py,sha256=efblARIBROVLWS2w3-98BxLX5VZ8grRpiTkJFtf_rAk,214
39
39
  ararpy/files/raw_file.py,sha256=B2k4RjAp4EViwHKv6CbI5400Liaa7OW_eBjGSPlN9Ek,22768
40
40
  ararpy/files/xls.py,sha256=8ibT4ZRY2grK34ikKm1pDmlWFlVTgDL7vSMO6mphzrY,702
41
- ararpy/smp/__init__.py,sha256=Go-NQjPgDOrIqYOuRCHAeCgx5xBGtAf3rzyECt56gJA,472
41
+ ararpy/smp/__init__.py,sha256=k6_fa27UJsQK7K7oC5GYlwMo6l0Xd8af3QtOrZz2XJk,478
42
42
  ararpy/smp/basic.py,sha256=1OgPXk-2OysJOZ9e_HuqB__fp3TNm844y0KKSlF5Wz0,21405
43
43
  ararpy/smp/calculation.py,sha256=JXo6vS-HcBhOe7b8OMLds-Sn9vofFjV6maY5u3E-X3c,2793
44
44
  ararpy/smp/consts.py,sha256=XIdjdz8cYxspG2jMnoItdlUsxr3hKbNFJjMZJh1bpzw,393
45
45
  ararpy/smp/corr.py,sha256=3lvs-2A3WjK_yfRnQRCG1Tb_QNhI4j82HU6a5OAN4Q8,23402
46
46
  ararpy/smp/diffusion_funcs.py,sha256=u7cEH7sac5tw0Z9Yvh7AuH93ZYEENJVtZ3Npni8dWUE,167616
47
47
  ararpy/smp/export.py,sha256=MBcisVfPwmdMyYqE7Tm3oLAMsVA5Rk0fl3Tqn0LxouI,78231
48
+ ararpy/smp/info.py,sha256=iKUELm-BuUduDlJKC1d8tKKNHbwwbNmhUg2pi6bcBvA,489
48
49
  ararpy/smp/initial.py,sha256=nZNrV4fv_PlNXYfqqIOOOkcQjnSOTLymVpJyJ9d_QtM,15359
49
50
  ararpy/smp/json.py,sha256=87zMMopD5eL3VsemDYTEAfhSWXO_1Z7Y782S4GR2UUs,1740
50
51
  ararpy/smp/plots.py,sha256=s6xDZyxeGl512Wn4knquhzFeECucZCWNAsfI70OInqI,31362
51
52
  ararpy/smp/raw.py,sha256=KtAmzTAwCDK4x1dRgvwj2TbOzHRv7LFwaU2hHCknF3c,6173
52
- ararpy/smp/sample.py,sha256=aRTrIpJTgj67-QexJZNH-Z2a-nkOTAO5rlR3wLgqjfY,54607
53
+ ararpy/smp/sample.py,sha256=S1vgt0LRihcAiqpXhuLLJnkft3kVp0QwzjH_JQkMyc0,54611
53
54
  ararpy/smp/style.py,sha256=NZwTeodhtHBBdCyjvupF64nh2B5EDdMHzlT8oE360zg,6746
54
55
  ararpy/smp/table.py,sha256=fyITVbj0JrPoB4SPW4dHoJl2jliKEZ_HpS2FSF9FQx4,6274
55
- ararpy-0.1.1.dist-info/LICENSE,sha256=cvG5t_C1qY_zUyJI7sNOa7gCArdngNPaOrfujl2LYuc,1085
56
- ararpy-0.1.1.dist-info/METADATA,sha256=BHMmwMCYAge-00gmPor6gseIYpjtqavxbQZ5YdpWfxQ,24330
57
- ararpy-0.1.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
58
- ararpy-0.1.1.dist-info/top_level.txt,sha256=9iTpsPCYuRYq09yQTk9d2lqB8JtTEOmbN-IcGB-K3vY,7
59
- ararpy-0.1.1.dist-info/RECORD,,
56
+ ararpy-0.1.11.dist-info/LICENSE,sha256=cvG5t_C1qY_zUyJI7sNOa7gCArdngNPaOrfujl2LYuc,1085
57
+ ararpy-0.1.11.dist-info/METADATA,sha256=uLONl17cQulcXUYmJ4BvhpxHyYrhIOs3i8Z9uOb6zD0,24331
58
+ ararpy-0.1.11.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
59
+ ararpy-0.1.11.dist-info/top_level.txt,sha256=9iTpsPCYuRYq09yQTk9d2lqB8JtTEOmbN-IcGB-K3vY,7
60
+ ararpy-0.1.11.dist-info/RECORD,,