Skip to content

Commit 81c10ea

Browse files
committed
binning toggle
1 parent 9f30a41 commit 81c10ea

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,11 @@ class SpectralExtraction(PluginTemplateMixin):
5151
* :attr:`trace_pixel` :
5252
pixel of the trace. If ``trace_type`` is not ``Flat``, then this
5353
is the "guess" for the automated trace.
54+
* :attr:`trace_do_binning` :
55+
only applicable if ``trace_type`` is not ``Flat``. Bin the input data when fitting the
56+
trace.
5457
* :attr:`trace_bins` :
55-
only applicable if ``trace_type`` is not ``Flat``.
58+
only applicable if ``trace_type`` is not ``Flat`` and ``trace_do_binning``.
5659
* :attr:`trace_window` :
5760
full width of the trace.
5861
* :meth:`import_trace`
@@ -111,6 +114,7 @@ class SpectralExtraction(PluginTemplateMixin):
111114
trace_peak_method_items = List().tag(sync=True)
112115
trace_peak_method_selected = Unicode().tag(sync=True)
113116

117+
trace_do_binning = Bool(True).tag(sync=True)
114118
trace_bins = IntHandleEmpty(20).tag(sync=True)
115119
trace_window = IntHandleEmpty(0).tag(sync=True)
116120

@@ -311,7 +315,8 @@ def user_api(self):
311315
return PluginUserApi(self, expose=('interactive_extract',
312316
'trace_dataset', 'trace_type',
313317
'trace_order', 'trace_peak_method',
314-
'trace_pixel', 'trace_bins', 'trace_window',
318+
'trace_pixel',
319+
'trace_do_binning', 'trace_bins', 'trace_window',
315320
'import_trace',
316321
'export_trace',
317322
'bg_dataset', 'bg_type',
@@ -483,7 +488,7 @@ def marks(self):
483488
@observe('trace_dataset_selected', 'trace_type_selected',
484489
'trace_trace_selected', 'trace_offset', 'trace_order',
485490
'trace_pixel', 'trace_peak_method_selected',
486-
'trace_bins', 'trace_window', 'active_step')
491+
'trace_do_binning', 'trace_bins', 'trace_window', 'active_step')
487492
def _interaction_in_trace_step(self, event={}):
488493
if not self.plugin_opened or not self._do_marks:
489494
return
@@ -626,6 +631,7 @@ def import_trace(self, trace):
626631
self.trace_pixel = trace.guess
627632
self.trace_window = trace.window
628633
self.trace_bins = trace.bins
634+
self.trace_do_binning = True
629635
if hasattr(trace.trace_model, 'degree'):
630636
self.trace_order = trace.trace_model.degree
631637
elif isinstance(trace, tracing.ArrayTrace): # pragma: no cover
@@ -668,7 +674,7 @@ def export_trace(self, add_data=False, **kwargs):
668674
trace_model = _model_cls[self.trace_type_selected](degree=self.trace_order)
669675
trace = tracing.FitTrace(self.trace_dataset.selected_obj,
670676
guess=self.trace_pixel,
671-
bins=int(self.trace_bins),
677+
bins=int(self.trace_bins) if self.trace_do_binning else None,
672678
window=self.trace_window,
673679
peak_method=self.trace_peak_method_selected.lower(),
674680
trace_model=trace_model)

jdaviz/configs/specviz2d/plugins/spectral_extraction/spectral_extraction.vue

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,17 @@
102102
</v-row>
103103

104104
<v-row v-if="trace_type_selected!=='Flat'">
105+
<v-switch
106+
v-model="trace_do_binning"
107+
label="Bin input spectrum"
108+
></v-switch>
105109
<v-text-field
110+
v-if="trace_do_binning"
106111
label="Bins"
107112
type="number"
108113
v-model.number="trace_bins"
109-
:rules="[() => trace_bins!=='' || 'This field is required']"
114+
:rules="[() => trace_bins!=='' || 'This field is required',
115+
() => trace_bins>=4 || 'Bins must be >= 4']"
110116
hint="Number of bins in the dispersion direction."
111117
persistent-hint
112118
>

0 commit comments

Comments
 (0)