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

Fix Function ExtrBetweenDates_MinMaxMean

* Old 'self' attribute existed
* move to pandas.DataFrame return
parent d500986a
No related branches found
No related tags found
No related merge requests found
......@@ -515,7 +515,7 @@ def ExtrBetweenDates(
def ExtrBetweenDates_MinMaxMean(
attribute,
dateStart,
dateStop=datetime.datetime.now(),
dateStop=None,
timeInterval=datetime.timedelta(seconds=60),
db='H',
):
......@@ -588,13 +588,13 @@ def ExtrBetweenDates_MinMaxMean(
timeInterval= datetime.timedelta(seconds=int(timeInterval[:-1])*mul)
# Get info about the attribute
info=self.infoattr(attribute)
self.logger.debug("Attribute information \n%s"%info)
info=infoattr(attribute)
logger.debug("Attribute information \n%s"%info)
# Detect spectrum
attrtype="scalar"
if int(info["max_dim_x"]) > 1:
self.logger.error("Attribute is not a scalar. Cannot perform this kind of operation.")
logger.error("Attribute is not a scalar. Cannot perform this kind of operation.")
return None
# Cut data range in time chunks
......@@ -603,7 +603,7 @@ def ExtrBetweenDates_MinMaxMean(
cdates.append(cdates[-1]+timeInterval)
cdates[-1] = dateStop
mdates = np.asarray(cdates[:-1])+timeInterval/2
self.logger.debug("Cutting time range to %d chunks of time, %s each."%(len(cdates)-1, timeInterval))
logger.debug("Cutting time range to %d chunks of time, %s each."%(len(cdates)-1, timeInterval))
# Prepare arrays
value_min = np.empty(len(cdates)-1)
......@@ -617,14 +617,14 @@ def ExtrBetweenDates_MinMaxMean(
[value_max, value_min, value_mean],
):
# Make requests
self.logger.debug("Perform GetAttData%sBetweenDates (%s, %s, %s)"%(
logger.debug("Perform GetAttData%sBetweenDates (%s, %s, %s)"%(
func,
attribute,
cdates[i_d].strftime(_DBDFMT2),
cdates[i_d+1].strftime(_DBDFMT2))
)
_val =getattr(self.extractor, "GetAttData%sBetweenDates"%func)([
_val =getattr(_extractors[{'H':0, 'T':1}[db]], "GetAttData%sBetweenDates"%func)([
attribute,
cdates[i_d].strftime(_DBDFMT2),
cdates[i_d+1].strftime(_DBDFMT2)
......@@ -632,6 +632,12 @@ def ExtrBetweenDates_MinMaxMean(
arr[i_d] = _val
self.logger.debug("Extraction done for %s."%attribute)
return [mdates, value_min, value_max, value_mean]
logger.debug("Extraction done for %s."%attribute)
return pd.DataFrame(
index=mdates,
data={
"Min":value_min,
"Mean":value_mean,
"Max":value_max,
},)
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