Browse Source

normalize_values() will respect preset exposure time

xmlparsing
Holger Frey 4 years ago
parent
commit
d6dac702e7
  1. 2
      sensospot_data/__init__.py
  2. 8
      sensospot_data/dynamic_range.py
  3. 23
      tests/test_dynamic_range.py

2
sensospot_data/__init__.py

@ -3,7 +3,7 @@
Parsing the numerical output from Sensovations Sensospot image analysis. Parsing the numerical output from Sensovations Sensospot image analysis.
""" """
__version__ = "0.5.1" __version__ = "0.5.2"
from pathlib import Path from pathlib import Path

8
sensospot_data/dynamic_range.py

@ -69,11 +69,13 @@ def normalize_values(data_frame, normalized_time=None):
"""add exposure time normalized values to a data frame """add exposure time normalized values to a data frame
will use the maximum exposure time, if none is provided will use the maximum exposure time, if none is provided
and the column SETTINGS_NORMALIZED_EXPOSURE_TIME was not
set before.
""" """
if normalized_time is None: if normalized_time:
data_frame[SETTINGS_NORMALIZED_EXPOSURE_TIME] = normalized_time
elif SETTINGS_NORMALIZED_EXPOSURE_TIME not in data_frame.columns:
normalized_time = data_frame[SETTINGS_EXPOSURE_TIME].max() normalized_time = data_frame[SETTINGS_EXPOSURE_TIME].max()
print(normalized_time)
data_frame[SETTINGS_NORMALIZED_EXPOSURE_TIME] = normalized_time data_frame[SETTINGS_NORMALIZED_EXPOSURE_TIME] = normalized_time
for original_col, normalized_col in RAW_DATA_NORMALIZATION_MAP.items(): for original_col, normalized_col in RAW_DATA_NORMALIZATION_MAP.items():

23
tests/test_dynamic_range.py

@ -213,6 +213,29 @@ def test_normalize_values_custom_param(normalization_data_frame):
assert list(sorted_results[normalized_col]) == expected_values assert list(sorted_results[normalized_col]) == expected_values
def test_normalize_values_preset_param(normalization_data_frame):
from sensospot_data.columns import (
RAW_DATA_NORMALIZATION_MAP,
SETTINGS_NORMALIZED_EXPOSURE_TIME,
)
from sensospot_data.dynamic_range import (
PROBE_MULTI_INDEX,
blend,
normalize_values,
)
reduced = blend(normalization_data_frame, "Saturation", 1)
reduced[SETTINGS_NORMALIZED_EXPOSURE_TIME] = 100
result = normalize_values(reduced)
sorted_results = result.sort_values(by=PROBE_MULTI_INDEX)
expected_values = [2, 8, 30, 2, 20, 20, 20, 20, 200, 200, 200, 200]
for normalized_col in RAW_DATA_NORMALIZATION_MAP.values():
assert list(sorted_results[normalized_col]) == expected_values
def test_create_xdr(normalization_data_frame): def test_create_xdr(normalization_data_frame):
from sensospot_data.columns import RAW_DATA_NORMALIZATION_MAP from sensospot_data.columns import RAW_DATA_NORMALIZATION_MAP
from sensospot_data.dynamic_range import PROBE_MULTI_INDEX, create_xdr from sensospot_data.dynamic_range import PROBE_MULTI_INDEX, create_xdr

Loading…
Cancel
Save