diff --git a/CHANGES.rst b/CHANGES.rst index ce0f9ad0d4..4baf6038e2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -26,6 +26,8 @@ Specviz2d API Changes ----------- - Removed API access to plugins that have passed the deprecation period: Links Control, Canvas Rotation, Export Plot. [#3270] + +- Renamed the ``Subset Tools`` plugin to ``Subsets`` which now exposes the ``subset``, ``combination_mode``, ``get_center``, and ``set_center`` in the user API. [#3293] Cubeviz ^^^^^^^ diff --git a/docs/cubeviz/import_data.rst b/docs/cubeviz/import_data.rst index 77177ca452..8a5ce40389 100644 --- a/docs/cubeviz/import_data.rst +++ b/docs/cubeviz/import_data.rst @@ -197,7 +197,7 @@ can load the regions into Cubeviz as follows: .. code-block:: python - cubeviz.plugins['Subset Tools']._obj.import_region("/path/to/data/myregions.reg") + cubeviz.plugins['Subsets'].import_region("/path/to/data/myregions.reg") Unsupported regions will be skipped and trigger a warning. Those that failed to load, if any, can be returned as a list of tuples of the @@ -205,7 +205,7 @@ form ``(region, reason)``: .. code-block:: python - bad_regions = cubeviz.plugins['Subset Tools']._obj.import_region("/path/to/data/myregions.reg", return_bad_regions=True) + bad_regions = cubeviz.plugins['Subsets'].import_region("/path/to/data/myregions.reg", return_bad_regions=True) .. note:: Sky regions are currently unsupported in Cubeviz, unlike Imviz. diff --git a/docs/cubeviz/plugins.rst b/docs/cubeviz/plugins.rst index 55fa3c0276..7f6649ec69 100644 --- a/docs/cubeviz/plugins.rst +++ b/docs/cubeviz/plugins.rst @@ -61,12 +61,12 @@ Visualize data quality arrays for spectral cubes from JWST. .. _cubeviz-subset-plugin: -Subset Tools -============ +Subsets +======= .. seealso:: - :ref:`Subset Tools ` + :ref:`Subsets ` Imviz documentation describing the concept of subsets in Jdaviz. diff --git a/docs/imviz/import_data.rst b/docs/imviz/import_data.rst index 6e94873b23..1179475c8b 100644 --- a/docs/imviz/import_data.rst +++ b/docs/imviz/import_data.rst @@ -218,7 +218,7 @@ can load the regions into Imviz as follows: .. code-block:: python - imviz.plugins['Subset Tools']._obj.import_region("/path/to/data/myregions.reg") + imviz.plugins['Subsets'].import_region("/path/to/data/myregions.reg") Unsupported regions will be skipped and trigger a warning. Those that failed to load, if any, can be returned as a list of tuples of the @@ -226,7 +226,7 @@ form ``(region, reason)``: .. code-block:: python - bad_regions = imviz.plugins['Subset Tools']._obj.import_region("/path/to/data/myregions.reg", return_bad_regions=True) + bad_regions = imviz.plugins['Subsets'].import_region("/path/to/data/myregions.reg", return_bad_regions=True) You could also define :ref:`regions:shapes` programmatically and load them; e.g.: diff --git a/docs/imviz/plugins.rst b/docs/imviz/plugins.rst index 57801499f6..aaab253aed 100644 --- a/docs/imviz/plugins.rst +++ b/docs/imviz/plugins.rst @@ -94,8 +94,8 @@ in the "Filter by bits" dropdown, or from the API we could: .. _imviz-subset-plugin: -Subset Tools -============ +Subsets +======= This plugin allows you to select an existing subset to modify, or to select :guilabel:`Create new` to create a new subset by selecting and using the region selector diff --git a/docs/mosviz/plugins.rst b/docs/mosviz/plugins.rst index c49ba83f67..670d85e0f6 100644 --- a/docs/mosviz/plugins.rst +++ b/docs/mosviz/plugins.rst @@ -36,12 +36,12 @@ This plugin gives access to per-viewer and per-layer plotting options. .. _mosviz-subset-plugin: -Subset Tools -============ +Subsets +======= .. seealso:: - :ref:`Subset Tools ` + :ref:`Subsets ` Imviz documentation describing the concept of subsets in Jdaviz. .. _imviz_export_markers: diff --git a/docs/rampviz/plugins.rst b/docs/rampviz/plugins.rst index 82301ea32b..63e731e32a 100644 --- a/docs/rampviz/plugins.rst +++ b/docs/rampviz/plugins.rst @@ -30,12 +30,12 @@ To show axes on image viewers, toggle on the "Show axes" option at the bottom of .. _rampviz-subset-plugin: -Subset Tools -============ +Subsets +======= .. seealso:: - :ref:`Subset Tools ` + :ref:`Subsets ` Imviz documentation describing the concept of subsets in Jdaviz. diff --git a/docs/specviz/plugins.rst b/docs/specviz/plugins.rst index 8770eb7be8..75653d944e 100644 --- a/docs/specviz/plugins.rst +++ b/docs/specviz/plugins.rst @@ -42,12 +42,12 @@ Plot Options .. _specviz-subset-plugin: -Subset Tools -============ +Subsets +======= .. seealso:: - :ref:`Subset Tools ` + :ref:`Subsets ` Imviz documentation describing the concept of subsets in Jdaviz. Subsets in Specviz are strictly spectral subsets and do not support rotation or recentering. diff --git a/docs/specviz2d/plugins.rst b/docs/specviz2d/plugins.rst index d7639dd97e..471e448842 100644 --- a/docs/specviz2d/plugins.rst +++ b/docs/specviz2d/plugins.rst @@ -30,12 +30,12 @@ Plot Options .. _specviz2d-subset-plugin: -Subset Tools -============ +Subsets +======= .. seealso:: - :ref:`Subset Tools ` + :ref:`Subsets ` Imviz documentation describing the concept of subsets in Jdaviz. Markers diff --git a/jdaviz/components/data_menu_subset_edit.vue b/jdaviz/components/data_menu_subset_edit.vue index f93d05aa25..246ddf8e04 100644 --- a/jdaviz/components/data_menu_subset_edit.vue +++ b/jdaviz/components/data_menu_subset_edit.vue @@ -25,7 +25,7 @@ - + ` for more details. + See the :ref:`Subsets ` for more details. Only the following attributes and methods are available through the :ref:`public plugin API `: @@ -73,6 +73,13 @@ class SubsetPlugin(PluginTemplateMixin, DatasetSelectMixin): * :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show` * :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray` * :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.close_in_tray` + * ``subset`` (:class:`~jdaviz.core.template_mixin.SubsetSelect`): + Manages subset selection and creation + * ``combination_mode`` (:class:`~jdaviz.core.template_mixin.SelectPluginComponent`): + Allows selection of combination modes for subsets + * :meth:`get_center` + * :meth:`set_center` + * :meth:`import_region` """ template_file = __file__, "subset_plugin.vue" select = List([]).tag(sync=True) @@ -130,11 +137,11 @@ def __init__(self, *args, **kwargs): self.session.hub.subscribe(self, LinkUpdatedMessage, handler=self._on_link_update) - self.subset_select = SubsetSelect(self, - 'subset_items', - 'subset_selected', - multiselect='multiselect', - default_text="Create New") + self.subset = SubsetSelect(self, + 'subset_items', + 'subset_selected', + multiselect='multiselect', + default_text="Create New") self.subset_states = [] self.spectral_display_unit = None @@ -148,7 +155,7 @@ def __init__(self, *args, **kwargs): @property def user_api(self): - expose = [] + expose = ['subset', 'combination_mode', 'get_center', 'set_center', 'import_region'] return PluginUserApi(self, expose) def _on_link_update(self, *args): @@ -161,16 +168,16 @@ def _on_link_update(self, *args): align_by = getattr(self.app, '_align_by', None) self.display_sky_coordinates = (align_by == 'wcs') - if self.subset_selected != self.subset_select.default_text: + if self.subset_selected != self.subset.default_text: self._get_subset_definition(*args) def _sync_selected_from_state(self, *args): - if not hasattr(self, 'subset_select') or self.multiselect: + if not hasattr(self, 'subset') or self.multiselect: # during initial init, this can trigger before the component is initialized return if self.session.edit_subset_mode.edit_subset == []: - if self.subset_selected != self.subset_select.default_text: - self.subset_selected = self.subset_select.default_text + if self.subset_selected != self.subset.default_text: + self.subset_selected = self.subset.default_text self.show_region_info = False else: new_label = self.session.edit_subset_mode.edit_subset[0].label @@ -192,14 +199,14 @@ def _on_subset_update(self, *args): return self._get_subset_definition(*args) subset_to_update = self.session.edit_subset_mode.edit_subset[0] - self.subset_select._update_subset(subset_to_update, attribute="type") + self.subset._update_subset(subset_to_update, attribute="type") def _sync_available_from_state(self, *args): - if not hasattr(self, 'subset_select'): + if not hasattr(self, 'subset'): # during initial init, this can trigger before the component is initialized return - self.subset_items = [{'label': self.subset_select.default_text}] + [ - self.subset_select._subset_to_dict(subset) for subset in + self.subset_items = [{'label': self.subset.default_text}] + [ + self.subset._subset_to_dict(subset) for subset in self.data_collection.subset_groups] @observe('subset_selected') @@ -209,12 +216,12 @@ def _sync_selected_from_ui(self, change): self.glue_state_types = [] self.is_centerable = False - if not hasattr(self, 'subset_select'): + if not hasattr(self, 'subset'): # during initial init, this can trigger before the component is initialized return - if change['new'] != self.subset_select.default_text: + if change['new'] != self.subset.default_text: self._get_subset_definition(change['new']) - self.show_region_info = change['new'] != self.subset_select.default_text + self.show_region_info = change['new'] != self.subset.default_text m = [s for s in self.app.data_collection.subset_groups if s.label == change['new']] if m != self.session.edit_subset_mode.edit_subset: self.session.edit_subset_mode.edit_subset = m @@ -412,7 +419,7 @@ def _on_display_unit_changed(self, msg): # We only care about the spectral units, since flux units don't affect spectral subsets if msg.axis == "spectral": self.spectral_display_unit = msg.unit - if self.subset_selected != self.subset_select.default_text: + if self.subset_selected != self.subset.default_text: self._get_subset_definition(self.subset_selected) def vue_update_subset(self, *args): @@ -592,15 +599,15 @@ def _do_recentering(subset, subset_state): self.set_center((x, y), subset_name=subset, update=True) if not self.multiselect: - _do_recentering(self.subset_selected, self.subset_select.selected_subset_state) + _do_recentering(self.subset_selected, self.subset.selected_subset_state) else: for sub, subset_state in zip(self.subset_selected, - self.subset_select.selected_subset_state): - if (sub != self.subset_select.default_text and + self.subset.selected_subset_state): + if (sub != self.subset.default_text and not isinstance(subset_state, CompositeSubsetState)): self.is_centerable = True _do_recentering(sub, subset_state) - elif (sub != self.subset_select.default_text and + elif (sub != self.subset.default_text and isinstance(subset_state, CompositeSubsetState)): self.hub.broadcast(SnackbarMessage(f"Unable to recenter " f"composite subset {sub}", @@ -611,9 +618,9 @@ def _get_subset_state(self, subset_name=None): raise ValueError("Please include subset_name in when in multiselect mode") if subset_name is not None: - return self.subset_select._get_subset_state(subset_name) + return self.subset._get_subset_state(subset_name) # guaranteed to only return a single entry because of check above - return self.subset_select.selected_subset_state + return self.subset.selected_subset_state def get_center(self, subset_name=None): """Return the center of the Subset. diff --git a/jdaviz/configs/default/plugins/subset_plugin/tests/test_subset_plugin.py b/jdaviz/configs/default/plugins/subset_plugin/tests/test_subset_plugin.py index bfc1b3b540..774af4c52b 100644 --- a/jdaviz/configs/default/plugins/subset_plugin/tests/test_subset_plugin.py +++ b/jdaviz/configs/default/plugins/subset_plugin/tests/test_subset_plugin.py @@ -16,13 +16,13 @@ @pytest.mark.filterwarnings('ignore') def test_plugin(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d) - p = specviz_helper.plugins['Subset Tools']._obj + p = specviz_helper.plugins['Subsets'] # regression test for https://github.com/spacetelescope/jdaviz/issues/1693 unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) p.import_region(SpectralRegion(6500 * unit, 7400 * unit)) - p.subset_select.selected = 'Create New' + p.subset.selected = 'Create New' po = specviz_helper.plugins['Plot Options'] po.layer = 'Subset 1' @@ -99,10 +99,10 @@ def test_circle_recenter_linking(roi_class, subset_info, imviz_helper, image_2d_ # apply subset roi_params = {key: subset_info[key]['initial_value'] for key in subset_info} - imviz_helper.plugins['Subset Tools']._obj.import_region(roi_class(**roi_params)) + imviz_helper.plugins['Subsets'].import_region(roi_class(**roi_params)) # get plugin and check that attribute tracking link type is set properly - plugin = imviz_helper.plugins['Subset Tools']._obj + plugin = imviz_helper.plugins['Subsets']._obj assert not plugin.display_sky_coordinates # get initial subset definitions from ROI applied @@ -146,7 +146,7 @@ def test_circle_recenter_linking(roi_class, subset_info, imviz_helper, image_2d_ img_wcs = imviz_helper.app.data_collection['Default orientation'].coords new_pix_region = original_sky_region.to_pixel(img_wcs) new_roi = regions2roi(new_pix_region) - imviz_helper.plugins['Subset Tools']._obj.import_region(new_roi) + imviz_helper.plugins['Subsets'].import_region(new_roi) # get subset definitions again, which should now be in sky coordinates subset_defs = plugin.subset_definitions @@ -194,7 +194,7 @@ def test_circle_recenter_linking(roi_class, subset_info, imviz_helper, image_2d_ def test_import_spectral_region(cubeviz_helper, spectrum1d_cube, spec_regions, mode, len_subsets, len_subregions): cubeviz_helper.load_data(spectrum1d_cube) - plg = cubeviz_helper.plugins['Subset Tools']._obj + plg = cubeviz_helper.plugins['Subsets'] plg.import_region(spec_regions, combination_mode=mode) subsets = cubeviz_helper.app.get_subsets() assert len(subsets) == len_subsets @@ -204,7 +204,7 @@ def test_import_spectral_region(cubeviz_helper, spectrum1d_cube, spec_regions, m def test_import_spectral_regions_file(cubeviz_helper, spectrum1d_cube, tmp_path): cubeviz_helper.load_data(spectrum1d_cube) - plg = cubeviz_helper.plugins['Subset Tools']._obj + plg = cubeviz_helper.plugins['Subsets'] s = SpectralRegion(5*u.um, 6*u.um) local_path = str(tmp_path / 'spectral_region.ecsv') s.write(local_path) @@ -212,7 +212,7 @@ def test_import_spectral_regions_file(cubeviz_helper, spectrum1d_cube, tmp_path) subsets = cubeviz_helper.app.get_subsets() assert len(subsets) == 1 - plg.combination_mode.selected = 'or' + plg.combination_mode = 'or' plg.import_region(SpectralRegion(7 * u.um, 8 * u.um)) subsets = cubeviz_helper.app.get_subsets() @@ -225,4 +225,4 @@ def test_import_spectral_regions_file(cubeviz_helper, spectrum1d_cube, tmp_path) assert cubeviz_helper.app.session.edit_subset_mode.mode == OrMode with pytest.raises(ValueError, match='\'test\' not one of'): - plg.combination_mode.selected = 'test' + plg.combination_mode = 'test' diff --git a/jdaviz/configs/default/tests/test_data_menu.py b/jdaviz/configs/default/tests/test_data_menu.py index 9316ac0cc7..46a6bef063 100644 --- a/jdaviz/configs/default/tests/test_data_menu.py +++ b/jdaviz/configs/default/tests/test_data_menu.py @@ -24,7 +24,7 @@ def test_data_menu_toggles(specviz_helper, spectrum1d): assert len(dm._obj.visible_layers) == 1 # add a subset and make sure it appears for the first data entry but not the second - specviz_helper.plugins['Subset Tools']._obj.import_region( + specviz_helper.plugins['Subsets'].import_region( SpectralRegion(6000 * spectrum1d.spectral_axis.unit, 6500 * spectrum1d.spectral_axis.unit)) assert len(dm._obj.layer_items) == 3 @@ -119,14 +119,14 @@ def test_data_menu_remove_subset(specviz_helper, spectrum1d): specviz_helper.load_data(new_spec, data_label="test2") dm = specviz_helper.viewers['spectrum-viewer']._obj.data_menu - sp = specviz_helper.plugins['Subset Tools'] + sp = specviz_helper.plugins['Subsets'] - sp._obj.import_region(SpectralRegion(6000 * spectrum1d.spectral_axis.unit, - 6100 * spectrum1d.spectral_axis.unit), - combination_mode='new') - sp._obj.import_region(SpectralRegion(6000 * spectrum1d.spectral_axis.unit, - 6100 * spectrum1d.spectral_axis.unit), - combination_mode='new') + sp.import_region(SpectralRegion(6000 * spectrum1d.spectral_axis.unit, + 6100 * spectrum1d.spectral_axis.unit), + combination_mode='new') + sp.import_region(SpectralRegion(6000 * spectrum1d.spectral_axis.unit, + 6100 * spectrum1d.spectral_axis.unit), + combination_mode='new') assert dm.layer.choices == ['test', 'test2', 'Subset 1', 'Subset 2'] dm.layer.selected = ['Subset 1'] @@ -153,10 +153,10 @@ def test_data_menu_subset_appearance(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d, data_label="test") dm = specviz_helper.viewers['spectrum-viewer']._obj.data_menu - sp = specviz_helper.plugins['Subset Tools'] + sp = specviz_helper.plugins['Subsets'] - sp._obj.import_region(SpectralRegion(6000 * spectrum1d.spectral_axis.unit, - 6100 * spectrum1d.spectral_axis.unit)) + sp.import_region(SpectralRegion(6000 * spectrum1d.spectral_axis.unit, + 6100 * spectrum1d.spectral_axis.unit)) assert dm.layer.choices == ['test', 'Subset 1'] @@ -169,14 +169,14 @@ def test_data_menu_view_info(specviz_helper, spectrum1d): dm = specviz_helper.viewers['spectrum-viewer']._obj.data_menu mp = specviz_helper.plugins['Metadata'] - sp = specviz_helper.plugins['Subset Tools'] + sp = specviz_helper.plugins['Subsets'] - sp._obj.import_region(SpectralRegion(6000 * spectrum1d.spectral_axis.unit, - 6100 * spectrum1d.spectral_axis.unit), - combination_mode='new') - sp._obj.import_region(SpectralRegion(6200 * spectrum1d.spectral_axis.unit, - 6300 * spectrum1d.spectral_axis.unit), - combination_mode='new') + sp.import_region(SpectralRegion(6000 * spectrum1d.spectral_axis.unit, + 6100 * spectrum1d.spectral_axis.unit), + combination_mode='new') + sp.import_region(SpectralRegion(6200 * spectrum1d.spectral_axis.unit, + 6300 * spectrum1d.spectral_axis.unit), + combination_mode='new') assert dm.layer.choices == ['test', 'test2', 'Subset 1', 'Subset 2'] @@ -186,7 +186,7 @@ def test_data_menu_view_info(specviz_helper, spectrum1d): dm.layer.selected = ["Subset 2"] dm.view_info() - assert sp._obj.subset_select.selected == "Subset 2" + assert sp.subset.selected == "Subset 2" dm.layer.selected = ["test", "test2"] with pytest.raises(ValueError, match="Only one layer can be selected to view info"): diff --git a/jdaviz/configs/imviz/plugins/viewers.py b/jdaviz/configs/imviz/plugins/viewers.py index 0486582e81..d1122057a6 100644 --- a/jdaviz/configs/imviz/plugins/viewers.py +++ b/jdaviz/configs/imviz/plugins/viewers.py @@ -81,7 +81,7 @@ def on_mouse_or_key_event(self, data): key_pressed = data['key'] if key_pressed in ('b', 'B'): - self.blink_once(reversed=key_pressed=='B') # noqa: E225 + self.blink_once(reversed=key_pressed == 'B') def blink_once(self, reversed=False): # Simple blinking of images - this will make it so that only one @@ -190,7 +190,7 @@ def _get_real_xy(self, image, x, y, reverse=False): When `True`, it sets the coords, otherwise it resets. ``reverse=True`` is only for internal roundtripping (e.g., centroiding - in Subset Tools plugin). Never use this for coordinates display panel. + in Subsets plugin). Never use this for coordinates display panel. """ # By default we'll assume the coordinates are valid and within any applicable bounding box. diff --git a/jdaviz/configs/imviz/tests/test_delete_data.py b/jdaviz/configs/imviz/tests/test_delete_data.py index 1502929f84..e5f03ab9a5 100644 --- a/jdaviz/configs/imviz/tests/test_delete_data.py +++ b/jdaviz/configs/imviz/tests/test_delete_data.py @@ -29,11 +29,11 @@ def test_delete_with_subset_wcs(self): # Add a subset reg = CirclePixelRegion(PixCoord(2, 2), 3).to_sky(self.wcs_1) - self.imviz.plugins['Subset Tools']._obj.import_region(reg) + self.imviz.plugins['Subsets'].import_region(reg) - self.imviz.plugins['Subset Tools']._obj.combination_mode.selected = 'new' + self.imviz.plugins['Subsets'].combination_mode = 'new' reg = RectanglePixelRegion(PixCoord(1, 1), 2, 2).to_sky(self.wcs_1) - self.imviz.plugins['Subset Tools']._obj.import_region(reg) + self.imviz.plugins['Subsets'].import_region(reg) assert len(self.imviz.app.data_collection.subset_groups) == 2 @@ -81,6 +81,7 @@ def test_delete_with_subset_wcs(self): class TestDeleteWCSLayerWithSubset(BaseImviz_WCS_GWCS): """Regression test for https://jira.stsci.edu/browse/JDAT-3958""" + def test_delete_wcs_layer_with_subset(self): lc_plugin = self.imviz.plugins['Orientation'] lc_plugin.align_by = 'WCS' @@ -91,7 +92,7 @@ def test_delete_wcs_layer_with_subset(self): # Create a rotated ellipse. reg = EllipsePixelRegion( PixCoord(3.5, 4.5), width=2, height=5, angle=Angle(30, 'deg')).to_sky(self.wcs_1) - self.imviz.plugins['Subset Tools']._obj.import_region(reg) + self.imviz.plugins['Subsets'].import_region(reg) # Switch back to Default Orientation. self.imviz.app._change_reference_data("Default orientation") diff --git a/jdaviz/configs/imviz/tests/test_linking.py b/jdaviz/configs/imviz/tests/test_linking.py index 438dff7ac7..326f36e5ff 100644 --- a/jdaviz/configs/imviz/tests/test_linking.py +++ b/jdaviz/configs/imviz/tests/test_linking.py @@ -101,8 +101,8 @@ def test_wcslink_affine_with_extras(self): # Add subsets, both interactive and static. self.imviz._apply_interactive_region('bqplot:truecircle', (1.5, 2.5), (3.6, 4.6)) - self.imviz.plugins['Subset Tools']._obj.combination_mode.selected = 'new' - self.imviz.plugins['Subset Tools']._obj.import_region([ + self.imviz.plugins['Subsets'].combination_mode = 'new' + self.imviz.plugins['Subsets'].import_region([ CirclePixelRegion(center=PixCoord(x=6, y=2), radius=5).to_sky(self.wcs_1), PolygonPixelRegion(vertices=PixCoord(x=[1, 2, 2], y=[1, 1, 2])).to_sky(self.wcs_1), PolygonPixelRegion(vertices=PixCoord(x=[2, 3, 3], y=[2, 2, 3])).to_sky(self.wcs_1)]) diff --git a/jdaviz/configs/imviz/tests/test_orientation.py b/jdaviz/configs/imviz/tests/test_orientation.py index 904d274d35..9049840207 100644 --- a/jdaviz/configs/imviz/tests/test_orientation.py +++ b/jdaviz/configs/imviz/tests/test_orientation.py @@ -197,7 +197,7 @@ def test_delete_orientation_with_subset(self, klass, angle, sbst_theta): # Create rotated shape reg = klass(center=SkyCoord(ra=337.51931488, dec=-20.83187472, unit="deg"), width=2.4 * u.arcsec, height=1.2 * u.arcsec, angle=angle) - self.imviz.plugins['Subset Tools']._obj.import_region(reg) + self.imviz.plugins['Subsets'].import_region(reg) # Switch to N-up E-right lc_plugin._obj.create_north_up_east_right(set_on_create=True) diff --git a/jdaviz/configs/imviz/tests/test_regions.py b/jdaviz/configs/imviz/tests/test_regions.py index 554a99e39e..25e5c577d5 100644 --- a/jdaviz/configs/imviz/tests/test_regions.py +++ b/jdaviz/configs/imviz/tests/test_regions.py @@ -16,6 +16,7 @@ class BaseRegionHandler: """Test to see if region is loaded. Does not check if region is actually at the correct place in display. """ + def verify_region_loaded(self, region_label, count=2): n = 0 for layer in self.viewer.state.layers: @@ -198,7 +199,7 @@ def test_ds9_load_all(self, imviz_helper): self.viewer = imviz_helper.default_viewer._obj imviz_helper.load_data(self.arr, data_label='my_image') - bad_regions = imviz_helper.plugins['Subset Tools']._obj.import_region( + bad_regions = imviz_helper.plugins['Subsets'].import_region( self.region_file, combination_mode='new', return_bad_regions=True) assert len(bad_regions) == 1 @@ -213,7 +214,7 @@ def test_ds9_load_all(self, imviz_helper): def test_ds9_load_two_good(self, imviz_helper): self.viewer = imviz_helper.default_viewer._obj imviz_helper.load_data(self.arr, data_label='my_image') - bad_regions = imviz_helper.plugins['Subset Tools']._obj.import_region( + bad_regions = imviz_helper.plugins['Subsets'].import_region( self.region_file, combination_mode='new', max_num_regions=2, return_bad_regions=True) assert len(bad_regions) == 0 subsets = imviz_helper.get_interactive_regions() @@ -223,7 +224,7 @@ def test_ds9_load_two_good(self, imviz_helper): def test_ds9_load_one_bad(self, imviz_helper): self.viewer = imviz_helper.default_viewer._obj imviz_helper.load_data(self.arr, data_label='my_image') - bad_regions = imviz_helper.plugins['Subset Tools']._obj.import_region( + bad_regions = imviz_helper.plugins['Subsets'].import_region( self.raw_regions[6], return_bad_regions=True) assert len(bad_regions) == 1 assert imviz_helper.get_interactive_regions() == {} @@ -232,7 +233,7 @@ def test_ds9_load_one_bad(self, imviz_helper): def test_ds9_load_one_good_one_bad(self, imviz_helper): self.viewer = imviz_helper.default_viewer._obj imviz_helper.load_data(self.arr, data_label='my_image') - bad_regions = imviz_helper.plugins['Subset Tools']._obj.import_region( + bad_regions = imviz_helper.plugins['Subsets'].import_region( [self.raw_regions[3], self.raw_regions[6]], return_bad_regions=True) assert len(bad_regions) == 1 diff --git a/jdaviz/configs/imviz/tests/test_simple_aper_phot.py b/jdaviz/configs/imviz/tests/test_simple_aper_phot.py index 76bee54e0c..f8dd2c18ae 100644 --- a/jdaviz/configs/imviz/tests/test_simple_aper_phot.py +++ b/jdaviz/configs/imviz/tests/test_simple_aper_phot.py @@ -25,7 +25,7 @@ def test_plugin_wcs_dithered(self): self.imviz.link_data(align_by='wcs') # They are dithered by 1 pixel on X reg = CirclePixelRegion(center=PixCoord(x=4.5, y=4.5), radius=4.5).to_sky(self.wcs_1) - self.imviz.plugins['Subset Tools']._obj.import_region(reg) + self.imviz.plugins['Subsets'].import_region(reg) phot_plugin = self.imviz.app.get_tray_item_from_name('imviz-aper-phot-simple') @@ -120,8 +120,8 @@ def test_plugin_wcs_dithered(self): # Make sure it also works on an ellipse subset. reg = EllipsePixelRegion(center=PixCoord(x=4.5, y=2.0), width=9.0, height=4.0).to_sky(self.wcs_1) # noqa: E501 - self.imviz.plugins['Subset Tools']._obj.combination_mode.selected = 'new' - self.imviz.plugins['Subset Tools']._obj.import_region(reg) + self.imviz.plugins['Subsets'].combination_mode = 'new' + self.imviz.plugins['Subsets'].import_region(reg) phot_plugin.dataset_selected = 'has_wcs_1[SCI,1]' phot_plugin.aperture_selected = 'Subset 2' @@ -144,8 +144,8 @@ def test_plugin_wcs_dithered(self): # Make sure it also works on a rectangle subset. # We also subtract off background from itself here. reg = RectanglePixelRegion(center=PixCoord(x=4.5, y=4.5), width=9, height=9).to_sky(self.wcs_1) # noqa: E501 - self.imviz.plugins['Subset Tools']._obj.combination_mode.selected = 'new' - self.imviz.plugins['Subset Tools']._obj.import_region(reg) + self.imviz.plugins['Subsets'].combination_mode = 'new' + self.imviz.plugins['Subsets'].import_region(reg) phot_plugin.dataset_selected = 'has_wcs_1[SCI,1]' phot_plugin.aperture_selected = 'Subset 3' @@ -282,7 +282,7 @@ def setup_class(self, imviz_helper): w = imviz_helper.app.data_collection[0].coords # Regions to be used for aperture photometry - imviz_helper.plugins['Subset Tools']._obj.import_region([ + imviz_helper.plugins['Subsets'].import_region([ CirclePixelRegion(center=PixCoord(x=145.1, y=168.3), radius=5).to_sky(w), CirclePixelRegion(center=PixCoord(x=48.3, y=200.3), radius=5).to_sky(w), EllipsePixelRegion(center=PixCoord(x=84.7, y=224.1), width=23, height=9, angle=2.356 * u.rad).to_sky(w), # noqa: E501 @@ -361,8 +361,8 @@ def test_annulus_background(imviz_helper): # Load annulus (this used to be part of the plugin but no longer) annulus_1 = CircleAnnulusPixelRegion( PixCoord(x=150, y=25), inner_radius=7, outer_radius=17) - imviz_helper.plugins['Subset Tools']._obj.import_region([circle_1, annulus_1], - combination_mode='new') + imviz_helper.plugins['Subsets'].import_region([circle_1, annulus_1], + combination_mode='new') phot_plugin.aperture_selected = 'Subset 1' phot_plugin.background_selected = 'Subset 2' @@ -379,8 +379,8 @@ def test_annulus_background(imviz_helper): # Load annulus (this used to be part of the plugin but no longer) annulus_2 = CircleAnnulusPixelRegion( PixCoord(x=20.5, y=37.5), inner_radius=20.5, outer_radius=30.5) - imviz_helper.plugins['Subset Tools']._obj.import_region([ellipse_1, annulus_2], - combination_mode='new') + imviz_helper.plugins['Subsets'].import_region([ellipse_1, annulus_2], + combination_mode='new') # Subset 4 (annulus) should be available in both sets of choices, but invalid for selection as # aperture @@ -412,7 +412,7 @@ def test_annulus_background(imviz_helper): assert_allclose(phot_plugin.background_value, bg_4gauss_2) # Edit the annulus and make sure background updates - subset_plugin = imviz_helper.plugins["Subset Tools"]._obj + subset_plugin = imviz_helper.plugins["Subsets"]._obj subset_plugin.subset_selected = "Subset 4" subset_plugin._set_value_in_subset_definition(0, "X Center (pixels)", "value", 25.5) subset_plugin._set_value_in_subset_definition(0, "Y Center (pixels)", "value", 42.5) @@ -431,7 +431,7 @@ def test_fit_radial_profile_with_nan(imviz_helper): # Mark an object of interest circle_1 = CirclePixelRegion(center=PixCoord(x=150, y=25), radius=7) - imviz_helper.plugins['Subset Tools']._obj.import_region( + imviz_helper.plugins['Subsets'].import_region( [circle_1], combination_mode='new') phot_plugin = imviz_helper.app.get_tray_item_from_name('imviz-aper-phot-simple') @@ -528,7 +528,7 @@ def test_cubeviz_batch(cubeviz_helper, spectrum1d_cube_fluxunit_jy_per_steradian cubeviz_helper.load_data(spectrum1d_cube_fluxunit_jy_per_steradian, data_label='test') phot_plugin = cubeviz_helper.plugins['Aperture Photometry']._obj uc_plugin = cubeviz_helper.plugins['Unit Conversion'] - subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj + subset_plugin = cubeviz_helper.plugins['Subsets'] subset_plugin.import_region(CirclePixelRegion(center=PixCoord(x=5, y=5), radius=2), combination_mode='new') diff --git a/jdaviz/configs/imviz/tests/test_subset_centroid.py b/jdaviz/configs/imviz/tests/test_subset_centroid.py index 7221986520..02da7e54ff 100644 --- a/jdaviz/configs/imviz/tests/test_subset_centroid.py +++ b/jdaviz/configs/imviz/tests/test_subset_centroid.py @@ -9,7 +9,7 @@ class TestImvizSpatialSubsetCentroidPixelLinked(BaseImviz_WCS_GWCS): def test_centroiding_pixel(self): reg = CirclePixelRegion(PixCoord(2, 2), 3) - plg = self.imviz.plugins['Subset Tools']._obj + plg = self.imviz.plugins['Subsets']._obj plg.import_region(reg) plg.subset_selected = 'Subset 1' @@ -40,7 +40,7 @@ def test_centroiding_wcs(self): self.imviz.link_data(align_by='wcs') reg = CirclePixelRegion(PixCoord(2, 2), 3).to_sky(self.wcs_1) - plg = self.imviz.plugins['Subset Tools']._obj + plg = self.imviz.plugins['Subsets']._obj plg.import_region(reg) plg.subset_selected = 'Subset 1' diff --git a/jdaviz/configs/imviz/tests/test_viewers.py b/jdaviz/configs/imviz/tests/test_viewers.py index 9388c5a69f..95ffb19823 100644 --- a/jdaviz/configs/imviz/tests/test_viewers.py +++ b/jdaviz/configs/imviz/tests/test_viewers.py @@ -67,7 +67,7 @@ def test_destroy_viewer_with_subset(imviz_helper): # Create a Subset. reg = CirclePixelRegion(center=PixCoord(x=4, y=4), radius=2) - imviz_helper.plugins['Subset Tools']._obj.import_region(reg) + imviz_helper.plugins['Subsets'].import_region(reg) # Remove the second viewer. imviz_helper.destroy_viewer('second') diff --git a/jdaviz/configs/imviz/tests/utils.py b/jdaviz/configs/imviz/tests/utils.py index 39d8beb2b5..eb091bc148 100644 --- a/jdaviz/configs/imviz/tests/utils.py +++ b/jdaviz/configs/imviz/tests/utils.py @@ -42,7 +42,7 @@ def setup_class(self, imviz_helper): self.wcs = WCS(hdu.header) self.imviz = imviz_helper self.viewer = imviz_helper.default_viewer._obj - self.subset_plugin = self.imviz.plugins['Subset Tools']._obj + self.subset_plugin = self.imviz.plugins['Subsets'] # Since we are not really displaying, need this to test zoom. self.viewer.shape = (100, 100) diff --git a/jdaviz/configs/rampviz/tests/test_ramp_extraction.py b/jdaviz/configs/rampviz/tests/test_ramp_extraction.py index 169c87ed05..527d27f854 100644 --- a/jdaviz/configs/rampviz/tests/test_ramp_extraction.py +++ b/jdaviz/configs/rampviz/tests/test_ramp_extraction.py @@ -18,7 +18,7 @@ def _ramp_extraction_previews(_rampviz_helper, _ramp_file): # add subset: region = CirclePixelRegion(center=PixCoord(12.5, 15.5), radius=2) - _rampviz_helper.plugins['Subset Tools']._obj.import_region(region) + _rampviz_helper.plugins['Subsets'].import_region(region) ramp_extr = _rampviz_helper.plugins['Ramp Extraction']._obj subsets = _rampviz_helper.app.get_subsets() diff --git a/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py b/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py index 8f54ea8afe..f96d12fde1 100644 --- a/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py +++ b/jdaviz/configs/specviz/plugins/line_analysis/tests/test_line_analysis.py @@ -32,8 +32,8 @@ def test_plugin(specviz_helper, spectrum1d): # add a region and rerun stats for that region unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6500 * unit, - 7400 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6500 * unit, + 7400 * unit)) specviz_helper.app.state.drawer = True assert 'Subset 1' in plugin.spectral_subset.labels @@ -58,14 +58,14 @@ def test_spatial_subset(cubeviz_helper, image_cube_hdu_obj): cubeviz_helper.load_data(image_cube_hdu_obj, data_label="Test Cube") # add a spatial region - cubeviz_helper.plugins['Subset Tools']._obj.import_region( + cubeviz_helper.plugins['Subsets'].import_region( RectanglePixelRegion(center=PixCoord(x=3, y=5), width=4, height=6)) # create a spectral region unit = u.Unit(cubeviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - cubeviz_helper.plugins['Subset Tools']._obj.combination_mode.selected = 'new' - cubeviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(3.623e-7 * unit, - 3.627e-7 * unit)) + cubeviz_helper.plugins['Subsets'].combination_mode = 'new' + cubeviz_helper.plugins['Subsets'].import_region(SpectralRegion(3.623e-7 * unit, + 3.627e-7 * unit)) cubeviz_helper.app.state.drawer = True plugin = cubeviz_helper.app.get_tray_item_from_name('specviz-line-analysis') @@ -130,8 +130,8 @@ def test_user_api(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d, data_label=label) unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6500 * unit, - 7400 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6500 * unit, + 7400 * unit)) la = specviz_helper.plugins['Line Analysis'] la.keep_active = True @@ -247,8 +247,8 @@ def test_continuum_surrounding_spectral_subset(specviz_helper, spectrum1d): # add a region and rerun stats for that region unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6500 * unit, - 7400 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6500 * unit, + 7400 * unit)) specviz_helper.app.state.drawer = True plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') @@ -276,8 +276,8 @@ def test_continuum_spectral_same_value(specviz_helper, spectrum1d): # add a region and rerun stats for that region unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6500 * unit, - 7400 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6500 * unit, + 7400 * unit)) specviz_helper.app.state.drawer = True plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') @@ -305,8 +305,8 @@ def test_continuum_surrounding_invalid_width(specviz_helper, spectrum1d): # add a region and rerun stats for that region unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6500 * unit, - 7400 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6500 * unit, + 7400 * unit)) specviz_helper.app.state.drawer = True plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') @@ -332,8 +332,8 @@ def test_continuum_subset_spectral_entire(specviz_helper, spectrum1d): # add a region and rerun stats for that region unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6500 * unit, - 7400 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6500 * unit, + 7400 * unit)) specviz_helper.app.state.drawer = True plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') @@ -361,13 +361,13 @@ def test_continuum_subset_spectral_subset2(specviz_helper, spectrum1d): # add a region and rerun stats for that region unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6200 * unit, - 7000 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6200 * unit, + 7000 * unit)) specviz_helper.app.state.drawer = True - specviz_helper.plugins['Subset Tools']._obj.combination_mode.selected = 'new' - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(7100 * unit, - 7700 * unit)) + specviz_helper.plugins['Subsets'].combination_mode = 'new' + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(7100 * unit, + 7700 * unit)) specviz_helper.app.state.drawer = True plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') @@ -396,8 +396,8 @@ def test_continuum_surrounding_no_right(specviz_helper, spectrum1d): # add a region and rerun stats for that region unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6500 * unit, - 8000 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6500 * unit, + 8000 * unit)) specviz_helper.app.state.drawer = True plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') @@ -426,8 +426,8 @@ def test_continuum_surrounding_no_left(specviz_helper, spectrum1d): # add a region and rerun stats for that region unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6000 * unit, - 7500 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6000 * unit, + 7500 * unit)) specviz_helper.app.state.drawer = True plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') @@ -456,8 +456,8 @@ def test_subset_changed(specviz_helper, spectrum1d): # add a region and rerun stats for that region unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6000 * unit, - 7500 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6000 * unit, + 7500 * unit)) specviz_helper.app.state.drawer = True plugin = specviz_helper.app.get_tray_item_from_name('specviz-line-analysis') @@ -467,8 +467,8 @@ def test_subset_changed(specviz_helper, spectrum1d): plugin.continuum_subset_selected = 'Surrounding' plugin.width = 3 - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(6500 * unit, - 7500 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(6500 * unit, + 7500 * unit)) specviz_helper.app.state.drawer = True # Values have not yet been validated @@ -488,8 +488,8 @@ def test_invalid_subset(specviz_helper, spectrum1d): # NOTE: using a subset that overlaps the right_spectrum (reference) results in errors when # retrieving the subset (https://github.com/spacetelescope/jdaviz/issues/1868) unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) - specviz_helper.plugins['Subset Tools']._obj.import_region(SpectralRegion(5000 * unit, - 6000 * unit)) + specviz_helper.plugins['Subsets'].import_region(SpectralRegion(5000 * unit, + 6000 * unit)) plugin = specviz_helper.plugins['Line Analysis'] plugin.dataset = 'right_spectrum' diff --git a/jdaviz/configs/specviz/tests/test_helper.py b/jdaviz/configs/specviz/tests/test_helper.py index 8e87125071..1c85ac532b 100644 --- a/jdaviz/configs/specviz/tests/test_helper.py +++ b/jdaviz/configs/specviz/tests/test_helper.py @@ -122,7 +122,7 @@ def test_get_spectral_regions_none(self): assert spec_region == {} def test_get_spectral_regions_one(self): - self.spec_app.plugins['Subset Tools']._obj.import_region( + self.spec_app.plugins['Subsets'].import_region( SpectralRegion(6000*self.spec.spectral_axis.unit, 6500*self.spec.spectral_axis.unit)) spec_region = self.spec_app.get_spectral_regions() assert len(spec_region['Subset 1'].subregions) == 1 @@ -132,7 +132,7 @@ def test_get_spectral_regions_two(self): 6500*self.spec.spectral_axis.unit) + SpectralRegion(7300*self.spec.spectral_axis.unit, 7800*self.spec.spectral_axis.unit)) - self.spec_app.plugins['Subset Tools']._obj.import_region(subset, combination_mode='or') + self.spec_app.plugins['Subsets'].import_region(subset, combination_mode='or') spec_region = self.spec_app.get_spectral_regions() @@ -145,7 +145,7 @@ def test_get_spectral_regions_three(self): 7000*self.spec.spectral_axis.unit) + SpectralRegion(7300*self.spec.spectral_axis.unit, 7800*self.spec.spectral_axis.unit)) - self.spec_app.plugins['Subset Tools']._obj.import_region(subset, combination_mode='or') + self.spec_app.plugins['Subsets'].import_region(subset, combination_mode='or') spec_region = self.spec_app.get_spectral_regions() @@ -171,7 +171,7 @@ def test_get_spectral_regions_does_not_raise_value_error(self): 3*self.spec.spectral_axis.unit) + SpectralRegion(4*self.spec.spectral_axis.unit, 6*self.spec.spectral_axis.unit)) - self.spec_app.plugins['Subset Tools']._obj.import_region(subset, combination_mode='or') + self.spec_app.plugins['Subsets'].import_region(subset, combination_mode='or') spec_region = self.spec_app.get_spectral_regions() assert_quantity_allclose(spec_region['Subset 1'].subregions[0][0].value, @@ -191,7 +191,7 @@ def test_get_spectral_regions_composite_region(self): 7000*self.spec.spectral_axis.unit) + SpectralRegion(7300*self.spec.spectral_axis.unit, 7800*self.spec.spectral_axis.unit)) - self.spec_app.plugins['Subset Tools']._obj.import_region( + self.spec_app.plugins['Subsets'].import_region( subset, combination_mode=['new', 'andnot', 'and']) spec_region = self.spec_app.get_spectral_regions() @@ -210,7 +210,7 @@ def test_get_spectral_regions_composite_region_multiple_and_nots(self): 6600*self.spec.spectral_axis.unit) + SpectralRegion(7300*self.spec.spectral_axis.unit, 7700*self.spec.spectral_axis.unit)) - self.spec_app.plugins['Subset Tools']._obj.import_region( + self.spec_app.plugins['Subsets'].import_region( subset, combination_mode=['new', 'andnot', 'andnot']) spec_region = self.spec_app.get_spectral_regions() @@ -261,7 +261,7 @@ def test_add_spectrum_after_subset(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d, data_label="test") subset = SpectralRegion(6200 * spectrum1d.spectral_axis.unit, 7000 * spectrum1d.spectral_axis.unit) - specviz_helper.plugins['Subset Tools']._obj.import_region(subset) + specviz_helper.plugins['Subsets'].import_region(subset) new_spec = specviz_helper.get_spectra(apply_slider_redshift=True)["test"]*0.9 specviz_helper.load_data(new_spec, data_label="test2") @@ -272,7 +272,7 @@ def test_get_spectral_regions_unit(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d) subset = SpectralRegion(6200 * spectrum1d.spectral_axis.unit, 7000 * spectrum1d.spectral_axis.unit) - specviz_helper.plugins['Subset Tools']._obj.import_region(subset) + specviz_helper.plugins['Subsets'].import_region(subset) subsets = specviz_helper.get_spectral_regions() reg = subsets.get('Subset 1') @@ -314,7 +314,7 @@ def test_get_spectral_regions_unit_conversion(specviz_helper, spectrum1d): specviz_helper.plugins['Unit Conversion'].spectral_unit = new_spectral_axis spectral_axis_unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) subset = SpectralRegion(0.6 * spectral_axis_unit, 0.7 * spectral_axis_unit) - specviz_helper.plugins['Subset Tools']._obj.import_region(subset) + specviz_helper.plugins['Subsets'].import_region(subset) # Retrieve the Subset subsets = specviz_helper.get_spectral_regions(use_display_units=False) @@ -349,7 +349,7 @@ def test_subset_default_thickness(specviz_helper, spectrum1d): spectral_axis_unit = u.Unit(specviz_helper.plugins['Unit Conversion'].spectral_unit.selected) subset = SpectralRegion(2.5 * spectral_axis_unit, 3.5 * spectral_axis_unit) - specviz_helper.plugins['Subset Tools']._obj.import_region(subset) + specviz_helper.plugins['Subsets'].import_region(subset) # _on_layers_update is not triggered within CI sv._on_layers_update() assert sv.state.layers[-1].linewidth == 3 @@ -513,7 +513,7 @@ def test_delete_data_with_subsets(specviz_helper, spectrum1d, spectrum1d_nm): subset = SpectralRegion(6200 * spectral_axis_unit, 7000 * spectral_axis_unit) - specviz_helper.plugins['Subset Tools']._obj.import_region(subset) + specviz_helper.plugins['Subsets'].import_region(subset) assert len(specviz_helper.app.data_collection.subset_groups) == 1 subset1 = specviz_helper.app.data_collection.subset_groups[0] diff --git a/jdaviz/core/tests/test_data_menu.py b/jdaviz/core/tests/test_data_menu.py index 0ec0f9e656..5ce1bb1a02 100644 --- a/jdaviz/core/tests/test_data_menu.py +++ b/jdaviz/core/tests/test_data_menu.py @@ -54,7 +54,7 @@ def test_data_menu_toggles(specviz_helper, spectrum1d): assert sv.layers[1].visible is False # add a subset and make sure it appears for the first data entry but not the second - specviz_helper.plugins['Subset Tools']._obj.import_region( + specviz_helper.plugins['Subsets'].import_region( SpectralRegion(6000 * spectrum1d.spectral_axis.unit, 6500 * spectrum1d.spectral_axis.unit)) assert len(sv.layers) == 4 diff --git a/jdaviz/core/tests/test_helpers.py b/jdaviz/core/tests/test_helpers.py index 8178fbe1cc..8e33b7411e 100644 --- a/jdaviz/core/tests/test_helpers.py +++ b/jdaviz/core/tests/test_helpers.py @@ -42,12 +42,12 @@ def setup_class(self, specviz_helper, spectrum1d, multi_order_spectrum_list): self.spec_app.load_data(self.spec2, data_label=self.label2) # Add 3 subsets to cover different parts of spec and spec2 - self.spec_app.plugins['Subset Tools']._obj.import_region( + self.spec_app.plugins['Subsets'].import_region( SpectralRegion(6000*spectral_axis_unit, 6500*spectral_axis_unit)) - self.spec_app.plugins['Subset Tools']._obj.import_region( + self.spec_app.plugins['Subsets'].import_region( SpectralRegion(6700*spectral_axis_unit, 7200*spectral_axis_unit), combination_mode='new') - self.spec_app.plugins['Subset Tools']._obj.import_region( + self.spec_app.plugins['Subsets'].import_region( SpectralRegion(8200*spectral_axis_unit, 8800*spectral_axis_unit), combination_mode='new') diff --git a/jdaviz/core/tests/test_template_mixin.py b/jdaviz/core/tests/test_template_mixin.py index 05cd152f8e..d92b723648 100644 --- a/jdaviz/core/tests/test_template_mixin.py +++ b/jdaviz/core/tests/test_template_mixin.py @@ -12,7 +12,7 @@ def test_spectralsubsetselect(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d) sv = specviz_helper.app.get_viewer('spectrum-viewer') # create a "Subset 1" entry - subset_plugin = specviz_helper.plugins['Subset Tools']._obj + subset_plugin = specviz_helper.plugins['Subsets'] subset_plugin.import_region(SpectralRegion(6500 * spectrum1d.spectral_axis.unit, 7400 * spectrum1d.spectral_axis.unit)) diff --git a/jdaviz/tests/test_subsets.py b/jdaviz/tests/test_subsets.py index 3892143a96..135878ade3 100644 --- a/jdaviz/tests/test_subsets.py +++ b/jdaviz/tests/test_subsets.py @@ -17,7 +17,7 @@ def test_region_from_subset_2d(cubeviz_helper): cubeviz_helper.load_data(np.ones((128, 128, 1)), data_label='Test 2D Flux') - subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj + subset_plugin = cubeviz_helper.plugins['Subsets'] cubeviz_helper.app.add_data_to_viewer('flux-viewer', 'Test 2D Flux') @@ -36,26 +36,30 @@ def test_region_from_subset_2d(cubeviz_helper): assert_allclose(reg.height, 6.6) assert_allclose(reg.angle.value, 0) - assert subset_plugin.subset_selected == "Subset 1" - assert subset_plugin.subset_types == ["EllipticalROI"] - assert subset_plugin.is_centerable + assert subset_plugin._obj.subset_selected == "Subset 1" + assert subset_plugin._obj.subset_types == ["EllipticalROI"] + assert subset_plugin._obj.is_centerable for key in ("orig", "value"): - assert subset_plugin._get_value_from_subset_definition(0, "X Center (pixels)", key) == 1 - assert subset_plugin._get_value_from_subset_definition(0, "Y Center (pixels)", key) == 3.5 - assert subset_plugin._get_value_from_subset_definition(0, "X Radius (pixels)", key) == 1.2 - assert subset_plugin._get_value_from_subset_definition(0, "Y Radius (pixels)", key) == 3.3 - assert subset_plugin._get_value_from_subset_definition(0, "Angle", key) == 0 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "X Center (pixels)", key) == 1 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "Y Center (pixels)", key) == 3.5 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "X Radius (pixels)", key) == 1.2 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "Y Radius (pixels)", key) == 3.3 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Angle", key) == 0 # Recenter GUI should not be exposed, but API call would raise exception. with pytest.raises(NotImplementedError, match='Cannot recenter'): - subset_plugin.vue_recenter_subset() + subset_plugin._obj.vue_recenter_subset() def test_region_from_subset_3d(cubeviz_helper): cubeviz_helper.load_data(np.ones((128, 128, 256)), data_label='Test 3D Flux') - subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj - assert subset_plugin.subset_selected == "Create New" + subset_plugin = cubeviz_helper.plugins['Subsets'] + assert subset_plugin._obj.subset_selected == "Create New" cubeviz_helper.app.add_data_to_viewer('flux-viewer', 'Test 3D Flux') @@ -73,32 +77,32 @@ def test_region_from_subset_3d(cubeviz_helper): assert_allclose(reg.height, 3.5) assert_allclose(reg.angle.value, 0) - assert subset_plugin.subset_selected == "Subset 1" - assert subset_plugin.subset_types == ["RectangularROI"] - assert subset_plugin.is_centerable + assert subset_plugin._obj.subset_selected == "Subset 1" + assert subset_plugin._obj.subset_types == ["RectangularROI"] + assert subset_plugin._obj.is_centerable assert subset_plugin.get_center() == (2.25, 1.55) for key in ("orig", "value"): - assert subset_plugin._get_value_from_subset_definition(0, "Xmin (pixels)", key) == 1 - assert subset_plugin._get_value_from_subset_definition(0, "Xmax (pixels)", key) == 3.5 - assert subset_plugin._get_value_from_subset_definition(0, "Ymin (pixels)", key) == -0.2 - assert subset_plugin._get_value_from_subset_definition(0, "Ymax (pixels)", key) == 3.3 - assert subset_plugin._get_value_from_subset_definition(0, "Angle", key) == 0 - - # Mimic user changing something in Subset Tool GUI. - subset_plugin._set_value_in_subset_definition(0, "Xmin (pixels)", "value", 2) - subset_plugin._set_value_in_subset_definition(0, "Ymin (pixels)", "value", 0) - subset_plugin._set_value_in_subset_definition(0, "Angle", "value", 45) # ccw deg + assert subset_plugin._obj._get_value_from_subset_definition(0, "Xmin (pixels)", key) == 1 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Xmax (pixels)", key) == 3.5 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Ymin (pixels)", key) == -0.2 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Ymax (pixels)", key) == 3.3 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Angle", key) == 0 + + # Mimic user changing something in Subset GUI. + subset_plugin._obj._set_value_in_subset_definition(0, "Xmin (pixels)", "value", 2) + subset_plugin._obj._set_value_in_subset_definition(0, "Ymin (pixels)", "value", 0) + subset_plugin._obj._set_value_in_subset_definition(0, "Angle", "value", 45) # ccw deg # "orig" is unchanged until user clicks Update button. - assert subset_plugin._get_value_from_subset_definition(0, "Xmin (pixels)", "orig") == 1 - assert subset_plugin._get_value_from_subset_definition(0, "Ymin (pixels)", "orig") == -0.2 - assert subset_plugin._get_value_from_subset_definition(0, "Angle", "orig") == 0 - subset_plugin.vue_update_subset() + assert subset_plugin._obj._get_value_from_subset_definition(0, "Xmin (pixels)", "orig") == 1 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Ymin (pixels)", "orig") == -0.2 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Angle", "orig") == 0 + subset_plugin._obj.vue_update_subset() for key in ("orig", "value"): - assert subset_plugin._get_value_from_subset_definition(0, "Xmin (pixels)", key) == 2 - assert subset_plugin._get_value_from_subset_definition(0, "Xmax (pixels)", key) == 3.5 - assert subset_plugin._get_value_from_subset_definition(0, "Ymin (pixels)", key) == 0 - assert subset_plugin._get_value_from_subset_definition(0, "Ymax (pixels)", key) == 3.3 - assert subset_plugin._get_value_from_subset_definition(0, "Angle", key) == 45 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Xmin (pixels)", key) == 2 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Xmax (pixels)", key) == 3.5 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Ymin (pixels)", key) == 0 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Ymax (pixels)", key) == 3.3 + assert subset_plugin._obj._get_value_from_subset_definition(0, "Angle", key) == 45 subsets = cubeviz_helper.app.get_subsets() reg = subsets.get('Subset 1')[0]['region'] @@ -120,33 +124,40 @@ def test_region_from_subset_3d(cubeviz_helper): assert_allclose(reg.angle.to_value(u.deg), 45) # Might be stored in radians # Circular Subset - subset_plugin.combination_mode.selected = 'new' + subset_plugin.combination_mode = 'new' subset_plugin.import_region(CircularROI(xc=3, yc=4, radius=2.4)) - assert subset_plugin.subset_selected == "Subset 2" - assert subset_plugin.subset_types == ["CircularROI"] - assert subset_plugin.is_centerable + assert subset_plugin._obj.subset_selected == "Subset 2" + assert subset_plugin._obj.subset_types == ["CircularROI"] + assert subset_plugin._obj.is_centerable for key in ("orig", "value"): - assert subset_plugin._get_value_from_subset_definition(0, "X Center (pixels)", key) == 3 - assert subset_plugin._get_value_from_subset_definition(0, "Y Center (pixels)", key) == 4 - assert subset_plugin._get_value_from_subset_definition(0, "Radius (pixels)", key) == 2.4 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "X Center (pixels)", key) == 3 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "Y Center (pixels)", key) == 4 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "Radius (pixels)", key) == 2.4 # Circular Annulus Subset - subset_plugin.combination_mode.selected = 'new' + subset_plugin.combination_mode = 'new' subset_plugin.import_region(CircularAnnulusROI(xc=5, yc=6, inner_radius=2, outer_radius=4)) - assert subset_plugin.subset_selected == "Subset 3" - assert subset_plugin.subset_types == ["CircularAnnulusROI"] + assert subset_plugin._obj.subset_selected == "Subset 3" + assert subset_plugin._obj.subset_types == ["CircularAnnulusROI"] for key in ("orig", "value"): - assert subset_plugin._get_value_from_subset_definition(0, "X Center (pixels)", key) == 5 - assert subset_plugin._get_value_from_subset_definition(0, "Y Center (pixels)", key) == 6 - assert subset_plugin._get_value_from_subset_definition(0, "Inner Radius (pixels)", key) == 2 - assert subset_plugin._get_value_from_subset_definition(0, "Outer Radius (pixels)", key) == 4 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "X Center (pixels)", key) == 5 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "Y Center (pixels)", key) == 6 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "Inner Radius (pixels)", key) == 2 + assert subset_plugin._obj._get_value_from_subset_definition( + 0, "Outer Radius (pixels)", key) == 4 def test_region_from_subset_profile(cubeviz_helper, spectral_cube_wcs): data = Spectrum1D(flux=np.ones((128, 128, 256)) * u.nJy, wcs=spectral_cube_wcs) - subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj + subset_plugin = cubeviz_helper.plugins['Subsets']._obj cubeviz_helper.load_data(data, data_label='Test 1D Flux') @@ -169,7 +180,7 @@ def test_region_from_subset_profile(cubeviz_helper, spectral_cube_wcs): assert subset_plugin._get_value_from_subset_definition(0, "Lower bound", key) == 5 assert subset_plugin._get_value_from_subset_definition(0, "Upper bound", key) == 15.5 - # Mimic user changing something in Subset Tool GUI. + # Mimic user changing something in Subset GUI. subset_plugin._set_value_in_subset_definition(0, "Lower bound", "value", 10) # "orig" is unchanged until user clicks Update button. assert subset_plugin._get_value_from_subset_definition(0, "Lower bound", "orig") == 5 @@ -193,7 +204,7 @@ def test_region_from_subset_profile(cubeviz_helper, spectral_cube_wcs): def test_disjoint_spectral_subset(cubeviz_helper, spectral_cube_wcs): - subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj + subset_plugin = cubeviz_helper.plugins['Subsets']._obj data = Spectrum1D(flux=np.ones((128, 128, 256)) * u.nJy, wcs=spectral_cube_wcs) cubeviz_helper.load_data(data, data_label="Test Flux") @@ -241,7 +252,7 @@ def test_composite_region_from_subset_3d(cubeviz_helper): cubeviz_helper.app.add_data_to_viewer('flux-viewer', 'Test 3D Flux') - subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj + subset_plugin = cubeviz_helper.plugins['Subsets'] subset_plugin.import_region(CircularROI(xc=25, yc=25, radius=5)) reg = cubeviz_helper.app.get_subsets("Subset 1") @@ -294,7 +305,7 @@ def test_composite_region_from_subset_3d(cubeviz_helper): def test_composite_region_with_consecutive_and_not_states(cubeviz_helper): cubeviz_helper.load_data(np.ones((128, 128, 10)), data_label='Test 3D Flux') - subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj + subset_plugin = cubeviz_helper.plugins['Subsets']._obj cubeviz_helper.app.add_data_to_viewer('flux-viewer', 'Test 3D Flux') viewer = cubeviz_helper.app.get_viewer('flux-viewer') @@ -360,7 +371,7 @@ def test_composite_region_with_consecutive_and_not_states(cubeviz_helper): def test_composite_region_with_imviz(imviz_helper, image_2d_wcs): arr = NDData(np.ones((10, 10)), wcs=image_2d_wcs) - subset_plugin = imviz_helper.plugins['Subset Tools']._obj + subset_plugin = imviz_helper.plugins['Subsets']._obj data_label = 'image-data' imviz_helper.load_data(arr, data_label=data_label, show_in_viewer=True) subset_plugin.import_region(CircularROI(xc=5, yc=5, radius=2)) @@ -415,16 +426,16 @@ def test_recenter_linked_by_wcs(imviz_helper): # This rectangle is over a real object in reference image but # only the last row in the second image if linked by pixel. - imviz_helper.plugins['Subset Tools']._obj.import_region( + imviz_helper.plugins['Subsets'].import_region( RectanglePixelRegion(center=PixCoord(x=229, y=152), width=17, height=7).to_sky(w)) - subset_plugin = imviz_helper.plugins["Subset Tools"]._obj - subset_plugin.subset_selected = "Subset 1" - subset_plugin.dataset_selected = "gauss100_fits_wcs_block_reduced[PRIMARY,1]" + subset_plugin = imviz_helper.plugins["Subsets"] + subset_plugin._obj.subset_selected = "Subset 1" + subset_plugin._obj.dataset_selected = "gauss100_fits_wcs_block_reduced[PRIMARY,1]" # Do it a few times to converge. for _ in range(5): - subset_plugin.vue_recenter_subset() + subset_plugin._obj.vue_recenter_subset() # If handled correctly, it won't change much. # But if not, it move down by 7 pix or so (229.05, 145.92) and fails the test. @@ -434,15 +445,15 @@ def test_recenter_linked_by_wcs(imviz_helper): # Now create a new subset that has a source in the corner and test # recentering with multiselect. - subset_plugin.combination_mode.selected = 'new' + subset_plugin.combination_mode = 'new' subset_plugin.import_region( CirclePixelRegion(center=PixCoord(x=145, y=175), radius=17).to_sky(w)) - subset_plugin.multiselect = True - subset_plugin.subset_selected = ["Subset 1", "Subset 2"] + subset_plugin._obj.multiselect = True + subset_plugin._obj.subset_selected = ["Subset 1", "Subset 2"] # Do it a few times to converge. for _ in range(5): - subset_plugin.vue_recenter_subset() + subset_plugin._obj.vue_recenter_subset() xy = imviz_helper.default_viewer._obj._get_real_xy( imviz_helper.app.data_collection[0], *subset_plugin.get_center("Subset 2"))[:2] @@ -463,7 +474,7 @@ def test_with_invalid_subset_name(cubeviz_helper): def test_composite_region_from_subset_2d(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d) viewer = specviz_helper.app.get_viewer(specviz_helper._default_spectrum_viewer_reference_name) - subset_plugin = specviz_helper.plugins['Subset Tools']._obj + subset_plugin = specviz_helper.plugins['Subsets']._obj subset1 = SpectralRegion(6000 * spectrum1d.spectral_axis.unit, 7000 * spectrum1d.spectral_axis.unit) @@ -516,7 +527,7 @@ def test_composite_region_from_subset_2d(specviz_helper, spectrum1d): def test_edit_composite_spectral_subset(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d) - subset_plugin = specviz_helper.plugins['Subset Tools']._obj + subset_plugin = specviz_helper.plugins['Subsets']._obj unit = spectrum1d.spectral_axis.unit subset = [SpectralRegion(6200 * unit, 6800 * unit), @@ -565,7 +576,7 @@ def test_edit_composite_spectral_subset(specviz_helper, spectrum1d): def test_composite_spectral_with_xor(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d) - subset_plugin = specviz_helper.plugins['Subset Tools']._obj + subset_plugin = specviz_helper.plugins['Subsets'] unit = spectrum1d.spectral_axis.unit subset = [SpectralRegion(6200 * unit, 6800 * unit), @@ -579,7 +590,7 @@ def test_composite_spectral_with_xor(specviz_helper, spectrum1d): assert reg[0].lower.value == 6100 and reg[0].upper.value == 6200 assert reg[1].lower.value == 6800 and reg[1].upper.value == 7200 - subset_plugin.combination_mode.selected = 'new' + subset_plugin.combination_mode = 'new' subset = [SpectralRegion(7000 * unit, 7200 * unit), SpectralRegion(7100 * unit, 7300 * unit), SpectralRegion(6900 * unit, 7105 * unit)] @@ -590,7 +601,7 @@ def test_composite_spectral_with_xor(specviz_helper, spectrum1d): assert reg[0].lower.value == 6900 and reg[0].upper.value == 7105 assert reg[1].lower.value == 7200 and reg[1].upper.value == 7300 - subset_plugin.combination_mode.selected = 'new' + subset_plugin.combination_mode = 'new' subset = [SpectralRegion(6000 * unit, 6500 * unit), SpectralRegion(6100 * unit, 6200 * unit)] mode = ['new', 'xor'] @@ -600,7 +611,7 @@ def test_composite_spectral_with_xor(specviz_helper, spectrum1d): assert reg[0].lower.value == 6000 and reg[0].upper.value == 6100 assert reg[1].lower.value == 6200 and reg[1].upper.value == 6500 - subset_plugin.combination_mode.selected = 'new' + subset_plugin.combination_mode = 'new' subset = [SpectralRegion(6100 * unit, 6200 * unit), SpectralRegion(6000 * unit, 6500 * unit)] mode = ['new', 'xor'] @@ -610,7 +621,7 @@ def test_composite_spectral_with_xor(specviz_helper, spectrum1d): assert reg[0].lower.value == 6000 and reg[0].upper.value == 6100 assert reg[1].lower.value == 6200 and reg[1].upper.value == 6500 - subset_plugin.combination_mode.selected = 'new' + subset_plugin.combination_mode = 'new' subset = [SpectralRegion(7500 * unit, 7600 * unit), SpectralRegion(6000 * unit, 6010 * unit)] mode = ['new', 'xor'] @@ -624,7 +635,7 @@ def test_composite_spectral_with_xor(specviz_helper, spectrum1d): def test_composite_spectral_with_xor_complicated(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d) - subset_plugin = specviz_helper.plugins['Subset Tools']._obj + subset_plugin = specviz_helper.plugins['Subsets'] unit = spectrum1d.spectral_axis.unit subset = [SpectralRegion(6100 * unit, 6700 * unit), @@ -654,7 +665,7 @@ def test_composite_spectral_with_xor_complicated(specviz_helper, spectrum1d): def test_overlapping_spectral_regions(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d) - subset_plugin = specviz_helper.plugins['Subset Tools']._obj + subset_plugin = specviz_helper.plugins['Subsets']._obj unit = spectrum1d.spectral_axis.unit subset = [SpectralRegion(6400 * unit, 7400 * unit), SpectralRegion(6600 * unit, 7200 * unit), @@ -671,7 +682,7 @@ def test_overlapping_spectral_regions(specviz_helper, spectrum1d): def test_only_overlapping_spectral_regions(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d) - subset_plugin = specviz_helper.plugins['Subset Tools']._obj + subset_plugin = specviz_helper.plugins['Subsets']._obj unit = spectrum1d.spectral_axis.unit subset_plugin.import_region(SpectralRegion(6400 * unit, 6600 * unit)) @@ -693,7 +704,7 @@ def test_only_overlapping_spectral_regions(specviz_helper, spectrum1d): def test_overlapping_in_specviz2d(specviz2d_helper, mos_spectrum2d): specviz2d_helper.load_data(spectrum_2d=mos_spectrum2d) - subset_plugin = specviz2d_helper.plugins['Subset Tools']._obj + subset_plugin = specviz2d_helper.plugins['Subsets']._obj unit = mos_spectrum2d.spectral_axis.unit subset_plugin.import_region(SpectralRegion(6400 * unit, 7400 * unit)) @@ -712,7 +723,7 @@ def test_overlapping_in_specviz2d(specviz2d_helper, mos_spectrum2d): def test_only_overlapping_in_specviz2d(specviz2d_helper, mos_spectrum2d): specviz2d_helper.load_data(spectrum_2d=mos_spectrum2d) - subset_plugin = specviz2d_helper.plugins['Subset Tools']._obj + subset_plugin = specviz2d_helper.plugins['Subsets']._obj unit = mos_spectrum2d.spectral_axis.unit subset_plugin.import_region(SpectralRegion(6400 * unit, 6600 * unit)) @@ -731,7 +742,7 @@ def test_only_overlapping_in_specviz2d(specviz2d_helper, mos_spectrum2d): def test_multi_mask_subset(specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d) - subset_plugin = specviz_helper.plugins['Subset Tools']._obj + subset_plugin = specviz_helper.plugins['Subsets']._obj unit = spectrum1d.spectral_axis.unit subset_plugin.import_region(SpectralRegion(6200 * unit, 6800 * unit)) @@ -786,7 +797,7 @@ def test_delete_subsets(cubeviz_helper, spectral_cube_wcs): spectrum_viewer = cubeviz_helper.app.get_viewer("spectrum-viewer") - subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj + subset_plugin = cubeviz_helper.plugins['Subsets'] unit = u.Unit(cubeviz_helper.plugins['Unit Conversion'].spectral_unit.selected) subset_plugin.import_region(SpectralRegion(6200 * unit, 6800 * unit)) @@ -796,7 +807,7 @@ def test_delete_subsets(cubeviz_helper, spectral_cube_wcs): flux_viewer = cubeviz_helper.app.get_viewer("flux-viewer") - subset_plugin.combination_mode.selected = 'new' + subset_plugin.combination_mode = 'new' subset_plugin.import_region(RectangularROI(1, 3.5, -0.2, 3.3)) dc.remove_subset_group(dc.subset_groups[0]) @@ -808,14 +819,13 @@ class TestRegionsFromSubsets: """Tests for obtaining Sky Regions from subsets.""" def test_get_regions_from_subsets_cubeviz(self, cubeviz_helper, spectral_cube_wcs): - """ Basic tests for retrieving Sky Regions from spatial subsets in Cubeviz. """ data = Spectrum1D(flux=np.ones((128, 128, 256)) * u.nJy, wcs=spectral_cube_wcs) cubeviz_helper.load_data(data) # basic test, a single circular region - subset_plugin = cubeviz_helper.plugins['Subset Tools']._obj + subset_plugin = cubeviz_helper.plugins['Subsets'] subset_plugin.import_region(CircularROI(25, 25, 10)) subsets = cubeviz_helper.app.get_subsets(include_sky_region=True) sky_region = subsets['Subset 1'][0]['sky_region'] @@ -849,7 +859,6 @@ def test_get_regions_from_subsets_cubeviz(self, cubeviz_helper, spectral_cube_wc assert subsets['Subset 1'][1]['sky_region'] is None def test_get_regions_from_subsets_imviz(self, imviz_helper, spectral_cube_wcs): - """ Basic tests for retrieving Sky Regions from subsets in Imviz. """ @@ -861,7 +870,7 @@ def test_get_regions_from_subsets_imviz(self, imviz_helper, spectral_cube_wcs): imviz_helper.load_data(data) # basic test, a single circular region - subset_plugin = imviz_helper.plugins['Subset Tools']._obj + subset_plugin = imviz_helper.plugins['Subsets'] subset_plugin.import_region(CircularROI(25, 25, 10)) subsets = imviz_helper.app.get_subsets(include_sky_region=True) sky_region = subsets['Subset 1'][0]['sky_region'] @@ -886,7 +895,6 @@ def test_get_regions_from_subsets_imviz(self, imviz_helper, spectral_cube_wcs): assert_allclose(sky_region_1.radius.arcsec, 25816.498273) def test_no_wcs_sky_regions(self, imviz_helper): - """ Make sure that if sky regions are requested and there is no WCS, that it returns None with no error. """ @@ -894,7 +902,7 @@ def test_no_wcs_sky_regions(self, imviz_helper): data = NDData(np.ones((40, 40)) * u.nJy) imviz_helper.load_data(data) - subset_plugin = imviz_helper.plugins['Subset Tools']._obj + subset_plugin = imviz_helper.plugins['Subsets'] subset_plugin.import_region(CircularROI(25, 25, 10)) subsets = imviz_helper.app.get_subsets(include_sky_region=True) assert subsets['Subset 1'][0]['sky_region'] is None @@ -902,7 +910,7 @@ def test_no_wcs_sky_regions(self, imviz_helper): def test_subset_renaming(self, specviz_helper, spectrum1d): specviz_helper.load_data(spectrum1d, 'myfile') - subset_plugin = specviz_helper.plugins['Subset Tools']._obj + subset_plugin = specviz_helper.plugins['Subsets'] subset_plugin.import_region(SpectralRegion(6200 * spectrum1d.spectral_axis.unit, 7200 * spectrum1d.spectral_axis.unit)) get_data_no_sub = specviz_helper.get_data('myfile') diff --git a/notebooks/CubevizExample.ipynb b/notebooks/CubevizExample.ipynb index c87bf2393c..2bf6cd4a38 100644 --- a/notebooks/CubevizExample.ipynb +++ b/notebooks/CubevizExample.ipynb @@ -164,7 +164,7 @@ "my_reg = CirclePixelRegion(center=PixCoord(x=35, y=35), radius=10)\n", "\n", "my_regions = [my_aper, my_reg]\n", - "cubeviz.plugins['Subset Tools']._obj.import_region(my_regions, combination_mode='new')" + "cubeviz.plugins['Subsets'].import_region(my_regions, combination_mode='new')" ] }, { diff --git a/notebooks/ImvizDitheredExample.ipynb b/notebooks/ImvizDitheredExample.ipynb index 6b50b6d93e..c89d59d3cd 100644 --- a/notebooks/ImvizDitheredExample.ipynb +++ b/notebooks/ImvizDitheredExample.ipynb @@ -339,7 +339,7 @@ "my_reg_sky = CircleSkyRegion(c, Angle(2, u.arcsec))\n", "\n", "my_regions = [my_aper, my_aper_sky, my_reg, my_reg_sky]\n", - "imviz.plugins['Subset Tools']._obj.import_region(my_reigons, combination_mode='new')" + "imviz.plugins['Subsets'].import_region(my_regions, combination_mode='new')" ] }, { diff --git a/notebooks/ImvizExample.ipynb b/notebooks/ImvizExample.ipynb index f43b999e8f..79df68f31e 100644 --- a/notebooks/ImvizExample.ipynb +++ b/notebooks/ImvizExample.ipynb @@ -108,11 +108,11 @@ "source": [ "filenames = [\n", " 'jw02727-o002_t062_nircam_clear-f090w_i2d.fits',\n", - " #'jw02727-o002_t062_nircam_clear-f150w_i2d.fits',\n", - " #'jw02727-o002_t062_nircam_clear-f200w_i2d.fits',\n", + " # 'jw02727-o002_t062_nircam_clear-f150w_i2d.fits',\n", + " # 'jw02727-o002_t062_nircam_clear-f200w_i2d.fits',\n", " 'jw02727-o002_t062_nircam_clear-f277w_i2d.fits',\n", - " #'jw02727-o002_t062_nircam_clear-f356w_i2d.fits',\n", - " #'jw02727-o002_t062_nircam_clear-f444w_i2d.fits'\n", + " # 'jw02727-o002_t062_nircam_clear-f356w_i2d.fits',\n", + " # 'jw02727-o002_t062_nircam_clear-f444w_i2d.fits'\n", "]\n", "\n", "for fn in filenames:\n", @@ -375,7 +375,7 @@ "my_reg_sky = CircleSkyRegion(c, Angle(2, u.arcsec))\n", "\n", "my_regions = [my_aper, my_aper_sky, my_reg, my_reg_sky]\n", - "imviz.plugins['Subset Tools']._obj.import_region(my_reigons, combination_mode='new')" + "imviz.plugins['Subsets'].import_region(my_regions, combination_mode='new')" ] }, { @@ -688,7 +688,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 3 (ipykernel)", + "display_name": "jdaviz0", "language": "python", "name": "python3" }, @@ -702,7 +702,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.10.12" } }, "nbformat": 4, diff --git a/notebooks/concepts/RampvizExample.ipynb b/notebooks/concepts/RampvizExample.ipynb index 3c849460f0..62297fc195 100644 --- a/notebooks/concepts/RampvizExample.ipynb +++ b/notebooks/concepts/RampvizExample.ipynb @@ -101,7 +101,7 @@ "from regions import CirclePixelRegion, PixCoord\n", "\n", "region = CirclePixelRegion(center=PixCoord(1797.2, 2051.2), radius=2)\n", - "rampviz.plugins['Subset Tools']._obj.import_region(region)" + "rampviz.plugins['Subsets'].import_region(region)" ] }, { diff --git a/notebooks/concepts/cubeviz_aperture_photometry.ipynb b/notebooks/concepts/cubeviz_aperture_photometry.ipynb index 255f852783..8f188b2dd6 100644 --- a/notebooks/concepts/cubeviz_aperture_photometry.ipynb +++ b/notebooks/concepts/cubeviz_aperture_photometry.ipynb @@ -80,6 +80,7 @@ "\n", " return fits.HDUList([fits.PrimaryHDU(), flux_hdu, uncert_hdu, mask_hdu])\n", "\n", + "\n", "test_cube = image_cube_hdu_obj_microns()" ] }, @@ -140,7 +141,7 @@ "metadata": {}, "outputs": [], "source": [ - "cubeviz.plugins['Subset Tools']._obj.import_region(aper)" + "cubeviz.plugins['Subsets'].import_region(aper)" ] }, { @@ -459,7 +460,7 @@ " \"CDELT1\": -0.0001, \"CDELT2\": 0.0001, \"CDELT3\": 8e-11,\n", " \"CRPIX1\": 0, \"CRPIX2\": 0, \"CRPIX3\": 0,\n", " # Need these for aperture photometry test.\n", - " \"TELESCOP\": \"JWST\", \"BUNIT\": fluxunit.to_string(), \"PIXAR_A2\": 0.01}\n", + " \"TELESCOP\": \"JWST\", \"BUNIT\": fluxunit.to_string(), \"PIXAR_A2\": 0.01}\n", " w = WCS(wcs_dict)\n", " if with_uncerts:\n", " uncert = StdDevUncertainty(np.abs(np.random.normal(flux) * u.Jy))\n", @@ -471,6 +472,7 @@ " else:\n", " return Spectrum1D(flux=flux, wcs=w, meta=wcs_dict)\n", "\n", + "\n", "test_cube2 = _create_spectrum1d_cube_with_fluxunit(fluxunit=u.MJy/u.sr)" ] }, @@ -523,7 +525,7 @@ "source": [ "aper2 = RectanglePixelRegion(center=PixCoord(x=1, y=3), width=1, height=1)\n", "bg2 = RectanglePixelRegion(center=PixCoord(x=0, y=2), width=1, height=1)\n", - "cubeviz2.plugins['Subset Tools'].import_region([aper2, bg2])" + "cubeviz2.plugins['Subsets'].import_region([aper2, bg2])" ] }, { diff --git a/notebooks/concepts/imviz_advanced_aper_phot.ipynb b/notebooks/concepts/imviz_advanced_aper_phot.ipynb index 1aa820adc2..789f7869a8 100644 --- a/notebooks/concepts/imviz_advanced_aper_phot.ipynb +++ b/notebooks/concepts/imviz_advanced_aper_phot.ipynb @@ -108,7 +108,7 @@ "metadata": {}, "outputs": [], "source": [ - "imviz.plugins['Subset Tools']._obj.import_region(reigons, combination_mode='new')" + "imviz.plugins['Subsets'].import_region(regions, combination_mode='new')" ] }, { @@ -132,7 +132,8 @@ "metadata": {}, "outputs": [], "source": [ - "file2 = get_pkg_data_filename('data/gauss100_fits_wcs_block_reduced.fits', package='jdaviz.configs.imviz.tests')\n", + "file2 = get_pkg_data_filename('data/gauss100_fits_wcs_block_reduced.fits',\n", + " package='jdaviz.configs.imviz.tests')\n", "imviz.load_data(file2)" ] }, @@ -153,7 +154,8 @@ "metadata": {}, "outputs": [], "source": [ - "file3 = get_pkg_data_filename('data/gauss100_fits_wcs_block_reduced_rotated.fits', package='jdaviz.configs.imviz.tests')\n", + "file3 = get_pkg_data_filename(\n", + " 'data/gauss100_fits_wcs_block_reduced_rotated.fits', package='jdaviz.configs.imviz.tests')\n", "imviz.load_data(file3)" ] }, @@ -256,9 +258,9 @@ "outputs": [], "source": [ "phot_plugin.aperture_selected = \"Subset 1\"\n", - "#phot_plugin.aperture_selected = \"Subset 2\"\n", - "#phot_plugin.aperture_selected = \"Subset 3\"\n", - "#phot_plugin.aperture_selected = \"Subset 4\"" + "# phot_plugin.aperture_selected = \"Subset 2\"\n", + "# phot_plugin.aperture_selected = \"Subset 3\"\n", + "# phot_plugin.aperture_selected = \"Subset 4\"" ] }, { diff --git a/notebooks/concepts/imviz_colorbar_mpl.ipynb b/notebooks/concepts/imviz_colorbar_mpl.ipynb index 864466e558..08c283ba29 100644 --- a/notebooks/concepts/imviz_colorbar_mpl.ipynb +++ b/notebooks/concepts/imviz_colorbar_mpl.ipynb @@ -135,8 +135,8 @@ "outputs": [], "source": [ "# Color (Monochromatic / RGB)\n", - "#plg.image_color_mode = \"Color\"\n", - "#plg.image_color = \"red\"" + "# plg.image_color_mode = \"Color\"\n", + "# plg.image_color = \"red\"" ] }, { @@ -159,8 +159,8 @@ "outputs": [], "source": [ "plg.stretch_function = \"Logarithmic\"\n", - "#plg.stretch_function = \"Square Root\"\n", - "#plg.stretch_function = \"Linear\"" + "# plg.stretch_function = \"Square Root\"\n", + "# plg.stretch_function = \"Linear\"" ] }, { @@ -171,7 +171,7 @@ "outputs": [], "source": [ "plg.stretch_preset = \"95%\"\n", - "#plg.stretch_preset = \"Min/Max\"" + "# plg.stretch_preset = \"Min/Max\"" ] }, { @@ -223,7 +223,7 @@ "outputs": [], "source": [ "plg.stretch_hist_zoom_limits = True\n", - "#plg.stretch_hist_zoom_limits = False" + "# plg.stretch_hist_zoom_limits = False" ] }, { @@ -234,7 +234,7 @@ "outputs": [], "source": [ "plg.image_contrast = 4\n", - "#plg.image_contrast = 1.0" + "# plg.image_contrast = 1.0" ] }, { @@ -245,7 +245,7 @@ "outputs": [], "source": [ "plg.image_bias = 1\n", - "#plg.image_bias = 0.5" + "# plg.image_bias = 0.5" ] }, { @@ -256,7 +256,7 @@ "outputs": [], "source": [ "# Re-displays the histogram\n", - "#plg._obj.stretch_histogram" + "# plg._obj.stretch_histogram" ] }, { @@ -284,7 +284,7 @@ "metadata": {}, "outputs": [], "source": [ - "imviz.plugins['Subset Tools']._obj.import_region(reg)" + "imviz.plugins['Subsets'].import_region(reg)" ] }, { @@ -315,8 +315,8 @@ "outputs": [], "source": [ "plg.layer = \"Array\"\n", - "#plg.layer = \"Subset 1\" # Buggy!\n", - "#plg.layer = \"test image\"" + "# plg.layer = \"Subset 1\" # Buggy!\n", + "# plg.layer = \"test image\"" ] }, { @@ -355,7 +355,7 @@ "outputs": [], "source": [ "plg.viewer = \"v2\"\n", - "#plg.viewer = \"imviz-0\"" + "# plg.viewer = \"imviz-0\"" ] }, { @@ -365,7 +365,7 @@ "metadata": {}, "outputs": [], "source": [ - "#imviz.destroy_viewer(\"v2\") # Buggy!" + "# imviz.destroy_viewer(\"v2\") # Buggy!" ] }, { diff --git a/notebooks/concepts/imviz_edit_subset_programmatic.ipynb b/notebooks/concepts/imviz_edit_subset_programmatic.ipynb index 98e3bc9656..d6fa3198b9 100644 --- a/notebooks/concepts/imviz_edit_subset_programmatic.ipynb +++ b/notebooks/concepts/imviz_edit_subset_programmatic.ipynb @@ -72,7 +72,7 @@ "metadata": {}, "outputs": [], "source": [ - "subset_tool = imviz.plugins['Subset Tools']._obj" + "subset_tool = imviz.plugins['Subsets']" ] }, { @@ -102,7 +102,7 @@ "metadata": {}, "outputs": [], "source": [ - "plg = subset_tool._obj\n", + "plg = subset_tool\n", "\n", "for i in range(10):\n", " plg.subset_selected = 'Subset 1'\n", @@ -111,7 +111,7 @@ "\n", " # We slow it down so you can see, otherwise this will complete too fast.\n", " time.sleep(0.5)\n", - " \n", + "\n", " plg.subset_selected = 'Subset 2'\n", " cur_x, cur_y = plg.get_center()\n", " plg.set_center((cur_x + 2, cur_y - 2), update=True)\n", @@ -144,7 +144,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.10.14" + "version": "3.11.6" } }, "nbformat": 4, diff --git a/notebooks/concepts/imviz_simple_aper_phot.ipynb b/notebooks/concepts/imviz_simple_aper_phot.ipynb index 7570bf2548..e5e4c52289 100644 --- a/notebooks/concepts/imviz_simple_aper_phot.ipynb +++ b/notebooks/concepts/imviz_simple_aper_phot.ipynb @@ -50,8 +50,10 @@ "metadata": {}, "outputs": [], "source": [ - "jwf277w = download_file('https://stsci.box.com/shared/static/iao1zxtigyrhq7k3wtu5nchrxzlhj9kv.fits', cache=True)\n", - "jwf444w = download_file('https://stsci.box.com/shared/static/rey83o5wq6g7qd7xym6r1jq9wlsxaqnt.fits', cache=True)\n", + "jwf277w = download_file(\n", + " 'https://stsci.box.com/shared/static/iao1zxtigyrhq7k3wtu5nchrxzlhj9kv.fits', cache=True)\n", + "jwf444w = download_file(\n", + " 'https://stsci.box.com/shared/static/rey83o5wq6g7qd7xym6r1jq9wlsxaqnt.fits', cache=True)\n", "\n", "my_aper = CirclePixelRegion(center=PixCoord(x=1002, y=1154), radius=20)\n", "my_bg = RectanglePixelRegion(center=PixCoord(x=925, y=1152), width=20, height=20)\n", @@ -155,7 +157,7 @@ "viewer.zoom_level = my_zoom\n", "\n", "# Click on image to finalize selection.\n", - "imviz.plugins['Subset Tools']._obj.import_region([my_aper, my_bg], combination_mode='new')" + "imviz.plugins['Subsets'].import_region([my_aper, my_bg], combination_mode='new')" ] }, {