Application#

class jdaviz.app.Application(**kwargs: Any)[source]#

Bases: VuetifyTemplate, HubListener

The main application object containing implementing the ipyvue/vuetify template instructions for composing the interface.

Public constructor

Attributes Summary

config

A trait for unicode strings.

data_collection

Reference to the stored DataCollection instance, used to maintain the the data objects that been loaded into the application this session.

docs_link

A trait for unicode strings.

history_verbosity

Verbosity of the logger history, choose from 'debug', 'info' (default), 'warning', or 'error'.

hub

Reference to the stored application handler Hub instance for the application.

loading

A boolean (True, False) trait.

popout_button

A trait which allows any value.

session

Reference to the stored Session instance maintained by Glue for this application.

state

style_registry_instance

A trait which allows any value.

template_file

vdocs

A trait for unicode strings.

verbosity

Verbosity of the application for popup snackbars, choose from 'debug', 'info', 'warning' (default), or 'error'.

Methods Summary

add_data(data[, data_label, notify_done, parent])

Add data to the Glue DataCollection.

add_data_to_viewer(viewer_reference, data_label)

Plots a data set from the data collection in the specific viewer.

get_configuration([path, section])

Returns a copy of the application configuration.

get_sub_regions(subset_state[, ...])

get_subsets([subset_name, spectral_only, ...])

Returns all branches of glue subset tree in the form that subset plugin can recognize.

get_tray_item_from_name(name)

Return the instance of a tray item for a given name.

get_viewer(viewer_reference)

Return a BqplotBaseView viewer instance.

get_viewer_by_id(vid)

Like get_viewer() but use ID directly instead of reference name.

get_viewer_ids([prefix])

Return a list of available viewer IDs.

get_viewer_reference_names()

Return a list of available viewer reference names.

is_there_overlap_spectral_subset(subset_name)

Returns True if the spectral subset with subset_name has overlapping subregions.

load_configuration([path, config])

Parses the provided input into a configuration dictionary and populates the appropriate state values with the results.

load_data(file_obj[, parser_reference])

Provided a path to a data file, open and parse the data into the DataCollection for this session.

merge_overlapping_spectral_regions(...)

Takes a spectral subset with subset_name and returns an OrState object that merges all overlapping subregions.

remove_data_from_viewer(viewer_reference, ...)

Removes a data set from the specified viewer.

return_data_label(loaded_object[, ext, ...])

Returns a unique data label that can be safely used to load data into data collection.

return_unique_name(data_label[, ext])

set_data_visibility(viewer_reference, data_label)

Set the visibility of the layers corresponding to data_label in a given viewer.

simplify_spectral_subset(subset_name, att[, ...])

Convert a composite spectral subset consisting of And, AndNot, Or, Replace, and Xor into one consisting of just Range and Or state objects.

vue_call_viewer_method(event)

vue_change_reference_data(event)

vue_close_snackbar_message(event)

Callback to close a message in the snackbar when the "close" button is clicked.

vue_data_item_remove(event)

vue_data_item_unload(event)

Callback for selection events in the front-end data list when clicking to unload an entry from the viewer.

vue_data_item_visibility(event)

vue_destroy_viewer_item(cid)

Callback for when viewer area tabs are destroyed.

Attributes Documentation

config#

A trait for unicode strings.

data_collection#

Reference to the stored DataCollection instance, used to maintain the the data objects that been loaded into the application this session.

A trait for unicode strings.

history_verbosity#

Verbosity of the logger history, choose from 'debug', 'info' (default), 'warning', or 'error'.

hub#

Reference to the stored application handler Hub instance for the application.

loading#

A boolean (True, False) trait.

popout_button#

A trait which allows any value.

session#

Reference to the stored Session instance maintained by Glue for this application.

state#
style_registry_instance#

A trait which allows any value.

template_file = ('/home/docs/checkouts/readthedocs.org/user_builds/jdaviz/envs/latest/lib/python3.11/site-packages/jdaviz/app.py', 'app.vue')#
vdocs#

A trait for unicode strings.

verbosity#

Verbosity of the application for popup snackbars, choose from 'debug', 'info', 'warning' (default), or 'error'.

Methods Documentation

add_data(data, data_label=None, notify_done=True, parent=None)[source]#

Add data to the Glue DataCollection.

Parameters:
dataany

Data to be stored in the DataCollection. This must either be a Data instance, or an arbitrary data instance for which there exists data translation functions in the glue astronomy repository.

data_labelstr, optional

The name associated with this data. If none is given, label is pulled from the input data (if Data) or a generic name is generated.

notify_donebool

Flag controlling whether a snackbar message is set when the data is added to the app. Set to False to avoid overwhelming the user if lots of data is getting loaded at once.

parentstr, optional

Associate the added Data entry as the child of layer parent.

add_data_to_viewer(viewer_reference, data_label, visible=True, clear_other_data=False)[source]#

Plots a data set from the data collection in the specific viewer.

Parameters:
viewer_referencestr

The reference to the viewer defined with the reference key in the yaml configuration file.

data_labelstr

The Glue data label found in the DataCollection.

visiblebool

Whether the layer should be initialized as visibile.

clear_other_databool

Removes all other currently plotted data and only shows the newly defined data set.

get_configuration(path=None, section=None)[source]#

Returns a copy of the application configuration.

Returns a copy of the configuration specification. If path is not specified, returns the currently loaded configuration.

Parameters:
pathstr, optional

path to the configuration file to be retrieved.

sectionstr, optional

A section of the configuration to retrieve.

Returns:
cfgdict

A configuration specification dictionary.

get_sub_regions(subset_state, simplify_spectral=True, use_display_units=False, get_sky_regions=False)[source]#
get_subsets(subset_name=None, spectral_only=False, spatial_only=False, object_only=False, simplify_spectral=True, use_display_units=False, include_sky_region=False)[source]#

Returns all branches of glue subset tree in the form that subset plugin can recognize.

Parameters:
subset_namestr

The subset name.

spectral_onlybool

Return only spectral subsets.

spatial_onlybool

Return only spatial subsets, except masked subsets (uncommon).

object_onlybool

Return only object relevant information and leave out the region class name and glue_state.

simplify_spectralbool

Return a composite spectral subset collapsed to a simplified SpectralRegion.

use_display_unitsbool, optional

Whether to convert to the display units defined in the Unit Conversion plugin.

include_sky_regionbool

If True, for spatial subsets that have a WCS associated with their parent data, return a sky region in addition to pixel region. If subset is composite, a sky region for each constituent subset will be returned.

Returns:
datadict

Returns a nested dictionary with, for each subset, ‘name’, ‘glue_state’, ‘region’, ‘sky_region’ (set to None if not applicable), and ‘subset_state’. If subset is composite, each constituant subset will be included individually.

get_tray_item_from_name(name)[source]#

Return the instance of a tray item for a given name. This is useful for direct programmatic access to Jdaviz plugins registered under tray items.

Parameters:
namestr

The name used when the plugin was registered to an internal TrayRegistry.

Returns:
tray_itemobj

The instance of the plugin registered to tray items.

Raises:
KeyError

Name not found.

get_viewer(viewer_reference)[source]#

Return a BqplotBaseView viewer instance. This is not an IPyWidget. This is stored here because the state of the viewer and data methods that allow add/removing data to the viewer exist in a wrapper around the core IPyWidget, which is needed to interact with the data rendered within a viewer.

Parameters:
viewer_referencestr

The reference to the viewer defined with the reference key in the YAML configuration file.

Returns:
viewerBqplotBaseView

The viewer class instance.

Notes

If viewer does not have a reference, it is going to try to look up the viewer using the given reference as ID.

get_viewer_by_id(vid)[source]#

Like get_viewer() but use ID directly instead of reference name. This is useful when reference name is None.

get_viewer_ids(prefix=None)[source]#

Return a list of available viewer IDs.

Parameters:
prefixstr or None

If not None, only return viewer IDs with given prefix (case-sensitive). Otherwise, all viewer IDs are returned.

Returns:
vidslist of str

Sorted list of viewer IDs.

get_viewer_reference_names()[source]#

Return a list of available viewer reference names.

is_there_overlap_spectral_subset(subset_name)[source]#

Returns True if the spectral subset with subset_name has overlapping subregions.

load_configuration(path=None, config=None)[source]#

Parses the provided input into a configuration dictionary and populates the appropriate state values with the results. Provided input can either be a configuration YAML file or a pre-made configuration dictionary.

Parameters:
pathstr, optional

Path to the configuration file to be loaded. In the case where this is None, it loads the default configuration. Optionally, this can be provided as name reference. NOTE This optional way to define the configuration will be removed in future versions.

configdict, optional

A dictionary of configuration settings to be loaded. The dictionary contents should be the same as a YAML config file specification.

load_data(file_obj, parser_reference=None, **kwargs)[source]#

Provided a path to a data file, open and parse the data into the DataCollection for this session.

For some parsers, this also attempts to find WCS links that exist between data components.

Parameters:
file_objstr or file-like

File object for the data to be loaded.

parser_referencestr or None

The actual data parser to use. It must already be registered to glue’s data parser registry. This is mainly for internal use.

**kwargsdict

Additional keywords to be passed into the parser defined by parser_reference.

merge_overlapping_spectral_regions(subset_name, att)[source]#

Takes a spectral subset with subset_name and returns an OrState object that merges all overlapping subregions.

Parameters:
subset_namestr

Name of subset to simplify.

attstr

Attribute that the subset uses to apply to data.

remove_data_from_viewer(viewer_reference, data_label)[source]#

Removes a data set from the specified viewer.

Parameters:
viewer_referencestr

The reference to the viewer defined with the reference key in the yaml configuration file.

data_labelstr

The Glue data label found in the DataCollection.

return_data_label(loaded_object, ext=None, alt_name=None, check_unique=True)[source]#

Returns a unique data label that can be safely used to load data into data collection.

Parameters:
loaded_objectstr or object

The path to a data file or FITS HDUList or image object or Spectrum1D or NDData array or numpy.ndarray.

extstr, optional

The extension (or other distinguishing feature) of data used to identify it. For example, “filename[FLUX]” where “FLUX” is the ext value.

alt_namestr, optional

Alternate names that can be used if none of the options provided are valid.

check_uniquebool

Included so that this method can be used with data label retrieval in addition to generation.

Returns:
data_labelstr

A unique data label that at its root is either given by the user at load time or created by Jdaviz using a description of the loaded filetype.

return_unique_name(data_label, ext=None)[source]#
set_data_visibility(viewer_reference, data_label, visible=True, replace=False)[source]#

Set the visibility of the layers corresponding to data_label in a given viewer.

Parameters:
viewer_referencestr

Reference (or ID) of the viewer

data_labelstr

Label of the data to set the visiblity. If not already loaded in the viewer, the data will automatically be loaded before setting the visibility

visiblebool

Whether to set the layer(s) to visible.

replacebool

Whether to disable the visibility of all other layers in the viewer

simplify_spectral_subset(subset_name, att, overwrite=False)[source]#

Convert a composite spectral subset consisting of And, AndNot, Or, Replace, and Xor into one consisting of just Range and Or state objects.

Parameters:
subset_namestr

Name of subset to simplify.

attstr

Attribute that the subset uses to apply to data.

overwritebool

Whether to update the current subset with the simplified state or apply it to a new subset.

vue_call_viewer_method(event)[source]#
vue_change_reference_data(event)[source]#
vue_close_snackbar_message(event)[source]#

Callback to close a message in the snackbar when the “close” button is clicked.

vue_data_item_remove(event)[source]#
vue_data_item_unload(event)[source]#

Callback for selection events in the front-end data list when clicking to unload an entry from the viewer.

vue_data_item_visibility(event)[source]#
vue_destroy_viewer_item(cid)[source]#

Callback for when viewer area tabs are destroyed. Finds the viewer item associated with the provided id and removes it from the stack_items list.

Parameters:
cidstr

The viewer ID associated with the viewer item dictionary.