diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2020-05-28 15:44:56 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2020-05-28 15:44:56 +0200 |
commit | 83c5b2e2281e51f02e2207a6fc4af5682ae0963d (patch) | |
tree | b960687422e8f7814d74b41c3ea6521dceb1a0e5 /lib/dfatool.py | |
parent | 84332ef2e448ea837503660898f96dcc2fa033f7 (diff) |
dfatool: EnergyTraceLog: Add power trace export (with_traces=True)
Diffstat (limited to 'lib/dfatool.py')
-rw-r--r-- | lib/dfatool.py | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/lib/dfatool.py b/lib/dfatool.py index 56f0f2d..e0eb0d4 100644 --- a/lib/dfatool.py +++ b/lib/dfatool.py @@ -405,6 +405,7 @@ def _preprocess_etlog(measurement): float(setup["voltage"]), int(setup["state_duration"]), measurement["transition_names"], + with_traces=measurement["with_traces"], ) try: etlog.load_data(measurement["content"]) @@ -1261,6 +1262,7 @@ class RawData: "setup": self.setup_by_fileno[j], "repeat_id": repeat_id, "expected_trace": ptalog["traces"][j], + "with_traces": self.with_traces, "transition_names": list( map( lambda x: x["name"], @@ -2592,7 +2594,13 @@ class EnergyTraceLog: at the moment. """ - def __init__(self, voltage: float, state_duration: int, transition_names: list): + def __init__( + self, + voltage: float, + state_duration: int, + transition_names: list, + with_traces=False, + ): """ Create a new EnergyTraceLog object. @@ -2604,6 +2612,7 @@ class EnergyTraceLog: self.voltage = voltage self.state_duration = state_duration * 1e-3 self.transition_names = transition_names + self.with_traces = with_traces self.verbose = False self.errors = list() @@ -2807,44 +2816,43 @@ class EnergyTraceLog: ), ) - energy_trace.append( - { - "isa": "transition", - "W_mean": np.mean( - self.interval_power[ - transition_start_index:transition_done_index - ] - ), - "W_std": np.std( - self.interval_power[ - transition_start_index:transition_done_index - ] - ), - "s": duration, - "s_coarse": self.interval_start_timestamp[transition_done_index] - - self.interval_start_timestamp[transition_start_index], - } - ) + transition_power_W = self.interval_power[ + transition_start_index:transition_done_index + ] + + transition = { + "isa": "transition", + "W_mean": np.mean(transition_power_W), + "W_std": np.std(transition_power_W), + "s": duration, + "s_coarse": self.interval_start_timestamp[transition_done_index] + - self.interval_start_timestamp[transition_start_index], + } + + if self.with_traces: + transition["uW"] = transition_power_W * 1e6 + + energy_trace.append(transition) if len(energy_trace) > 1: energy_trace[-1]["W_mean_delta_prev"] = ( energy_trace[-1]["W_mean"] - energy_trace[-2]["W_mean"] ) - energy_trace.append( - { - "isa": "state", - "W_mean": np.mean( - self.interval_power[state_start_index:state_done_index] - ), - "W_std": np.std( - self.interval_power[state_start_index:state_done_index] - ), - "s": self.state_duration, - "s_coarse": self.interval_start_timestamp[state_done_index] - - self.interval_start_timestamp[state_start_index], - } - ) + state_power_W = self.interval_power[state_start_index:state_done_index] + state = { + "isa": "state", + "W_mean": np.mean(state_power_W), + "W_std": np.std(state_power_W), + "s": self.state_duration, + "s_coarse": self.interval_start_timestamp[state_done_index] + - self.interval_start_timestamp[state_start_index], + } + + if self.with_traces: + state["uW"] = state_power_W * 1e6 + + energy_trace.append(state) energy_trace[-2]["W_mean_delta_next"] = ( energy_trace[-2]["W_mean"] - energy_trace[-1]["W_mean"] |