Skip to content
Snippets Groups Projects
Commit 553a4d47 authored by BRONES Romain's avatar BRONES Romain
Browse files

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.
parent 99819c55
No related branches found
No related tags found
No related merge requests found
"""
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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment