In [118]:
from ginga import __version__
__version__
Out[118]:
In [7]:
# import ginga remote control module
from ginga.util import grc
Start up the reference viewer and invoke the "RC" (Remote Control) plugin from the "Plugins" menu
In [119]:
# for debugging
reload(grc)
Out[119]:
In [120]:
# host and port parameters can be set in the graphical ui of the plugin.
# These are the defaults
viewer = grc.RemoteClient('localhost', 9000)
In [121]:
# This gives you a handle to the reference viewer shell.
# It is similar to what you can do from the command line with:
# $ grc ginga ...
#
shell = viewer.shell()
In [123]:
# If you get a lot of errors when you run this, it might be because you didn't start
# the RC plugin in the viewer
shell.add_channel('Messier')
Out[123]:
In [124]:
# This gives you a handle to a reference viewer channel.
# It is similar to what you can do from the command line with:
# $ grc channel ...
#
ch = viewer.channel('Messier')
In [125]:
# example of loading an HDU from an astropy HDUlist
# parameters are (image_name, channel_name, hdulist, hdulist_key)
#
from astropy.io import fits
hdulist = fits.open("/home/eric/testdata/SPCAM/SUPA01118766.fits", "readonly")
ch.load_hdu("M27", hdulist, 0)
Out[125]:
In [126]:
# example
shell.zoom_in()
Out[126]:
In [127]:
ch.set_color_map('rainbow3')
Out[127]:
In [128]:
# example of loading numpy arrays directly
# parameters are (image_name, channel_name, array, image_type, header_dict)
#
import numpy as np
data_np = np.random.randint(0, 2000, (512, 512))
ch.load_np("image", data_np, 'fits', {})
Out[128]:
In [ ]: