diff --git a/CHANGES.rst b/CHANGES.rst
index 149c26d8ad..eaf88d0608 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -20,7 +20,7 @@ Imviz
- Orientation plugin API now exposes create_north_up_east_left and create_north_up_east_right methods. [#3308]
-- Add Roman WFI and CGI footprints to the Footprints plugin. [#3322]
+- Add Roman WFI and CGI footprints to the Footprints plugin. [#3322, #3345]
- Catalog Search plugin now exposes a maximum sources limit for all catalogs and resolves an edge case
when loading a catalog from a file that only contains one source. [#3337]
diff --git a/jdaviz/components/plugin_file_import_select.vue b/jdaviz/components/plugin_file_import_select.vue
index d037d025c0..941bc476e6 100644
--- a/jdaviz/components/plugin_file_import_select.vue
+++ b/jdaviz/components/plugin_file_import_select.vue
@@ -4,7 +4,9 @@
-
-
- {{ api_hints_enabled ?
- '\'' + item + '\''
- :
- item
- }}
+
+
+
+ {{'\'' + selected + '\''}}
+
+
+ {{ item.icon }}
+
+ {{ selected }}
+
+
+
+
+
+ {{ item.icon }}
+
+ {{ item.label }}
+
1:
- self.subset_invalid_msg = 'Export for composite subsets not yet supported.'
+ if self.subset.selected not in [None, '']:
+ try:
+ subset = self.app.get_subsets(self.subset.selected)
+ except Exception as e:
+ self.subset_invalid_msg = f"Export for subset not supported: {e}"
else:
- self.subset_invalid_msg = ''
+ if self.subset.selected == '':
+ self.subset_invalid_msg = ''
+ elif self.app._is_subset_spectral(subset[0]):
+ self.subset_invalid_msg = ''
+ elif len(subset) > 1:
+ self.subset_invalid_msg = 'Export for composite subsets not yet supported.'
+ else:
+ self.subset_invalid_msg = ''
else: # no subset selected (can be '' instead of None if previous selection made)
self.subset_invalid_msg = ''
diff --git a/jdaviz/configs/default/plugins/subset_tools/subset_tools.py b/jdaviz/configs/default/plugins/subset_tools/subset_tools.py
index 930eb5444f..4e9dc5290a 100644
--- a/jdaviz/configs/default/plugins/subset_tools/subset_tools.py
+++ b/jdaviz/configs/default/plugins/subset_tools/subset_tools.py
@@ -116,8 +116,8 @@ class SubsetTools(PluginTemplateMixin):
icon_radialtocheck = Unicode(read_icon(os.path.join(ICON_DIR, 'radialtocheck.svg'), 'svg+xml')).tag(sync=True) # noqa
icon_checktoradial = Unicode(read_icon(os.path.join(ICON_DIR, 'checktoradial.svg'), 'svg+xml')).tag(sync=True) # noqa
- combination_items = List([]).tag(sync=True)
- combination_selected = Any().tag(sync=True)
+ combination_mode_items = List([]).tag(sync=True)
+ combination_mode_selected = Any().tag(sync=True)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
@@ -160,8 +160,8 @@ def __init__(self, *args, **kwargs):
multiselect=None)
self.combination_mode = SelectPluginComponent(self,
- items='combination_items',
- selected='combination_selected',
+ items='combination_mode_items',
+ selected='combination_mode_selected',
manual_options=COMBO_OPTIONS)
@property
@@ -1125,11 +1125,11 @@ def _load_regions(self, regions, combination_mode=None, max_num_regions=None,
if return_bad_regions:
return bad_regions
- @observe('combination_selected')
- def _combination_selected_updated(self, change):
+ @observe('combination_mode_selected')
+ def _combination_mode_selected_updated(self, change):
self.app.session.edit_subset_mode.mode = SUBSET_MODES_PRETTY[change['new']]
def _update_combination_mode(self):
if self.app.session.edit_subset_mode.mode in SUBSET_TO_PRETTY.keys():
- self.combination_mode.selected = SUBSET_TO_PRETTY[
+ self.combination_mode_selected = SUBSET_TO_PRETTY[
self.app.session.edit_subset_mode.mode]
diff --git a/jdaviz/configs/default/plugins/subset_tools/subset_tools.vue b/jdaviz/configs/default/plugins/subset_tools/subset_tools.vue
index 7055a0b45a..d6c16dd72d 100644
--- a/jdaviz/configs/default/plugins/subset_tools/subset_tools.vue
+++ b/jdaviz/configs/default/plugins/subset_tools/subset_tools.vue
@@ -52,7 +52,7 @@
- plg.combination_mode = '{{ combination_selected }}'
+ plg.combination_mode = '{{ combination_mode_selected }}'
diff --git a/jdaviz/configs/imviz/plugins/footprints/footprints.py b/jdaviz/configs/imviz/plugins/footprints/footprints.py
index 862b58b9c9..4ba333b604 100644
--- a/jdaviz/configs/imviz/plugins/footprints/footprints.py
+++ b/jdaviz/configs/imviz/plugins/footprints/footprints.py
@@ -1,8 +1,10 @@
from traitlets import Bool, List, Unicode, observe
import numpy as np
+import os
import regions
from glue.core.message import DataCollectionAddMessage, DataCollectionDeleteMessage
+from glue_jupyter.common.toolbar_vuetify import read_icon
from jdaviz.core.custom_traitlets import FloatHandleEmpty
from jdaviz.core.events import LinkUpdatedMessage, ChangeRefDataMessage
@@ -10,8 +12,9 @@
from jdaviz.core.region_translators import regions2roi
from jdaviz.core.registries import tray_registry
from jdaviz.core.template_mixin import (PluginTemplateMixin, ViewerSelectMixin,
- EditableSelectPluginComponent,
+ EditableSelectPluginComponent, SelectPluginComponent,
FileImportSelectPluginComponent, HasFileImportSelect)
+from jdaviz.core.tools import ICON_DIR
from jdaviz.core.user_api import PluginUserApi
from jdaviz.configs.imviz.plugins.footprints import preset_regions
@@ -20,13 +23,6 @@
__all__ = ['Footprints']
-_available_instruments = {
- display_name: {'label': display_name, 'siaf_name': siaf_name, 'observatory': observatory}
- for observatory, instruments in preset_regions._instruments.items()
- for display_name, siaf_name in instruments.items()
-}
-
-
@tray_registry('imviz-footprints', label="Footprints")
class Footprints(PluginTemplateMixin, ViewerSelectMixin, HasFileImportSelect):
"""
@@ -54,6 +50,8 @@ class Footprints(PluginTemplateMixin, ViewerSelectMixin, HasFileImportSelect):
color of the currently selected overlay
* ``fill_opacity``
opacity of the filled region of the currently selected overlay
+ * ``preset_obs`` (:class:`~jdaviz.core.template_mixin.SelectPluginComponent`):
+ selected observatories to filter ``preset`` choices.
* ``preset`` (:class:`~jdaviz.core.template_mixin.SelectPluginComponent`):
selected overlay preset
* :meth:`import_region`
@@ -92,6 +90,8 @@ class Footprints(PluginTemplateMixin, ViewerSelectMixin, HasFileImportSelect):
# PRESET OVERLAYS AND OPTIONS
has_pysiaf = Bool(preset_regions._has_pysiaf).tag(sync=True)
+ preset_obs_items = List().tag(sync=True)
+ preset_obs_selected = Unicode().tag(sync=True)
preset_items = List().tag(sync=True)
preset_selected = Unicode().tag(sync=True)
@@ -126,17 +126,31 @@ def __init__(self, *args, **kwargs):
on_remove=self._on_overlay_remove)
if self.has_pysiaf:
- preset_options = list(_available_instruments.keys())
+ obs_icons = {'JWST': read_icon(os.path.join(ICON_DIR, 'jwst_solid.svg'), 'svg+xml'),
+ 'Roman': read_icon(os.path.join(ICON_DIR, 'roman_solid.svg'), 'svg+xml')}
+ preset_options = [{'label': display_name,
+ 'siaf_name': siaf_name,
+ 'observatory': observatory,
+ 'icon': obs_icons.get(observatory, None)}
+ for observatory, instruments in preset_regions._instruments.items()
+ for display_name, siaf_name in instruments.items()]
+ preset_obs_options = ['Any'] + [{'label': obs, 'icon': obs_icons.get(obs)}
+ for obs in preset_regions._instruments.keys()]
else:
preset_options = ['None']
+ preset_obs_options = []
- if not self.app.state.settings.get('server_is_remote', False):
- preset_options.append('From File...')
+ self.preset_obs = SelectPluginComponent(self,
+ items='preset_obs_items',
+ selected='preset_obs_selected',
+ manual_options=preset_obs_options)
self.preset = FileImportSelectPluginComponent(self,
items='preset_items',
selected='preset_selected',
- manual_options=preset_options)
+ manual_options=preset_options,
+ apply_filters_to_manual_options=True,
+ server_is_remote=self.app.state.settings.get('server_is_remote', False)) # noqa
# set the custom file parser for importing catalogs
self.preset._file_parser = self._file_parser
@@ -153,7 +167,7 @@ def user_api(self):
return PluginUserApi(self, expose=('overlay',
'rename_overlay', 'add_overlay', 'remove_overlay',
'viewer', 'visible', 'color', 'fill_opacity',
- 'preset', 'import_region',
+ 'preset_obs', 'preset', 'import_region',
'center_on_viewer', 'ra', 'dec', 'pa',
'v2_offset', 'v3_offset',
'overlay_regions'))
@@ -489,15 +503,34 @@ def overlay_regions(self):
regs = [regs]
overlay['regions'] = regs
regs = overlay.get('regions', [])
- elif self.has_pysiaf and self.preset_selected in _available_instruments.keys():
+ elif self.has_pysiaf:
regs = preset_regions.instrument_footprint(
- _available_instruments[self.preset_selected]['observatory'],
+ self.preset.selected_item['observatory'],
self.preset_selected, **callable_kwargs
)
else: # pragma: no cover
regs = []
return regs
+ @observe('preset_obs_selected')
+ def _update_preset_filters(self, event={}):
+ if not hasattr(self, 'preset'):
+ # during plugin init
+ return
+
+ def only_jwst(item):
+ return item['label'] == 'From File...' or item.get('observatory') == 'JWST'
+
+ def only_roman(item):
+ return item['label'] == 'From File...' or item.get('observatory') == 'Roman'
+
+ if self.preset_obs_selected == 'JWST':
+ self.preset.filters = [only_jwst]
+ elif self.preset_obs_selected == 'Roman':
+ self.preset.filters = [only_roman]
+ else:
+ self.preset.filters = []
+
@observe('preset_selected', 'from_file', 'ra', 'dec', 'pa', 'v2_offset', 'v3_offset')
def _preset_args_changed(self, msg={}, overlay_selected=None):
if self._ignore_traitlet_change:
diff --git a/jdaviz/configs/imviz/plugins/footprints/footprints.vue b/jdaviz/configs/imviz/plugins/footprints/footprints.vue
index 39ba1d4f09..23289de8be 100644
--- a/jdaviz/configs/imviz/plugins/footprints/footprints.vue
+++ b/jdaviz/configs/imviz/plugins/footprints/footprints.vue
@@ -95,6 +95,26 @@
and running `pip install pysiaf` and then launching Jdaviz.
+
+
+
+ {if (preset_obs_selected === preset_obs_item.label) {preset_obs_selected = 'Any'} else {preset_obs_selected = preset_obs_item.label}}"
+ >
+
+ {{ preset_obs_item.label }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jdaviz/data/icons/jwst_solid.svg b/jdaviz/data/icons/jwst_solid.svg
new file mode 100644
index 0000000000..36d5ce20e4
--- /dev/null
+++ b/jdaviz/data/icons/jwst_solid.svg
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jdaviz/data/icons/roman.svg b/jdaviz/data/icons/roman.svg
new file mode 100644
index 0000000000..1ff0e60d69
--- /dev/null
+++ b/jdaviz/data/icons/roman.svg
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jdaviz/data/icons/roman_solid.svg b/jdaviz/data/icons/roman_solid.svg
new file mode 100644
index 0000000000..d0a78297cc
--- /dev/null
+++ b/jdaviz/data/icons/roman_solid.svg
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
\ No newline at end of file