You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
load 2 spectra that do not entirely overlap in wavelength
select a subset on the first spectrum, in the overlapping region, and on the second spectrum
use the region in model fitting
the region selected on the first spectrum creates a traceback (the other two are fine)
ValueError Traceback (most recent call last)
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:756, in Widget._handle_msg(self, msg)
754 if 'buffer_paths' in data:
755 _put_buffers(state, data['buffer_paths'], msg['buffers'])
--> 756 self.set_state(state)
758 # Handle a state request.
759 elif method == 'request_state':
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:620, in Widget.set_state(self, sync_data)
615 self._send(msg, buffers=echo_buffers)
617 # The order of these context managers is important. Properties must
618 # be locked when the hold_trait_notification context manager is
619 # released and notifications are fired.
--> 620 with self._lock_property(**sync_data), self.hold_trait_notifications():
621 for name in sync_data:
622 if name in self.keys:
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/contextlib.py:142, in _GeneratorContextManager.exit(self, typ, value, traceback)
140 if typ is None:
141 try:
--> 142 next(self.gen)
143 except StopIteration:
144 return False
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/traitlets/traitlets.py:1371, in HasTraits.hold_trait_notifications(self)
1369 for changes in cache.values():
1370 for change in changes:
-> 1371 self.notify_change(change)
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:686, in Widget.notify_change(self, change)
683 if name in self.keys and self._should_send_property(name, getattr(self, name)):
684 # Send new state to front-end
685 self.send_state(key=name)
--> 686 super(Widget, self).notify_change(change)
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/traitlets/traitlets.py:1386, in HasTraits.notify_change(self, change)
1384 def notify_change(self, change):
1385 """Notify observers of a change event"""
-> 1386 return self._notify_observers(change)
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/traitlets/traitlets.py:1431, in HasTraits._notify_observers(self, event)
1428 elif isinstance(c, EventHandler) and c.name is not None:
1429 c = getattr(self, c.name)
-> 1431 c(event)
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/functools.py:981, in cached_property.get(self, instance, owner)
979 val = cache.get(self.attrname, _NOT_FOUND)
980 if val is _NOT_FOUND:
--> 981 val = self.func(instance)
982 try:
983 cache[self.attrname] = val
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/jdaviz/core/template_mixin.py:936, in SubsetSelect.selected_obj(self)
932 # NOTE: we use reference names here instead of IDs since get_subsets_from_viewer requires
933 # that. For imviz, this will mean we won't be able to loop through each of the viewers,
934 # but the original viewer should have access to all the subsets.
935 for viewer_ref in self.viewer_refs:
--> 936 match = self.app.get_subsets_from_viewer(viewer_ref,
937 subset_type=subset_type).get(self.selected)
938 if match is not None:
939 return match
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/jdaviz/app.py:742, in Application.get_subsets_from_viewer.._get_all_subregions(mask, spec_axis_data)
725 """
726 Return all subregions within a subset.
727
(...)
737 SpectralRegion object containing all subregions of the subset.
738 """
739 if len(mask) == 0:
740 # Mask should only be 0 if ApplyROI is used to incorrectly
741 # create subsets via the API
--> 742 raise ValueError("Mask has length 0, ApplyROI may have been used incorrectly")
744 current_edge = 0
745 combined_spec_region = None
ValueError: Mask has length 0, ApplyROI may have been used incorrectly
DISCLAIMER: This issue was autocreated by the Jdaviz Issue Creation Bot on behalf of the reporter. If any information is incorrect, please contact Duy Nguyen
The text was updated successfully, but these errors were encountered:
import numpy as np
from jdaviz import Specviz
import tempfile
from astroquery.mast import Observations
data_dir = tempfile.gettempdir()
fn = "jw02732-o004_t004_miri_ch1-shortmediumlong_x1d.fits"
result = Observations.download_file(f"mast:JWST/product/{fn}", local_path=f'{data_dir}/{fn}')
specviz = Specviz()
specviz.load_spectrum(f'{data_dir}/{fn}', "right_spectrum")
sp = specviz.app.get_data_from_viewer('spectrum-viewer', 'right_spectrum')
from specutils import Spectrum1D
sp2 = Spectrum1D(spectral_axis=sp.spectral_axis - 2*sp.spectral_axis.unit,
flux=sp.flux * 1.25)
specviz.load_spectrum(sp2, data_label="left_spectrum")
specviz.show()
from glue.core.roi import XRangeROI
specviz.app.get_viewer('spectrum-viewer').apply_roi(XRangeROI(6, 6.45)) # on right only
mf = specviz.plugins['Model Fitting']
mf.create_model_component('Linear1D')
mf.dataset = 'left_spectrum' # second to be added
mf.spectral_subset = 'Subset 1' # fails with error above when setting subset
Reporter: Camilla Pacifici
ValueError Traceback (most recent call last)
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:756, in Widget._handle_msg(self, msg)
754 if 'buffer_paths' in data:
755 _put_buffers(state, data['buffer_paths'], msg['buffers'])
--> 756 self.set_state(state)
758 # Handle a state request.
759 elif method == 'request_state':
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:620, in Widget.set_state(self, sync_data)
615 self._send(msg, buffers=echo_buffers)
617 # The order of these context managers is important. Properties must
618 # be locked when the hold_trait_notification context manager is
619 # released and notifications are fired.
--> 620 with self._lock_property(**sync_data), self.hold_trait_notifications():
621 for name in sync_data:
622 if name in self.keys:
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/contextlib.py:142, in _GeneratorContextManager.exit(self, typ, value, traceback)
140 if typ is None:
141 try:
--> 142 next(self.gen)
143 except StopIteration:
144 return False
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/traitlets/traitlets.py:1371, in HasTraits.hold_trait_notifications(self)
1369 for changes in cache.values():
1370 for change in changes:
-> 1371 self.notify_change(change)
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/ipywidgets/widgets/widget.py:686, in Widget.notify_change(self, change)
683 if name in self.keys and self._should_send_property(name, getattr(self, name)):
684 # Send new state to front-end
685 self.send_state(key=name)
--> 686 super(Widget, self).notify_change(change)
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/traitlets/traitlets.py:1386, in HasTraits.notify_change(self, change)
1384 def notify_change(self, change):
1385 """Notify observers of a change event"""
-> 1386 return self._notify_observers(change)
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/traitlets/traitlets.py:1431, in HasTraits._notify_observers(self, event)
1428 elif isinstance(c, EventHandler) and c.name is not None:
1429 c = getattr(self, c.name)
-> 1431 c(event)
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/jdaviz/core/template_mixin.py:874, in SubsetSelect._selected_changed(self, event)
872 def _selected_changed(self, event):
873 super()._selected_changed(event)
--> 874 self._update_has_subregions()
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/jdaviz/core/template_mixin.py:925, in SubsetSelect._update_has_subregions(self)
923 self.selected_has_subregions = False
924 else:
--> 925 self.selected_has_subregions = len(self.selected_obj.subregions) > 1
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/functools.py:981, in cached_property.get(self, instance, owner)
979 val = cache.get(self.attrname, _NOT_FOUND)
980 if val is _NOT_FOUND:
--> 981 val = self.func(instance)
982 try:
983 cache[self.attrname] = val
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/jdaviz/core/template_mixin.py:936, in SubsetSelect.selected_obj(self)
932 # NOTE: we use reference names here instead of IDs since get_subsets_from_viewer requires
933 # that. For imviz, this will mean we won't be able to loop through each of the viewers,
934 # but the original viewer should have access to all the subsets.
935 for viewer_ref in self.viewer_refs:
--> 936 match = self.app.get_subsets_from_viewer(viewer_ref,
937 subset_type=subset_type).get(self.selected)
938 if match is not None:
939 return match
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/jdaviz/app.py:815, in Application.get_subsets_from_viewer(self, viewer_reference, data_label, subset_type)
812 else:
813 data_wcs = value.data.coords
--> 815 subregions_in_subset = _get_all_subregions(
816 np.where(value.to_mask() == True)[0], # noqa
817 data_wcs.spectral_axis)
819 regions[key] = subregions_in_subset
820 continue
File ~/opt/miniconda3/envs/jdavizdev/lib/python3.10/site-packages/jdaviz/app.py:742, in Application.get_subsets_from_viewer.._get_all_subregions(mask, spec_axis_data)
725 """
726 Return all subregions within a subset.
727
(...)
737 SpectralRegion object containing all subregions of the subset.
738 """
739 if len(mask) == 0:
740 # Mask should only be 0 if ApplyROI is used to incorrectly
741 # create subsets via the API
--> 742 raise ValueError("Mask has length 0, ApplyROI may have been used incorrectly")
744 current_edge = 0
745 combined_spec_region = None
ValueError: Mask has length 0, ApplyROI may have been used incorrectly
DISCLAIMER: This issue was autocreated by the Jdaviz Issue Creation Bot on behalf of the reporter. If any information is incorrect, please contact Duy Nguyen
The text was updated successfully, but these errors were encountered: