Skip to content

Commit

Permalink
binning toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
kecnry committed Dec 2, 2022
1 parent d8c538e commit 6079a9b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ class SpectralExtraction(PluginTemplateMixin):
* :attr:`trace_pixel` :
pixel of the trace. If ``trace_type`` is not ``Flat``, then this
is the "guess" for the automated trace.
* :attr:`trace_do_binning` :
only applicable if ``trace_type`` is not ``Flat``. Bin the input data when fitting the
trace.
* :attr:`trace_bins` :
only applicable if ``trace_type`` is not ``Flat``.
only applicable if ``trace_type`` is not ``Flat`` and ``trace_do_binning``.
* :attr:`trace_window` :
full width of the trace.
* :meth:`import_trace`
Expand Down Expand Up @@ -111,6 +114,7 @@ class SpectralExtraction(PluginTemplateMixin):
trace_peak_method_items = List().tag(sync=True)
trace_peak_method_selected = Unicode().tag(sync=True)

trace_do_binning = Bool(True).tag(sync=True)
trace_bins = IntHandleEmpty(20).tag(sync=True)
trace_window = IntHandleEmpty(0).tag(sync=True)

Expand Down Expand Up @@ -311,7 +315,8 @@ def user_api(self):
return PluginUserApi(self, expose=('interactive_extract',
'trace_dataset', 'trace_type',
'trace_order', 'trace_peak_method',
'trace_pixel', 'trace_bins', 'trace_window',
'trace_pixel',
'trace_do_binning', 'trace_bins', 'trace_window',
'import_trace',
'export_trace',
'bg_dataset', 'bg_type',
Expand Down Expand Up @@ -483,7 +488,7 @@ def marks(self):
@observe('trace_dataset_selected', 'trace_type_selected',
'trace_trace_selected', 'trace_offset', 'trace_order',
'trace_pixel', 'trace_peak_method_selected',
'trace_bins', 'trace_window', 'active_step')
'trace_do_binning', 'trace_bins', 'trace_window', 'active_step')
def _interaction_in_trace_step(self, event={}):
if not self.plugin_opened or not self._do_marks:
return
Expand Down Expand Up @@ -626,6 +631,7 @@ def import_trace(self, trace):
self.trace_pixel = trace.guess
self.trace_window = trace.window
self.trace_bins = trace.bins
self.trace_do_binning = True
self.trace_order = trace.degree
elif isinstance(trace, tracing.ArrayTrace): # pragma: no cover
raise NotImplementedError(f"cannot import ArrayTrace into plugin. Use viz.load_trace instead") # noqa
Expand Down Expand Up @@ -667,7 +673,7 @@ def export_trace(self, add_data=False, **kwargs):
trace_model = _model_cls[self.trace_type_selected](degree=self.trace_order)
trace = tracing.FitTrace(self.trace_dataset.selected_obj.data,
guess=self.trace_pixel,
bins=int(self.trace_bins),
bins=int(self.trace_bins) if self.trace_do_binning else None,
window=self.trace_window,
peak_method=self.trace_peak_method_selected.lower(),
trace_model=trace_model)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,17 @@
</v-row>

<v-row v-if="trace_type_selected!=='Flat'">
<v-switch
v-model="trace_do_binning"
label="Bin input spectrum"
></v-switch>
<v-text-field
v-if="trace_do_binning"
label="Bins"
type="number"
v-model.number="trace_bins"
:rules="[() => trace_bins!=='' || 'This field is required']"
:rules="[() => trace_bins!=='' || 'This field is required',
() => trace_bins>=4 || 'Bins must be >= 4']"
hint="Number of bins in the dispersion direction."
persistent-hint
>
Expand Down

0 comments on commit 6079a9b

Please sign in to comment.