ararpy 0.1.27__py3-none-any.whl → 0.1.29__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/export.py CHANGED
@@ -310,7 +310,7 @@ def getRectFromSpectra(data):
310
310
 
311
311
  """
312
312
  data = np.array(data)
313
- return list(map(lambda index: [data[index,0], min(data[index,[1,2]]), np.diff(data[[index,index+1],0])[0], np.diff(data[index,[1,2]])[0]], list(range(len(data) - 1))))
313
+ return list(filter(lambda rect: rect[2] != 0 and rect[3] != 0, map(lambda index: [data[index,0], min(data[index,[1,2]]), abs(data[index+1,0] - data[index,0]), abs(data[index,1] - data[index,2])], list(range(len(data) - 1)))))
314
314
 
315
315
 
316
316
  def _get_additional_text_series(name):
@@ -364,7 +364,6 @@ def _get_plot_data_age_spectra_series(smp: sample, **options):
364
364
  plateau_data = np.array(set_data[index])
365
365
  # 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))
366
366
  spectra_fill_data = getRectFromSpectra(plateau_data)
367
- print(spectra_fill_data)
368
367
  series.append({
369
368
  'type': 'series.rect', 'id': f'rect-{smp.name()}-{get_random_digits()}', 'name': f'rect-{smp.name()}-{get_random_digits()}',
370
369
  'color': ['red', 'blue'][index], 'fill_color': ['red', 'blue'][index], 'line_width': 0, 'line_style': 'none', 'z_index': 9,
@@ -1229,20 +1228,36 @@ class WritingWorkbook:
1229
1228
 
1230
1229
  def write_sht_table(self, sht_name, prop_name, sht_type, row, col, _, smp_attr_name, header_name, style, xls, sigma=1):
1231
1230
  sht = xls.add_worksheet(sht_name)
1231
+ num_step = len(self.sample.SequenceName)
1232
1232
  data = arr.transpose(getattr(self.sample, smp_attr_name, None).data)
1233
1233
  sht.hide_gridlines(2) # 0 = show grids, 1 = hide print grid, else = hide print and screen grids
1234
1234
  sht.hide() # default hidden table sheet
1235
1235
  sht.set_column(0, len(data), width=12) # column width
1236
1236
  header = getattr(sample, header_name)
1237
1237
  header = list(map(lambda each: each if "σ" not in each else each.replace('1', str(sigma)) if str(sigma) not in each else each.replace('2', str(sigma)), header))
1238
- sht.write_row(row=row - 1, col=col, data=header, cell_format=style)
1239
- for index, col_data in enumerate(data):
1240
- if "σ" in header[col]:
1241
- col_data = list(map(lambda each: each * sigma, col_data))
1242
- res = sht.write_column(row=row, col=col, data=col_data, cell_format=style)
1243
- if res:
1244
- raise ValueError(res)
1245
- col += 1
1238
+
1239
+ content = [
1240
+ [(0, 0), f"{sht_name}", {'bold': 1, 'top': 1, 'align': 'left'}],
1241
+ *[[(1, col, 2, col), each, {'bold': 1, 'top': 1, 'bottom': 6}] for col, each in enumerate(header)],
1242
+ *[[(3, col, 1), each if "σ" not in header[col] else list(map(lambda _: _ * sigma, each)), {}] for col, each in enumerate(data)],
1243
+ [(3 + num_step, 0, 0), [''] * len(data), {'bold': 1, 'top': 1}],
1244
+ ]
1245
+
1246
+ for pos, value, _prop in content:
1247
+ prop = self.default_fmt_prop.copy()
1248
+ prop.update(_prop)
1249
+ fmt = Format(prop, xls.xf_format_indices, xls.dxf_format_indices)
1250
+ xls.formats.append(fmt)
1251
+ if isinstance(value, (list, np.ndarray)) and len(pos) == 3:
1252
+ value = [None if isinstance(v, (float, int)) and np.isnan(v) else v for v in value]
1253
+ [sht.write_row, sht.write_column][pos[2]](*pos[:2], value, fmt)
1254
+ elif len(pos) == 2:
1255
+ isnumeric = isinstance(value, (float, int)) and not np.isnan(value) and not np.isinf(value)
1256
+ [sht.write_string, sht.write_number][isnumeric](*pos, value if isnumeric else str(value), fmt)
1257
+ elif len(pos) == 4:
1258
+ isnumeric = isinstance(value, (float, int)) and not np.isnan(value) and not np.isinf(value)
1259
+ sht.merge_range(*pos, value if isnumeric else str(value), fmt)
1260
+
1246
1261
 
1247
1262
  def write_sht_chart(self, sht_name, prop_name, sht_type, row, col, _, smp_attr_name, header_name, style, xls, start_row, total_rows):
1248
1263
  sht = xls.add_chartsheet(sht_name)
ararpy/smp/initial.py CHANGED
@@ -298,21 +298,42 @@ def check_version(smp: Sample):
298
298
  std = initial(Sample())
299
299
  basic.get_merged_smp(smp, std)
300
300
 
301
+ try:
302
+ version = int(smp.version)
303
+ except ValueError:
304
+ return smp
305
+
301
306
  # 20250328: # Experiment info
302
307
  smp.Info.experiment.name = smp.name()
303
308
  smp.Info.experiment.step_num = smp.sequence().size
304
309
 
305
- # 20250404
310
+ # old version: add masses and gain factors
311
+ if version < 20240730:
312
+ gains = np.ones([10, smp.Info.experiment.step_num])
313
+ gains[[1, 3, 5, 7, 9], :] = 0
314
+ smp.TotalParam[126:136] = gains.tolist()
315
+ gains[0] = 35.96754628
316
+ gains[2] = 36.9667759
317
+ gains[4] = 37.9627322
318
+ gains[6] = 38.964313
319
+ gains[8] = 39.962383123
320
+ smp.TotalParam[71:81] = gains.tolist()
321
+ smp.version = "20240730"
322
+
323
+ # 20250404: # Normalization for steps with different J values
306
324
  doNormalize = True
307
325
  v, sv = [], []
308
- if smp.Info.sample.type.lower() == "unknown":
309
- v, sv = smp.TotalParam[67:69]
310
- sv = np.multiply(v, sv) / 100
311
- elif smp.Info.sample.type.lower() == "air":
312
- v, sv = smp.TotalParam[93:95]
313
- sv = np.multiply(v, sv) / 100
314
- elif smp.Info.sample.type.lower() == "standard":
315
- v, sv = smp.TotalParam[59:61]
326
+ try:
327
+ if smp.Info.sample.type.lower() == "unknown":
328
+ v, sv = smp.TotalParam[67:69]
329
+ sv = np.multiply(v, sv) / 100
330
+ elif smp.Info.sample.type.lower() == "air":
331
+ v, sv = smp.TotalParam[93:95]
332
+ sv = np.multiply(v, sv) / 100
333
+ elif smp.Info.sample.type.lower() == "standard":
334
+ v, sv = smp.TotalParam[59:61]
335
+ except:
336
+ doNormalize = False
316
337
  smp.NormalizeFactor = [
317
338
  [1 if v[0] == each or not doNormalize else v[0] / each for each in v],
318
339
  [0 if v[0] == v[i] or not doNormalize else err.div((v[0], sv[0]), (v[i], sv[i])) for i in range(len(v))]
ararpy/smp/sample.py CHANGED
@@ -776,7 +776,7 @@ DEFAULT_PLOT_STYLES = lambda sample_type, age_unit: {
776
776
  },
777
777
  }
778
778
 
779
- VERSION = '20250404'
779
+ VERSION = '20250622'
780
780
 
781
781
  NAMED_DICT = {
782
782
  "unknown": {"header": SAMPLE_INTERCEPT_HEADERS.copy()},
@@ -884,12 +884,20 @@ class Sample:
884
884
  # self.__version = '20250301' # update sample info
885
885
  # self.__version = '20250321' # error sigma adjustment
886
886
  # self.__version = '20250328' # Experiment info
887
- self.__version = '20250404' # J normalization factor
887
+ # self.__version = '20250404' # J normalization factor
888
+ self.__version = '20250622' # version setter
888
889
 
889
890
  @property
890
891
  def version(self):
891
892
  return self.__version
892
893
 
894
+ @version.setter
895
+ def version(self, v):
896
+ if isinstance(v, (str, int)) and str(v).startswith("20"):
897
+ self.__version = str(v)
898
+ else:
899
+ raise ValueError("Version setter Error")
900
+
893
901
  def help(self) -> str: ...
894
902
 
895
903
  def name(self) -> str: ...
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ararpy
3
- Version: 0.1.27
3
+ Version: 0.1.29
4
4
  Summary: A project for Ar-Ar geochronology
5
5
  Home-page: https://github.com/wuyangchn/ararpy.git
6
6
  Author: Yang Wu
@@ -46,21 +46,21 @@ ararpy/smp/calculation.py,sha256=LCFJWjLVLEKEQ5b7RFUIxsMahEzgLdodW4kCYXV5Z34,291
46
46
  ararpy/smp/consts.py,sha256=XIdjdz8cYxspG2jMnoItdlUsxr3hKbNFJjMZJh1bpzw,393
47
47
  ararpy/smp/corr.py,sha256=TzH7rymToJP0RCI0pQm-SrqnwAZ58HJbxahE8chv2wQ,26511
48
48
  ararpy/smp/diffusion_funcs.py,sha256=4-PMMIZWzjk2HOYYWNgSp4GmApygp1MmOxJ2g3xrqWc,175049
49
- ararpy/smp/export.py,sha256=VvpqV_WxScbJ1bcmS6lDiBCa2bIn-TuumUOcDo78ItA,116201
49
+ ararpy/smp/export.py,sha256=eBUGx9eUHQ7EoibT-PC1HK7Zw_V1LUfuKJv56_XccUQ,117284
50
50
  ararpy/smp/info.py,sha256=iKUELm-BuUduDlJKC1d8tKKNHbwwbNmhUg2pi6bcBvA,489
51
- ararpy/smp/initial.py,sha256=VSNku2fYD1xGkpHxMqnSJCAhSQawfsDCdqYCxtDJryQ,17196
51
+ ararpy/smp/initial.py,sha256=GFLEYxes-_PT_qgZj0Dagy_blg9JmzjO7uh3vQHbS78,17891
52
52
  ararpy/smp/json.py,sha256=BTZCjVN0aj9epc700nwkYEYMKN2lHBYo-pLmtnz5oHY,2300
53
53
  ararpy/smp/plots.py,sha256=rF0vrFu9dMt2Eu1EHiDfDRC9232M6dH0Unc_3qNDxLY,33579
54
54
  ararpy/smp/raw.py,sha256=51n-rrbW2FqeZHQyevuG7iObPLGvIBzTe414QDVM1FE,6523
55
- ararpy/smp/sample.py,sha256=N0ChOxMgNYLU_EwJvGXJARWnubsaKXmvS7jmM-uW7mg,57948
55
+ ararpy/smp/sample.py,sha256=slKiGUobEG7ZfJW6byBgc9jlWN1-zLg27iEdm-No5dw,58228
56
56
  ararpy/smp/style.py,sha256=wCygwtpCflhzwmI7u08X-feYGPytOyfR98YcgJx813c,7678
57
57
  ararpy/smp/table.py,sha256=9bNAOqAIOc0nSC3LNeqjJKUYSJSM28Ji3o9VimwMU8A,6645
58
58
  ararpy/thermo/__init__.py,sha256=6VBuqTRFl403PVqOuMkVrut0nKaQsAosBmfW91X1dMg,263
59
59
  ararpy/thermo/arrhenius.py,sha256=Ass1ichHfqIAtpv8eLlgrUc1UOb3Urh1qzr1E3gLB4U,233
60
60
  ararpy/thermo/atomic_level_random_walk.py,sha256=Q97zfe2h2RaxADkoBAqd0uEiP16BFOajrTmXHMkL2EQ,25502
61
61
  ararpy/thermo/basic.py,sha256=nBGHI9uK7VdJwThwBIOcKAzdnYqPyQseFoY6s4zKizk,11504
62
- ararpy-0.1.27.dist-info/licenses/LICENSE,sha256=cvG5t_C1qY_zUyJI7sNOa7gCArdngNPaOrfujl2LYuc,1085
63
- ararpy-0.1.27.dist-info/METADATA,sha256=ekOHHUdF4oyaBG5S7NJR7I4daFUFs-YzFCLo-Z3JXng,24516
64
- ararpy-0.1.27.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
65
- ararpy-0.1.27.dist-info/top_level.txt,sha256=9iTpsPCYuRYq09yQTk9d2lqB8JtTEOmbN-IcGB-K3vY,7
66
- ararpy-0.1.27.dist-info/RECORD,,
62
+ ararpy-0.1.29.dist-info/licenses/LICENSE,sha256=cvG5t_C1qY_zUyJI7sNOa7gCArdngNPaOrfujl2LYuc,1085
63
+ ararpy-0.1.29.dist-info/METADATA,sha256=4OPGl6KfTwxwSI6oU5gcILqUjMTrazzzhC-acKZ54MY,24516
64
+ ararpy-0.1.29.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
65
+ ararpy-0.1.29.dist-info/top_level.txt,sha256=9iTpsPCYuRYq09yQTk9d2lqB8JtTEOmbN-IcGB-K3vY,7
66
+ ararpy-0.1.29.dist-info/RECORD,,