ararpy 0.1.22__tar.gz → 0.1.25__tar.gz

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.
Files changed (74) hide show
  1. {ararpy-0.1.22 → ararpy-0.1.25}/PKG-INFO +1 -1
  2. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/__init__.py +2 -2
  3. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/regression.py +28 -43
  4. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/files/raw_file.py +20 -26
  5. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/sample.py +15 -10
  6. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy.egg-info/PKG-INFO +1 -1
  7. {ararpy-0.1.22 → ararpy-0.1.25}/setup.py +1 -1
  8. {ararpy-0.1.22 → ararpy-0.1.25}/LICENSE +0 -0
  9. {ararpy-0.1.22 → ararpy-0.1.25}/README.md +0 -0
  10. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/__init__.py +0 -0
  11. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/age.py +0 -0
  12. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/arr.py +0 -0
  13. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/basic.py +0 -0
  14. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/corr.py +0 -0
  15. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/err.py +0 -0
  16. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/histogram.py +0 -0
  17. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/isochron.py +0 -0
  18. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/jvalue.py +0 -0
  19. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/plot.py +0 -0
  20. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/raw_funcs.py +0 -0
  21. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/calc/spectra.py +0 -0
  22. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/022_VU124-M11a.ahd +0 -0
  23. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/20WHA0103.age +0 -0
  24. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/22WHA0078.xls +0 -0
  25. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/22WHA0433.age +0 -0
  26. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/22WHA0433.arr +0 -0
  27. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/22WHA0433.full.xls +0 -0
  28. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/24WHN0001-51-592.XLS +0 -0
  29. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/AHD.input-filter +0 -0
  30. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/ArAr.calc +0 -0
  31. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/ArArCALC.age +0 -0
  32. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/NGX-600 - Copy.TXT +0 -0
  33. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/NGX-600.TXT +0 -0
  34. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/NGX-XLS.input-filter +0 -0
  35. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/Qtegra-exported-xls.input-filter +0 -0
  36. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/S01-239.csv +0 -0
  37. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/WH01.irra +0 -0
  38. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/WHA.pdf +0 -0
  39. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/raw_example.xls +0 -0
  40. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/examples/sample-default.smp +0 -0
  41. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/files/__init__.py +0 -0
  42. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/files/arr_file.py +0 -0
  43. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/files/basic.py +0 -0
  44. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/files/calc_file.py +0 -0
  45. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/files/new_file.py +0 -0
  46. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/files/xls.py +0 -0
  47. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/EXPORT_TO_PDF_DATA_PROPERTIES.py +0 -0
  48. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/__init__.py +0 -0
  49. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/basic.py +0 -0
  50. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/calculation.py +0 -0
  51. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/consts.py +0 -0
  52. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/corr.py +0 -0
  53. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/diffusion_funcs.py +0 -0
  54. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/export.py +0 -0
  55. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/info.py +0 -0
  56. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/initial.py +0 -0
  57. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/json.py +0 -0
  58. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/plots.py +0 -0
  59. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/raw.py +0 -0
  60. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/style.py +0 -0
  61. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/smp/table.py +0 -0
  62. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/test.py +0 -0
  63. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/thermo/__init__.py +0 -0
  64. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/thermo/arrhenius.py +0 -0
  65. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/thermo/atomic_level_random_walk.py +0 -0
  66. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy/thermo/basic.py +0 -0
  67. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy.egg-info/SOURCES.txt +0 -0
  68. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy.egg-info/dependency_links.txt +0 -0
  69. {ararpy-0.1.22 → ararpy-0.1.25}/ararpy.egg-info/top_level.txt +0 -0
  70. {ararpy-0.1.22 → ararpy-0.1.25}/setup.cfg +0 -0
  71. {ararpy-0.1.22 → ararpy-0.1.25}/tests/test.py +0 -0
  72. {ararpy-0.1.22 → ararpy-0.1.25}/tests/test2.py +0 -0
  73. {ararpy-0.1.22 → ararpy-0.1.25}/tests/test_error_correlation.py +0 -0
  74. {ararpy-0.1.22 → ararpy-0.1.25}/tests/test_regression_methods.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ararpy
3
- Version: 0.1.22
3
+ Version: 0.1.25
4
4
  Summary: A project for Ar-Ar geochronology
5
5
  Home-page: https://github.com/wuyangchn/ararpy.git
6
6
  Author: Yang Wu
@@ -16,10 +16,10 @@ from . import calc, smp, files, thermo, test
16
16
  """ Information """
17
17
 
18
18
  name = 'ararpy'
19
- version = '0.1.22'
19
+ version = '0.1.25'
20
20
  __version__ = version
21
21
  full_version = version
22
- last_update = '2024-03-28'
22
+ last_update = '2024-05-20'
23
23
 
24
24
  """ ArArPy Functions """
25
25
 
@@ -794,39 +794,31 @@ def power(a0: list, a1: list):
794
794
  def _pow_func(x, a, b, c):
795
795
  return a * x ** b + c
796
796
 
797
- def _solve_pow(params):
797
+ def _residuals(params):
798
798
  a, b, c = params
799
- x, y = [0, 0, 0], [0, 0, 0]
800
- x[0] = sum(a1[:3]) / 3
801
- y[0] = sum(a0[:3]) / 3
802
- x[1] = sum(a1) / len(a1)
803
- y[1] = sum(a0) / len(a0)
804
- x[2] = sum(a1[-3:]) / 3
805
- y[2] = sum(a0[-3:]) / 3
806
- return np.array([
807
- _pow_func(x[0], a, b, c) - y[0],
808
- _pow_func(x[1], a, b, c) - y[1],
809
- _pow_func(x[2], a, b, c) - y[2],
810
- ])
811
-
812
- def _get_sum(a, b, c):
813
- y_predicted = [_pow_func(_x, a, b, c) for _x in a1]
814
- return sum([(y_predicted[i] - a0[i]) ** 2 for i in range(len(a0))])
799
+ return [_pow_func(xi, a, b, c) - yi for xi, yi in zip(a1, a0)]
800
+
801
+ def _sum_squared_error(params):
802
+ return sum(r**2 for r in _residuals(params))
815
803
 
816
804
  def _get_abc(b): # Return a, b, c given b based on linest regression
817
805
  f = linest(a0, [_x ** b for _x in a1])
818
806
  return f[5][1], b, f[0]
819
807
 
808
+ def _get_init():
809
+ f = linest(np.log(np.array(a0)), np.log(np.array(a1)))
810
+ return np.exp(f[0]), f[5][1], 0
811
+
820
812
  try:
821
- a, b, c = fsolve(func=_solve_pow, x0=np.array([1, 1, 1])) # initial estimate
813
+ a, b, c = _get_init() # initial estimate
822
814
  count = 0
823
815
  step = 0.01
824
816
  while count < 100:
825
817
  a, b, c = _get_abc(b)
826
- s = _get_sum(a, b, c)
818
+ s = _sum_squared_error([a, b, c])
827
819
  b_left, b_right = b - step * b, b + step * b
828
- s_left = _get_sum(*_get_abc(b_left))
829
- s_right = _get_sum(*_get_abc(b_right))
820
+ s_left = _sum_squared_error(_get_abc(b_left))
821
+ s_right = _sum_squared_error(_get_abc(b_right))
830
822
  if s_left > s > s_right:
831
823
  b = b_right
832
824
  continue
@@ -886,39 +878,32 @@ def exponential(a0: list, a1: list):
886
878
  def _exp_func(x, a, b, c):
887
879
  return a * b ** x + c
888
880
 
889
- def _solve_exp(params):
881
+ def _residuals(params):
890
882
  a, b, c = params
891
- x, y = [0, 0, 0], [0, 0, 0]
892
- x[0] = sum(a1[:3]) / 3
893
- y[0] = sum(a0[:3]) / 3
894
- x[1] = sum(a1) / len(a1)
895
- y[1] = sum(a0) / len(a0)
896
- x[2] = sum(a1[-3:]) / 3
897
- y[2] = sum(a0[-3:]) / 3
898
- return np.array([
899
- _exp_func(x[0], a, b, c) - y[0],
900
- _exp_func(x[1], a, b, c) - y[1],
901
- _exp_func(x[2], a, b, c) - y[2],
902
- ])
903
-
904
- def _get_sum(a, b, c):
905
- y_predicted = [_exp_func(_x, a, b, c) for _x in a1]
906
- return sum([(y_predicted[i] - a0[i]) ** 2 for i in range(len(a0))])
883
+ return [_exp_func(xi, a, b, c) - yi for xi, yi in zip(a1, a0)]
884
+
885
+ def _sum_squared_error(params):
886
+ return sum(r**2 for r in _residuals(params))
907
887
 
908
888
  def _get_ac(b):
909
- f = linest(a0, [b ** _x for _x in a1])
889
+ f = linest(a0, [b ** xi for xi in a1])
910
890
  return f[5][1], b, f[0]
911
891
 
892
+ def _get_init():
893
+ f = linest(np.log(np.array(a0)), np.array(a1))
894
+ return np.exp(f[0]), np.exp(f[5][1]), 0
895
+
912
896
  try:
913
- a, b, c = fsolve(_solve_exp, np.array([1, 1, 1]))
897
+ a, b, c = _get_init()
898
+ # a, b, c = minimize(_sum_squared_error, [a, b, c], method="Nelder-Mead").x # 优化方法
914
899
  count = 0
915
900
  step = 0.01
916
901
  while count < 100:
917
902
  a, b, c = _get_ac(b)
918
- s = _get_sum(a, b, c)
903
+ s = _sum_squared_error([a, b, c])
919
904
  b_left, b_right = b - step * b, b + step * b
920
- s_left = _get_sum(*_get_ac(b_left))
921
- s_right = _get_sum(*_get_ac(b_right))
905
+ s_left = _sum_squared_error(_get_ac(b_left))
906
+ s_right = _sum_squared_error(_get_ac(b_right))
922
907
  if s_left > s > s_right:
923
908
  b = b_right
924
909
  continue
@@ -224,24 +224,23 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
224
224
 
225
225
  timezone = sample_info_index[3] if sample_info_index[3] != "" else "utc"
226
226
  while True: # measurment steps sloop
227
+
228
+ # all text information
229
+ options = get_sample_info(file_contents, optional_info_index, default="", base=[1, 1 - idx, 1])
230
+
227
231
  # Zero datetime
228
232
  try:
229
233
  if check_box_index[2]: # input_filter[134]: date in one string
230
- zero_date = datetime_parse(
231
- get_item(file_contents, sample_info_index[16:19], base=[1, 1 - idx, 1]), sample_info_index[1])
234
+ zero_date = datetime_parse(options.get('ZeroYear'), sample_info_index[1])
232
235
  else:
233
- zero_date = datetime(year=get_item(file_contents, sample_info_index[16:19], base=1),
234
- month=get_item(file_contents, sample_info_index[22:25], base=[1, 1 - idx, 1]),
235
- day=get_item(file_contents, sample_info_index[28:31], base=[1, 1 - idx, 1]))
236
+ zero_date = datetime(year=options.get('ZeroYear'), month=options.get('ZeroMon'),
237
+ day=options.get('ZeroDay'))
236
238
 
237
239
  if check_box_index[3]: # input_filter[135]: time in one string
238
- zero_time = datetime_parse(
239
- get_item(file_contents, sample_info_index[19:22], base=[1, 1 - idx, 1]), sample_info_index[2])
240
+ zero_time = datetime_parse(options.get('ZeroHour'), sample_info_index[2])
240
241
  else:
241
- zero_time = datetime(year=2020, month=12, day=31,
242
- hour=get_item(file_contents, sample_info_index[19:22], base=[1, 1 - idx, 1]),
243
- minute=get_item(file_contents, sample_info_index[25:28], base=[1, 1 - idx, 1]),
244
- second=get_item(file_contents, sample_info_index[31:34], base=[1, 1 - idx, 1]))
242
+ zero_time = datetime(year=2020, month=12, day=31, hour=options.get('ZeroHour'),
243
+ minute=options.get('ZeroMin'), second=options.get('ZeroSec'))
245
244
 
246
245
  zero_datetime = datetime(
247
246
  zero_date.year, zero_date.month, zero_date.day, zero_time.hour, zero_time.minute, zero_time.second)
@@ -251,16 +250,10 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
251
250
  # print(f"Cannot parse zero datetime")
252
251
  zero_datetime = datetime(1970, 1, 1, 0, 0, 0).isoformat(timespec='seconds')
253
252
 
254
- # Experiment name
255
- try:
256
- experiment_name = get_item(file_contents, sample_info_index[4:7], default="", base=[1, 1 - idx, 1])
257
- except (TypeError, ValueError, IndexError):
258
- # print(f"Cannot parse experiment name")
259
- experiment_name = "ExpName"
260
-
261
253
  # Step name
262
254
  try:
263
- step_name = get_item(file_contents, sample_info_index[7:10], default="", base=[1, 1 - idx, 1]) if input_filter[7] > 0 else ""
255
+ step_name = options.get('StepName')
256
+ experiment_name = options.get('ExpName')
264
257
  if check_box_index[1] and sample_info_index[0].strip() != "":
265
258
  _res = string_parser(sample_info_index[0], file_name)
266
259
  if _res is not None:
@@ -274,12 +267,13 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
274
267
  raise ValueError(f"Step name not found")
275
268
  except (TypeError, ValueError, IndexError):
276
269
  # When parsing the step name fails, the end of the file has been reached
277
- raise
278
-
279
- # other information
280
- options = get_sample_info(file_contents, optional_info_index, default="", base=[1, 1 - idx, 1])
270
+ # raise
271
+ break
272
+ else:
273
+ options.update({'StepName': step_name})
274
+ options.update({'ExpName': experiment_name})
281
275
 
282
- current_step = [[step_name, zero_datetime, experiment_name, options]]
276
+ current_step = [[step_name, zero_datetime, options]]
283
277
 
284
278
  break_num = 0
285
279
  cycle_num = 0
@@ -370,7 +364,7 @@ def get_sample_info(file_contents: list, index_list: list, default="", base: Uni
370
364
  sample_info.update({
371
365
  "ExpName": get_item(file_contents, index_list[0:3], default=default, base=base),
372
366
  "StepName": get_item(file_contents, index_list[3:6], default=default, base=base),
373
- "SmpType": get_item(file_contents, index_list[6:9], default=default, base=base),
367
+ "StepType": get_item(file_contents, index_list[6:9], default=default, base=base),
374
368
  "StepLabel": get_item(file_contents, index_list[9:12], default=default, base=base),
375
369
  "ZeroYear": get_item(file_contents, index_list[12:15], default=default, base=base), # year
376
370
  "ZeroHour": get_item(file_contents, index_list[15:18], default=default, base=base), # hour
@@ -402,7 +396,7 @@ def get_sample_info(file_contents: list, index_list: list, default="", base: Uni
402
396
  "StdAgeSig": get_item(file_contents, index_list[93:96], default=default, base=base),
403
397
  # "Experiment Name": get_item(file_contents, sample_info_index[0:3], default=default, base=base),
404
398
  # "Step Name": get_item(file_contents, sample_info_index[3:6], default=default, base=base),
405
- # "Sample Type": get_item(file_contents, sample_info_index[6:9], default=default, base=base),
399
+ # "Step Type": get_item(file_contents, sample_info_index[6:9], default=default, base=base),
406
400
  # "Step Label": get_item(file_contents, sample_info_index[9:12], default=default, base=base),
407
401
  # "Zero Date Year": get_item(file_contents, sample_info_index[12:15], default=default, base=base),
408
402
  # "Zero Time Hour": get_item(file_contents, sample_info_index[15:18], default=default, base=base),
@@ -1110,27 +1110,33 @@ class Plot:
1110
1110
 
1111
1111
  class Sequence:
1112
1112
  def __init__(self, index=None, data=None, flag=None, name=None, datetime=None,
1113
- type_str=None, results=None, coefficients=None, fitting_method=None,
1113
+ type_str=None, label=None, results=None, coefficients=None, fitting_method=None,
1114
1114
  is_estimated=False, options=None, **kwargs):
1115
1115
  if options is None:
1116
1116
  options = {}
1117
- self.index = index
1118
1117
  if name is None or not isinstance(name, str):
1119
- name = ""
1120
- self.name = name.strip()
1121
- self.datetime = datetime
1122
- self.data = data
1118
+ name = options.get('StepName', "")
1123
1119
  # flag is to check if the data point is selected
1124
1120
  if flag is None and data is not None:
1125
1121
  flag = [[j if i == 0 else True for i, j in enumerate(_m)] for _m in data]
1126
- self.flag = flag
1127
- self.type_str = type_str
1122
+ if type_str is None:
1123
+ type_str = options.get('StepType', "Unknown")
1124
+ if label is None:
1125
+ label = options.get('StepLabel', "")
1128
1126
  if results is None:
1129
1127
  results = []
1130
1128
  if fitting_method is None:
1131
1129
  fitting_method = []
1132
1130
  if coefficients is None:
1133
1131
  coefficients = []
1132
+
1133
+ self.index = index
1134
+ self.datetime = datetime
1135
+ self.data = data
1136
+ self.name = name.strip()
1137
+ self.flag = flag
1138
+ self.type_str = type_str.strip()
1139
+ self.label = str(label).strip()
1134
1140
  self.results = results
1135
1141
  self.coefficients = coefficients
1136
1142
  self.fitting_method = fitting_method
@@ -1211,9 +1217,8 @@ class RawData:
1211
1217
  name=item[0][0] if isinstance(item[0][0], str) and item[0][0] != '' else f"{self.name}-{index + 1:02d}",
1212
1218
  data=item[1:],
1213
1219
  datetime=item[0][1],
1214
- type_str=item[0][2],
1215
1220
  fitting_method=[*kwargs.get("fitting_method", [0] * 5)],
1216
- options=item[0][3]
1221
+ options=item[0][2]
1217
1222
  ) for index, item in enumerate(data)]
1218
1223
  else:
1219
1224
  self.sequence: List[Sequence] = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ararpy
3
- Version: 0.1.22
3
+ Version: 0.1.25
4
4
  Summary: A project for Ar-Ar geochronology
5
5
  Home-page: https://github.com/wuyangchn/ararpy.git
6
6
  Author: Yang Wu
@@ -16,7 +16,7 @@ long_description = (here / 'README.md').read_text(encoding='utf-8')
16
16
 
17
17
  setuptools.setup(
18
18
  name='ararpy', #
19
- version='0.1.22', # version
19
+ version='0.1.25', # version
20
20
  author='Yang Wu',
21
21
  author_email='wuycug@hotmail.com',
22
22
  description='A project for Ar-Ar geochronology', # short description
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes