Skip to content

Commit

Permalink
Grab reference gain/value metadata also for custom-named filtersets (#9)
Browse files Browse the repository at this point in the history
* Add regression test against #8
See #9 for evidence that it works.

* Use filtername lookup to find reference gain/value entries

Closes #8
  • Loading branch information
michaelosthege authored Jan 26, 2022
1 parent 69b3e4c commit 2c18287
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bletl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
from . splines import get_crossvalidated_spline


__version__ = '1.0.3'
__version__ = '1.0.4'
10 changes: 8 additions & 2 deletions bletl/parsing/blpro.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,15 @@ def extract_filtersets(metadata):
filtersets[num][key] = v

# grab data from metadata['process']
fname_lookup = {
"201": "Biomass",
"202": "pH(HP8)",
"203": "DO(PSt3)",
}
for fnum, fset in filtersets.items():
for k in ['reference_value', 'reference_gain', 'gain']:
pk = '{:02d}_{}_{}'.format(fnum, k, fset['name'])
fn = fname_lookup.get(fset['filter_id'], fset['name'])
pk = f'{fnum:02d}_{k}_{fn}'
if pk in process:
filtersets[fnum][k] = process.pop(pk)

Expand Down Expand Up @@ -491,4 +497,4 @@ def calibrate_DO(raw, cal_0, cal_100):
S_cal_100 = numpy.tan(cal_100 * numpy.pi / 180)
ksv = 0.01 * ((S_cal_0 / S_cal_100) - 1)
DO = (1 / ksv) * ((S_cal_0 / numpy.tan(raw * numpy.pi / 180)) - 1)
return DO
return DO
4 changes: 4 additions & 0 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,10 @@ def test_parse_metadata_data(self):

assert isinstance(metadata, dict)
assert isinstance(data, pandas.DataFrame)

# 👇 Regression check against https://github.com/JuBiotech/bletl/issues/8
filtersets = bletl.parsing.blpro.extract_filtersets(metadata)
assert "01_reference_gain_Biomass" not in metadata["process"]
return

def test_parsing(self):
Expand Down

0 comments on commit 2c18287

Please sign in to comment.