SubsetSelect

class jdaviz.core.template_mixin.SubsetSelect(plugin, items, selected, selected_has_subregions=None, viewer_refs=None, default_text=None, allowed_type=None)[source] [edit on github]

Bases: jdaviz.core.template_mixin.BasePluginComponent

Traitlets (in the object, custom traitlets in the plugin):

  • items (list of dicts with keys: label, color)

  • selected (string)

  • selected_has_subregions (bool, OPTIONAL)

Properties (in the object only):

  • labels (list of labels corresponding to items)

  • selected_item (dictionary in items coresponding to selected, cached)

  • selected_obj (subset object corresponding to selected, cached)

Methods (in the object only):

  • selected_min(cube) (float, only applicable for spectral subsets)

  • selected_max(cube) (float, only applicable for spectral subsets)

To use in a plugin:

  • create (empty) traitlets in the plugin

  • register with all the automatic logic in the plugin’s init by passing the string names of the respective traitlets. Pass allowed_type='spectral' or allowed_type='spatial' to only support spectral or spatial subsets, respectively.

  • use component in plugin template (see below)

  • refer to properties above based on the interally stored reference to the instantiated object of this component

  • observe the traitlets created and defined in the plugin, as necessary

Example template (label and hint are optional):

<plugin-subset-select
  :items="spectral_subset_items"
  :selected.sync="spectral_subset_selected"
  label="Subset"
  hint="Select subset."
/>
Parameters
plugin

the parent plugin object

itemsstr

the name of the items traitlet defined in plugin

selectedstr

the name of the selected traitlet defined in plugin

selected_has_subregions: str

the name of the selected_has_subregions traitlet defined in plugin, optional

viewer_refslist

the reference names of the viewer to extract the subregion. If not provided or None, will loop through all references.

default_textstr or None

the text to show for no selection. If not provided or None, no entry will be provided in the dropdown for no selection.

allowed_typestr or None

whether to filter to ‘spatial’ or ‘spectral’ types of subsets. If not provided or None, will include both entries.

Attributes Summary

labels

selected_item

selected_obj

viewer_refs

viewers

Methods Summary

selected_max(spectrum1d)

selected_min(spectrum1d)

Attributes Documentation

labels
selected_item
selected_obj
viewer_refs
viewers

Methods Documentation

selected_max(spectrum1d)[source] [edit on github]
selected_min(spectrum1d)[source] [edit on github]