Print power values of all nodes, including missing ones

This commit is contained in:
Jose Gracia 2024-02-20 16:51:32 +01:00
parent 5b07b407de
commit 277b3e936e

View file

@ -143,7 +143,7 @@ class Power:
return _body return _body
def summarize_time(self, ts): def summarize_time(self, ts):
return ts, "" return Power.to_csv((ts, ""))
@staticmethod @staticmethod
def summarize_values(df): def summarize_values(df):
@ -152,16 +152,21 @@ class Power:
min, max = values.min(), values.max() min, max = values.min(), values.max()
avg, stddev = values.mean(), values.std() avg, stddev = values.mean(), values.std()
median = np.median(values) 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): def summarize_epoch(self, epoch):
ts, values = epoch ts, values = epoch
return self.summarize_time(ts) \ return self.summarize_time(ts), \
+ self.summarize_values(values) \ self.summarize_values(values), \
+ self.all_values(values) self.all_values(values)
def all_values(self, 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): def energy_total(self):
energy = None energy = None