From 4da81fa674866550ea1b686911efbbeaabfecad0 Mon Sep 17 00:00:00 2001 From: Birte Friesel Date: Tue, 11 Jul 2023 14:22:26 +0200 Subject: analyze-log: add --export-json-unparam --- lib/cli.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'lib') diff --git a/lib/cli.py b/lib/cli.py index 4b2d1ca..17e7b29 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -199,6 +199,22 @@ def export_pgf_unparam(model, pgf_prefix): print(f"{i} {value} {parameters}", file=f) +def export_json_unparam(model, filename): + import json + from dfatool.utils import NpEncoder + + ret = {"paramNames": model.parameters, "byName": dict()} + for name in model.names: + ret["byName"][name] = dict() + for attribute in model.attributes(name): + ret["byName"][name][attribute] = { + "paramValues": model.attr_by_name[name][attribute].param_values, + "data": model.attr_by_name[name][attribute].data, + } + with open(filename, "w") as f: + json.dump(ret, f, cls=NpEncoder) + + def add_standard_arguments(parser): parser.add_argument( "--export-dot", @@ -218,6 +234,12 @@ def add_standard_arguments(parser): type=str, help="Export raw (parameter-independent) observations in tikz-pgf-compatible format to {PREFIX}{name}-{attribute}.txt", ) + parser.add_argument( + "--export-json-unparam", + metavar="FILENAME", + type=str, + help="Export raw (parameter-independent) observations in JSON format to FILENAME", + ) parser.add_argument( "--dref-precision", metavar="NDIG", -- cgit v1.2.3