From 966833fd1477e72597705fb8a95586596efd4a20 Mon Sep 17 00:00:00 2001 From: ralf Date: Thu, 11 Jul 2024 13:43:33 +0300 Subject: [PATCH] added missing experiment fitter --- __pycache__/experiment_fitter.py | 35 ++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 __pycache__/experiment_fitter.py diff --git a/__pycache__/experiment_fitter.py b/__pycache__/experiment_fitter.py new file mode 100644 index 0000000..1f2a5fd --- /dev/null +++ b/__pycache__/experiment_fitter.py @@ -0,0 +1,35 @@ +import h5py +import pandas as pd +import re + +from Model import Model +from fitter import Fitter +from Data import Data + + +def fit_data(): + filename = "ltcc_current.h5" + with h5py.File(filename, "r") as h5: + eids = list(h5.keys()) + + for eid in eids: + data = Data(filename, group_key=eid) + fit = Fitter(Model, data) + fit.optimize() + res, fig = fit.optimize() + + fit_hist = pd.DataFrame.from_dict(fit.fit_results, orient="index").T + fit_hist.index.name = "Iterations" + + res_filename = f"fit_results_{eid}.csv" + res_filename = res_filename.replace(" ", "_").replace(":", "-") + fit_hist.to_csv(res_filename, index=True) + + eid_cleaned = re.sub( + r"[^\w.-]", "", eid + ) # Eemaldab kõik eritähed + fig.savefig(f"plot_{eid_cleaned}.png") + fig.savefig(f"plot_{eid_cleaned}.pdf") + + +fit_data()