Application

class jdaviz.app.Application(**kwargs: Any)[source] [edit on github]

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.

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

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])

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_data_from_viewer(viewer_reference[, ...])

Returns each data component currently rendered within a viewer instance.

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_subsets_from_viewer(viewer_reference[, ...])

Returns the subsets of a specified viewer converted to astropy regions objects.

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.

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.

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.

set_style_template_file(path)

Sets the path to a vue file containing a <style> tag that will be applied on top of the style defined in app.vue.

vue_call_viewer_method(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.

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
template_file = ('/home/docs/checkouts/readthedocs.org/user_builds/jdaviz/envs/v3.5.0/lib/python3.9/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)[source] [edit on github]

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_done: bool

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.

add_data_to_viewer(viewer_reference, data_label, visible=True, clear_other_data=False)[source] [edit on github]

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] [edit on github]

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_data_from_viewer(viewer_reference, data_label=None, cls='default', include_subsets=True)[source] [edit on github]

Returns each data component currently rendered within a viewer instance. Viewers themselves store a default data type to which the Glue data components are transformed upon retrieval. This can be optionally overridden with the cls keyword.

Parameters:
viewer_referencestr

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

data_labelstr, optional

Optionally provide a label to retrieve a specific data set from the viewer instance.

clsclass

The class definition the Glue data components get transformed to when retrieved. This requires that a working set of translation functions exist in the glue_astronomy package. See https://github.com/glue-viz/glue-astronomy for more info. If this is the special string 'default', the default_class attribute of the viewer referenced by viewer_reference is used.

include_subsetsbool

Whether to include subset layer data that exists in the viewer but has not been included in the core data collection object.

Returns:
datadict

A dict of the transformed Glue data objects, indexed to corresponding viewer data labels.

Notes

This is only used in cases where the viewers have been pre-defined in the configuration file. Otherwise, viewers are not stored via reference.

get_sub_regions(subset_state, simplify_spectral=True)[source] [edit on github]
get_subsets(subset_name=None, spectral_only=False, spatial_only=False, object_only=False, simplify_spectral=True)[source] [edit on github]

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.

Returns:
datadict

A dict with keys representing the subset name and values as astropy regions objects.

get_subsets_from_viewer(viewer_reference, data_label=None, subset_type=None)[source] [edit on github]

Returns the subsets of a specified viewer converted to astropy regions objects.

It should be noted that the subset translation machinery lives in the glue-astronomy repository. Currently, the machinery only works on 2D data for cases like range selection. For e.g. a profile viewer that is ostensibly just a view into a 3D data set, it is necessary to first reduce the dimensions of the data, then retrieve the subset information as a regions object. This means that the returned y extents in the region are not strictly representative of the subset range in y.

Parameters:
viewer_referencestr

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

data_labelstr, optional

Optionally provide a label to retrieve a specific data set from the viewer instance.

subset_typestr, optional

Optionally specify either “spectral” or “spatial” to return only subsets created in a profile (spectrum) viewer or image viewer, respectively.

Returns:
datadict

A dict of the transformed Glue subset objects, with keys representing the subset name and values as astropy regions objects.

get_tray_item_from_name(name)[source] [edit on github]

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] [edit on github]

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] [edit on github]

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] [edit on github]

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] [edit on github]

Return a list of available viewer reference names.

load_configuration(path=None, config=None)[source] [edit on github]

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] [edit on github]

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.

remove_data_from_viewer(viewer_reference, data_label)[source] [edit on github]

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] [edit on github]

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] [edit on github]
set_data_visibility(viewer_reference, data_label, visible=True, replace=False)[source] [edit on github]

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 visilility of all other layers in the viewer

set_style_template_file(path)[source] [edit on github]

Sets the path to a vue file containing a <style> tag that will be applied on top of the style defined in app.vue. This is useful for config-specific or downstream styling at the app-level.

Parameters:
pathstr or tuple

Path to a .vue file containing style rules to inject into the app.

vue_call_viewer_method(event)[source] [edit on github]
vue_close_snackbar_message(event)[source] [edit on github]

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

vue_data_item_remove(event)[source] [edit on github]
vue_data_item_unload(event)[source] [edit on github]

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] [edit on github]
vue_destroy_viewer_item(cid)[source] [edit on github]

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.