diff options
author | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-02-26 11:17:18 +0100 |
---|---|---|
committer | Birte Kristina Friesel <birte.friesel@uos.de> | 2024-02-26 11:17:18 +0100 |
commit | d5b1a62a8d8423565e8a8a54ae09961e018a3eb2 (patch) | |
tree | 3d91bdd9ecf48f81195c1d6b7ecba5a424363b04 | |
parent | 1ce6856206097d7deb975567d17d853d5df91108 (diff) |
add --export-csv-unparam support
-rwxr-xr-x | bin/analyze-archive.py | 3 | ||||
-rwxr-xr-x | bin/analyze-kconfig.py | 3 | ||||
-rwxr-xr-x | bin/analyze-log.py | 3 | ||||
-rw-r--r-- | lib/cli.py | 24 | ||||
-rw-r--r-- | lib/model.py | 3 |
5 files changed, 36 insertions, 0 deletions
diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py index 6fc014a..53a8c37 100755 --- a/bin/analyze-archive.py +++ b/bin/analyze-archive.py @@ -425,6 +425,9 @@ def main(): if args.info: dfatool.cli.print_info_by_name(model, by_name) + if args.export_csv_unparam: + dfatool.cli.export_csv_unparam(model, args.export_csv_unparam) + if args.export_pgf_unparam: dfatool.cli.export_pgf_unparam(model, args.export_pgf_unparam) diff --git a/bin/analyze-kconfig.py b/bin/analyze-kconfig.py index 44b7e24..d148641 100755 --- a/bin/analyze-kconfig.py +++ b/bin/analyze-kconfig.py @@ -353,6 +353,9 @@ def main(): if args.info: dfatool.cli.print_info_by_name(model, by_name) + if args.export_csv_unparam: + dfatool.cli.export_csv_unparam(model, args.export_csv_unparam) + if args.export_pgf_unparam: dfatool.cli.export_pgf_unparam(model, args.export_pgf_unparam) diff --git a/bin/analyze-log.py b/bin/analyze-log.py index db071fd..d6ae27a 100755 --- a/bin/analyze-log.py +++ b/bin/analyze-log.py @@ -120,6 +120,9 @@ def main(): if args.info: dfatool.cli.print_info_by_name(model, by_name) + if args.export_csv_unparam: + dfatool.cli.export_csv_unparam(model, args.export_csv_unparam) + if args.export_pgf_unparam: dfatool.cli.export_pgf_unparam(model, args.export_pgf_unparam) @@ -370,6 +370,24 @@ def export_dot(model, dot_prefix): logger.info(f"Dot export of model saved to {filename}") +def export_csv_unparam(model, csv_prefix): + import csv + + for name in sorted(model.names): + filename = f"{csv_prefix}{name}.csv" + with open(filename, "w") as f: + writer = csv.writer(f) + writer.writerow( + ["measurement"] + model.parameters + sorted(model.attributes(name)) + ) + for i, param_tuple in enumerate(model.param_values(name)): + row = [i] + param_tuple + for attr in sorted(model.attributes(name)): + row.append(model.attr_by_name[name][attr].data[i]) + writer.writerow(row) + logger.info(f"CSV unparam data saved to {filename}") + + def export_pgf_unparam(model, pgf_prefix): for name in model.names: for attribute in model.attributes(name): @@ -467,6 +485,12 @@ def add_standard_arguments(parser): help="Export model and model quality to LaTeX dataref file", ) parser.add_argument( + "--export-csv-unparam", + metavar="PREFIX", + type=str, + help="Export raw (parameter-independent) observations in CSV format to {PREFIX}{name}-{attribute}.csv", + ) + parser.add_argument( "--export-pgf-unparam", metavar="PREFIX", type=str, diff --git a/lib/model.py b/lib/model.py index b92a50c..ffe1fb7 100644 --- a/lib/model.py +++ b/lib/model.py @@ -214,6 +214,9 @@ class AnalyticModel: def attributes(self, name): return self.attr_by_name[name].keys() + def param_values(self, name): + return self.by_name[name]["param"] + def param_index(self, param_name): if param_name in self.parameters: return self.parameters.index(param_name) |