Skip to content

Information for STScI DADF sprinters

Thomas Robitaille edited this page May 2, 2019 · 4 revisions

The aim of this page is to collect information that would be useful for developers trying out and working on glue-jupyter as part of the STScI DADF sprints.

Background

glue-jupyter is a package that builds on top of the glue package (also referred to as glue-core, in particular on PyPI and in conda). The glue-core package contains all the GUI-independent code for glue, as well as the Qt front-end code. Any code in the core package that is not inside a qt/ sub-folder should be re-usable for e.g. glue-jupyter and other front-ends.

The documentation for glue-jupyter can be found at http://glueviz.org/glue-jupyter/, although some of the documentation for the core package (http://docs.glueviz.org) is also relevant, in particular the tutorial on data objects, and the pages on the linking framework and the event handling. There are links to these in the glue-jupyter docs, under a page called Notes for Developers.

Important: the docs attempt to document how things are, not how things should be! We can still work on improving the API to make things as intuitive as possible.

Pull requests to improve/clarify the documentation and/or add functionality/fix bugs are very welcome, and please also feel free to open issues if anything is unclear!

Known issues

Known issues/bugs can be found in the issue tracker labelled using Bug. If you run into an issue that isn't listed there, please open a new issue!

Accessing subset/selection information

To access subsets/selections, the first thing you need is an object of type Subset. There are various ways to access this information. If you have a data object data that you loaded in, you can just find out about all the subsets in it using data.subsets (returns a list of Subset). Alternatively, you can find out what subsets are shown in any given plot/viewer by first accessing viewer.state.layers, which returns a list. Each item of this list is a LayerState which represents a plotted dataset or subset. To access the actual dataset or subset, you need to then do viewer.state.layers[index of the layer you want].layer. The terminology of the .layer is unfortunate and I'm planning on changing it, it would be better named .data_or_subset.

So let's say you have one dataset with one subset, and you are showing them in a profile viewer. You can access the Subset object with:

subset = data.subsets[0]

or

subset = viewer.state.layers[1].layer

Now given the subset object, there are multiple things you can do. You can get a mask of 1s and 0s showing which elements of the data are in the subset:

subset.to_mask()

You can show the values of the flux of the values in the subset:

subset['FLUX']

Or finally, you can find out about the region used to select the subset by doing:

subset.subset_state

A subset state is a conceptual representation of a selection, so for example it might be a RangeSubsetState which represents a 1-dimensional selection in e.g a profile viewer. This class has attributes .lo and .hi that can be used to get the min/max of the range.

You can find a full list of subset state classes and a description of their attributes here:

http://docs.glueviz.org/en/stable/developer_guide/api.html#module-glue.core.subset

There are a number of different classes because there are different ways of selecting data, for example lasso selections and so on. Once you have the subset state you should be able to use tab completion to figure out what attributes it has that could be useful.

Clone this wiki locally