Skip to content

Commit

Permalink
Rename Subsets Plugin (spacetelescope#3304)
Browse files Browse the repository at this point in the history
* Revert Renaming of Subsets Plugin to Subset Tools

* Continue with renaming of subset tools

* Add change log

* Fix codestyle

* Continue with renaming subsets to subset tools

* Continue with renaming including the paths

* Add missing widget autoapi

* remove the widget api that was added to test docs build
  • Loading branch information
haticekaratay authored Nov 26, 2024
1 parent 7f0b3f4 commit 3dc6573
Show file tree
Hide file tree
Showing 68 changed files with 1,398 additions and 1,401 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ 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]
- Subset Tools plugin now exposes the ``subset``, ``combination_mode``, ``get_center``, and ``set_center`` in the user API. [#3293, #3304]

- Metadata plugin: ``metadata_plugin.metadata`` API has been deprecated; use
``metadata_plugin.meta`` instead, which will return a Python dictionary instead of
Expand Down
4 changes: 2 additions & 2 deletions docs/cubeviz/import_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@ can load the regions into Cubeviz as follows:

.. code-block:: python
cubeviz.plugins['Subsets'].import_region("/path/to/data/myregions.reg")
cubeviz.plugins['Subset Tools'].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
form ``(region, reason)``:

.. code-block:: python
bad_regions = cubeviz.plugins['Subsets'].import_region("/path/to/data/myregions.reg", return_bad_regions=True)
bad_regions = cubeviz.plugins['Subset Tools'].import_region("/path/to/data/myregions.reg", return_bad_regions=True)
.. note:: Sky regions are currently unsupported in Cubeviz, unlike Imviz.

Expand Down
6 changes: 3 additions & 3 deletions docs/cubeviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ Visualize data quality arrays for spectral cubes from JWST.

.. _cubeviz-subset-plugin:

Subsets
=======
Subset Tools
============

.. seealso::

:ref:`Subsets <imviz-subset-plugin>`
:ref:`Subset Tools <imviz-subset-plugin>`
Imviz documentation describing the concept of subsets in Jdaviz.


Expand Down
4 changes: 2 additions & 2 deletions docs/imviz/import_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -218,15 +218,15 @@ can load the regions into Imviz as follows:

.. code-block:: python
imviz.plugins['Subsets'].import_region("/path/to/data/myregions.reg")
imviz.plugins['Subset Tools'].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
form ``(region, reason)``:

.. code-block:: python
bad_regions = imviz.plugins['Subsets'].import_region("/path/to/data/myregions.reg", return_bad_regions=True)
bad_regions = imviz.plugins['Subset Tools'].import_region("/path/to/data/myregions.reg", return_bad_regions=True)
You could also define :ref:`regions:shapes` programmatically and load them; e.g.:

Expand Down
4 changes: 2 additions & 2 deletions docs/imviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ in the "Filter by bits" dropdown, or from the API we could:
.. _imviz-subset-plugin:

Subsets
=======
Subset Tools
============

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
Expand Down
6 changes: 3 additions & 3 deletions docs/mosviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ This plugin gives access to per-viewer and per-layer plotting options.

.. _mosviz-subset-plugin:

Subsets
=======
Subset Tools
============

.. seealso::

:ref:`Subsets <imviz-subset-plugin>`
:ref:`Subset Tools <imviz-subset-plugin>`
Imviz documentation describing the concept of subsets in Jdaviz.

.. _imviz_export_markers:
Expand Down
6 changes: 3 additions & 3 deletions docs/rampviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ To show axes on image viewers, toggle on the "Show axes" option at the bottom of

.. _rampviz-subset-plugin:

Subsets
=======
Subset Tools
============

.. seealso::

:ref:`Subsets <imviz-subset-plugin>`
:ref:`Subset Tools <imviz-subset-plugin>`
Imviz documentation describing the concept of subsets in Jdaviz.


Expand Down
3 changes: 0 additions & 3 deletions docs/reference/api_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ Plugins API
.. automodapi:: jdaviz.configs.default.plugins.plot_options.plot_options
:no-inheritance-diagram:

.. automodapi:: jdaviz.configs.default.plugins.subset_plugin.subset_plugin
:no-inheritance-diagram:

.. automodapi:: jdaviz.configs.default.plugins.subset_tools.subset_tools
:no-inheritance-diagram:

Expand Down
6 changes: 3 additions & 3 deletions docs/specviz/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ Plot Options

.. _specviz-subset-plugin:

Subsets
=======
Subset Tools
============

.. seealso::

:ref:`Subsets <imviz-subset-plugin>`
:ref:`Subset Tools <imviz-subset-plugin>`
Imviz documentation describing the concept of subsets in Jdaviz. Subsets
in Specviz are strictly spectral subsets and do not support rotation or
recentering.
Expand Down
6 changes: 3 additions & 3 deletions docs/specviz2d/plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ Plot Options

.. _specviz2d-subset-plugin:

Subsets
=======
Subset Tools
============

.. seealso::

:ref:`Subsets <imviz-subset-plugin>`
:ref:`Subset Tools <imviz-subset-plugin>`
Imviz documentation describing the concept of subsets in Jdaviz.

Markers
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/components/data_menu_subset_edit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<v-list dense style="width: 300px">
<v-list-item>
<v-list-item-content>
<j-tooltip :tooltipcontent="'Open '+subset_selected+' in Subsets plugin'">
<j-tooltip :tooltipcontent="'Open '+subset_selected+' in Subset Tools plugin'">
<span
style="cursor: pointer; width: 100%"
@click="() => {$emit('view-info')}"
Expand Down
2 changes: 1 addition & 1 deletion jdaviz/configs/cubeviz/cubeviz.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ tray:
- g-metadata-viewer
- g-plot-options
- g-data-quality
- g-subset-plugin
- g-subset-tools
- g-markers
- cube-slice
- g-unit-conversion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ def test_moment_frequency_unit_conversion(cubeviz_helper, spectrum1d_cube_larger
mm = cubeviz_helper.plugins['Moment Maps']

unit = u.Unit(uc.spectral_unit.selected)
cubeviz_helper.plugins['Subsets'].import_region(SpectralRegion(4.624e-07 * unit,
4.627e-07 * unit))
cubeviz_helper.plugins['Subset Tools'].import_region(
SpectralRegion(4.624e-07 * unit, 4.627e-07 * unit))

uc.spectral_unit = 'Hz'
mm.spectral_subset = 'Subset 1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def test_gauss_smooth_before_spec_extract(cubeviz_helper, spectrum1d_cube_with_u
# two-pixel region:
CirclePixelRegion(PixCoord(0.5, 0), radius=1.2)
]
cubeviz_helper.plugins['Subsets'].import_region(regions, combination_mode='new')
cubeviz_helper.plugins['Subset Tools'].import_region(regions, combination_mode='new')

extract_plugin = cubeviz_helper.plugins['Spectral Extraction']
extract_plugin.function = "Sum"
Expand Down Expand Up @@ -123,7 +123,7 @@ def test_subset(
]

cubeviz_helper.load_data(spectrum1d_cube_with_uncerts)
cubeviz_helper.plugins['Subsets'].import_region(regions, combination_mode='new')
cubeviz_helper.plugins['Subset Tools'].import_region(regions, combination_mode='new')

plg = cubeviz_helper.plugins['Spectral Extraction']
plg.function = function
Expand Down Expand Up @@ -174,7 +174,7 @@ def test_extracted_file_in_export_plugin(cubeviz_helper, spectrum1d_cube_with_un
def test_aperture_markers(cubeviz_helper, spectrum1d_cube):

cubeviz_helper.load_data(spectrum1d_cube)
cubeviz_helper.plugins['Subsets'].import_region(
cubeviz_helper.plugins['Subset Tools'].import_region(
[CirclePixelRegion(PixCoord(0.5, 0), radius=1.2)])

extract_plg = cubeviz_helper.plugins['Spectral Extraction']
Expand Down Expand Up @@ -227,9 +227,9 @@ def test_cone_aperture_with_different_methods(cubeviz_helper, spectrum1d_cube_la
expected_flux_2400):
cubeviz_helper.load_data(spectrum1d_cube_largest)
center = PixCoord(5, 10)
cubeviz_helper.plugins['Subsets'].import_region(
cubeviz_helper.plugins['Subset Tools'].import_region(
CirclePixelRegion(center, radius=2.5), combination_mode='new')
cubeviz_helper.plugins['Subsets'].import_region(
cubeviz_helper.plugins['Subset Tools'].import_region(
EllipsePixelRegion(center, width=5, height=5), combination_mode='new')

extract_plg = cubeviz_helper.plugins['Spectral Extraction']
Expand Down Expand Up @@ -260,7 +260,7 @@ def test_cylindrical_aperture_with_different_methods(cubeviz_helper, spectrum1d_
subset, aperture_method, expected_flux_wav):
cubeviz_helper.load_data(spectrum1d_cube_largest, data_label="test")
center = PixCoord(5, 10)
cubeviz_helper.plugins['Subsets'].import_region([
cubeviz_helper.plugins['Subset Tools'].import_region([
CirclePixelRegion(center, radius=2.5),
EllipsePixelRegion(center, width=5, height=5)], combination_mode='new')

Expand All @@ -284,7 +284,7 @@ def test_cylindrical_aperture_with_different_methods(cubeviz_helper, spectrum1d_
# NOTE: Not as thorough as circle and ellipse above but good enough.
def test_rectangle_aperture_with_exact(cubeviz_helper, spectrum1d_cube_largest):
cubeviz_helper.load_data(spectrum1d_cube_largest)
cubeviz_helper.plugins['Subsets'].import_region(
cubeviz_helper.plugins['Subset Tools'].import_region(
RectanglePixelRegion(PixCoord(5, 10), width=4, height=4))

extract_plg = cubeviz_helper.plugins['Spectral Extraction']
Expand Down Expand Up @@ -312,7 +312,7 @@ def test_background_subtraction(cubeviz_helper, spectrum1d_cube_largest):
spectrum1d_cube_largest = spectrum1d_cube_largest + 1 * u.Jy

cubeviz_helper.load_data(spectrum1d_cube_largest)
cubeviz_helper.plugins['Subsets'].import_region([
cubeviz_helper.plugins['Subset Tools'].import_region([
CirclePixelRegion(PixCoord(5, 10), radius=2.5),
EllipsePixelRegion(PixCoord(13, 10), width=3, height=5)], combination_mode='new')

Expand Down Expand Up @@ -365,7 +365,7 @@ def test_background_subtraction(cubeviz_helper, spectrum1d_cube_largest):
def test_cone_and_cylinder_errors(cubeviz_helper, spectrum1d_cube_largest):
cubeviz_helper.load_data(spectrum1d_cube_largest)
center = PixCoord(5, 10)
cubeviz_helper.plugins['Subsets'].import_region([
cubeviz_helper.plugins['Subset Tools'].import_region([
CirclePixelRegion(center, radius=2.5),
CircleAnnulusPixelRegion(center, inner_radius=2.5, outer_radius=4)], combination_mode='new')

Expand All @@ -392,7 +392,7 @@ def test_cone_and_cylinder_errors(cubeviz_helper, spectrum1d_cube_largest):
def test_cone_aperture_with_frequency_units(cubeviz_helper, spectral_cube_wcs):
data = Spectrum1D(flux=np.ones((128, 129, 256)) * u.nJy, wcs=spectral_cube_wcs)
cubeviz_helper.load_data(data, data_label="Test Flux")
cubeviz_helper.plugins['Subsets'].import_region(
cubeviz_helper.plugins['Subset Tools'].import_region(
[CirclePixelRegion(PixCoord(14, 15), radius=2.5)])

extract_plg = cubeviz_helper.plugins['Spectral Extraction']
Expand All @@ -413,7 +413,7 @@ def test_cube_extraction_with_nan(cubeviz_helper, image_cube_hdu_obj):
sp = extract_plg.extract() # Default settings (sum)
assert_allclose(sp.flux.value, 9.6E-16) # (10 x 10) - 4

cubeviz_helper.plugins['Subsets'].import_region(
cubeviz_helper.plugins['Subset Tools'].import_region(
RectanglePixelRegion(PixCoord(1.5, 1.5), width=4, height=4))
extract_plg.aperture = 'Subset 1'
sp_subset = extract_plg.extract() # Default settings but on Subset
Expand All @@ -422,7 +422,7 @@ def test_cube_extraction_with_nan(cubeviz_helper, image_cube_hdu_obj):

def test_autoupdate_results(cubeviz_helper, spectrum1d_cube_largest):
cubeviz_helper.load_data(spectrum1d_cube_largest)
cubeviz_helper.plugins['Subsets'].import_region(
cubeviz_helper.plugins['Subset Tools'].import_region(
CircularROI(xc=5, yc=5, radius=2))

extract_plg = cubeviz_helper.plugins['Spectral Extraction']
Expand All @@ -434,8 +434,8 @@ def test_autoupdate_results(cubeviz_helper, spectrum1d_cube_largest):
# orig_med_flux = np.median(cubeviz_helper.get_data('extracted').flux)

# replace Subset 1 with a larger subset, resulting fluxes should increase
cubeviz_helper.plugins['Subsets'].combination_mode = 'replace'
cubeviz_helper.plugins['Subsets'].import_region(CircularROI(xc=5, yc=5, radius=3))
cubeviz_helper.plugins['Subset Tools'].combination_mode = 'replace'
cubeviz_helper.plugins['Subset Tools'].import_region(CircularROI(xc=5, yc=5, radius=3))

# update should take place automatically, but since its async, we'll call manually to ensure
# the update is complete before comparing results
Expand All @@ -449,7 +449,7 @@ def test_autoupdate_results(cubeviz_helper, spectrum1d_cube_largest):

def test_aperture_composite_detection(cubeviz_helper, spectrum1d_cube):
cubeviz_helper.load_data(spectrum1d_cube)
subset_plugin = cubeviz_helper.plugins['Subsets']
subset_plugin = cubeviz_helper.plugins['Subset Tools']
spec_extr_plugin = cubeviz_helper.plugins['Spectral Extraction']._obj

# create a rectangular subset with all spaxels:
Expand All @@ -473,7 +473,7 @@ def test_aperture_composite_detection(cubeviz_helper, spectrum1d_cube):
def test_extraction_composite_subset(cubeviz_helper, spectrum1d_cube):
cubeviz_helper.load_data(spectrum1d_cube)

subset_plugin = cubeviz_helper.plugins['Subsets']
subset_plugin = cubeviz_helper.plugins['Subset Tools']
spec_extr_plugin = cubeviz_helper.plugins['Spectral Extraction']._obj

lower_aperture = RectangularROI(-0.5, 0.5, -0.5, 1.5)
Expand Down Expand Up @@ -533,7 +533,7 @@ def test_default_spectral_extraction(cubeviz_helper, spectrum1d_cube_fluxunit_jy
# for non-science pixels in the sums:
cubeviz_helper.load_data(spectrum1d_cube_fluxunit_jy_per_steradian)

subset_plugin = cubeviz_helper.plugins['Subsets']
subset_plugin = cubeviz_helper.plugins['Subset Tools']

subset_plugin.import_region(CircularROI(1.5, 2, 5))

Expand Down Expand Up @@ -619,7 +619,7 @@ def test_spectral_extraction_scientific_validation(
cubeviz_helper.load_data(uri, cache=True)

# add a subset with an aperture centered on each source
subset_plugin = cubeviz_helper.plugins['Subsets']
subset_plugin = cubeviz_helper.plugins['Subset Tools']
subset_plugin.import_region(CircularROI(*aperture))

# set the slice to the blue end of MIRI CH1
Expand Down
8 changes: 4 additions & 4 deletions jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_aperphot.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def test_cubeviz_aperphot_cube_orig_flux(cubeviz_helper, image_cube_hdu_obj_micr
solid_angle_unit = PIX2

aper = RectanglePixelRegion(center=PixCoord(x=1, y=2), width=3, height=5)
cubeviz_helper.plugins['Subsets'].import_region(aper)
cubeviz_helper.plugins['Subset Tools'].import_region(aper)

# Make sure MASK is not an option even when shown in viewer.
cubeviz_helper.app.add_data_to_viewer("flux-viewer", "test[MASK]", visible=True)
Expand Down Expand Up @@ -112,7 +112,7 @@ def test_cubeviz_aperphot_generated_3d_gaussian_smooth(cubeviz_helper, image_cub
cubeviz_helper.app.add_data_to_viewer("uncert-viewer", "test[FLUX] spatial-smooth stddev-1.0")

aper = RectanglePixelRegion(center=PixCoord(x=1, y=2), width=3, height=5)
cubeviz_helper.plugins['Subsets'].import_region(aper)
cubeviz_helper.plugins['Subset Tools'].import_region(aper)

plg = cubeviz_helper.plugins["Aperture Photometry"]._obj
plg.dataset_selected = "test[FLUX] spatial-smooth stddev-1.0"
Expand Down Expand Up @@ -210,7 +210,7 @@ def test_cubeviz_aperphot_cube_orig_flux_mjysr(cubeviz_helper, spectrum1d_cube_c

aper = RectanglePixelRegion(center=PixCoord(x=3, y=1), width=1, height=1)
bg = RectanglePixelRegion(center=PixCoord(x=2, y=0), width=1, height=1)
cubeviz_helper.plugins['Subsets'].import_region([aper, bg], combination_mode='new')
cubeviz_helper.plugins['Subset Tools'].import_region([aper, bg], combination_mode='new')

plg = cubeviz_helper.plugins["Aperture Photometry"]._obj
plg.dataset_selected = "test[FLUX]"
Expand Down Expand Up @@ -277,7 +277,7 @@ def test_cubeviz_aperphot_unit_conversion(cubeviz_helper, spectrum1d_cube_custom
bg = RectanglePixelRegion(center=PixCoord(x=1, y=2), width=1, height=1)

cubeviz_helper.load_data(mjy_sr_cube, data_label="test")
cubeviz_helper.plugins['Subsets'].import_region([aper, bg], combination_mode='new')
cubeviz_helper.plugins['Subset Tools'].import_region([aper, bg], combination_mode='new')

ap = cubeviz_helper.plugins['Aperture Photometry']._obj

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def test_get_data_spatial_and_spectral(cubeviz_helper, spectrum1d_cube_larger):
cubeviz_helper._apply_interactive_region('bqplot:ellipse', (0, 0), (9, 8))

# Subset 2 (spectral)
subset_plugin = cubeviz_helper.plugins['Subsets']
subset_plugin = cubeviz_helper.plugins['Subset Tools']
unit = spectrum1d_cube_larger.spectral_axis.unit
subset_plugin.import_region(SpectralRegion(4.62440061e-07 * unit, 4.62520112e-07 * unit))

Expand Down
4 changes: 2 additions & 2 deletions jdaviz/configs/cubeviz/plugins/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def test_spectrum1d_with_fake_fixed_units(spectrum1d, cubeviz_helper):

cubeviz_helper.app.add_data_to_viewer('spectrum-viewer', 'test')
unit = u.Unit(cubeviz_helper.plugins['Unit Conversion'].spectral_unit.selected)
cubeviz_helper.plugins['Subsets'].import_region(SpectralRegion(6600 * unit,
7400 * unit))
cubeviz_helper.plugins['Subset Tools'].import_region(SpectralRegion(6600 * unit,
7400 * unit))

subsets = cubeviz_helper.app.get_subsets()
reg = subsets.get('Subset 1')
Expand Down
Loading

0 comments on commit 3dc6573

Please sign in to comment.