diff options
author | Daniel Friesel <daniel.friesel@uos.de> | 2020-06-24 16:09:14 +0200 |
---|---|---|
committer | Daniel Friesel <daniel.friesel@uos.de> | 2020-06-24 16:09:14 +0200 |
commit | 0df48c75bf77abfc8c721d1045bc43c8da9f8989 (patch) | |
tree | a7be05ae4c824d416858294a198b9fa0fa624ddc /bin | |
parent | 83c5b2e2281e51f02e2207a6fc4af5682ae0963d (diff) |
analyze-archive: --plot-traces: Limit to <=40 traces
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/analyze-archive.py | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py index 2044731..f582b0a 100755 --- a/bin/analyze-archive.py +++ b/bin/analyze-archive.py @@ -98,6 +98,7 @@ Options: import getopt import json +import random import re import sys from dfatool import plotter @@ -343,7 +344,7 @@ if __name__ == "__main__": pta = PTA.from_file(opt["hwmodel"]) except getopt.GetoptError as err: - print(err) + print(err, file=sys.stderr) sys.exit(2) raw_data = RawData( @@ -376,6 +377,17 @@ if __name__ == "__main__": traces.extend( map(lambda x: x["uW"], state_or_transition["offline"]) ) + if len(traces) == 0: + print( + f"""Did not find traces for state or transition {opt["plot-traces"]}. Abort.""", + file=sys.stderr, + ) + sys.exit(2) + + if len(traces) > 20: + print(f"""Truncating plot to 40 of {len(traces)} traces (random sample)""") + traces = random.sample(traces, 40) + plotter.plot_y( traces, xlabel="t [1e-5 s]", @@ -385,7 +397,7 @@ if __name__ == "__main__": ) if raw_data.preprocessing_stats["num_valid"] == 0: - print("No valid data available. Abort.") + print("No valid data available. Abort.", file=sys.stderr) sys.exit(2) if pta is None and raw_data.pta is not None: @@ -694,7 +706,9 @@ if __name__ == "__main__": if "export-energymodel" in opt: if not pta: - print("[E] --export-energymodel requires --hwmodel to be set") + print( + "[E] --export-energymodel requires --hwmodel to be set", file=sys.stderr + ) sys.exit(1) json_model = model.to_json() with open(opt["export-energymodel"], "w") as f: |