ararpy 0.1.33__tar.gz → 0.1.35__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 (81) hide show
  1. {ararpy-0.1.33 → ararpy-0.1.35}/PKG-INFO +1 -1
  2. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/__init__.py +2 -2
  3. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/basic.py +3 -4
  4. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/plot.py +1 -2
  5. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/regression.py +2 -2
  6. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/files/basic.py +0 -22
  7. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/files/calc_file.py +6 -6
  8. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/files/raw_file.py +8 -8
  9. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/diffusion_funcs.py +1 -1
  10. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/export.py +32 -32
  11. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/plots.py +3 -3
  12. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/raw.py +7 -11
  13. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy.egg-info/PKG-INFO +1 -1
  14. {ararpy-0.1.33 → ararpy-0.1.35}/setup.py +1 -1
  15. {ararpy-0.1.33 → ararpy-0.1.35}/LICENSE +0 -0
  16. {ararpy-0.1.33 → ararpy-0.1.35}/README.md +0 -0
  17. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/Example - Check arr.py +0 -0
  18. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/Example - Granite Cooling History.py +0 -0
  19. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/Example - Plot temperature calibration.py +0 -0
  20. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/Example - Show MDD results.py +0 -0
  21. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/Example - Show all Kfs age spectra.py +0 -0
  22. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/Example - Show random walk results.py +0 -0
  23. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/Example - Tc calculation.py +0 -0
  24. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/__init__.py +0 -0
  25. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/age.py +0 -0
  26. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/arr.py +0 -0
  27. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/corr.py +0 -0
  28. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/err.py +0 -0
  29. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/histogram.py +0 -0
  30. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/isochron.py +0 -0
  31. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/jvalue.py +0 -0
  32. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/raw_funcs.py +0 -0
  33. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/calc/spectra.py +0 -0
  34. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/022_VU124-M11a.ahd +0 -0
  35. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/20WHA0103.age +0 -0
  36. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/22WHA0078.xls +0 -0
  37. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/22WHA0433.age +0 -0
  38. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/22WHA0433.arr +0 -0
  39. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/22WHA0433.full.xls +0 -0
  40. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/24WHN0001-51-592.XLS +0 -0
  41. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/AHD.input-filter +0 -0
  42. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/ArAr.calc +0 -0
  43. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/ArArCALC.age +0 -0
  44. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/NGX-600 - Copy.TXT +0 -0
  45. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/NGX-600.TXT +0 -0
  46. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/NGX-XLS.input-filter +0 -0
  47. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/Qtegra-exported-xls.input-filter +0 -0
  48. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/S01-239.csv +0 -0
  49. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/WH01.irra +0 -0
  50. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/WHA.pdf +0 -0
  51. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/raw_example.xls +0 -0
  52. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/examples/sample-default.smp +0 -0
  53. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/files/__init__.py +0 -0
  54. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/files/arr_file.py +0 -0
  55. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/files/new_file.py +0 -0
  56. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/files/xls.py +0 -0
  57. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/EXPORT_TO_PDF_DATA_PROPERTIES.py +0 -0
  58. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/__init__.py +0 -0
  59. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/basic.py +0 -0
  60. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/calculation.py +0 -0
  61. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/consts.py +0 -0
  62. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/corr.py +0 -0
  63. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/info.py +0 -0
  64. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/initial.py +0 -0
  65. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/json.py +0 -0
  66. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/sample.py +0 -0
  67. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/style.py +0 -0
  68. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/smp/table.py +0 -0
  69. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/test.py +0 -0
  70. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/thermo/__init__.py +0 -0
  71. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/thermo/arrhenius.py +0 -0
  72. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/thermo/atomic_level_random_walk.py +0 -0
  73. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy/thermo/basic.py +0 -0
  74. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy.egg-info/SOURCES.txt +0 -0
  75. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy.egg-info/dependency_links.txt +0 -0
  76. {ararpy-0.1.33 → ararpy-0.1.35}/ararpy.egg-info/top_level.txt +0 -0
  77. {ararpy-0.1.33 → ararpy-0.1.35}/setup.cfg +0 -0
  78. {ararpy-0.1.33 → ararpy-0.1.35}/tests/test.py +0 -0
  79. {ararpy-0.1.33 → ararpy-0.1.35}/tests/test2.py +0 -0
  80. {ararpy-0.1.33 → ararpy-0.1.35}/tests/test_error_correlation.py +0 -0
  81. {ararpy-0.1.33 → ararpy-0.1.35}/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.33
3
+ Version: 0.1.35
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.33'
19
+ version = '0.1.35'
20
20
  __version__ = version
21
21
  full_version = version
22
- last_update = '2025-10-01'
22
+ last_update = '2025-12-02'
23
23
 
24
24
  """ ArArPy Functions """
25
25
 
@@ -10,8 +10,7 @@
10
10
  #
11
11
  """
12
12
  import copy
13
- import random
14
- import string
13
+ import secrets
15
14
  import numpy as np
16
15
  from scipy import stats
17
16
  from datetime import datetime, timezone, timedelta
@@ -100,8 +99,8 @@ def update_dicts(a: dict, b: dict):
100
99
  return res
101
100
 
102
101
 
103
- def get_random_digits(length: int = 7) -> str:
104
- return ''.join(random.choices(string.digits, k=length))
102
+ def get_random_string(length: int = 8) -> str:
103
+ return secrets.token_hex(max(int(length/2), 1))
105
104
 
106
105
 
107
106
  def monte_carlo(func, inputs, confidence_level, **kwargs):
@@ -53,9 +53,8 @@ def get_axis_scale(data: list, count=6, increment=None, extra_count=0, min_inter
53
53
  str(decimal.Decimal(int(interval / mag // min_interval) + min_interval) * decimal.Decimal(str(mag))))
54
54
  else:
55
55
  increment = decimal.Decimal(increment)
56
- start = decimal.Decimal(0)
56
+ start = decimal.Decimal(_min) // increment * increment
57
57
  if _min < 0:
58
- start = -increment
59
58
  while start > _min:
60
59
  start -= increment
61
60
  else:
@@ -928,7 +928,7 @@ def exponential(a0: list, a1: list):
928
928
  except IndexError:
929
929
  raise IndexError
930
930
 
931
- f = linest(a0, [b ** _x for _x in a1])
931
+ f = linest(a0, [b ** xi for xi in a1])
932
932
  a, sea, c, sec = f[5][1], f[6][1], f[0], f[1]
933
933
 
934
934
  calculated_y = [_exp_func(i, a, b, c) for i in a1]
@@ -942,7 +942,7 @@ def exponential(a0: list, a1: list):
942
942
  m_ssresid = ssresid / df
943
943
  r2 = ssreg / sstotal if sstotal != 0 else 1
944
944
 
945
- z = [b ** i for i in a1]
945
+ z = [b ** xi for xi in a1]
946
946
  intercept = a + c
947
947
  se_intercept_1 = np.sqrt(sea ** 2 + sec ** 2)
948
948
  # calculate error of intercept
@@ -12,31 +12,9 @@
12
12
 
13
13
  import os
14
14
  import pickle
15
- import traceback
16
15
  import json
17
16
 
18
17
 
19
- def upload(file, media_dir):
20
- try:
21
- name, suffix = os.path.splitext(file.name)
22
- if suffix.lower() not in [
23
- '.xls', '.age', '.xlsx', '.arr', '.jpg', '.png', '.txt',
24
- '.log', '.seq', '.json', '.ahd', '.csv', '.ngxdp']:
25
- raise TypeError(f"The imported file is not supported: {suffix}")
26
- web_file_path = os.path.join(media_dir, file.name)
27
- with open(web_file_path, 'wb') as f:
28
- for chunk in file.chunks():
29
- f.write(chunk)
30
- print("File path on the server: %s" % web_file_path)
31
- except PermissionError:
32
- raise ValueError(f'Permission denied')
33
- except (Exception, BaseException) as e:
34
- print(traceback.format_exc())
35
- raise ValueError(f'Error in opening file: {e}')
36
- else:
37
- return web_file_path, name, suffix
38
-
39
-
40
18
  def read(file_path):
41
19
  """ Read text files, default 'r', 'rb'
42
20
  Parameters
@@ -291,8 +291,8 @@ def open_240(data: pd.DataFrame, logs01: pd.DataFrame, logs02: pd.DataFrame):
291
291
  -999, -999, -999, -999, -999, -999, -999, -999,
292
292
  # 123-130
293
293
  -999, -999, -999, -999, -999, -999, -999, -999,
294
- # 131-135
295
- -999, -999, -999, -999, -999,
294
+ # 131-137
295
+ -999, -999, -999, -999, -999, -999, -999,
296
296
  ]
297
297
 
298
298
  # double transpose to remove keys
@@ -591,9 +591,9 @@ class ArArCalcFile:
591
591
  book_contents = read_calc_file(self.file_path)
592
592
  # create data frames for book values
593
593
  content = pd.DataFrame(book_contents['Data Tables'])
594
- logs01 = pd.DataFrame(book_contents['Logs01'])
595
- logs02 = pd.DataFrame(book_contents['Logs02'])
596
- logs03 = pd.DataFrame(book_contents['Logs03'])
594
+ logs01 = pd.DataFrame(book_contents.get('Logs01', [[]]))
595
+ logs02 = pd.DataFrame(book_contents.get('Logs02', [[]]))
596
+ logs03 = pd.DataFrame(book_contents.get('Logs03', [[]]))
597
597
 
598
598
  start_row = 5
599
599
  sequence_num = int(logs03[2][0])
@@ -613,7 +613,7 @@ class ArArCalcFile:
613
613
  material = data[46][0]
614
614
  analyst = data[48][0]
615
615
  else:
616
- raise ValueError(f'non-supported version: {version}')
616
+ raise ValueError(f'Unsupported version: {version}')
617
617
 
618
618
  # change error type, 2sigma to 1sigma..., relative errors to absolute errors
619
619
  data = change_error_type(data, header)
@@ -65,7 +65,7 @@ DEFAULT_SAMPLE_INFO = {
65
65
 
66
66
 
67
67
 
68
- def open_file(file_path: str, input_filter: List[Union[str, int, bool]]):
68
+ def open_file(file_path: str, input_filter: List[Union[str, int, bool]], name=None):
69
69
  """
70
70
  Parameters
71
71
  ----------
@@ -99,10 +99,10 @@ def open_file(file_path: str, input_filter: List[Union[str, int, bool]]):
99
99
  ['txt', 'excel', 'Qtegra Exported XLS', 'Seq'][int(input_filter[1])]]
100
100
  except KeyError:
101
101
  raise FileNotFoundError("Wrong File.")
102
- return handler(file_path, input_filter)
102
+ return handler(file_path, input_filter, name)
103
103
 
104
104
 
105
- def open_qtegra_exported_xls(filepath, input_filter=None):
105
+ def open_qtegra_exported_xls(filepath, input_filter=None, name=None):
106
106
  if input_filter is None:
107
107
  input_filter = []
108
108
  try:
@@ -150,7 +150,7 @@ def open_qtegra_exported_xls(filepath, input_filter=None):
150
150
  return {'data': step_list}
151
151
 
152
152
 
153
- def open_raw_txt(file_path, input_filter: List[Union[str, int]]):
153
+ def open_raw_txt(file_path, input_filter: List[Union[str, int]], name=None):
154
154
  """
155
155
  Parameters
156
156
  ----------
@@ -173,12 +173,12 @@ def open_raw_txt(file_path, input_filter: List[Union[str, int]]):
173
173
  lines = [line.strip().split(['\t', ';', " ", ",", input_filter[3]][int(input_filter[2])])
174
174
  for line in contents.decode(encoding=encoding["encoding"]).split('\r\n')]
175
175
 
176
- file_name = os.path.basename(file_path).rstrip(os.path.splitext(file_path)[-1])
176
+ file_name = os.path.basename(file_path).rstrip(os.path.splitext(file_path)[-1]) if name is None else name
177
177
  step_list = get_raw_data([lines], input_filter, file_name=file_name)
178
178
  return {'data': step_list}
179
179
 
180
180
 
181
- def open_raw_xls(file_path, input_filter: List[Union[str, int]]):
181
+ def open_raw_xls(file_path, input_filter: List[Union[str, int]], name):
182
182
  """
183
183
  Parameters
184
184
  ----------
@@ -205,13 +205,13 @@ def open_raw_xls(file_path, input_filter: List[Union[str, int]]):
205
205
 
206
206
  wb = open_workbook(file_path)
207
207
  contents = [_get_content_from_sheet(i) for i in range(100)]
208
- file_name = os.path.basename(file_path).rstrip(os.path.splitext(file_path)[-1])
208
+ file_name = os.path.basename(file_path).rstrip(os.path.splitext(file_path)[-1]) if name is None else name
209
209
  step_list = get_raw_data(contents, input_filter, file_name=file_name)
210
210
 
211
211
  return {'data': step_list}
212
212
 
213
213
 
214
- def open_raw_seq(file_path, input_filter=None):
214
+ def open_raw_seq(file_path, input_filter=None, name=None):
215
215
 
216
216
  class RenameUnpickler(pickle.Unpickler):
217
217
  def find_class(self, module: str, name: str):
@@ -4436,7 +4436,7 @@ def get_random_dir(path: str, length=7, random_index=""):
4436
4436
  try:
4437
4437
  exist_ok = random_index != ""
4438
4438
  if random_index == "":
4439
- random_index = calc.basic.get_random_digits(length=length)
4439
+ random_index = calc.basic.get_random_string(length=length)
4440
4440
  destination_folder = os.path.join(path, random_index)
4441
4441
  os.makedirs(destination_folder, exist_ok=exist_ok)
4442
4442
  return destination_folder, random_index
@@ -23,7 +23,7 @@ from math import log
23
23
  from decimal import Decimal
24
24
 
25
25
  from ..calc import arr, isochron, spectra, err
26
- from ..calc.basic import get_random_digits, merge_dicts
26
+ from ..calc.basic import get_random_string, merge_dicts
27
27
  from ..calc.plot import get_axis_scale
28
28
  from . import basic, sample, consts
29
29
 
@@ -329,8 +329,8 @@ def getRectFromSpectra(data):
329
329
 
330
330
  def _get_additional_text_series(name):
331
331
  return {
332
- 'type': 'text', 'id': f'text-{name}-{get_random_digits()}',
333
- 'name': f'text-{name}-{get_random_digits()}', 'color': 'black',
332
+ 'type': 'text', 'id': f'text-{name}-{get_random_string()}',
333
+ 'name': f'text-{name}-{get_random_string()}', 'color': 'black',
334
334
  'text': "", 'size': title_size,
335
335
  'data': [[50, 50]], 'axis_index': 1,
336
336
  'h_align': "middle", 'v_align': "center",
@@ -353,7 +353,7 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
353
353
  X = x + list(reversed(x))
354
354
  Y = y1 + list(reversed(y2))
355
355
  series.append({
356
- 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
356
+ 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_string()}', 'name': f'line-{smp.name()}-{get_random_string()}',
357
357
  'color': color, 'fill_color': color, 'line_width': line_width, 'line_style': 'solid', 'z_index': 19,
358
358
  'data': np.transpose([X, Y]).tolist(),
359
359
  'line_caps': line_caps,
@@ -373,7 +373,7 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
373
373
  # spectra_fill_data = list(map(lambda each: [data[0][each - 1], min(data[1][each], data[2][each]), data[0][each + 1] - data[0][each], sigma * abs(data[1][each] - data[2][each])], selection))
374
374
  spectra_fill_data = getRectFromSpectra(plateau_data)
375
375
  series.append({
376
- 'type': 'series.rect', 'id': f'rect-{smp.name()}-{get_random_digits()}', 'name': f'rect-{smp.name()}-{get_random_digits()}',
376
+ 'type': 'series.rect', 'id': f'rect-{smp.name()}-{get_random_string()}', 'name': f'rect-{smp.name()}-{get_random_string()}',
377
377
  'color': [colors_map['red'], colors_map['blue']][index], 'fill_color': [colors_map['red'], colors_map['blue']][index], 'line_style': 'none', 'z_index': 9,
378
378
  'data': spectra_fill_data, 'line_caps': 'none', 'fill': True,
379
379
  'axis_index': 0,
@@ -382,8 +382,8 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
382
382
  X = x + list(reversed(x))
383
383
  Y = y1 + list(reversed(y2))
384
384
  series.append({
385
- 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}',
386
- 'name': f'line-{smp.name()}-{get_random_digits()}',
385
+ 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_string()}',
386
+ 'name': f'line-{smp.name()}-{get_random_string()}',
387
387
  'color': [colors_map['red'], colors_map['blue']][index], 'line_width': line_width, 'line_style': 'solid', 'z_index': 9,
388
388
  'data': np.transpose([X, Y]).tolist(),
389
389
  'line_caps': line_caps,
@@ -392,8 +392,8 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
392
392
  })
393
393
  # plateau line
394
394
  series.append({
395
- 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}',
396
- 'name': f'line-{smp.name()}-{get_random_digits()}',
395
+ 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_string()}',
396
+ 'name': f'line-{smp.name()}-{get_random_string()}',
397
397
  'color': '#A9A9A9', 'line_width': line_width, 'line_style': 'solid', 'z_index': 9,
398
398
  'data': [[0, res['age']], [100, res['age']]],
399
399
  'line_caps': line_caps,
@@ -401,7 +401,7 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
401
401
  'axis_index': 0,
402
402
  })
403
403
  series.append({
404
- 'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}', 'name': f'text-{smp.name()}-{get_random_digits()}',
404
+ 'type': 'text', 'id': f'text-{smp.name()}-{get_random_string()}', 'name': f'text-{smp.name()}-{get_random_string()}',
405
405
  'color': [colors_map['red'], colors_map['blue']][index], 'fill_color': [colors_map['red'], colors_map['blue']][index],
406
406
  'text': f"Corrected = {res['age']:.2f} ± {(sigma * res['s2']):.2f} {unit} ({sigma}s)<r>"
407
407
  f"MSWD = {res['MSWD']:.2f}, n = {res['Num']:.0f}<r>"
@@ -416,8 +416,8 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
416
416
  spe = smp.Info.results.age_spectra[index]
417
417
  if not np.isnan(res['age']):
418
418
  series.append({
419
- 'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}',
420
- 'name': f'text-{smp.name()}-{get_random_digits()}',
419
+ 'type': 'text', 'id': f'text-{smp.name()}-{get_random_string()}',
420
+ 'name': f'text-{smp.name()}-{get_random_string()}',
421
421
  'color': color, 'fill_color': color,
422
422
  'text': f"WMPA = {spe['age']:.2f} ± {(sigma * spe['s2']):.2f} {unit} ({sigma}s)",
423
423
  'size': title_size,
@@ -431,7 +431,7 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
431
431
  tga = smp.Info.results.age_spectra['TGA']
432
432
  if not np.isnan(tga['age']):
433
433
  series.append({
434
- 'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}', 'name': f'text-{smp.name()}-{get_random_digits()}',
434
+ 'type': 'text', 'id': f'text-{smp.name()}-{get_random_string()}', 'name': f'text-{smp.name()}-{get_random_string()}',
435
435
  'color': color, 'fill_color': color,
436
436
  'text': f"TGA = {tga['age']:.2f} ± {(sigma * tga['s2']):.2f} {unit} ({sigma}s)",
437
437
  'size': title_size,
@@ -455,7 +455,7 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
455
455
  # print(f"{min_index = }")
456
456
 
457
457
  series.append({
458
- 'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}', 'name': f'text-{smp.name()}-{get_random_digits()}',
458
+ 'type': 'text', 'id': f'text-{smp.name()}-{get_random_string()}', 'name': f'text-{smp.name()}-{get_random_string()}',
459
459
  'color': color, 'fill_color': color,
460
460
  'text': f"Max. = {age[max_index, 0]:.2f} ± {(sigma * age[max_index, 2]):.2f} {unit}",
461
461
  'size': title_size,
@@ -466,7 +466,7 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
466
466
  })
467
467
 
468
468
  series.append({
469
- 'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}', 'name': f'text-{smp.name()}-{get_random_digits()}',
469
+ 'type': 'text', 'id': f'text-{smp.name()}-{get_random_string()}', 'name': f'text-{smp.name()}-{get_random_string()}',
470
470
  'color': color, 'fill_color': color,
471
471
  'text': f"Min. = {age[min_index, 0]:.2f} ± {(sigma * age[min_index, 2]):.2f} {unit}",
472
472
  'size': title_size,
@@ -477,8 +477,8 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
477
477
  })
478
478
 
479
479
  series.append({
480
- 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}',
481
- 'name': f'line-{smp.name()}-{get_random_digits()}',
480
+ 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_string()}',
481
+ 'name': f'line-{smp.name()}-{get_random_string()}',
482
482
  'color': '#A9A9A9', 'line_width': line_width, 'line_style': 'solid', 'z_index': 9,
483
483
  'data': [[0, age[max_index, 0]], [100, age[max_index, 0]]],
484
484
  'line_caps': line_caps,
@@ -486,8 +486,8 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
486
486
  'axis_index': 0,
487
487
  })
488
488
  series.append({
489
- 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}',
490
- 'name': f'line-{smp.name()}-{get_random_digits()}',
489
+ 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_string()}',
490
+ 'name': f'line-{smp.name()}-{get_random_string()}',
491
491
  'color': '#A9A9A9', 'line_width': line_width, 'line_style': 'solid', 'z_index': 9,
492
492
  'data': [[0, age[min_index, 0]], [100, age[min_index, 0]]],
493
493
  'line_caps': line_caps,
@@ -496,8 +496,8 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
496
496
  })
497
497
  # title
498
498
  series.append({
499
- 'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}',
500
- 'name': f'text-{smp.name()}-{get_random_digits()}', 'color': color,
499
+ 'type': 'text', 'id': f'text-{smp.name()}-{get_random_string()}',
500
+ 'name': f'text-{smp.name()}-{get_random_string()}', 'color': color,
501
501
  'text': smp.name(), 'size': title_size,
502
502
  'data': [[50, 95]], 'axis_index': 1, 'z_index': 29,
503
503
  'h_align': "middle", 'v_align': "center",
@@ -624,21 +624,21 @@ def _get_plot_data_inv_isochron_series(smp: sample, **options):
624
624
  set3 = smp.InvIsochronPlot.set3.data
625
625
  # set 1
626
626
  series.append({
627
- 'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_digits()}', 'name': f'scatter-{smp.name()}-{get_random_digits()}',
627
+ 'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_string()}', 'name': f'scatter-{smp.name()}-{get_random_string()}',
628
628
  'stroke_color': colors_map['red'], 'fill_color': colors_map['red80'], 'myType': 'scatter', 'size': marker_size, 'line_width': 0,
629
629
  'data': (data[[0, 2], :][:, set1]).transpose().tolist(),
630
630
  'axis_index': 0, 'z_index': 99
631
631
  })
632
632
  # set 2
633
633
  series.append({
634
- 'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_digits()}', 'name': f'scatter-{smp.name()}-{get_random_digits()}',
634
+ 'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_string()}', 'name': f'scatter-{smp.name()}-{get_random_string()}',
635
635
  'stroke_color': colors_map['blue'], 'fill_color': colors_map['blue80'], 'myType': 'scatter', 'size': marker_size, 'line_width': 0,
636
636
  'data': (data[[0, 2], :][:, set2]).transpose().tolist(),
637
637
  'axis_index': 0, 'z_index': 99
638
638
  })
639
639
  # set 3
640
640
  series.append({
641
- 'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_digits()}', 'name': f'scatter-{smp.name()}-{get_random_digits()}',
641
+ 'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_string()}', 'name': f'scatter-{smp.name()}-{get_random_string()}',
642
642
  'stroke_color': 'black', 'fill_color': 'white', 'myType': 'scatter', 'size': marker_size, 'line_width': 0,
643
643
  'data': (data[[0, 2], :][:, set3]).transpose().tolist(),
644
644
  'axis_index': 0, 'z_index': 0
@@ -653,14 +653,14 @@ def _get_plot_data_inv_isochron_series(smp: sample, **options):
653
653
  (float(xAxis[0]['extent'][1]), float(xAxis[0]['extent'][1]) * smp.Info.results.isochron['figure_3'][index]['m1'] + smp.Info.results.isochron['figure_3'][index]['k']),
654
654
  ]
655
655
  series.append({
656
- 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
656
+ 'type': 'series.line', 'id': f'line-{smp.name()}-{get_random_string()}', 'name': f'line-{smp.name()}-{get_random_string()}',
657
657
  'color': [colors_map['red'], colors_map['blue']][index], 'fill_color': [colors_map['red'], colors_map['blue']][index],
658
658
  'line_width': 1, 'line_style': 'solid',
659
659
  'data': isochron_data,
660
660
  'axis_index': 0,
661
661
  })
662
662
  series.append({
663
- 'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}', 'name': f'text-{smp.name()}-{get_random_digits()}',
663
+ 'type': 'text', 'id': f'text-{smp.name()}-{get_random_string()}', 'name': f'text-{smp.name()}-{get_random_string()}',
664
664
  'color': [colors_map['red'], colors_map['blue']][index], 'fill_color': [colors_map['red'], colors_map['blue']][index],
665
665
  'text': f"IIA = {smp.Info.results.isochron['figure_3'][index]['age']:.2f} ± {(sigma * smp.Info.results.isochron['figure_3'][index]['s2']):.2f} Ma ({sigma}s)<r>"
666
666
  f"(40Ar/36Ar)0 = {smp.Info.results.isochron['figure_3'][index]['initial']:.2f} ± {(sigma * smp.Info.results.isochron['figure_3'][index]['sinitial']):.2f}<r>"
@@ -673,8 +673,8 @@ def _get_plot_data_inv_isochron_series(smp: sample, **options):
673
673
  })
674
674
 
675
675
  series.append({
676
- 'type': 'text', 'id': f'text-{smp.name()}-{get_random_digits()}',
677
- 'name': f'text-{smp.name()}-{get_random_digits()}', 'color': color,
676
+ 'type': 'text', 'id': f'text-{smp.name()}-{get_random_string()}',
677
+ 'name': f'text-{smp.name()}-{get_random_string()}', 'color': color,
678
678
  'text': smp.name(), 'size': title_size,
679
679
  'data': [[50, 95]], 'axis_index': 1,
680
680
  'h_align': "middle", 'v_align': "center",
@@ -695,7 +695,7 @@ def _get_plot_data_degas_pattern(smp: sample, **options):
695
695
  data = np.array([x, y])
696
696
  # set 1
697
697
  series.append({
698
- 'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_digits()}', 'name': f'scatter-{smp.name()}-{get_random_digits()}',
698
+ 'type': 'series.scatter', 'id': f'scatter-{smp.name()}-{get_random_string()}', 'name': f'scatter-{smp.name()}-{get_random_string()}',
699
699
  'stroke_color': color, 'fill_color': 'white', 'myType': 'scatter', 'size': 4, 'line_width': 1,
700
700
  'data': data.transpose().tolist(), 'axis_index': 0, 'z_index': 99
701
701
  })
@@ -787,7 +787,7 @@ def _get_plot_data_degas_spectra_series(smp: sample, **options):
787
787
 
788
788
  # set 1
789
789
  series.append({
790
- 'type': 'rect', 'id': f'rect-{smp.name()}-{get_random_digits()}', 'name': f'rect-{smp.name()}-{get_random_digits()}',
790
+ 'type': 'rect', 'id': f'rect-{smp.name()}-{get_random_string()}', 'name': f'rect-{smp.name()}-{get_random_string()}',
791
791
  'color': color, 'myType': 'rect', 'line_width': 1,
792
792
  'data': data.transpose().tolist(),
793
793
  'axis_index': 0, 'z_index': 99
@@ -844,13 +844,13 @@ def _get_plot_data_degas_curve_series(smp: sample, **options):
844
844
 
845
845
  # line
846
846
  series.append({
847
- 'type': 'line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
847
+ 'type': 'line', 'id': f'line-{smp.name()}-{get_random_string()}', 'name': f'line-{smp.name()}-{get_random_string()}',
848
848
  'color': color, 'myType': 'line', 'line_width': 1, 'line_style': 'solid',
849
849
  'data': np.array([x, released]).transpose().tolist(),
850
850
  'axis_index': 0, 'z_index': 99
851
851
  })
852
852
  series.append({
853
- 'type': 'line', 'id': f'line-{smp.name()}-{get_random_digits()}', 'name': f'line-{smp.name()}-{get_random_digits()}',
853
+ 'type': 'line', 'id': f'line-{smp.name()}-{get_random_string()}', 'name': f'line-{smp.name()}-{get_random_string()}',
854
854
  'color': color, 'myType': 'line', 'line_width': 1, 'line_style': 'solid',
855
855
  'data': np.array([x, remained]).transpose().tolist(),
856
856
  'axis_index': 0, 'z_index': 99
@@ -247,10 +247,10 @@ def get_isochron_results(data: list, smp: Sample, sequence, figure_type: int = 0
247
247
 
248
248
  if len(sequence) < 3:
249
249
  return iso_res
250
- regression_method = {
251
- "york-2": calc.regression.york2, "olst": calc.regression.olst
252
- }.get(smp.TotalParam[97][min(sequence)].lower(), calc.regression.york2)
253
250
  try:
251
+ regression_method = {
252
+ "york-2": calc.regression.york2, "olst": calc.regression.olst
253
+ }.get(smp.TotalParam[97][min(sequence)].lower(), calc.regression.york2)
254
254
  regression_res = regression_method(*data[:5])
255
255
  except (Exception, BaseException):
256
256
  # print(f"Warning: {traceback.format_exc()}")
@@ -22,7 +22,7 @@ RawData = samples.RawData
22
22
  Sequence = samples.Sequence
23
23
 
24
24
 
25
- def to_raw(file_path: Union[str, List[str]], input_filter_path: Union[str, List[str]], **kwargs):
25
+ def to_raw(file_path: Union[str, List[str]], input_filter_path: Union[str, List[str]], file_name=None, **kwargs):
26
26
  """ Read raw data from files, can create raw data instance based on the given files
27
27
  Raw data will have the structure like:
28
28
  [
@@ -35,6 +35,7 @@ def to_raw(file_path: Union[str, List[str]], input_filter_path: Union[str, List[
35
35
  ----------
36
36
  file_path
37
37
  input_filter_path
38
+ file_name
38
39
  kwargs
39
40
 
40
41
  Returns
@@ -42,21 +43,16 @@ def to_raw(file_path: Union[str, List[str]], input_filter_path: Union[str, List[
42
43
 
43
44
  """
44
45
  if isinstance(file_path, list) and isinstance(input_filter_path, list):
45
- raw = concatenate([to_raw(file, input_filter_path[index]) for index, file in enumerate(file_path)])
46
+ raw = concatenate([to_raw(file, input_filter_path[index],
47
+ file_name[index] if isinstance(file_name, list) else file_name) for index, file in enumerate(file_path)])
46
48
  elif isinstance(file_path, str) and isinstance(input_filter_path, str):
47
49
  input_filter = read_params(input_filter_path)
48
- file_name = str(os.path.split(file_path)[-1]).split('.')[0]
49
- res = raw_file.open_file(file_path, input_filter)
50
+ file_name = str(os.path.split(file_path)[-1]).split('.')[0] if file_name is None else file_name
51
+ res = raw_file.open_file(file_path, input_filter, file_name)
50
52
  data = res.get('data', None)
51
53
  sequences = res.get('sequences', None)
52
54
  sequence_num = len(data) if data is not None else len(sequences)
53
- # default fitting method, all exponential
54
- # <option value=0>Linear</option>
55
- # <option value=1>Quadratic</option>
56
- # <option value=2>Exponential</option>
57
- # <option value=3>Power</option>
58
- # <option value=4>Average</option>
59
- fitting_method = [2, 0, 2, 2, 2]
55
+ fitting_method = [2, 0, 2, 2, 2] # 0 - linear, 1 - quadratic, 2 - exponential, 3 - power, 4 - average
60
56
  raw = RawData(name=file_name, data=data, isotopic_num=10, sequence_num=sequence_num, source=[file_path],
61
57
  sequence=sequences, unit=str(input_filter[30]), fitting_method=[*fitting_method])
62
58
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ararpy
3
- Version: 0.1.33
3
+ Version: 0.1.35
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.33', # version
19
+ version='0.1.35', # 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