spacetelescope / imexam

imexam is a python tool for simple image examination, and plotting, with similar functionality to IRAF's imexamine
http://imexam.readthedocs.io
BSD 3-Clause "New" or "Revised" License
74 stars 45 forks source link

connecting to non-HTML5 ginga #187

Closed mdhoney closed 5 years ago

mdhoney commented 5 years ago

The documentation gives a good example of displaying images in ginga, but only using the HTML5 canvas in a web browser. Is there a way I can send my image to a standalone ginga instance, similar to how this works for a DS9 window (using imexam.list_active_ds9 etc.)? Thanks.

sosey commented 5 years ago

There is a separate imexam plugin for ginga that gives you access to imexam commands/plots in the ginga reference viewer. I haven't tried it in a while, but here are some instructions for using ginga plugins: https://ginga.readthedocs.io/en/latest/manual/customizing.html?highlight=imexam

I think however that you are asking whether from a python terminal you can start up imexam, and have it display images directly to the ginga gui, I don't think that's possible right now.

@ejeschke I can't think of a way to do this off the top of my head, but maybe through the toolkit API?

ejeschke commented 5 years ago

@sosey, I dusted off the imexam plugin and gave it a whirl with the latest imexam from master. Works fine! Screenshot:

ginga-imexam-plugin

I committed a small fix to the plugin. In case you are interested, @mdhoney, you can find it here. Follow the instructions at the top of the file.

@sosey, if you want to add remote loading into a separate running ginga viewer, I think it would be fairly straightforward using the remote control api. Note that to use this the user has to have started the RC (aka "Remote Control") plugin in their Ginga instance ("Operation"=>"Remote"=>"Remote Control"). Example code for how to load an image:

from astropy.io import fits
f = fits.open('testdata/SPCAM/SUPA01118766.fits', 'readonly')
from ginga.util.grc import RemoteClient
rc = RemoteClient('localhost', 9000)
ch = rc.channel('Image')
ch.load_hdu('SUPA01118766', f, 0)

Parameters to the load_hdu command are a name for the image in the viewer, an HDUList, and an index or key into the HDUList).

If you want to load a ndarray, you can use the load_np method.

sosey commented 5 years ago

nice! I hadn't played with RemoteClient. Cool beans @ejeschke!

mdhoney commented 5 years ago

Thank you @sosey for helping with the plugin... and @ejeschke for that trick with the RC! :smile: I managed to get it working from within an astroconda environment.