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