From 4a94e2149fbb8e92e02cbc713ef48ecdda522710 Mon Sep 17 00:00:00 2001 From: Steffen Hirtle Date: Fri, 30 Sep 2022 18:18:58 +0200 Subject: [PATCH] Relevant options are now saved in fits header --- src/gui.py | 2 +- src/preferences.py | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/gui.py b/src/gui.py index 111bb07..b5d4481 100644 --- a/src/gui.py +++ b/src/gui.py @@ -462,7 +462,7 @@ def menu_open_clicked(self, event=None): self.prefs["width"] = width self.prefs["height"] = height - tmp_state = fitsheader_2_app_state(self.cmd.app_state, self.images["Original"].fits_header) + tmp_state = fitsheader_2_app_state(self, self.cmd.app_state, self.images["Original"].fits_header) self.cmd: Command = Command(INIT_HANDLER, background_points=tmp_state["background_points"]) self.cmd.execute() diff --git a/src/preferences.py b/src/preferences.py index 7b865ef..a8860fb 100644 --- a/src/preferences.py +++ b/src/preferences.py @@ -142,14 +142,28 @@ def save_preferences(prefs_filename, prefs): def app_state_2_fitsheader(app, app_state, fits_header): prefs = Prefs() prefs = app_state_2_prefs(prefs, app_state, app) + fits_header["INTP-OPT"] = prefs["interpol_type_option"] + fits_header["SMOOTHING"] = prefs["smoothing_option"] + fits_header["SAMPLE-SIZE"] = prefs["sample_size"] + fits_header["RBF-KERNEL"] = prefs["RBF_kernel"] + fits_header["SPLINE-ORDER"] = prefs["spline_order"] + fits_header["CORR-TYPE"] = prefs["corr_type"] fits_header["BG-PTS"] = str(prefs["background_points"]) return fits_header -def fitsheader_2_app_state(app_state, fits_header): +def fitsheader_2_app_state(app, app_state, fits_header): if "BG-PTS" in fits_header.keys(): app_state["background_points"] = [np.array(p) for p in json.loads(fits_header["BG-PTS"])] + if "BG-EXTR" in fits_header.keys(): + app.interpol_type.set(fits_header["INTP-OPT"]) + app.smoothing_slider.set(fits_header["SMOOTHING"]) + app.help_panel.sample_size_slider.set(fits_header["SAMPLE-SIZE"]) + app.RBF_kernel.set(fits_header["RBF-KERNEL"]) + app.spline_order.set(fits_header["SPLINE-ORDER"]) + app.corr_type.set(fits_header["CORR-TYPE"]) + return app_state