From 277b3e936ee1b1e76c65949b87c7a92f42470916 Mon Sep 17 00:00:00 2001 From: Jose Gracia Date: Tue, 20 Feb 2024 16:51:32 +0100 Subject: [PATCH] Print power values of all nodes, including missing ones --- monitoring/db/scripts/get_detailed_power.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) 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