ararpy 0.0.24__py3-none-any.whl → 0.1.1__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/sample.py CHANGED
@@ -22,16 +22,22 @@ from types import MethodType
22
22
  import pandas as pd
23
23
 
24
24
  SAMPLE_INTERCEPT_HEADERS = [
25
- 'Sequence', '', '\u00B3\u2076Ar', '1\u03C3', '\u00B3\u2077Ar', '1\u03C3',
26
- '\u00B3\u2078Ar', '1\u03C3', '\u00B3\u2079Ar', '1\u03C3', '\u2074\u2070Ar', '1\u03C3'
25
+ 'Sequence', '', # 0-1
26
+ '\u00B3\u2076Ar', '1\u03C3', '\u00B3\u2077Ar', '1\u03C3', # 2-5
27
+ '\u00B3\u2078Ar', '1\u03C3', '\u00B3\u2079Ar', '1\u03C3', # 6-9
28
+ '\u2074\u2070Ar', '1\u03C3', # 10-11
27
29
  ]
28
30
  BLANK_INTERCEPT_HEADERS = [
29
- 'Sequence', '', '\u00B3\u2076Ar', '1\u03C3', '\u00B3\u2077Ar', '1\u03C3',
30
- '\u00B3\u2078Ar', '1\u03C3', '\u00B3\u2079Ar', '1\u03C3', '\u2074\u2070Ar', '1\u03C3'
31
+ 'Sequence', '', # 0-1
32
+ '\u00B3\u2076Ar', '1\u03C3', '\u00B3\u2077Ar', '1\u03C3', # 2-5
33
+ '\u00B3\u2078Ar', '1\u03C3', '\u00B3\u2079Ar', '1\u03C3', # 6-9
34
+ '\u2074\u2070Ar', '1\u03C3', # 10-11
31
35
  ]
32
36
  CORRECTED_HEADERS = [
33
- 'Sequence', '', '\u00B3\u2076Ar', '1\u03C3', '\u00B3\u2077Ar', '1\u03C3',
34
- '\u00B3\u2078Ar', '1\u03C3', '\u00B3\u2079Ar', '1\u03C3', '\u2074\u2070Ar', '1\u03C3'
37
+ 'Sequence', '', # 0-1
38
+ '\u00B3\u2076Ar', '1\u03C3', '\u00B3\u2077Ar', '1\u03C3', # 2-5
39
+ '\u00B3\u2078Ar', '1\u03C3', '\u00B3\u2079Ar', '1\u03C3', # 6-9
40
+ '\u2074\u2070Ar', '1\u03C3', # 10-11
35
41
  ]
36
42
  DEGAS_HEADERS = [
37
43
  'Sequence', '', # 0-1
@@ -42,16 +48,20 @@ DEGAS_HEADERS = [
42
48
  '\u00B3\u2078Ar[K]', '1\u03C3', '\u00B3\u2078Ar[Ca]', '1\u03C3', # 18-21
43
49
  '\u00B3\u2079Ar[K]', '1\u03C3', '\u00B3\u2079Ar[Ca]', '1\u03C3', # 22-25
44
50
  '\u2074\u2070Ar[r]', '1\u03C3', '\u2074\u2070Ar[a]', '1\u03C3', # 26-29
45
- '\u2074\u2070Ar[c]', '1\u03C3', '\u2074\u2070Ar[K]', '1\u03C3' # 29-32
51
+ '\u2074\u2070Ar[c]', '1\u03C3', '\u2074\u2070Ar[K]', '1\u03C3' # 30-33
46
52
  ]
47
53
  PUBLISH_TABLE_HEADERS = [
48
- 'Sequence', '', '\u00B3\u2076Ar[a]', '\u00B3\u2077Ar[Ca]', '\u00B3\u2078Ar[Cl]',
49
- '\u00B3\u2079Ar[K]', '\u2074\u2070Ar[r]', 'Apparent Age', '1\u03C3', '\u2074\u2070Arr%',
50
- '\u00B3\u2079ArK%', 'Ca/K', '1\u03C3'
54
+ 'Sequence', '', # 0-1
55
+ '\u00B3\u2076Ar[a]', '\u00B3\u2077Ar[Ca]', '\u00B3\u2078Ar[Cl]', # 2-4
56
+ '\u00B3\u2079Ar[K]', '\u2074\u2070Ar[r]', # 5-6
57
+ 'Apparent Age', '1\u03C3', '\u2074\u2070Arr%', '\u00B3\u2079ArK%', # 7-10
58
+ 'Ca/K', '1\u03C3', # 11-12
51
59
  ]
52
60
  SPECTRUM_TABLE_HEADERS = [
53
- 'Sequence', '', '\u2074\u2070Ar/\u00B3\u2079Ar', '1\u03C3', 'Apparent Age',
54
- '1\u03C3', '1\u03C3', '1\u03C3', '\u2074\u2070Ar[r]%', '\u00B3\u2079Ar[K]%'
61
+ 'Sequence', '', # 0-1
62
+ '\u2074\u2070Ar/\u00B3\u2079Ar', '1\u03C3', # 2-3
63
+ 'Apparent Age', '1\u03C3', '1\u03C3', '1\u03C3', # 4-7
64
+ '\u2074\u2070Ar[r]%', '\u00B3\u2079Ar[K]%', # 8-9
55
65
  ]
56
66
  ISOCHRON_TABLE_HEADERS = [
57
67
  'Sequence', '', 'Mark', # 0-2
@@ -124,6 +134,9 @@ TOTAL_PARAMS_HEADERS = [
124
134
  'Isotopic Errors', # 122
125
135
  'Parameter Errors', # 123
126
136
  'Plot Errors', # 124
137
+ 'Heating Time (s)', # 125
138
+ 'Heating Actual Temp (C)', # 126
139
+ 'Heating AT 1\u03C3', # 127
127
140
  ]
128
141
 
129
142
  SAMPLE_INTERCEPT_SHORT_HEADERS = [
@@ -229,6 +242,9 @@ TOTAL_PARAMS_SHORT_HEADERS = [
229
242
  'IsotopicErrors', # 122
230
243
  'ParameterErrors', # 123
231
244
  'PlotErrors', # 124
245
+ 'HeatingTime', # 125
246
+ 'HeatingActualTemp', # 126
247
+ 'HeatingActualTempError', # 127
232
248
  ]
233
249
 
234
250
  DEFAULT_PLOT_STYLES = {
@@ -715,7 +731,7 @@ DEFAULT_PLOT_STYLES = {
715
731
  },
716
732
  }
717
733
 
718
- VERSION = '20231208'
734
+ VERSION = '20240730'
719
735
 
720
736
  NAMED_DICT = {
721
737
  "unknown": {"header": SAMPLE_INTERCEPT_HEADERS.copy()},
@@ -815,7 +831,8 @@ class Sample:
815
831
  # self.__version = '20230724' # change header
816
832
  # self.__version = '20230730' # delete calcparams attribute
817
833
  # self.__version = '20230827' # using merge smp to update arr version
818
- self.__version = '20231116' # change smp parameters
834
+ # self.__version = '20231116' # change smp parameters
835
+ self.__version = '20240730' # change parameter table for thermo calculation
819
836
 
820
837
  @property
821
838
  def version(self):
@@ -859,7 +876,7 @@ class Sample:
859
876
 
860
877
  def set_selection(self): ...
861
878
 
862
- def update_table(self): ...
879
+ def update_table(self, data: list, table_id: name): ...
863
880
 
864
881
  def unknown(self) -> ArArData: ...
865
882
 
@@ -901,6 +918,8 @@ class Sample:
901
918
 
902
919
  def set_info(self, info: dict): ...
903
920
 
921
+ def get_comp(self, name: str):...
922
+
904
923
  def to_pdf(self, file_path: str, figure: str = "figure_3"): ...
905
924
 
906
925
 
@@ -1031,19 +1050,12 @@ class Plot:
1031
1050
  setattr(self, k, v)
1032
1051
 
1033
1052
 
1034
- class Info:
1035
- def __init__(self, id='', name='', type='Info', **kwargs):
1036
- self.id = id
1037
- self.name = name
1038
- self.type = type
1039
- for k, v in kwargs.items():
1040
- setattr(self, k, v)
1041
-
1042
-
1043
1053
  class Sequence:
1044
1054
  def __init__(self, index=None, data=None, flag=None, name=None, datetime=None,
1045
1055
  type_str=None, results=None, coefficients=None, fitting_method=None,
1046
- is_estimated=False, **kwargs):
1056
+ is_estimated=False, options=None, **kwargs):
1057
+ if options is None:
1058
+ options = {}
1047
1059
  self.index = index
1048
1060
  if name is None or not isinstance(name, str):
1049
1061
  name = ""
@@ -1065,6 +1077,8 @@ class Sequence:
1065
1077
  self.coefficients = coefficients
1066
1078
  self.fitting_method = fitting_method
1067
1079
  self.is_estimated = is_estimated
1080
+ self.is_removed = False
1081
+ self.options = options
1068
1082
 
1069
1083
  for k, v in kwargs.items():
1070
1084
  if hasattr(self, k) and type(getattr(self, k)) is MethodType:
@@ -1109,8 +1123,8 @@ class Sequence:
1109
1123
 
1110
1124
 
1111
1125
  class RawData:
1112
- def __init__(self, id='', name='', type='raw', data=None, sequence_num=0,
1113
- isotopic_num=10, source=None, sequence=None, **kwargs):
1126
+ def __init__(self, id='', name='', type='Unknown', data=None, sequence_num=0,
1127
+ isotopic_num=10, source=None, sequence=None, unit='fA', **kwargs):
1114
1128
  """
1115
1129
  Parameters
1116
1130
  ----------
@@ -1126,6 +1140,7 @@ class RawData:
1126
1140
  self.name = name
1127
1141
  self.type = type
1128
1142
  self.source = source
1143
+ self.unit = unit
1129
1144
  self.isotopic_num = isotopic_num
1130
1145
  self.sequence_num = sequence_num
1131
1146
  self.interpolated_blank = None
@@ -1133,7 +1148,7 @@ class RawData:
1133
1148
  self.sequence: List[Sequence] = [
1134
1149
  Sequence(index=index, name=item[0][0] if isinstance(item[0][0], str) and item[0][
1135
1150
  0] != '' else f"{self.name}-{index + 1:02d}", data=item[1:], datetime=item[0][1], type_str=item[0][2],
1136
- fitting_method=[0] * 5)
1151
+ fitting_method=[0] * 5, options=item[0][3])
1137
1152
  for index, item in enumerate(data)]
1138
1153
  else:
1139
1154
  self.sequence: List[Sequence] = []
ararpy/smp/style.py CHANGED
@@ -16,7 +16,6 @@ from .. import calc
16
16
  from . import (sample as samples, basic, initial, plots, )
17
17
 
18
18
  Sample = samples.Sample
19
- Info = samples.Info
20
19
  Table = samples.Table
21
20
  Plot = samples.Plot
22
21
 
@@ -49,8 +48,8 @@ def set_plot_style(smp: Sample):
49
48
  reset_plot_scale(smp)
50
49
  # Reset isochron data
51
50
  plots.reset_isochron_line_data(smp)
52
- # Auto position of text
53
- reset_text_position(smp)
51
+ # Auto position and contents of texts
52
+ reset_text(smp)
54
53
  # Set title, which are deleted in initializing
55
54
  suffix = f"{smp.Info.sample.name} {smp.Info.sample.material}"
56
55
  for figure_id, figure in basic.get_components(smp).items():
@@ -142,7 +141,7 @@ def reset_plot_scale(smp: Sample, only_figure: str = None):
142
141
  return xscale, yscale
143
142
 
144
143
 
145
- def reset_text_position(smp: Sample, only_figure: str = None):
144
+ def reset_text(smp: Sample, only_figure: str = None):
146
145
  """
147
146
  Reset text position to default, if only figure is defined, only this figure will be reset.
148
147
  Parameters
@@ -161,9 +160,11 @@ def reset_text_position(smp: Sample, only_figure: str = None):
161
160
  text_1 = basic.get_plot_set(figure, 'Text for Set 1')
162
161
  if text_1 is not None:
163
162
  setattr(text_1, 'pos', [20, 40])
163
+ setattr(text_1, 'text', "")
164
164
  text_2 = basic.get_plot_set(figure, 'Text for Set 2')
165
165
  if text_2 is not None:
166
166
  setattr(text_2, 'pos', [70, 40])
167
+ setattr(text_2, 'text', "")
167
168
 
168
169
 
169
170
  # =======================
ararpy/smp/table.py CHANGED
@@ -85,52 +85,103 @@ def update_handsontable(smp: Sample, data: list, id: str):
85
85
 
86
86
  def _strToBool(cols):
87
87
  bools_dict = {
88
- 'true': True, 'false': False, '1': True, '0': False, 'none': False,
88
+ 'true': True, 'false': False, 'True': True, 'False': False, '1': True, '0': False, 'none': False,
89
89
  }
90
90
  return [bools_dict.get(str(col).lower(), False) for col in cols]
91
91
  try:
92
92
  smp.SequenceName = data[0]
93
93
  except IndexError:
94
94
  pass
95
+
96
+ update_all_table = False
95
97
  try:
96
- smp.SequenceValue = data[1]
98
+ if data[1] != smp.SequenceValue:
99
+ smp.SequenceValue = data[1]
97
100
  except IndexError:
98
101
  pass
102
+ else:
103
+ update_all_table = True
104
+
99
105
  if id == '1': # 样品值
100
- data = _normalize_data(data, 12, 2)
106
+ data = _normalize_data(data, len(samples.SAMPLE_INTERCEPT_HEADERS), 2)
101
107
  smp.SampleIntercept = data
102
108
  elif id == '2': # 本底值
103
- data = _normalize_data(data, 12, 2)
109
+ data = _normalize_data(data, len(samples.BLANK_INTERCEPT_HEADERS), 2)
104
110
  smp.BlankIntercept = data
105
111
  elif id == '3': # 校正值
106
- data = _normalize_data(data, 12, 2)
112
+ data = _normalize_data(data, len(samples.CORRECTED_HEADERS), 2)
107
113
  smp.CorrectedValues = data
108
- elif id == '4': #
109
- data = _normalize_data(data, 34, 2)
114
+ elif id == '4': # Degas table
115
+ data = _normalize_data(data, len(samples.DEGAS_HEADERS), 2)
110
116
  smp.DegasValues = data
111
117
  elif id == '5': # 发行表
112
- data = _normalize_data(data, 13, 2)
118
+ data = _normalize_data(data, len(samples.PUBLISH_TABLE_HEADERS), 2)
113
119
  smp.PublishValues = data
114
120
  elif id == '6': # 年龄谱
115
- data = _normalize_data(data, 10, 2)
121
+ data = _normalize_data(data, len(samples.SPECTRUM_TABLE_HEADERS), 2)
116
122
  smp.ApparentAgeValues = data
117
123
  elif id == '7': # 等时线
118
124
  smp.IsochronMark = data[2]
119
- data = _normalize_data(data, 42, 3)
125
+ data = _normalize_data(data, len(samples.ISOCHRON_TABLE_HEADERS), 3)
120
126
  smp.IsochronValues = data
121
127
  smp.SelectedSequence1 = [
122
- i for i in range(len(smp.IsochronMark)) if smp.IsochronMark[i] == 1]
128
+ i for i in range(len(smp.IsochronMark)) if str(smp.IsochronMark[i]) == "1"]
123
129
  smp.SelectedSequence2 = [
124
- i for i in range(len(smp.IsochronMark)) if smp.IsochronMark[i] == 2]
130
+ i for i in range(len(smp.IsochronMark)) if str(smp.IsochronMark[i]) == "2"]
125
131
  smp.UnselectedSequence = [
126
132
  i for i in range(len(smp.IsochronMark)) if
127
133
  i not in smp.SelectedSequence1 + smp.SelectedSequence2]
134
+ #
135
+ smp.Info.results.selection[0]['data'] = smp.SelectedSequence1
136
+ smp.Info.results.selection[1]['data'] = smp.SelectedSequence2
137
+ smp.Info.results.selection[2]['data'] = smp.UnselectedSequence
128
138
  elif id == '8': # 总参数
129
- data = _normalize_data(data, 125, 2)
130
- data[103: 115] = [_strToBool(i) for i in data[103: 115]]
139
+ data = _normalize_data(data, len(samples.TOTAL_PARAMS_HEADERS), 2)
140
+ data[101: 112] = [_strToBool(i) for i in data[101: 112]]
131
141
  smp.TotalParam = data
132
142
  else:
133
143
  raise ValueError(f"{id = }, The table id is not supported.")
134
- update_table_data(smp, only_table=id) # Update data of tables after changes of a table
144
+ if update_all_table:
145
+ update_table_data(smp)
146
+ else:
147
+ update_table_data(smp, only_table=id) # Update data of tables after changes of a table
148
+
149
+
150
+ def update_data_from_table(smp: Sample, only_table: str = None):
151
+ """
152
+ Update table data
153
+ Parameters
154
+ ----------
155
+ smp
156
+ only_table
157
+
158
+ Returns
159
+ -------
160
+
161
+ """
162
+ for key, comp in basic.get_components(smp).items():
163
+ if not isinstance(comp, Table):
164
+ continue
165
+ if only_table is not None and key != only_table:
166
+ continue
167
+ if key == '1':
168
+ smp.SampleIntercept = calc.arr.transpose(comp.data)[2:]
169
+ elif key == '2':
170
+ smp.BlankIntercept = calc.arr.transpose(comp.data)[2:]
171
+ elif key == '3':
172
+ smp.CorrectedValues = calc.arr.transpose(comp.data)[2:]
173
+ elif key == '4':
174
+ smp.DegasValues = calc.arr.transpose(comp.data)[2:]
175
+ elif key == '5':
176
+ smp.PublishValues = calc.arr.transpose(comp.data)[2:]
177
+ elif key == '6':
178
+ smp.ApparentAgeValues = calc.arr.transpose(comp.data)[2:]
179
+ elif key == '7':
180
+ smp.IsochronValues = calc.arr.transpose(comp.data)[3:]
181
+ elif key == '8':
182
+ smp.TotalParam = calc.arr.transpose(comp.data)[2:]
183
+ else:
184
+ pass
185
+
135
186
 
136
187
 
ararpy/test.py CHANGED
@@ -10,26 +10,287 @@
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
+
13
229
 
14
230
 
15
231
  def test():
16
232
  example_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), r'examples')
17
233
  print(f"Running: ararpy.test()")
18
234
  print(f"============= Open an example .arr file =============")
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
- print(f"{sample.help = }")
27
- print(f"sample.parameters() = {sample.parameters()}")
28
- print(f"sample.parameters().to_df() = \n{sample.parameters().to_df()}")
29
- print(sample.show_data())
30
- print(sample.sample())
31
- print(sample.blank().to_df().iloc[:, [1, 2, 3]])
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
+
32
292
 
293
+ ### 梳理这些函数 用numba加速
33
294
 
34
295
  if __name__ == "__main__":
35
296
  test()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ararpy
3
- Version: 0.0.24
3
+ Version: 0.1.1
4
4
  Summary: A project for Ar-Ar geochronology
5
5
  Home-page: https://github.com/wuyangchn/ararpy.git
6
6
  Author: Yang Wu