Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Join on multiple keys #974

Merged
merged 10 commits into from
Aug 8, 2016
Merged

Conversation

astrofrog
Copy link
Member

@astrofrog astrofrog commented May 2, 2016

I realized today that we can solve the linking case described in #958 by extending join_on_key to support linking on pairs, triplets, and n-tuples of components rather than just single components. The current PR implements a very rough (and very slow) version of that, just to test the concept. If things work well, then I can work on a way to make the calculation of the masks much faster. Here's an example in use:

We have a position-position-velocity cube and a second moment map (on the same celestial pixel scale).

from glue.core import DataCollection, Data
from glue.app.qt.application import GlueApplication
from glue.core.data_factories import load_data
from glue.viewers.image.qt.viewer_widget import ImageWidget
from glue.viewers.histogram.qt.viewer_widget import HistogramWidget

data_linewidth = load_data('linewidth.fits')
data_cube = load_data('ppv_cube.fits')

dc = DataCollection([data_linewidth, data_cube])

# We can now link on pairs of components
data_linewidth.join_on_key(data_cube, ('Pixel x', 'Pixel y'), ('Pixel Axis 2', 'Pixel Axis 1'))

ga = GlueApplication(dc)

image = ga.new_data_viewer(ImageWidget)
image.add_data(data_cube)

histogram = ga.new_data_viewer(HistogramWidget)
histogram.add_data(data_linewidth)

ga.exec_()

Selecting in the linewidth histogram will now highlight pixels in the image.

Note that the fact the pixel axes have different naming conventions needs to be fixed (see #959)

@ChrisBeaumont - do you have any thoughts on this approach so far?

@astrofrog
Copy link
Member Author

Note that at the moment this is not going to be backward-compatible in terms of loading save files.

@astrofrog astrofrog changed the title WIP: join on multiple keys Join on multiple keys Aug 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant