diff --git a/monitoring/db/scripts/get_detailed_power.py b/monitoring/db/scripts/get_detailed_power.py index 6d98e38..a3c7ff8 100755 --- a/monitoring/db/scripts/get_detailed_power.py +++ b/monitoring/db/scripts/get_detailed_power.py @@ -143,7 +143,7 @@ class Power: return _body def summarize_time(self, ts): - return ts, "" + return Power.to_csv((ts, "")) @staticmethod def summarize_values(df): @@ -152,16 +152,21 @@ class Power: min, max = values.min(), values.max() avg, stddev = values.mean(), values.std() median = np.median(values) - return head, avg, median, min, max, stddev + return Power.to_csv((head, avg, median, min, max, stddev)) def summarize_epoch(self, epoch): ts, values = epoch - return self.summarize_time(ts) \ - + self.summarize_values(values) \ - + self.all_values(values) + return self.summarize_time(ts), \ + self.summarize_values(values), \ + self.all_values(values) def all_values(self, values): - return tuple(values['power'].tolist()) + # reindex frame to get all nodes; introduces gaps + values = values[['node', 'power']].set_index('node').reindex(self.nodes) + # hack to_csv() to transpose array + csv = values.to_csv(header=False, index=False, line_terminator=',', na_rep=' ') + csv = csv[:-1] # strip line terminator ',' from end of string + return csv def energy_total(self): energy = None