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( ...@@ -515,7 +515,7 @@ def ExtrBetweenDates(
def ExtrBetweenDates_MinMaxMean( def ExtrBetweenDates_MinMaxMean(
attribute, attribute,
dateStart, dateStart,
dateStop=datetime.datetime.now(), dateStop=None,
timeInterval=datetime.timedelta(seconds=60), timeInterval=datetime.timedelta(seconds=60),
db='H', db='H',
): ):
...@@ -588,13 +588,13 @@ def ExtrBetweenDates_MinMaxMean( ...@@ -588,13 +588,13 @@ def ExtrBetweenDates_MinMaxMean(
timeInterval= datetime.timedelta(seconds=int(timeInterval[:-1])*mul) timeInterval= datetime.timedelta(seconds=int(timeInterval[:-1])*mul)
# Get info about the attribute # Get info about the attribute
info=self.infoattr(attribute) info=infoattr(attribute)
self.logger.debug("Attribute information \n%s"%info) logger.debug("Attribute information \n%s"%info)
# Detect spectrum # Detect spectrum
attrtype="scalar" attrtype="scalar"
if int(info["max_dim_x"]) > 1: 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 return None
# Cut data range in time chunks # Cut data range in time chunks
...@@ -603,7 +603,7 @@ def ExtrBetweenDates_MinMaxMean( ...@@ -603,7 +603,7 @@ def ExtrBetweenDates_MinMaxMean(
cdates.append(cdates[-1]+timeInterval) cdates.append(cdates[-1]+timeInterval)
cdates[-1] = dateStop cdates[-1] = dateStop
mdates = np.asarray(cdates[:-1])+timeInterval/2 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 # Prepare arrays
value_min = np.empty(len(cdates)-1) value_min = np.empty(len(cdates)-1)
...@@ -617,14 +617,14 @@ def ExtrBetweenDates_MinMaxMean( ...@@ -617,14 +617,14 @@ def ExtrBetweenDates_MinMaxMean(
[value_max, value_min, value_mean], [value_max, value_min, value_mean],
): ):
# Make requests # Make requests
self.logger.debug("Perform GetAttData%sBetweenDates (%s, %s, %s)"%( logger.debug("Perform GetAttData%sBetweenDates (%s, %s, %s)"%(
func, func,
attribute, attribute,
cdates[i_d].strftime(_DBDFMT2), cdates[i_d].strftime(_DBDFMT2),
cdates[i_d+1].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, attribute,
cdates[i_d].strftime(_DBDFMT2), cdates[i_d].strftime(_DBDFMT2),
cdates[i_d+1].strftime(_DBDFMT2) cdates[i_d+1].strftime(_DBDFMT2)
...@@ -632,6 +632,12 @@ def ExtrBetweenDates_MinMaxMean( ...@@ -632,6 +632,12 @@ def ExtrBetweenDates_MinMaxMean(
arr[i_d] = _val arr[i_d] = _val
self.logger.debug("Extraction done for %s."%attribute) logger.debug("Extraction done for %s."%attribute)
return [mdates, value_min, value_max, value_mean] 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.
Please register or to comment