|
|
|
@ -14,6 +14,7 @@ from .columns import (
@@ -14,6 +14,7 @@ from .columns import (
|
|
|
|
|
META_DATA_PARAMETERS_TIME, |
|
|
|
|
META_DATA_PARAMETERS_CHANNEL, |
|
|
|
|
) |
|
|
|
|
from .utils import apply_map |
|
|
|
|
|
|
|
|
|
ExposureInfo = namedtuple("ExposureInfo", ["channel", "time"]) |
|
|
|
|
|
|
|
|
@ -58,23 +59,19 @@ def get_measurement_params(folder):
@@ -58,23 +59,19 @@ def get_measurement_params(folder):
|
|
|
|
|
|
|
|
|
|
def _add_measurement_params(data_frame, params): |
|
|
|
|
""" adds measurement parameters to a data frame """ |
|
|
|
|
for exposure_id, info in params.items(): |
|
|
|
|
mask = data_frame[META_DATA_EXPOSURE_ID] == exposure_id |
|
|
|
|
data_frame.loc[mask, META_DATA_PARAMETERS_CHANNEL] = info.channel |
|
|
|
|
data_frame.loc[mask, META_DATA_PARAMETERS_TIME] = info.time |
|
|
|
|
data_frame[META_DATA_PARAMETERS_CHANNEL] = data_frame[ |
|
|
|
|
META_DATA_PARAMETERS_CHANNEL |
|
|
|
|
].astype("category") |
|
|
|
|
return data_frame |
|
|
|
|
columns=[META_DATA_PARAMETERS_CHANNEL, META_DATA_PARAMETERS_TIME] |
|
|
|
|
map = {k: dict(zip(columns, v)) for k, v in params.items()} |
|
|
|
|
return apply_map(data_frame, map, META_DATA_EXPOSURE_ID) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def add_optional_measurement_parameters(data_frame, folder): |
|
|
|
|
""" adds measurement params to the data frame, if they could be parsed """ |
|
|
|
|
data_frame[META_DATA_PARAMETERS_CHANNEL] = numpy.nan |
|
|
|
|
data_frame[META_DATA_PARAMETERS_TIME] = numpy.nan |
|
|
|
|
params = get_measurement_params(folder) |
|
|
|
|
if params: |
|
|
|
|
available_exposures = set(data_frame[META_DATA_EXPOSURE_ID].unique()) |
|
|
|
|
if available_exposures == set(params.keys()): |
|
|
|
|
return _add_measurement_params(data_frame, params) |
|
|
|
|
else: |
|
|
|
|
data_frame[META_DATA_PARAMETERS_CHANNEL] = numpy.nan |
|
|
|
|
data_frame[META_DATA_PARAMETERS_TIME] = numpy.nan |
|
|
|
|
return data_frame |
|
|
|
|