This was originally a much longer message with a great
> deal of context, but I'm going to make it a lot shorter
> as a series of questions in the hopes of getting a
> Socratic dialog going?
> 1. Is anyone else bothered by the fact that
> imshow(array) displays array[i,j] at Cartesian
> coordinates [j,shape(array)-i] if origin is 'upper'
> and at [j,i] if origin is 'lower'?
Just to make sure I understand, does it bother you that rows and
columns are reversed, or is there a specific gripe with the upper and
lower handling. My motivation in doing is illustrated in this example
In : x = arange(50.); x.shape=5,10
In : imshow(x, interpolation='nearest', origin='upper')
Out: <matplotlib.image.AxesImage instance at 0xb5f00e6c>
In : x
[[ 0., 1., 2., 3., 4., 5., 6., 7., 8., 9.,]
[ 10., 11., 12., 13., 14., 15., 16., 17., 18., 19.,]
[ 20., 21., 22., 23., 24., 25., 26., 27., 28., 29.,]
[ 30., 31., 32., 33., 34., 35., 36., 37., 38., 39.,]
[ 40., 41., 42., 43., 44., 45., 46., 47., 48., 49.,]]
The voxels on the screen and the array as printed have the same
layout: 5 rows and 10 columns. Basically the inversion happens
because event though it is tradtional to think of x as the first axis
and y as the second, visually if you move along the x axis you are
moving across columns and if you move along the y axis you are moving
In any case, I am not sure exactly what your complaint is (and how you
want it to work) so I am just offering a bit of explanation of why it
is the way it is. I think matlab behaves differently, but I don't
have matlab installed right now. I am not sure that the way we are
doing it is the right way, so feel free to offer suggestions.
> 2. In light of the above, how do you handle overlaying
> contours on an image? I see by experiment that
> contour(array) also treats array[i,j] the same way as
Right; does that answer your question? If you want to flip the
indices, you can always transpose....
> 3. Are the astronomers as confused by all of this in
> relation to the FITS WCS standard as I seem to be? How
> do I do the computation correctly so that x[i,j] is the
> first WCS coordinate of FITS pixel (i,j) (which is at
> array[j-1,i-1] after a PyFITS read)?
I'll leave this one to the astronomers... If desired, we can probably
add an option to handle images in the layout that is typical for
astronomers, but the image and contour code is already a bit hairy
trying to deal with upper and lower origin.