ararpy 0.2.2__py3-none-any.whl → 0.2.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
ararpy/__init__.py CHANGED
@@ -16,10 +16,10 @@ from . import calc, smp, files, thermo, test
16
16
  """ Information """
17
17
 
18
18
  name = 'ararpy'
19
- version = '0.2.2'
19
+ version = '0.2.4'
20
20
  __version__ = version
21
21
  full_version = version
22
- last_update = '2026-01-01'
22
+ last_update = '2026-01-07'
23
23
 
24
24
  """ ArArPy Functions """
25
25
 
@@ -97,24 +97,6 @@ Sample.set_params = smp.basic.set_params
97
97
  Sample.set_info = lambda _smp, info: setattr(_smp, 'Info', smp.basic.update_plot_from_dict(_smp.Info, info))
98
98
 
99
99
  Sample.recalculate = lambda _smp, *args, **kwargs: smp.calculation.recalculate(_smp, *args, **kwargs)
100
- Sample.plot_init = lambda _smp: smp.calculation.recalculate(
101
- _smp, re_plot=True, isIsochron=False, isInit=True, isPlateau=False)
102
- Sample.plot_isochron = lambda _smp, **kwargs: smp.calculation.recalculate(
103
- _smp, re_plot=True, isIsochron=True, isInit=False, isPlateau=False, **kwargs)
104
- Sample.plot_age_plateau = lambda _smp: smp.calculation.recalculate(
105
- _smp, re_plot=True, isIsochron=False, isInit=False, isPlateau=True)
106
- Sample.plot_normal = lambda _smp: smp.calculation.recalculate(
107
- _smp, re_plot=True, isIsochron=True, isInit=False, isPlateau=False, figures=['figure_2'])
108
- Sample.plot_inverse = lambda _smp: smp.calculation.recalculate(
109
- _smp, re_plot=True, isIsochron=True, isInit=False, isPlateau=False, figures=['figure_3'])
110
- Sample.plot_cl_1 = lambda _smp: smp.calculation.recalculate(
111
- _smp, re_plot=True, isIsochron=True, isInit=False, isPlateau=False, figures=['figure_4'])
112
- Sample.plot_cl_2 = lambda _smp: smp.calculation.recalculate(
113
- _smp, re_plot=True, isIsochron=True, isInit=False, isPlateau=False, figures=['figure_5'])
114
- Sample.plot_cl_3 = lambda _smp: smp.calculation.recalculate(
115
- _smp, re_plot=True, isIsochron=True, isInit=False, isPlateau=False, figures=['figure_6'])
116
- Sample.plot_3D = lambda _smp: smp.calculation.recalculate(
117
- _smp, re_plot=True, isIsochron=True, isInit=False, isPlateau=False, figures=['figure_7'])
118
100
 
119
101
  Sample.to_excel = lambda _smp, file_path, *args, **kwargs: smp.export.to_excel(_smp, file_path=file_path, *args, **kwargs)
120
102
 
ararpy/calc/arr.py CHANGED
@@ -311,7 +311,10 @@ def multi_append(a, *args):
311
311
 
312
312
  """
313
313
  for arg in args:
314
- a.append(arg)
314
+ if isinstance(a, list):
315
+ a.append(arg)
316
+ if isinstance(a, np.ndarray):
317
+ a = np.append(a, arg)
315
318
  return a
316
319
 
317
320
 
@@ -351,7 +354,7 @@ def create_arr(shape: tuple):
351
354
 
352
355
  """
353
356
  if len(shape) == 1:
354
- return []
357
+ return [0 for i in range(shape[0])]
355
358
  return [create_arr(shape[1:]) for i in range(shape[0])]
356
359
 
357
360
 
ararpy/calc/corr.py CHANGED
@@ -272,6 +272,7 @@ def Monte_Carlo_F(ar40m: Tuple[float, float], ar39m: Tuple[float, float], ar38m:
272
272
  G40: Tuple[float, float], G39: Tuple[float, float], G38: Tuple[float, float],
273
273
  G37: Tuple[float, float], G36: Tuple[float, float],
274
274
  stand_time_year: float, JNFactor: Tuple[float, float],
275
+ KCaFactor: Tuple[float, float], KClFactor: Tuple[float, float],
275
276
  **options):
276
277
  """
277
278
 
@@ -359,6 +360,9 @@ def Monte_Carlo_F(ar40m: Tuple[float, float], ar39m: Tuple[float, float], ar38m:
359
360
  R38v39k = random_normal_relative(*R38v39k, size=Monte_Carlo_Size)
360
361
  R36v38clp = random_normal_relative(*R36v38clp, size=Monte_Carlo_Size)
361
362
 
363
+ KCa = random_normal_relative(*KCaFactor, size=Monte_Carlo_Size)
364
+ KCl = random_normal_relative(*KClFactor, size=Monte_Carlo_Size)
365
+
362
366
  JNFactor = random_normal_absolute(*JNFactor, size=Monte_Carlo_Size)
363
367
 
364
368
  def do_simulation():
@@ -380,31 +384,23 @@ def Monte_Carlo_F(ar40m: Tuple[float, float], ar39m: Tuple[float, float], ar38m:
380
384
  _ar39 = (ar39m[i] / G39[i] - ar39b[i] / (G39[i] if blank_gain_corr else 1)) * P39Mdf * P39Decay
381
385
  _ar40 = (ar40m[i] / G40[i] - ar40b[i] / (G40[i] if blank_gain_corr else 1)) * P40Mdf
382
386
 
387
+ _ar37ca = _ar37
388
+
383
389
  if force_to_zero:
384
- _ar36 = max(_ar36, 0)
385
- _ar37 = max(_ar37, 0)
386
- _ar38 = max(_ar38, 0)
387
- _ar39 = max(_ar39, 0)
388
- _ar40 = max(_ar40, 0)
390
+ _ar37ca = max(_ar37, 0)
389
391
 
390
- _ar37ca = _ar37
391
392
  _ar39ca = _ar37ca * R39v37ca[i]
392
393
  _ar38ca = _ar37ca * R38v37ca[i]
393
394
  _ar36ca = _ar37ca * R36v37ca[i]
394
395
 
396
+ _ar39k = _ar39 - _ar39ca
397
+
395
398
  if force_to_zero:
396
- _ar39ca = min(_ar39ca, _ar39)
397
- _ar38ca = min(_ar38ca, _ar38)
398
- _ar36ca = min(_ar36ca, _ar36)
399
+ _ar39k = max(_ar39k, 0)
399
400
 
400
- _ar39k = _ar39 - _ar39ca
401
401
  _ar38k = _ar39k * R38v39k[i]
402
402
  _ar40k = _ar39k * R40v39k[i]
403
403
 
404
- if force_to_zero:
405
- _ar38k = min(_ar38k, _ar38 - _ar38ca)
406
- _ar40k = min(_ar40k, _ar40)
407
-
408
404
  _ar38res = _ar38 - _ar38k - _ar38ca
409
405
  _ar36res = _ar36 - _ar36ca
410
406
 
@@ -433,6 +429,8 @@ def Monte_Carlo_F(ar40m: Tuple[float, float], ar39m: Tuple[float, float], ar38m:
433
429
 
434
430
  factor = JNFactor[i]
435
431
 
432
+ _CaK = _ar37ca / _ar39k / KCa[i]
433
+
436
434
  i += 1
437
435
 
438
436
  yield _ar36a, 0, _ar36ca, _ar36cl, _ar37ca, _ar38cl, _ar38a, 0, _ar38k, _ar38ca, _ar39k, _ar39ca, _ar40r, _ar40a, 0, _ar40k, \
@@ -442,7 +440,7 @@ def Monte_Carlo_F(ar40m: Tuple[float, float], ar39m: Tuple[float, float], ar38m:
442
440
  (_ar39k * factor) / _ar40r, _ar38cl / _ar40r, \
443
441
  _ar38cl / (_ar39k * factor), _ar40r / (_ar39k * factor), \
444
442
  _ar36res / _ar40ar, _ar38res / _ar40ar, (_ar39k * factor) / _ar40ar, \
445
- _ar36, _ar37, _ar38, _ar39, _ar40
443
+ _ar36, _ar37, _ar38, _ar39, _ar40, _CaK
446
444
 
447
445
  data = np.array(list(do_simulation()))
448
446
  means = data.mean(axis=0)
@@ -467,8 +465,9 @@ def Monte_Carlo_F(ar40m: Tuple[float, float], ar39m: Tuple[float, float], ar38m:
467
465
  corrected_data = np.column_stack((means[29:34], stds[29:34])).ravel()
468
466
 
469
467
  F = np.append(means[25], stds[25])
468
+ CaK = np.append(means[34], stds[34])
470
469
 
471
- return *F, *degas_data, *nor_iso, *inv_iso, *cl1_iso, *cl2_iso, *cl3_iso, *threed_iso, *corrected_data
470
+ return *F, *degas_data, *nor_iso, *inv_iso, *cl1_iso, *cl2_iso, *cl3_iso, *threed_iso, *corrected_data, *CaK
472
471
 
473
472
  # print("F = {0} ± {1}".format(np.mean(F), np.std(F)))
474
473
  #
ararpy/files/calc_file.py CHANGED
@@ -81,7 +81,7 @@ def open_252(data: pd.DataFrame, logs01: pd.DataFrame, logs02: pd.DataFrame):
81
81
  162, 163, 164, 165, 166, 167, 168, 169, # 40 r, a, c, k 26-33
82
82
  ]
83
83
  publish_values_index = [
84
- 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
84
+ 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205,
85
85
  ]
86
86
  apparent_age_values_index = [
87
87
  198, 199, 200, 201, -999, -999, 202, 203, # f, sf, ages, s, s, s, 40Arr%, 39Ar%
@@ -244,7 +244,9 @@ def open_240(data: pd.DataFrame, logs01: pd.DataFrame, logs02: pd.DataFrame):
244
244
  148, -999, 149, -999, 150, -999, 151, -999,
245
245
  ]
246
246
  publish_values_index = [
247
- 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
247
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
248
+ -1, -1, -1, -1,
249
+ -1, -1, -1, -1,
248
250
  ]
249
251
  apparent_age_values_index = [
250
252
  # f, sf, ages, s, s, s, 39Ar%
ararpy/smp/basic.py CHANGED
@@ -35,15 +35,16 @@ pd.options.mode.chained_assignment = None # default='warn'
35
35
  # =======================
36
36
  class ParamsInvalid(Exception):
37
37
  """ """
38
- def __init__(self, code, message, context=None):
38
+ def __init__(self, code=400, message="", context=None, fatal=True):
39
39
  self.code = code
40
40
  self.message = message
41
41
  self.context = context or {}
42
+ self.fatal = fatal
42
43
  # 调用父类构造函数,确保异常能正常抛出
43
44
  super().__init__(f"{self.message}")
44
45
 
45
46
 
46
- def validate_params(**kwargs):
47
+ def validate_params(fatal=True, **kwargs):
47
48
 
48
49
  def check(data, dtype, **kwargs):
49
50
  k = np.array(data, dtype=dtype)
@@ -65,7 +66,7 @@ def validate_params(**kwargs):
65
66
  if not kwargs.get('func')(each):
66
67
  raise ValueError
67
68
  except (Exception, BaseException) as e:
68
- raise ValueError(f"{type(e).__name__}: invalid value, {each}")
69
+ raise ValueError(f"invalid value, {each}")
69
70
 
70
71
  context = {'names': [], 'classnames': [], 'messages': []}
71
72
  for index, (name, content) in enumerate(kwargs.items(), 1):
@@ -83,7 +84,7 @@ def validate_params(**kwargs):
83
84
  if not context['names']:
84
85
  return True
85
86
  else:
86
- raise ParamsInvalid(400, '. '.join(context['messages']), context)
87
+ raise ParamsInvalid(400, '. '.join(context['messages']), context, fatal=fatal)
87
88
 
88
89
 
89
90
  # =======================
@@ -119,7 +120,7 @@ def calc_apparent_ages(smp: Sample):
119
120
  raise TypeError(f"Sample type is not supported: {smp.Info.sample.type}")
120
121
 
121
122
  smp.ApparentAgeValues[2:6] = v[0:4]
122
- smp.PublishValues[5:7] = copy.deepcopy(v[0:2])
123
+ smp.PublishValues[12:14] = copy.deepcopy(v[0:2])
123
124
 
124
125
 
125
126
  def calc_j(ar40ar39=None, params: dict = None, smp: Sample = None, index: list = None):
@@ -268,7 +269,7 @@ def calc_age(ar40ar39=None, params: dict = None, smp: Sample = None, index: list
268
269
  age_unit_factor = 1
269
270
 
270
271
  # check if using Min equation
271
- params['Min'] = [i if isinstance(i, bool) else False for i in params['Min']]
272
+ params['Min'] = [bool(i) for i in params['Min']]
272
273
 
273
274
  idx1 = np.flatnonzero(np.where(params['Min'], True, False)) # True, using Min equation
274
275
  idx2 = np.flatnonzero(np.where(params['Min'], False, True)) # False
@@ -591,7 +592,7 @@ def get_diff_smp(backup: (dict, Sample), smp: (dict, Sample)):
591
592
  if _res != {}:
592
593
  res.update({name: _res})
593
594
  continue
594
- if str(backup[name]) == str(attr) or backup[name] == attr:
595
+ if str(backup[name]) == str(attr):
595
596
  continue
596
597
  res.update({name: attr})
597
598
  return res
@@ -668,6 +669,10 @@ def set_params(smp: Sample, params: Union[List, str], flag: Optional[str] = None
668
669
  else:
669
670
  smp.TotalParam[32] = [item / (3600 * 24 * 365.242) if index in rows else smp.TotalParam[32][index] for index, item in enumerate(stand_time_second)] # stand year
670
671
 
672
+ smp.Info.irradiation.label = params[-3]
673
+ smp.Info.irradiation.location = params[-2]
674
+ smp.Info.irradiation.info = params[-1]
675
+
671
676
  elif flag == 'smp':
672
677
  smp.TotalParam[67:71] = remove_none(smp.TotalParam[67:71], params[0:4], rows, n)
673
678
  smp.TotalParam[58:67] = remove_none(smp.TotalParam[58:67], params[4:13], rows, n)
@@ -702,6 +707,7 @@ def get_sequence(smp: Sample):
702
707
  smp.Info.results.selection[0]['data'] = smp.SelectedSequence1
703
708
  smp.Info.results.selection[1]['data'] = smp.SelectedSequence2
704
709
  smp.Info.results.selection[2]['data'] = smp.UnselectedSequence
710
+ smp.Info.experiment.step_num = len(smp.SequenceName)
705
711
  return ArArBasic(
706
712
  size=len(smp.SequenceName), name=smp.SequenceName, value=smp.SequenceValue, unit=smp.SequenceUnit,
707
713
  mark=ArArBasic(
ararpy/smp/corr.py CHANGED
@@ -55,7 +55,6 @@ def corr_blank(sample: Sample):
55
55
  for i in range(0, 10, 2):
56
56
  blank_corrected[i] = [blank_corrected[i][index] if sample.TotalParam[102][index] else j for index, j in enumerate(sample.SampleIntercept[i])]
57
57
  blank_corrected[i + 1] = [blank_corrected[i + 1][index] if sample.TotalParam[102][index] else j for index, j in enumerate(sample.SampleIntercept[i + 1])]
58
- blank_corrected[i] = [0 if j < 0 and sample.TotalParam[101][index] else j for index, j in enumerate(blank_corrected[i])]
59
58
  sample.BlankCorrected = blank_corrected
60
59
 
61
60
 
@@ -147,9 +146,6 @@ def corr_decay(sample: Sample):
147
146
  *sample.MassDiscrCorrected[2:4], t1, t2, t3, *sample.TotalParam[44:46], isRelative=True)
148
147
  decay_corrected[6:8] = calc.corr.decay(
149
148
  *sample.MassDiscrCorrected[6:8], t1, t2, t3, *sample.TotalParam[42:44], isRelative=True)
150
- # Negative number set to zero in decay correction
151
- decay_corrected[2] = [0 if i < 0 else i for i in decay_corrected[2]]
152
- decay_corrected[6] = [0 if i < 0 else i for i in decay_corrected[6]]
153
149
  except Exception as e:
154
150
  print(traceback.format_exc())
155
151
  raise ValueError(f'Decay correction error: {str(e)}')
@@ -157,10 +153,17 @@ def corr_decay(sample: Sample):
157
153
  corrDecay37 = sample.TotalParam[104]
158
154
  corrDecay39 = sample.TotalParam[105]
159
155
  sample.CorrectedValues = copy.deepcopy(sample.MassDiscrCorrected)
160
- sample.CorrectedValues[2] = [val if corrDecay37[idx] else 0 for idx, val in enumerate(decay_corrected[2])]
161
- sample.CorrectedValues[3] = [val if corrDecay37[idx] else 0 for idx, val in enumerate(decay_corrected[3])]
162
- sample.CorrectedValues[6] = [val if corrDecay39[idx] else 0 for idx, val in enumerate(decay_corrected[6])]
163
- sample.CorrectedValues[7] = [val if corrDecay39[idx] else 0 for idx, val in enumerate(decay_corrected[7])]
156
+ for idx in range(sample.Info.experiment.step_num):
157
+ if corrDecay37[idx]:
158
+ sample.CorrectedValues[2][idx] = decay_corrected[2][idx]
159
+ sample.CorrectedValues[3][idx] = decay_corrected[3][idx]
160
+ if corrDecay39[idx]:
161
+ sample.CorrectedValues[6][idx] = decay_corrected[6][idx]
162
+ sample.CorrectedValues[7][idx] = decay_corrected[7][idx]
163
+
164
+ data = np.array(sample.CorrectedValues)
165
+ data[1:10:2] = data[1:10:2] = np.abs(np.divide(data[1:10:2], data[0:10:2])) * 100
166
+ sample.PublishValues[0:10] = copy.deepcopy(data.tolist())
164
167
 
165
168
 
166
169
  # =======================
@@ -189,8 +192,10 @@ def calc_degas_ca(sample: Sample):
189
192
  if not validate_params(**params_to_check):
190
193
  return
191
194
 
195
+ set_negative_zero = sample.TotalParam[101]
192
196
  corrDegasCa = sample.TotalParam[106]
193
- ar37ca = sample.CorrectedValues[2:4]
197
+ ar37ca = copy.deepcopy(sample.CorrectedValues[2:4])
198
+ ar37ca[0] = [0 if val < 0 and set_negative_zero[i] else val for i, val in enumerate(ar37ca[0])]
194
199
  ar39ca = calc.arr.mul_factor(ar37ca, sample.TotalParam[8:10], isRelative=True)
195
200
  ar38ca = calc.arr.mul_factor(ar37ca, sample.TotalParam[10:12], isRelative=True)
196
201
  ar36ca = calc.arr.mul_factor(ar37ca, sample.TotalParam[12:14], isRelative=True)
@@ -201,7 +206,6 @@ def calc_degas_ca(sample: Sample):
201
206
  sample.DegasValues[19] = [val if corrDegasCa[idx] else 0 for idx, val in enumerate(ar38ca[1])]
202
207
  sample.DegasValues[22] = [val if corrDegasCa[idx] else 0 for idx, val in enumerate(ar39ca[0])] # 39Ca
203
208
  sample.DegasValues[23] = [val if corrDegasCa[idx] else 0 for idx, val in enumerate(ar39ca[1])]
204
- sample.PublishValues[1] = copy.deepcopy(sample.DegasValues[8])
205
209
 
206
210
 
207
211
  # =======================
@@ -242,7 +246,6 @@ def calc_degas_k(sample: Sample):
242
246
  sample.DegasValues[17] = [val if corrDecasK[idx] else 0 for idx, val in enumerate(ar38k[1])]
243
247
  sample.DegasValues[30] = [val if corrDecasK[idx] else 0 for idx, val in enumerate(ar40k[0])]
244
248
  sample.DegasValues[31] = [val if corrDecasK[idx] else 0 for idx, val in enumerate(ar40k[1])]
245
- sample.PublishValues[3] = copy.deepcopy(sample.DegasValues[20])
246
249
 
247
250
 
248
251
  # =======================
@@ -351,7 +354,6 @@ def calc_degas_cl(sample: Sample):
351
354
 
352
355
  sample.DegasValues[6:8] = copy.deepcopy(ar36cl)
353
356
  sample.DegasValues[10:12] = copy.deepcopy(ar38cl)
354
- sample.PublishValues[2] = copy.deepcopy(sample.DegasValues[10])
355
357
 
356
358
 
357
359
  # =======================
@@ -408,7 +410,6 @@ def calc_degas_atm(sample: Sample):
408
410
  sample.DegasValues[13] = [val if corrDecasAtm[idx] else 0 for idx, val in enumerate(ar38a[1])]
409
411
  sample.DegasValues[26] = [val if corrDecasAtm[idx] else 0 for idx, val in enumerate(ar40a[0])] # Ar40a
410
412
  sample.DegasValues[27] = [val if corrDecasAtm[idx] else 0 for idx, val in enumerate(ar40a[1])]
411
- sample.PublishValues[0] = copy.deepcopy(sample.DegasValues[ 0])
412
413
 
413
414
 
414
415
  # =======================
@@ -439,7 +440,6 @@ def calc_degas_r(sample: Sample):
439
440
  ar40r = calc.arr.sub(ar40ar, sample.DegasValues[26:28])
440
441
  ar40r[0] = [0 if item < 0 and sample.TotalParam[101][index] else item for index, item in enumerate(ar40r[0])]
441
442
  sample.DegasValues[24:26] = copy.deepcopy(ar40r)
442
- sample.PublishValues[4] = copy.deepcopy(sample.DegasValues[24])
443
443
 
444
444
 
445
445
  def calc_degas_c(sample: Sample):
@@ -588,7 +588,8 @@ def calc_ratio(sample: Sample):
588
588
  calc.arr.rec_factor(sample.TotalParam[20:22], isRelative=True))
589
589
 
590
590
  sample.ApparentAgeValues[6] = ar40r_percent
591
- sample.PublishValues[7:11] = copy.deepcopy([*sample.ApparentAgeValues[6:8], *CaK])
591
+ sample.PublishValues[10:12] = copy.deepcopy(sample.ApparentAgeValues[0:2])
592
+ sample.PublishValues[14:18] = copy.deepcopy([*sample.ApparentAgeValues[6:8], *CaK])
592
593
 
593
594
  sample.IsochronValues[0:5], sample.IsochronValues[6:11] = calc_nor_inv_isochrons(sample)
594
595
  sample.IsochronValues[12:17], sample.IsochronValues[18:23], sample.IsochronValues[24:29] = \
@@ -629,13 +630,11 @@ def calc_ratio_monte_carlo(sample: Sample):
629
630
  # corrected
630
631
  sample.CorrectedValues = res[2 + 32 + 39:2 + 32 + 39 + 10]
631
632
  # publish
632
- sample.PublishValues[0] = copy.deepcopy(sample.DegasValues[ 0])
633
- sample.PublishValues[1] = copy.deepcopy(sample.DegasValues[ 8])
634
- sample.PublishValues[2] = copy.deepcopy(sample.DegasValues[10])
635
- sample.PublishValues[3] = copy.deepcopy(sample.DegasValues[20])
636
- sample.PublishValues[4] = copy.deepcopy(sample.DegasValues[24])
637
- sample.PublishValues[5:7] = copy.deepcopy(sample.ApparentAgeValues[2:4])
638
- sample.PublishValues[7:9] = copy.deepcopy(sample.ApparentAgeValues[6:8])
633
+ data = np.array(sample.CorrectedValues)
634
+ data[1:10:2] = data[1:10:2] = np.abs(np.divide(data[1:10:2], data[0:10:2])) * 100
635
+ sample.PublishValues[0:10] = copy.deepcopy(data.tolist())
636
+ sample.PublishValues[10:14] = copy.deepcopy(sample.ApparentAgeValues[0:4])
637
+ sample.PublishValues[14:16] = copy.deepcopy(sample.ApparentAgeValues[6:8])
639
638
 
640
639
 
641
640
  def monte_carlo_f(sample: Sample):
@@ -731,6 +730,10 @@ def monte_carlo_f(sample: Sample):
731
730
  R38v36a = np.transpose(sample.TotalParam[4:6])
732
731
  R36v38clp = np.transpose(sample.TotalParam[56:58])
733
732
 
733
+ R36v38cl = np.transpose(sample.TotalParam[18:20]) # ?
734
+ KCaFactor = np.transpose(sample.TotalParam[20:22])
735
+ KClFactor = np.transpose(sample.TotalParam[22:24])
736
+
734
737
  stand_time_year = np.transpose(sample.TotalParam[32])
735
738
  JNFactor = np.transpose(sample.TotalParam[136:138])
736
739
 
@@ -764,10 +767,12 @@ def monte_carlo_f(sample: Sample):
764
767
  L37ar=L37ar[i], L39ar=L39ar[i], L36cl=L36cl[i],
765
768
  MDF=MDF[i], stand_time_year=stand_time_year[i],
766
769
  JNFactor=JNFactor[i],
770
+ KCaFactor=KCaFactor[i],
771
+ KClFactor=KClFactor[i],
767
772
  blank_gain_corr=sample.TotalParam[111][i],
768
773
  MDF_method=sample.TotalParam[100][i],
769
774
  force_to_zero=sample.TotalParam[101][i],
770
- monte_carlo_size=1000,
775
+ monte_carlo_size=4000,
771
776
  )
772
777
 
773
778
  yield res
ararpy/smp/export.py CHANGED
@@ -1219,7 +1219,7 @@ class WritingWorkbook:
1219
1219
  [(4, 11, 1), list(map(lambda x: 2*x, self.sample.ApparentAgeValues[3])), {'num_format': '± ' + self.default_fmt_prop['num_format']}],
1220
1220
  [(4, 12, 1), self.sample.ApparentAgeValues[6], {}],
1221
1221
  [(4, 13, 1), self.sample.ApparentAgeValues[7], {}],
1222
- [(4, 14, 1), self.sample.PublishValues[9], {}],
1222
+ [(4, 14, 1), self.sample.PublishValues[16], {}],
1223
1223
  [(4 + num_step, 0, 0), [''] * 15, {'bold': 1, 'top': 1}],
1224
1224
 
1225
1225
  [(5 + num_step, 0), "Table 2. 40Ar/39Ar age summary", {'bold': 1, 'align': 'left'}],
ararpy/smp/initial.py CHANGED
@@ -128,6 +128,8 @@ def initial(smp: Sample):
128
128
  smp.BlankIntercept = arr.create_arr((len(samples.BLANK_INTERCEPT_HEADERS) - 3, 0))
129
129
  smp.SampleIntercept = arr.create_arr((len(samples.SAMPLE_INTERCEPT_HEADERS) - 3, 0))
130
130
  smp.PublishValues = arr.create_arr((len(samples.PUBLISH_TABLE_HEADERS) - 3, 0))
131
+ smp.BlankCorrected = arr.create_arr((10, 0))
132
+ smp.MassDiscrCorrected = arr.create_arr((10, 0))
131
133
  smp.DecayCorrected = arr.create_arr((10, 0))
132
134
  smp.CorrectedValues = arr.create_arr((len(samples.CORRECTED_HEADERS) - 3, 0))
133
135
  smp.DegasValues = arr.create_arr((len(samples.DEGAS_HEADERS) - 3, 0))
@@ -189,7 +191,7 @@ def initial(smp: Sample):
189
191
  ),
190
192
  preference=ArArBasic(**PREFERENCE_RES),
191
193
  irradiation= ArArBasic(
192
- label='', pos_h='', pos_x='', pos_y='',
194
+ label='', pos_h='', pos_x='', pos_y='', location='', info=''
193
195
  )
194
196
  ))
195
197
 
@@ -232,7 +234,7 @@ def initial(smp: Sample):
232
234
  ))
233
235
  setattr(smp, 'TotalParamsTable', Table(
234
236
  id='8', name='Total Params', header=samples.TOTAL_PARAMS_HEADERS, decimal_places=decimal_places,
235
- text_indexes=[0, 1, 2, 30, 31, 33, 34, 61, 100, 103, *list(range(104, 118))],
237
+ text_indexes=[0, 1, 2, 29, 30, 31, 33, 34, 61, 100, 103, 118],
236
238
  # numeric_indexes=list(range(1, 120)),
237
239
  ))
238
240
 
@@ -357,10 +359,25 @@ def check_version(smp: Sample):
357
359
  smp.TotalParam[32] = [np.nan for index in range(smp.Info.experiment.step_num)]
358
360
  else:
359
361
  smp.TotalParam[32] = [item / (3600 * 24 * 365.242) for item in stand_time_second] # stand year
360
- smp = smp.recalculate(re_table_style=True)
361
- smp = smp.recalculate(re_set_table=True)
362
362
  smp.version = "20251001"
363
363
 
364
+ # 20251231 change publish table
365
+ if version < 20251231:
366
+ smp.PublishValues = arr.create_arr((len(samples.PUBLISH_TABLE_HEADERS) - 3, smp.Info.experiment.step_num))
367
+ try:
368
+ data = np.array(smp.CorrectedValues)
369
+ data[1:10:2] = np.abs(np.divide(data[1:10:2], data[0:10:2])) * 100
370
+ smp.PublishValues[0:10] = copy.deepcopy(data.tolist())
371
+ smp.PublishValues[10:14] = copy.deepcopy(smp.ApparentAgeValues[0:4])
372
+ smp.PublishValues[14:16] = copy.deepcopy(smp.ApparentAgeValues[6:8])
373
+ except (BaseException, Exception) as e:
374
+ print(f"{type(e).__name__}: {str(e)}")
375
+ pass
376
+ else:
377
+ smp = smp.recalculate(re_table_style=True)
378
+ smp = smp.recalculate(re_set_table=True)
379
+ smp.version = "20251231"
380
+
364
381
  return smp
365
382
 
366
383