Skip to content

Commit

Permalink
Add "Plot error" checkbox to the Ginga Spec1dView plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
ejeschke committed Oct 19, 2024
1 parent 27f9314 commit c990de8
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions pypeit/display/ginga_spec1dview.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def __init__(self, fv, fitsimage):
prefs = self.fv.get_preferences()
self.settings = prefs.create_category('plugin_Spec1dView')
self.settings.add_defaults(lines="error", start_ext=0,
extraction='OPT', fluxed=False, masked=False)
extraction='OPT', fluxed=False, masked=False,
plot_error=True)
self.settings.load(onError='silent')

# will be set if we are invoked
Expand Down Expand Up @@ -124,6 +125,7 @@ def build_gui(self, container):
("Extraction:", 'label', 'extraction', 'combobox'),
("Fluxed:", 'label', 'fluxed', 'combobox'),
("Masked:", 'label', 'masked', 'combobox'),
("Plot Error", 'checkbox'),
)
w, b = Widgets.build_info(captions, orientation='vertical')
self.w = b
Expand Down Expand Up @@ -153,6 +155,10 @@ def build_gui(self, container):
combobox.set_index(index)
combobox.add_callback('activated', self.set_masked_cb)

b.plot_error.set_state(self.settings.get('plot_error', True))
b.plot_error.set_tooltip("Include the error plot")
b.plot_error.add_callback('activated', self.plot_error_cb)

fr.set_widget(w)
vbox.add_widget(fr, stretch=0)

Expand Down Expand Up @@ -312,11 +318,12 @@ def replot(self):
alpha=0.7, color='black')
canvas.add(p1, tag='spectrum', redraw=False)

# additionally, plot error vs. wavelength
points = np.array((self.data.wave, self.data.sig)).T
p2 = self.dc.Path(points, linewidth=2, linestyle='solid',
alpha=1.0, color='red')
canvas.add(p2, tag='error', redraw=False)
# optionally, plot error vs. wavelength
if self.settings.get('plot_error', False):
points = np.array((self.data.wave, self.data.sig)).T
p2 = self.dc.Path(points, linewidth=2, linestyle='solid',
alpha=1.0, color='red')
canvas.add(p2, tag='error', redraw=False)

self.plot.set_titles(title="Spec1dView",
x_axis="Wavelength (Ang)", y_axis="Flux")
Expand Down Expand Up @@ -444,6 +451,12 @@ def set_exten_cb(self, w, val):
self.exten = val
self.recalc()

def plot_error_cb(self, w, val):
"""Callback for toggling the "Plot Error" checkbox in the UI.
"""
self.settings.set(plot_error=val)
self.recalc()

def set_params(self, ext=None, extraction=None, masked=None, fluxed=None):
"""Used to set up defaults from command line args to pypeit_show_1dspec script."""
self.logger.info(f"ext={ext} extraction={extraction} masked={masked} fluxed={fluxed}")
Expand Down

0 comments on commit c990de8

Please sign in to comment.