SubsetSelect#

class jdaviz.core.template_mixin.SubsetSelect(**kwargs: Any)[source]#

Bases: SelectPluginComponent

Plugin select for subsets, with support for single or multi-selection.

Useful API methods/attributes:

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

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

  • 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_max(cube) (quantity, 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.

  • 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"
  :show_if_single_entry="true"
  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

multiselectstr

the name of the traitlet defining whether the dropdown should accept multiple selections

selected_has_subregionsstr

the name of the selected_has_subregions traitlet defined in plugin, optional

datasetstr

the name of the dataset traitlet defined in plugin, to be used for accessing how the subset is applied to the data (masks, etc), optional

viewerslist

the reference names or ids 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.

manual_optionslist

list of options to provide that are not automatically populated by subsets. If default text is provided but not in manual_options it will still be included as the first item in the list.

filterslist

list of strings (for built-in filters) or callables to filter to only valid options.

default_modestr, optional

What mode to use when making the default selection. Valid options: first, default_text, empty.

Attributes Summary

selected_obj

selected_spatial_region

selected_subset_mask

selected_subset_state

Methods Summary

selected_min_max(dataset)

Get the min/max spectral range of dataset given the selected spectral subset

Attributes Documentation

selected_obj#
selected_spatial_region#
selected_subset_mask#
selected_subset_state#

Methods Documentation

selected_min_max(dataset)[source]#

Get the min/max spectral range of dataset given the selected spectral subset