Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate conf-specific helper methods in specviz, specviz2d, cubeviz #3388

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ Mosviz
Specviz
^^^^^^^

- Specviz-specific helper-level methods are deprecated and will be removed in the future in favor of plugin APIs as configs are centralized. [#3388]

Specviz2d
^^^^^^^^^

- Specviz2d-specific helper-level methods are deprecated and will be removed in the future in favor of plugin APIs as configs are centralized. [#3388]

Bug Fixes
---------

Expand All @@ -64,9 +68,13 @@ Cubeviz

- Fixed copious warnings from spaxel tool when data has INF. [#3368]

- Cubeviz-specific helper-level methods are deprecated and will be removed in the future in favor of plugin APIs as configs are centralized. [#3388]

Imviz
^^^^^

- ``get_aperture_photometry_results`` helper-level method is deprecated and will be removed in the future in favor of plugin APIs as configs are centralized. [#3388]

Mosviz
^^^^^^

Expand Down
6 changes: 3 additions & 3 deletions docs/cubeviz/export_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,20 @@ For a list of model labels:

.. code-block:: python

models = cubeviz.get_models()
models = cubeviz.plugins['Model Fitting'].get_models()
models

Once you know the model labels, to get a specific model:

.. code-block:: python

mymodel = cubeviz.get_models(model_label="ModelLabel", x=10)
mymodel = cubeviz.plugins['Model Fitting'].get_models(model_label="ModelLabel", x=10)

To extract all of the model parameters:

.. code-block:: python

myparams = cubeviz.get_model_parameters(model_label="ModelLabel", x=x, y=y)
myparams = cubeviz.plugins['Model Fitting'].get_model_parameters(model_label="ModelLabel", x=x, y=y)
myparams

where the ``model_label`` parameter identifies which model should be returned and
Expand Down
6 changes: 3 additions & 3 deletions docs/specviz/export_data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -84,20 +84,20 @@ For a list of model labels:

.. code-block:: python

models = specviz.get_models()
models = specviz.plugins['Model Fitting'].get_models()
models

Once you know the model labels, to get a specific model:

.. code-block:: python

mymodel = specviz.get_models(model_label="ModelLabel")
mymodel = specviz.plugins['Model Fitting'].get_models(model_label="ModelLabel")

To extract all of the model parameters:

.. code-block:: python

myparams = specviz.get_model_parameters(model_label="ModelLabel")
myparams = specviz.plugins['Model Fitting'].get_model_parameters(model_label="ModelLabel")
myparams

where the ``model_label`` parameter identifies which model should be returned.
Expand Down
3 changes: 0 additions & 3 deletions jdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,6 @@ def __init__(self, configuration=None, *args, **kwargs):
self.hub.subscribe(self, SnackbarMessage,
handler=self._on_snackbar_message)

# Add a fitted_models dictionary that the helpers (or user) can access
self.fitted_models = {}

# Internal cache so we don't have to keep calling get_object for the same Data.
# Key should be (data_label, statistic) and value the translated object.
self._get_object_cache = {}
Expand Down
8 changes: 5 additions & 3 deletions jdaviz/configs/cubeviz/helper.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from astropy.utils.decorators import deprecated

from jdaviz.configs.default.plugins.line_lists.line_list_mixin import LineListMixin
from jdaviz.configs.specviz import Specviz
from jdaviz.core.events import AddDataMessage, SnackbarMessage
Expand Down Expand Up @@ -97,6 +99,7 @@ def load_data(self, data, data_label=None, override_cube_limit=False, **kwargs):
color='warning', sender=self, timeout=10000)
self.app.hub.broadcast(msg)

@deprecated(since="4.2", alternative="plugins['Slice'].value")
def select_wavelength(self, wavelength):
"""
Select the slice closest to the provided wavelength.
Expand Down Expand Up @@ -149,8 +152,7 @@ def get_data(self, data_label=None, spatial_subset=None, spectral_subset=None,
spectral_subset=spectral_subset,
cls=cls, use_display_units=use_display_units)

# Need this method for Imviz Aperture Photometry plugin.

@deprecated(since="4.2", alternative="plugins['Aperture Photometry'].export_table()")
def get_aperture_photometry_results(self):
"""Return aperture photometry results, if any.
Results are calculated using :ref:`cubeviz-aper-phot` plugin.
Expand All @@ -161,4 +163,4 @@ def get_aperture_photometry_results(self):
Photometry results if available or `None` otherwise.

"""
return self.plugins['Aperture Photometry']._obj.export_table()
return self.plugins['Aperture Photometry'].export_table()
8 changes: 4 additions & 4 deletions jdaviz/configs/cubeviz/plugins/slice/tests/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def test_slice(cubeviz_helper, spectrum1d_cube):
assert cubeviz_helper.app.get_viewer("flux-viewer").slice == 1
assert cubeviz_helper.app.get_viewer("flux-viewer").state.slices[-1] == 1
assert cubeviz_helper.app.get_viewer("uncert-viewer").state.slices[-1] == 1
cubeviz_helper.select_wavelength(slice_values[0])
sl.value = slice_values[0]
assert cubeviz_helper.app.get_viewer("flux-viewer").slice == 0
assert sl.value == slice_values[0]

cubeviz_helper.select_wavelength(slice_values[1])
sl.value = slice_values[1]
assert sl.value == slice_values[1]

# test setting a static 2d image to the "watched" flux viewer to make sure it disconnects
Expand All @@ -57,14 +57,14 @@ def test_slice(cubeviz_helper, spectrum1d_cube):
sv.state.layers[0].as_steps = True
new_len = len(sv.native_marks[0].x)
assert new_len == 2*orig_len
cubeviz_helper.select_wavelength(4.62360028e-07)
sl.value = 4.62360028e-07
assert sl.value == slice_values[1]

# Add test for unit conversion
uc_plugin = cubeviz_helper.plugins['Unit Conversion']._obj
uc_plugin.spectral_unit.selected = 'Angstrom'
assert sl.value_unit == 'Angstrom'
cubeviz_helper.select_wavelength(4623.60028)
sl.value = 4623.60028
assert sl.value == 4623.600276968349

# Retrieve updated slice_values
Expand Down
12 changes: 6 additions & 6 deletions jdaviz/configs/cubeviz/plugins/tests/test_cubeviz_aperphot.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def test_cubeviz_aperphot_cube_orig_flux(cubeviz_helper, image_cube_hdu_obj_micr
plg.dataset_selected = "test[FLUX]"
plg.aperture_selected = "Subset 1"
plg.vue_do_aper_phot()
row = cubeviz_helper.get_aperture_photometry_results()[0]
row = plg.export_table()[0]

# Basically, we should recover the input rectangle here.
assert_allclose(row["xcenter"], 1 * u.pix)
Expand All @@ -51,7 +51,7 @@ def test_cubeviz_aperphot_cube_orig_flux(cubeviz_helper, image_cube_hdu_obj_micr
cube_slice_plg = cubeviz_helper.plugins["Slice"]._obj
cube_slice_plg.vue_goto_first()
plg.vue_do_aper_phot()
row = cubeviz_helper.get_aperture_photometry_results()[1]
row = plg.export_table()[1]

# Same rectangle but different slice value.
assert_allclose(row["xcenter"], 1 * u.pix)
Expand Down Expand Up @@ -79,7 +79,7 @@ def test_cubeviz_aperphot_cube_orig_flux(cubeviz_helper, image_cube_hdu_obj_micr
plg.dataset_selected = "test[FLUX] collapsed"
plg.aperture_selected = "Subset 1"
plg.vue_do_aper_phot()
row = cubeviz_helper.get_aperture_photometry_results()[2]
row = plg.export_table()[2]

# Basically, we should recover the input rectangle here.
assert_allclose(row["xcenter"], 1 * u.pix)
Expand Down Expand Up @@ -121,7 +121,7 @@ def test_cubeviz_aperphot_generated_3d_gaussian_smooth(cubeviz_helper, image_cub
plg.dataset_selected = "test[FLUX] spatial-smooth stddev-1.0"
plg.aperture_selected = "Subset 1"
plg.vue_do_aper_phot()
row = cubeviz_helper.get_aperture_photometry_results()[0]
row = cubeviz_helper.plugins['Aperture Photometry'].export_table()[0]

# Basically, we should recover the input rectangle here.
assert_allclose(row["xcenter"], 1 * u.pix)
Expand Down Expand Up @@ -182,7 +182,7 @@ def test_cubeviz_aperphot_cube_sr_and_pix2(cubeviz_helper,
cube_unit = u.MJy / solid_angle_unit # cube unit in app is now per pix2

plg.vue_do_aper_phot()
row = cubeviz_helper.get_aperture_photometry_results()[0]
row = cubeviz_helper.plugins['Aperture Photometry'].export_table()[0]

# Basically, we should recover the input rectangle here, minus background.
assert_allclose(row["xcenter"], 3 * u.pix)
Expand Down Expand Up @@ -227,7 +227,7 @@ def test_cubeviz_aperphot_cube_orig_flux_mjysr(cubeviz_helper,
assert_allclose(plg.flux_scaling, 0.003631)

plg.vue_do_aper_phot()
row = cubeviz_helper.get_aperture_photometry_results()[0]
row = cubeviz_helper.plugins['Aperture Photometry'].export_table()[0]

# Basically, we should recover the input rectangle here, minus background.
assert_allclose(row["xcenter"], 3 * u.pix)
Expand Down
2 changes: 0 additions & 2 deletions jdaviz/configs/default/plugins/data_quality/data_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ class DataQuality(PluginTemplateMixin, ViewerSelectMixin):
"""
template_file = __file__, "data_quality.vue"

irrelevant_msg = Unicode("").tag(sync=True)
kecnry marked this conversation as resolved.
Show resolved Hide resolved

# `layer` is the science data layer
science_layer_multiselect = Bool(False).tag(sync=True)
science_layer_items = List().tag(sync=True)
Expand Down
Loading
Loading