Skip to content

Commit

Permalink
Relevant options are now saved in fits header
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffenhir committed Sep 30, 2022
1 parent 7b1d41c commit 4a94e21
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
16 changes: 15 additions & 1 deletion src/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4a94e21

Please sign in to comment.