ararpy 0.1.11__py3-none-any.whl → 0.1.13__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/calc/arr.py +4 -1
- ararpy/calc/basic.py +36 -14
- ararpy/calc/corr.py +15 -30
- ararpy/calc/isochron.py +4 -2
- ararpy/calc/raw_funcs.py +2 -2
- ararpy/calc/regression.py +3 -1
- ararpy/examples/WHA.pdf +2863 -0
- ararpy/files/calc_file.py +1 -1
- ararpy/files/raw_file.py +84 -82
- ararpy/smp/EXPORT_TO_PDF_DATA_PROPERTIES.py +95 -0
- ararpy/smp/basic.py +9 -7
- ararpy/smp/calculation.py +4 -0
- ararpy/smp/corr.py +104 -56
- ararpy/smp/diffusion_funcs.py +285 -124
- ararpy/smp/export.py +464 -1
- ararpy/smp/json.py +12 -1
- ararpy/smp/plots.py +10 -6
- ararpy/smp/raw.py +9 -2
- ararpy/smp/sample.py +28 -12
- ararpy/smp/table.py +8 -0
- ararpy/test.py +63 -0
- {ararpy-0.1.11.dist-info → ararpy-0.1.13.dist-info}/METADATA +1 -1
- {ararpy-0.1.11.dist-info → ararpy-0.1.13.dist-info}/RECORD +26 -24
- {ararpy-0.1.11.dist-info → ararpy-0.1.13.dist-info}/WHEEL +1 -1
- {ararpy-0.1.11.dist-info → ararpy-0.1.13.dist-info}/LICENSE +0 -0
- {ararpy-0.1.11.dist-info → ararpy-0.1.13.dist-info}/top_level.txt +0 -0
ararpy/files/calc_file.py
CHANGED
|
@@ -342,7 +342,7 @@ def general_adjustment(
|
|
|
342
342
|
irradiation_name: str
|
|
343
343
|
):
|
|
344
344
|
"""
|
|
345
|
-
General handle for all age files, including set
|
|
345
|
+
General handle for all age files, including set irradiation time, initial ratios, error display
|
|
346
346
|
:param total_param:
|
|
347
347
|
:param logs02:
|
|
348
348
|
:param experimental_time:
|
ararpy/files/raw_file.py
CHANGED
|
@@ -21,6 +21,7 @@ from datetime import datetime
|
|
|
21
21
|
from parse import parse as string_parser
|
|
22
22
|
import dateutil.parser as datetime_parser
|
|
23
23
|
from ..calc.arr import get_item
|
|
24
|
+
from ..calc.basic import utc_dt
|
|
24
25
|
|
|
25
26
|
""" Open raw data file """
|
|
26
27
|
|
|
@@ -159,16 +160,15 @@ def open_raw_xls(file_path, input_filter: List[Union[str, int]]):
|
|
|
159
160
|
raise ValueError("The file does not comply with the extension in the given filter.")
|
|
160
161
|
|
|
161
162
|
def _get_content_from_sheet(_index) -> List[List[Union[str, bool, int, float]]]:
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
try:
|
|
164
|
+
_sheet = wb.sheet_by_index(_index)
|
|
165
|
+
except IndexError:
|
|
166
|
+
return []
|
|
167
|
+
else:
|
|
168
|
+
return [[_sheet.cell(_row, _col).value for _col in range(_sheet.ncols)] for _row in range(_sheet.nrows)]
|
|
164
169
|
|
|
165
170
|
wb = open_workbook(file_path)
|
|
166
|
-
|
|
167
|
-
[4, 36, 39, 42, 45, 48, 51, 54, 57, 60, 63, 66, 69, 72, 75, 78, 81, 84, 87,
|
|
168
|
-
90, 93, 96, 99, 102, 105, 108, 111, 114, 117, 120, 123, 126, 129]])
|
|
169
|
-
contents = [[] if i not in used_sheet_index else _get_content_from_sheet(i)
|
|
170
|
-
for i in range(max(used_sheet_index) + 1)]
|
|
171
|
-
|
|
171
|
+
contents = [_get_content_from_sheet(i) for i in range(100)]
|
|
172
172
|
file_name = os.path.basename(file_path).rstrip(os.path.splitext(file_path)[-1])
|
|
173
173
|
step_list = get_raw_data(contents, input_filter, file_name=file_name)
|
|
174
174
|
|
|
@@ -201,13 +201,15 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
201
201
|
|
|
202
202
|
"""
|
|
203
203
|
|
|
204
|
-
def datetime_parse(string,
|
|
204
|
+
def datetime_parse(string, f):
|
|
205
205
|
try:
|
|
206
|
-
return datetime.strptime(string,
|
|
206
|
+
return datetime.strptime(string, f)
|
|
207
207
|
except ValueError as v:
|
|
208
|
-
if
|
|
208
|
+
if f.strip() == "":
|
|
209
|
+
return datetime_parser.parse(string)
|
|
210
|
+
elif len(v.args) > 0 and v.args[0].startswith('unconverted data remains: '):
|
|
209
211
|
string = string[:-(len(v.args[0]) - 26)]
|
|
210
|
-
return datetime.strptime(string,
|
|
212
|
+
return datetime.strptime(string, f)
|
|
211
213
|
else:
|
|
212
214
|
raise
|
|
213
215
|
|
|
@@ -215,52 +217,51 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
215
217
|
idx = step_index = 0
|
|
216
218
|
|
|
217
219
|
header = input_filter[5]
|
|
218
|
-
sample_info_index = input_filter[33:64]
|
|
219
220
|
isotopic_data_index = input_filter[8:28]
|
|
221
|
+
sample_info_index = input_filter[33:65]
|
|
222
|
+
optional_info_index = input_filter[37:-6]
|
|
223
|
+
check_box_index = input_filter[-6:]
|
|
220
224
|
|
|
221
|
-
|
|
225
|
+
timezone = sample_info_index[3] if sample_info_index[3] != "" else "utc"
|
|
226
|
+
while True: # measurment steps sloop
|
|
222
227
|
# Zero datetime
|
|
223
228
|
try:
|
|
224
|
-
if
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
get_item(file_contents, sample_info_index[15:18], base=[1, 1 - idx, 1]), sample_info_index[1])
|
|
228
|
-
else:
|
|
229
|
-
zero_date = datetime_parser.parse(get_item(file_contents, sample_info_index[15:18], base=[1, 1 - idx, 1]))
|
|
229
|
+
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])
|
|
230
232
|
else:
|
|
231
|
-
zero_date = datetime(year=get_item(file_contents, sample_info_index[
|
|
232
|
-
month=get_item(file_contents, sample_info_index[
|
|
233
|
-
day=get_item(file_contents, sample_info_index[
|
|
234
|
-
|
|
235
|
-
if
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
get_item(file_contents, sample_info_index[18:21], base=[1, 1 - idx, 1]), sample_info_index[2])
|
|
239
|
-
else:
|
|
240
|
-
zero_time = datetime_parser.parse(get_item(file_contents, sample_info_index[18:21], base=[1, 1 - idx, 1]))
|
|
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
|
+
|
|
237
|
+
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])
|
|
241
240
|
else:
|
|
242
241
|
zero_time = datetime(year=2020, month=12, day=31,
|
|
243
|
-
hour=get_item(file_contents, sample_info_index[
|
|
244
|
-
minute=get_item(file_contents, sample_info_index[
|
|
245
|
-
second=get_item(file_contents, sample_info_index[
|
|
246
|
-
|
|
247
|
-
zero_datetime = datetime(
|
|
248
|
-
|
|
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]))
|
|
245
|
+
|
|
246
|
+
zero_datetime = datetime(
|
|
247
|
+
zero_date.year, zero_date.month, zero_date.day, zero_time.hour, zero_time.minute, zero_time.second)
|
|
248
|
+
# adjust to UTC
|
|
249
|
+
zero_datetime = utc_dt(zero_datetime, tz=timezone).isoformat(timespec='seconds')
|
|
249
250
|
except (TypeError, ValueError, IndexError):
|
|
250
251
|
# print(f"Cannot parse zero datetime")
|
|
251
|
-
zero_datetime = datetime(
|
|
252
|
+
zero_datetime = datetime(1970, 1, 1, 0, 0, 0).isoformat(timespec='seconds')
|
|
252
253
|
|
|
253
254
|
# Experiment name
|
|
254
255
|
try:
|
|
255
|
-
experiment_name = get_item(file_contents, sample_info_index[
|
|
256
|
+
experiment_name = get_item(file_contents, sample_info_index[4:7], default="", base=[1, 1 - idx, 1])
|
|
256
257
|
except (TypeError, ValueError, IndexError):
|
|
257
258
|
# print(f"Cannot parse experiment name")
|
|
258
|
-
experiment_name = "
|
|
259
|
+
experiment_name = "ExpName"
|
|
259
260
|
|
|
260
261
|
# Step name
|
|
261
262
|
try:
|
|
262
|
-
step_name = get_item(file_contents, sample_info_index[
|
|
263
|
-
if
|
|
263
|
+
step_name = get_item(file_contents, sample_info_index[7:10], default="", base=[1, 1 - idx, 1]) if input_filter[7] > 0 else ""
|
|
264
|
+
if check_box_index[1] and sample_info_index[0].strip() != "":
|
|
264
265
|
_res = string_parser(sample_info_index[0], file_name)
|
|
265
266
|
if _res is not None:
|
|
266
267
|
experiment_name = _res.named.get("en", experiment_name)
|
|
@@ -276,15 +277,15 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
276
277
|
break
|
|
277
278
|
|
|
278
279
|
# other information
|
|
279
|
-
options = get_sample_info(file_contents,
|
|
280
|
+
options = get_sample_info(file_contents, optional_info_index, default="", base=[1, 1 - idx, 1])
|
|
280
281
|
|
|
281
282
|
current_step = [[step_name, zero_datetime, experiment_name, options]]
|
|
282
283
|
|
|
283
284
|
break_num = 0
|
|
284
285
|
cycle_num = 0
|
|
285
|
-
f = float(input_filter[31])
|
|
286
|
+
f = float(input_filter[31]) # Intensity Scale Factor
|
|
286
287
|
data_content = file_contents[input_filter[4] - 1 if input_filter[4] != 0 else 0]
|
|
287
|
-
for i in range(2000):
|
|
288
|
+
for i in range(2000): # measurement cycle sloop
|
|
288
289
|
if break_num < input_filter[29]:
|
|
289
290
|
break_num += 1
|
|
290
291
|
continue
|
|
@@ -307,7 +308,8 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
307
308
|
float(data_content[start_row + isotopic_data_index[ 0]][isotopic_data_index[ 1] - 1]) * f,
|
|
308
309
|
])
|
|
309
310
|
except (ValueError, IndexError):
|
|
310
|
-
|
|
311
|
+
print(f"Cannot parse isotope data")
|
|
312
|
+
print(traceback.format_exc())
|
|
311
313
|
current_step.append([
|
|
312
314
|
str(cycle_num + 1), None, None, None, None, None, None, None, None, None, None,
|
|
313
315
|
])
|
|
@@ -330,7 +332,8 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
330
332
|
float(data_content[start_row][isotopic_data_index[ 1] + col_inc]) * f,
|
|
331
333
|
])
|
|
332
334
|
except (ValueError, IndexError):
|
|
333
|
-
|
|
335
|
+
print(f"Cannot parse isotope data")
|
|
336
|
+
print(traceback.format_exc())
|
|
334
337
|
current_step.append([
|
|
335
338
|
str(cycle_num + 1), None, None, None, None, None, None, None, None, None, None,
|
|
336
339
|
])
|
|
@@ -345,18 +348,18 @@ def get_raw_data(file_contents: List[List[Union[int, float, str, bool, list]]],
|
|
|
345
348
|
step_index += 1
|
|
346
349
|
idx = input_filter[32] * step_index
|
|
347
350
|
|
|
348
|
-
if not
|
|
351
|
+
if not check_box_index[0] or step_index >= 500: # check_box_index[0]: multiple sequences
|
|
349
352
|
break
|
|
350
353
|
|
|
351
354
|
return step_list
|
|
352
355
|
|
|
353
356
|
|
|
354
|
-
def get_sample_info(file_contents: list,
|
|
357
|
+
def get_sample_info(file_contents: list, index_list: list, default="", base: Union[int, tuple, list] = 1) -> dict:
|
|
355
358
|
"""
|
|
356
359
|
Parameters
|
|
357
360
|
----------
|
|
358
361
|
file_contents
|
|
359
|
-
|
|
362
|
+
index_list
|
|
360
363
|
default
|
|
361
364
|
base
|
|
362
365
|
|
|
@@ -364,41 +367,40 @@ def get_sample_info(file_contents: list, input_filter: list, default="", base=1)
|
|
|
364
367
|
-------
|
|
365
368
|
|
|
366
369
|
"""
|
|
367
|
-
sample_info_index = input_filter[36:132]
|
|
368
370
|
sample_info = DEFAULT_SAMPLE_INFO.copy()
|
|
369
371
|
sample_info.update({
|
|
370
|
-
"ExpName": get_item(file_contents,
|
|
371
|
-
"StepName": get_item(file_contents,
|
|
372
|
-
"SmpType": get_item(file_contents,
|
|
373
|
-
"StepLabel": get_item(file_contents,
|
|
374
|
-
"ZeroYear": get_item(file_contents,
|
|
375
|
-
"ZeroHour": get_item(file_contents,
|
|
376
|
-
"ZeroMon": get_item(file_contents,
|
|
377
|
-
"ZeroMin": get_item(file_contents,
|
|
378
|
-
"ZeroDay": get_item(file_contents,
|
|
379
|
-
"ZeroSec": get_item(file_contents,
|
|
380
|
-
"SmpName": get_item(file_contents,
|
|
381
|
-
"SmpLoc": get_item(file_contents,
|
|
382
|
-
"SmpMatr": get_item(file_contents,
|
|
383
|
-
"ExpType": get_item(file_contents,
|
|
384
|
-
"SmpWeight": get_item(file_contents,
|
|
385
|
-
"Stepunit": get_item(file_contents,
|
|
386
|
-
"HeatingTime": get_item(file_contents,
|
|
387
|
-
"InstrName": get_item(file_contents,
|
|
388
|
-
"Researcher": get_item(file_contents,
|
|
389
|
-
"Analyst": get_item(file_contents,
|
|
390
|
-
"Lab": get_item(file_contents,
|
|
391
|
-
"Jv": get_item(file_contents,
|
|
392
|
-
"Jsig": get_item(file_contents,
|
|
393
|
-
"CalcName": get_item(file_contents,
|
|
394
|
-
"IrraName": get_item(file_contents,
|
|
395
|
-
"IrraLabel": get_item(file_contents,
|
|
396
|
-
"IrraPosH": get_item(file_contents,
|
|
397
|
-
"IrraPosX": get_item(file_contents,
|
|
398
|
-
"IrraPosY": get_item(file_contents,
|
|
399
|
-
"StdName": get_item(file_contents,
|
|
400
|
-
"StdAge": get_item(file_contents,
|
|
401
|
-
"StdAgeSig": get_item(file_contents,
|
|
372
|
+
"ExpName": get_item(file_contents, index_list[0:3], default=default, base=base),
|
|
373
|
+
"StepName": get_item(file_contents, index_list[3:6], default=default, base=base),
|
|
374
|
+
"SmpType": get_item(file_contents, index_list[6:9], default=default, base=base),
|
|
375
|
+
"StepLabel": get_item(file_contents, index_list[9:12], default=default, base=base),
|
|
376
|
+
"ZeroYear": get_item(file_contents, index_list[12:15], default=default, base=base), # year
|
|
377
|
+
"ZeroHour": get_item(file_contents, index_list[15:18], default=default, base=base), # hour
|
|
378
|
+
"ZeroMon": get_item(file_contents, index_list[18:21], default=default, base=base), # month
|
|
379
|
+
"ZeroMin": get_item(file_contents, index_list[21:24], default=default, base=base), # minute
|
|
380
|
+
"ZeroDay": get_item(file_contents, index_list[24:27], default=default, base=base), # day
|
|
381
|
+
"ZeroSec": get_item(file_contents, index_list[27:30], default=default, base=base), # second
|
|
382
|
+
"SmpName": get_item(file_contents, index_list[30:33], default=default, base=base),
|
|
383
|
+
"SmpLoc": get_item(file_contents, index_list[33:36], default=default, base=base),
|
|
384
|
+
"SmpMatr": get_item(file_contents, index_list[36:39], default=default, base=base),
|
|
385
|
+
"ExpType": get_item(file_contents, index_list[39:42], default=default, base=base),
|
|
386
|
+
"SmpWeight": get_item(file_contents, index_list[42:45], default=default, base=base),
|
|
387
|
+
"Stepunit": get_item(file_contents, index_list[45:48], default=default, base=base),
|
|
388
|
+
"HeatingTime": get_item(file_contents, index_list[48:51], default=default, base=base),
|
|
389
|
+
"InstrName": get_item(file_contents, index_list[51:54], default=default, base=base),
|
|
390
|
+
"Researcher": get_item(file_contents, index_list[54:57], default=default, base=base),
|
|
391
|
+
"Analyst": get_item(file_contents, index_list[57:60], default=default, base=base),
|
|
392
|
+
"Lab": get_item(file_contents, index_list[60:63], default=default, base=base),
|
|
393
|
+
"Jv": get_item(file_contents, index_list[63:66], default=default, base=base),
|
|
394
|
+
"Jsig": get_item(file_contents, index_list[66:69], default=default, base=base),
|
|
395
|
+
"CalcName": get_item(file_contents, index_list[69:72], default=default, base=base),
|
|
396
|
+
"IrraName": get_item(file_contents, index_list[72:75], default=default, base=base),
|
|
397
|
+
"IrraLabel": get_item(file_contents, index_list[75:78], default=default, base=base),
|
|
398
|
+
"IrraPosH": get_item(file_contents, index_list[78:81], default=default, base=base),
|
|
399
|
+
"IrraPosX": get_item(file_contents, index_list[81:84], default=default, base=base),
|
|
400
|
+
"IrraPosY": get_item(file_contents, index_list[84:87], default=default, base=base),
|
|
401
|
+
"StdName": get_item(file_contents, index_list[87:90], default=default, base=base),
|
|
402
|
+
"StdAge": get_item(file_contents, index_list[90:93], default=default, base=base),
|
|
403
|
+
"StdAgeSig": get_item(file_contents, index_list[93:96], default=default, base=base),
|
|
402
404
|
# "Experiment Name": get_item(file_contents, sample_info_index[0:3], default=default, base=base),
|
|
403
405
|
# "Step Name": get_item(file_contents, sample_info_index[3:6], default=default, base=base),
|
|
404
406
|
# "Sample Type": get_item(file_contents, sample_info_index[6:9], default=default, base=base),
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# -*- coding: UTF-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
# ==========================================
|
|
5
|
+
# Copyright 2024 Yang
|
|
6
|
+
# webarar - EXPORT_TO_PDF_DATA_PROPERTIES
|
|
7
|
+
# ==========================================
|
|
8
|
+
#
|
|
9
|
+
#
|
|
10
|
+
#
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
def plot_data(data: dict):
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
Parameters
|
|
17
|
+
----------
|
|
18
|
+
data: dict
|
|
19
|
+
- file_name: string
|
|
20
|
+
file name, like "24WHA0001"
|
|
21
|
+
- data: list of dicts
|
|
22
|
+
properties:
|
|
23
|
+
- name: string
|
|
24
|
+
diagram name, like "Age spectra"
|
|
25
|
+
|
|
26
|
+
- xAxis: list
|
|
27
|
+
properties:
|
|
28
|
+
- extend: list
|
|
29
|
+
limits of values of axis, like [0, 100]
|
|
30
|
+
- interval: list
|
|
31
|
+
sticks location, like [0, 20, 40, 60, 80, 100]
|
|
32
|
+
- title: string
|
|
33
|
+
- nameLocation: string
|
|
34
|
+
axis title location, 'middle'
|
|
35
|
+
|
|
36
|
+
- yAxis: same as xAxis
|
|
37
|
+
|
|
38
|
+
- series: list
|
|
39
|
+
properties:
|
|
40
|
+
- type: string
|
|
41
|
+
series type, 'line', 'scatter', 'text', and any string contains these characters
|
|
42
|
+
- id: string
|
|
43
|
+
- name: string
|
|
44
|
+
- color: string or list
|
|
45
|
+
color for outlines, color name | RGB triplet | Hex color code
|
|
46
|
+
- fillColor: string or list
|
|
47
|
+
color for filling markers, format is similar to that of color
|
|
48
|
+
- data: 2-dimensional array
|
|
49
|
+
[[x1, y1], [x2, y2], ...]
|
|
50
|
+
|
|
51
|
+
optional:
|
|
52
|
+
- lineCaps: string
|
|
53
|
+
for lines only, 'square', 'none', 'butt'
|
|
54
|
+
- text: string
|
|
55
|
+
for texts only
|
|
56
|
+
- size: int
|
|
57
|
+
for scatters only
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
Returns
|
|
61
|
+
-------
|
|
62
|
+
|
|
63
|
+
"""
|
|
64
|
+
pass
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
data = {
|
|
68
|
+
"data": [
|
|
69
|
+
{
|
|
70
|
+
'name': 'spectra',
|
|
71
|
+
'xAxis': [{'extent': [0, 100], 'interval': [0, 20, 40, 60, 80, 100],
|
|
72
|
+
'title': 'Cumulative <sup>39</sup>Ar Released (%)', 'title_location': 'middle', }],
|
|
73
|
+
'yAxis': [{'extent': [0, 25], 'interval': [0, 5, 10, 15, 20, 25],
|
|
74
|
+
'title': 'Apparent Age (Ma)', 'title_location': 'middle', }],
|
|
75
|
+
'series': [
|
|
76
|
+
{
|
|
77
|
+
'type': 'text', 'id': f'text_0', 'name': f'text_0', 'color': '#222222',
|
|
78
|
+
'text': f'xxx<r>xxxxxx', 'size': 10,
|
|
79
|
+
'data': [[5, 23]],
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
'type': 'series.line', 'id': f'line_0', 'name': f'line_0',
|
|
83
|
+
'color': '#333333',
|
|
84
|
+
'data': [[]], 'line_caps': 'square',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
'type': 'series.line', 'id': f'line_2', 'name': f'line_2',
|
|
88
|
+
'color': '#555555',
|
|
89
|
+
'data': [[]], 'line_caps': 'square',
|
|
90
|
+
}
|
|
91
|
+
]
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"file_name": "WHA"
|
|
95
|
+
}
|
ararpy/smp/basic.py
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"""
|
|
12
12
|
# === Internal imports ===
|
|
13
13
|
import os
|
|
14
|
+
import re
|
|
14
15
|
import traceback
|
|
15
16
|
import pandas as pd
|
|
16
17
|
import numpy as np
|
|
@@ -521,23 +522,24 @@ def set_params(smp: Sample, params: Union[List, str], flag: Optional[str] = None
|
|
|
521
522
|
smp.TotalParam[30] = [params[-5]] * n
|
|
522
523
|
try:
|
|
523
524
|
stand_time_second = [
|
|
524
|
-
calc.basic.get_datetime(*smp.TotalParam[31][i]
|
|
525
|
-
*smp.TotalParam[30][i]
|
|
526
|
-
except
|
|
527
|
-
|
|
528
|
-
pass
|
|
525
|
+
calc.basic.get_datetime(*re.findall(r"\d+", smp.TotalParam[31][i])) - calc.basic.get_datetime(
|
|
526
|
+
*re.findall(r"\d+", smp.TotalParam[30][i])) for i in range(n)]
|
|
527
|
+
except TypeError:
|
|
528
|
+
print(f'Error in calculate standing duration: {traceback.format_exc()}')
|
|
529
529
|
else:
|
|
530
530
|
smp.TotalParam[32] = [i / (3600 * 24 * 365.242) for i in stand_time_second] # stand year
|
|
531
531
|
|
|
532
532
|
elif flag == 'smp':
|
|
533
|
+
print(params)
|
|
533
534
|
smp.TotalParam[67:71] = remove_none(smp.TotalParam[67:71], params[0:4], n, 71 - 67)
|
|
534
535
|
smp.TotalParam[58:67] = remove_none(smp.TotalParam[58:67], params[4:13], n, 67 - 58)
|
|
535
536
|
smp.TotalParam[97:100] = remove_none(smp.TotalParam[97:100], params[13:16], n, 100 - 97)
|
|
536
537
|
smp.TotalParam[115:120] = remove_none(smp.TotalParam[115:120], params[16:21], n, 120 - 115)
|
|
537
|
-
smp.TotalParam[
|
|
538
|
+
smp.TotalParam[126:136] = remove_none(smp.TotalParam[126:136], params[21:31], n, 136 - 126)
|
|
539
|
+
smp.TotalParam[120:123] = remove_none(smp.TotalParam[120:123], params[31:34], n, 123 - 120)
|
|
538
540
|
smp.TotalParam[100:114] = remove_none(
|
|
539
541
|
smp.TotalParam[100:114],
|
|
540
|
-
[['Linear', 'Exponential', 'Power'][params[
|
|
542
|
+
[['Linear', 'Exponential', 'Power'][params[34:37].index(True)] if True in params[34:37] else '', *params[37:]], n, 114 - 100)
|
|
541
543
|
else:
|
|
542
544
|
raise KeyError(f"{flag = } is not supported. It must be 'calc' for Calc Params, "
|
|
543
545
|
f"'irra' for Irradiation Params, or 'smp' for Sample Params.")
|
ararpy/smp/calculation.py
CHANGED
|
@@ -47,6 +47,7 @@ def recalculate(
|
|
|
47
47
|
re_plot_style
|
|
48
48
|
re_set_table
|
|
49
49
|
re_table_style
|
|
50
|
+
re_corr_gain
|
|
50
51
|
kwargs
|
|
51
52
|
|
|
52
53
|
Returns
|
|
@@ -59,9 +60,12 @@ def recalculate(
|
|
|
59
60
|
# print(f"{sample.SelectedSequence1 = }")
|
|
60
61
|
# print(f"{sample.SelectedSequence2 = }")
|
|
61
62
|
# --- initializing ---
|
|
63
|
+
re_corr_gain = re_corr_blank
|
|
62
64
|
if re_initial: # 1
|
|
63
65
|
initial.re_set_smp(sample)
|
|
64
66
|
# --- calculating ---
|
|
67
|
+
if re_corr_gain: # 2 2024-10-04 add
|
|
68
|
+
corr.corr_gain(sample)
|
|
65
69
|
if re_corr_blank: # 2
|
|
66
70
|
corr.corr_blank(sample)
|
|
67
71
|
if re_corr_massdiscr: # 3
|