DatasetSelect#

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

Bases: SelectPluginComponent

Plugin select for data entries, 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)

  • selected (string)

Properties (in the object only):

  • selected_obj

  • selected_dc_item

Methods (in the object only):

  • get_object

  • add_filter (more useful for the mixin, when creating a custom component, pass filters)

To use in a plugin:

  • create traitlets with default values

  • 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

Example template (label and hint are optional):

<plugin-dataset-select
  :items="dataset_items"
  :selected.sync="dataset_selected"
  label="Data"
  hint="Select data."
/>
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

filterslist

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

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_options: list

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

Attributes Summary

Methods Summary

get_object(*args, **kwargs)

get_selected_spectrum([use_display_units])

Get the selected spectrum, optionally converted to display units.

Attributes Documentation

default_data_cls#
get_data_cls = None#
selected_dc_item[source]#
selected_obj[source]#
selected_spectrum[source]#
viewers_with_selected_visible[source]#

Methods Documentation

get_object(*args, **kwargs)[source]#
get_selected_spectrum(use_display_units=True)[source]#

Get the selected spectrum, optionally converted to display units.

Parameters:
use_display_unitsbool, optional

Whether to convert the spectrum to the current display units set in the unit conversion plugin. Default is True.

Returns:
spectrumSpectrum1D

The selected spectrum, converted to display units if requested.

Notes

If the spectral axis unit of data is pixels, and the display unit is not pixels (or vice versa), no conversion is done to allow for mixed pixel/world unit viewing (this logic is handled by spectral_axis_conversion, which is called from this method when converting the spectral axis).