Browse Source

changed defaults for xdr since sensospot bug is fixed

xmlparsing
Holger Frey 3 years ago
parent
commit
2274a2101b
  1. 4
      README.md
  2. 10
      sensospot_data/dynamic_range.py
  3. 4
      tests/test_dynamic_range.py

4
README.md

@ -52,14 +52,14 @@ from .parser import parse_file, parse_folder # noqa: F401 @@ -52,14 +52,14 @@ from .parser import parse_file, parse_folder # noqa: F401
- **ExposureInfo(exposure_channel, exposure_time)**
A named tuple for defining an exposure map. Usage will increase readability
and karma points.
- **blend(data_frame, [column="Spot.Mean", limit=0.5])**
- **blend(data_frame, [column="Spot.Saturation", limit=2])**
If provided with a data frame with multiple exposure times for the same
exposure channel, the function will blend theese two times together based
on given column and limit.
- **normalize_values(data_frame, [normalized_time=None])**
Adds new columns to the data frame with intensity values recalculated to the
normalized exposure time. If no time is given, the max exposure time is used.
- **create_xdr(data_frame, [normalized_time=None, column="Spot.Mean", limit=0.5])**
- **create_xdr(data_frame, [normalized_time=None, column="Spot.Saturation", limit=2])**
This combines the methods `blend()` and `normalize_values()` into one call.
What a joy!

10
sensospot_data/dynamic_range.py

@ -5,7 +5,7 @@ from .columns import ( @@ -5,7 +5,7 @@ from .columns import (
RAW_DATA_POS_ID,
CALC_SPOT_OVERFLOW,
META_DATA_WELL_ROW,
RAW_DATA_SPOT_MEAN,
RAW_DATA_SPOT_SAT,
META_DATA_WELL_COLUMN,
SETTINGS_EXPOSURE_TIME,
SETTINGS_EXPOSURE_CHANNEL,
@ -33,7 +33,7 @@ def _check_if_xdr_ready(data_frame): @@ -33,7 +33,7 @@ def _check_if_xdr_ready(data_frame):
raise ValueError("XDR: Exposure time contains NaNs")
def _calc_overflow_info(data_frame, column=RAW_DATA_SPOT_MEAN, limit=0.5):
def _calc_overflow_info(data_frame, column=RAW_DATA_SPOT_SAT, limit=2):
""" add overflow info, based on column and limit """
data_frame.loc[:, CALC_SPOT_OVERFLOW] = data_frame[column] > limit
return data_frame
@ -64,7 +64,7 @@ def _reduce_overflow(data_frame): @@ -64,7 +64,7 @@ def _reduce_overflow(data_frame):
return result_frame.reset_index()
def blend(data_frame, column=RAW_DATA_SPOT_MEAN, limit=0.5):
def blend(data_frame, column=RAW_DATA_SPOT_SAT, limit=2):
""" creates an extended dynamic range, eliminating overflowing spots """
_check_if_xdr_ready(data_frame)
if CALC_SPOT_OVERFLOW not in data_frame.columns:
@ -96,8 +96,8 @@ def normalize_values(data_frame, normalized_time=None): @@ -96,8 +96,8 @@ def normalize_values(data_frame, normalized_time=None):
def create_xdr(
data_frame,
normalized_time=None,
column=RAW_DATA_SPOT_MEAN,
limit=0.5,
column=RAW_DATA_SPOT_SAT,
limit=2,
):
"""normalize measurement exposures

4
tests/test_dynamic_range.py

@ -79,10 +79,10 @@ def test_check_if_xdr_ready_raises_error_on_nan(exposure_df): @@ -79,10 +79,10 @@ def test_check_if_xdr_ready_raises_error_on_nan(exposure_df):
def test_check_overflow_limit_defaults():
from sensospot_data.columns import CALC_SPOT_OVERFLOW, RAW_DATA_SPOT_MEAN
from sensospot_data.columns import CALC_SPOT_OVERFLOW, RAW_DATA_SPOT_SAT
from sensospot_data.dynamic_range import _calc_overflow_info
data_frame = pandas.DataFrame(data={RAW_DATA_SPOT_MEAN: [0.1, 0.5, 0.6]})
data_frame = pandas.DataFrame(data={RAW_DATA_SPOT_SAT: [1, 2, 3]})
result = _calc_overflow_info(data_frame)

Loading…
Cancel
Save