diff --git a/sensospot_data/__init__.py b/sensospot_data/__init__.py index 53db413..83d87a6 100644 --- a/sensospot_data/__init__.py +++ b/sensospot_data/__init__.py @@ -3,7 +3,7 @@ Parsing the numerical output from Sensovations Sensospot image analysis. """ -__version__ = "0.5.1" +__version__ = "0.5.2" from pathlib import Path diff --git a/sensospot_data/dynamic_range.py b/sensospot_data/dynamic_range.py index c41e9e4..790288f 100644 --- a/sensospot_data/dynamic_range.py +++ b/sensospot_data/dynamic_range.py @@ -69,12 +69,14 @@ def normalize_values(data_frame, normalized_time=None): """add exposure time normalized values to a data frame 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() - 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(): data_frame[normalized_col] = ( diff --git a/tests/test_dynamic_range.py b/tests/test_dynamic_range.py index ade94f7..22e58fc 100644 --- a/tests/test_dynamic_range.py +++ b/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 +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): from sensospot_data.columns import RAW_DATA_NORMALIZATION_MAP from sensospot_data.dynamic_range import PROBE_MULTI_INDEX, create_xdr