[Numpy-discussion] announcing a ds9 module and a question about indices

Perry Greenfield perry at stsci.edu
Fri Apr 16 15:03:01 EDT 2004

Russel Owen wrote:
> I wrote a simple module that allows one to display numarray arrays in 
> ds9. It is available as part of the RO package (RO.DS9) 
> <http://www.astro.washington.edu/owen/ROPython.html>, though it is 
> presently self-contained. (I may well end up expanding it.) It sends 
> a copy of the data, rather than trying to share a buffer.
> It uses the command-line XPA interface instead of trying to use the 
> underlying C XPA API. I'm curious if anybody has gotten a python 
> interface to the C XPA API working. It looks a bit messy, but popen2 
> messy in other ways (detecting errors without hanging on read, for 
> example).
We distributed a simple module with PyRAF that could display
to DS9 (and other similar display tools, SAOIMAGE, ximtool, etc)
using the underlying protocol used by them (offhand, I don't know
if that was the XPA interface; I seem to recall it was the
iis protocol). Unfortunately, outside of the PyRAF announcement,
we never really publicized it. We'll take a look at yours.
It could be that it has more features.
> I have what is probably a dumb question, but...if I load an array 
> using PyFits and display it using ds9, I find that the array indices 
> appear to be transposed relative to what I expect, i.e. numarray 
> seems to use array[yind, xind].
> Is this normal? Any hints on handling notation in code (I suspect 
> there's not much I can do except document it)?
Yep, it's normal. The indexing convention in Python is the same
as C with regard to multidimensional arrays and opposite to that
of Fortran and IDL. There are many reasons for that and it would
cause more trouble than it is worth trying to emulate Fortran on 
this. I know it is probably the single biggest annoyance to those
not used to it. 

Perry Greenfield 

More information about the NumPy-Discussion mailing list