Skip to content

Instantly share code, notes, and snippets.

@keflavich
Created June 26, 2020 22:46
Show Gist options
  • Save keflavich/08546cfd9b7d0b56df03ff34b4a0046a to your computer and use it in GitHub Desktop.
Save keflavich/08546cfd9b7d0b56df03ff34b4a0046a to your computer and use it in GitHub Desktop.
import numpy as np
from glue.core import Data, DataCollection
from glue.app.qt.application import GlueApplication
try:
from glue.viewers.image.qt.data_viewer import ImageViewer
except ImportError:
from glue.viewers.image.qt.viewer_widget import ImageWidget as ImageViewer
from glue.core.coordinates import coordinates_from_wcs
from spectral_cube import SpectralCube
cube1 = SpectralCube.read('/orange/adamginsburg/ALMA_IMF/2017.1.01355.L/imaging_results/G353.41_B3_spw0_12M_n2hp.image', format='casa_image')
cube2 = SpectralCube.read('/orange/adamginsburg/ALMA_IMF/2017.1.01355.L/imaging_results/G353.41_B3_spw0_12M_n2hp.model', format='casa_image')
cube3 = SpectralCube.read('/orange/adamginsburg/ALMA_IMF/2017.1.01355.L/imaging_results/G353.41_B3_spw0_12M_n2hp.residual', format='casa_image')
# create some data
d1 = Data(label='image')
d2 = Data(label='model')
d3 = Data(label='residual')
d1.coords = coordinates_from_wcs(cube1.wcs)
d2.coords = coordinates_from_wcs(cube2.wcs)
d3.coords = coordinates_from_wcs(cube3.wcs)
print(f"Adding data: {cube1}")
d1.add_component(cube1, 'imcube')
print(f"Adding data: {cube2}")
d2.add_component(cube2, 'modcube')
print(f"Adding data: {cube3}")
d3.add_component(cube3, 'rescube')
print("assembling datacollection")
dc = DataCollection([d1,d2,d3])
print("create a GUI session")
ga = GlueApplication(dc)
print("imshow")
imshow = ga.new_data_viewer(ImageViewer, data=d1)
print("add d1")
imshow.add_data(d1)
print("add d2")
imshow.add_data(d2)
print("add d3")
imshow.add_data(d3)
print("show the GUI")
ga.start()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment