From 553a4d47f80ef7728b73356716bb295830e0d63d Mon Sep 17 00:00:00 2001 From: Romain Broucquart <romain.broucquart@synchrotron-soleil.fr> Date: Tue, 31 Oct 2023 11:25:17 +0100 Subject: [PATCH] Quick fix on attribute type boolean * This is a quick fix, needs more work. * Cast was always to float, which fails for boolean. * Better handle all the type values and ask for a better cast. --- ArchiveExtractor.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ArchiveExtractor.py b/ArchiveExtractor.py index cf26417..3617a18 100755 --- a/ArchiveExtractor.py +++ b/ArchiveExtractor.py @@ -1,5 +1,5 @@ """ -Python module for extracting attribute from Arhive Extractor Device. +Python module for extracting attribute from Archive Extractor Device. """ import logging import datetime @@ -519,13 +519,19 @@ def _extract_attribute(attribute, method, date1, date2, db): # ============= # For now we handle multi dimension the same way as scalar, which will get only the first element if (attrtype=="scalar") or (attrtype=="multi"): - return _extract_scalar(attribute, method, date1, date2, db) + if info["data_type"] == '1': + # Boolean data type, quick fix + dtype=bool + else: + dtype=float + + return _extract_scalar(attribute, method, date1, date2, db, dtype) if attrtype=="vector": return _extract_vector(attribute, method, date1, date2, db) ##---------------------------------------------------------------------------## -def _extract_scalar(attribute, method, date1, date2, db): +def _extract_scalar(attribute, method, date1, date2, db, dtype): # ===================== if method == "nearest": @@ -572,12 +578,12 @@ def _extract_scalar(attribute, method, date1, date2, db): # Transform to datetime - value arrays - _value = np.asarray(_value, dtype=float) + _value = np.asarray(_value, dtype=dtype) if len(_date) > 0: _date = _ArrayTimeStampToDatetime(_date/1000.0) # Fabricate return pandas.Series - data.append(pd.Series(index=_date, data=_value,name=attribute)) + data.append(pd.Series(index=_date, data=_value, name=attribute)) # Concatenate chunks return pd.concat(data) -- GitLab