From 4ccf4eb9a05a390678637de311eec3e78a549ef6 Mon Sep 17 00:00:00 2001 From: Robin Scheibler Date: Fri, 17 Apr 2020 18:06:31 +0900 Subject: [PATCH] Analysis script, environment --- analysis.py | 29 +++++++++++++++++++++++++++++ environment.yml | 10 ++++++++++ process.py | 4 ++-- 3 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 analysis.py create mode 100644 environment.yml diff --git a/analysis.py b/analysis.py new file mode 100644 index 0000000..041c32a --- /dev/null +++ b/analysis.py @@ -0,0 +1,29 @@ +import json +import pandas as pd +import argparse +from pathlib import Path +import numpy as np + +if __name__ == "__main__": + + parser = argparse.ArgumentParser(description="Sparse minimum distortion simulation results analaysis") + parser.add_argument("results_dir", type=Path, help="Location of simulation results") + args = parser.parse_args() + + + with open(args.results_dir / "data.json") as f: + data = json.load(f) + + with open(args.results_dir / "parameters.json") as f: + params = json.load(f) + + # concatenate all the results + results = [] + for r in data: + results += r + + for r in results: + for metric in ["sdr", "sir"]: + r[metric] = np.mean(r[metric]) + + df = pd.DataFrame(results) diff --git a/environment.yml b/environment.yml new file mode 100644 index 0000000..4c3e2ee --- /dev/null +++ b/environment.yml @@ -0,0 +1,10 @@ +name: sparse_projection_back +dependencies: + - numpy + - scipy + - pandas + - matplotlib + - pip + - seaborn + - pip: + - repsimtools diff --git a/process.py b/process.py index f22424d..be4d6b9 100644 --- a/process.py +++ b/process.py @@ -111,8 +111,8 @@ def process(args, config): # minimum distortion lo, hi, step = config["minimum_distortion"]["p_list"] kwargs = config["minimum_distortion"]["kwargs"] - for p in np.arange(lo, hi, step): - for q in np.arange(p, hi, step): + for p in np.arange(lo, hi + step, step): + for q in np.arange(p, hi + step, step): t["p"], t["q"], t["proj_algo"] = ( f"{p:.1f}", f"{q:.1f}",