In [118]:
from ginga import __version__
__version__


Out[118]:
'2.5.20160408100758'

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]:
<module 'ginga.util.grc' from '/home/eric/Git/Ginga/ginga/util/grc.py'>

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]:
'#UNDEFINED'

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]:
0

In [126]:
# example
shell.zoom_in()


Out[126]:
True

In [127]:
ch.set_color_map('rainbow3')


Out[127]:
'#UNDEFINED'

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]:
0

In [ ]: