Skip to content

Commit b0868c3

Browse files
committed
Test files received
1 parent c98cebd commit b0868c3

96 files changed

Lines changed: 21072 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tests/_test_geomar_dec25.py

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# %%
2+
import os
3+
4+
import pandas as pd
5+
6+
import calkulate as calk
7+
8+
9+
# Set the acid concentration (mol/kg) to use for "uncalibrated" alkalinity
10+
titrant_molinity_guess = 0.01
11+
12+
# Set the file paths where the data files can be found
13+
path_to_files = "tests/data/geomar-dec25/"
14+
metadata_file = "Acidbatch 4.xlsx"
15+
subpath = "Acidbatch 4 20240712 to 20240725"
16+
#
17+
# This assumes a folder structure like the following:
18+
# .
19+
# └── tests/data/geomar-dec25/ (<-- defined by `path_to_files`)
20+
# ├── Acidbatch 4.xlsx (<-- defined by `metadata_file`)
21+
# └── Acidbatch 4 20240712 to 20240725/ (<-- defined by `subpath`)
22+
# ├── 20240712/
23+
# │ ├── Junk-SW-01.old
24+
# │ ├── Junk-SW-02.old
25+
# │ └── ...
26+
# ├── 20240716/
27+
# │ └── ...
28+
# └── ...
29+
#
30+
# The subfolder names (20240712, 20240716, etc.) need to be specified in the
31+
# `session` column of the metadata spreadsheet.
32+
#
33+
# The file names, excluding the ".old", need to be in the `name` column.
34+
#
35+
# ==================================================
36+
#
37+
# You shouldn't need to change anything below here
38+
# (but there is more info at the bottom)
39+
#
40+
# ==================================================
41+
#
42+
# Next, we use the information provided above to construct columns containing
43+
# the correct file paths and file names
44+
ds = pd.read_excel(os.path.join(path_to_files, metadata_file))
45+
ds["file_path"] = [
46+
os.path.join(path_to_files, subpath, str(int(session)))
47+
if pd.notnull(session)
48+
else None
49+
for session in ds.session
50+
]
51+
ds["file_name"] = ds.name + ".old"
52+
ds["file_good"] = ds.file_name.notnull()
53+
54+
# Define some settings we need to read your data files properly
55+
kwargs_tiamo = dict(
56+
file_type="tiamo_de",
57+
solve_mode="pH_gran", # can try "pH" or "pH_adjust" or "pH_gran"
58+
)
59+
60+
# First, manually set the acid concentration (`titrant_molinity`) and solve
61+
ds["titrant_molinity"] = titrant_molinity_guess
62+
calk.solve(ds, **kwargs_tiamo)
63+
ds["alkalinity_uncalibrated"] = ds.alkalinity.copy()
64+
65+
# Then, calibrate with CRMs and solve for alkalinity again
66+
calk.calibrate(ds, **kwargs_tiamo)
67+
68+
# Export results to a new spreadsheet
69+
ds.to_excel(
70+
os.path.join(
71+
path_to_files,
72+
metadata_file.replace(".xlsx", " processed.xlsx"),
73+
),
74+
index=False,
75+
)
76+
# Columns of interest
77+
# -------------------
78+
# alkalinity_uncalibrated
79+
# TA with the manually set acid concentration (µmol/kg-sw)
80+
# alkalinity
81+
# Final TA values, calibrated to CRMs (µmol/kg-sw)
82+
# alkalinity_offset
83+
# Difference between measured and certified CRM values (µmol/kg-sw)
84+
# titrant_molinity_here
85+
# Best-fitting acid concentration for each CRM (mol/kg)
86+
# titrant_molinity
87+
# Average of titrant_molinity_here, used for the final alkalinity values

tests/data/geomar-dec25/Acidbatch 4 20240712 to 20240725/20240712/CRM-210-0039-01.old

Lines changed: 221 additions & 0 deletions
Large diffs are not rendered by default.

tests/data/geomar-dec25/Acidbatch 4 20240712 to 20240725/20240712/CRM-210-0039-02.old

Lines changed: 220 additions & 0 deletions
Large diffs are not rendered by default.

tests/data/geomar-dec25/Acidbatch 4 20240712 to 20240725/20240712/CRM-210-0477.old

Lines changed: 220 additions & 0 deletions
Large diffs are not rendered by default.

tests/data/geomar-dec25/Acidbatch 4 20240712 to 20240725/20240712/ICOS-258.old

Lines changed: 223 additions & 0 deletions
Large diffs are not rendered by default.

tests/data/geomar-dec25/Acidbatch 4 20240712 to 20240725/20240712/ICOS-264-01.old

Lines changed: 224 additions & 0 deletions
Large diffs are not rendered by default.

tests/data/geomar-dec25/Acidbatch 4 20240712 to 20240725/20240712/ICOS-264-02.old

Lines changed: 223 additions & 0 deletions
Large diffs are not rendered by default.

tests/data/geomar-dec25/Acidbatch 4 20240712 to 20240725/20240712/ICOS-278.old

Lines changed: 223 additions & 0 deletions
Large diffs are not rendered by default.

tests/data/geomar-dec25/Acidbatch 4 20240712 to 20240725/20240712/Junk-SW-01.old

Lines changed: 218 additions & 0 deletions
Large diffs are not rendered by default.

tests/data/geomar-dec25/Acidbatch 4 20240712 to 20240725/20240712/Junk-SW-02.old

Lines changed: 219 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)