[AstroPy] Confusion about WCS origin

David Shupe shupe at ipac.caltech.edu
Wed Mar 18 13:37:49 EDT 2015


Hi Rahul,

To elaborate a bit more on what Christoph wrote:

> On Mar 18, 2015, at 8:59 AM, Christoph Deil <Deil.Christoph at gmail.com> wrote:
> 
> To confirm that this gives correct results, you can do this:
> 1) transform the pixel coordinate (0, 0) to world coordinates (with origin=1) using Astropy
> 2) open the image in ds9, zoom in on the lower-left pixel and read off the world coordinates of the pixel center
> 
> The world coordinates you get with method 1) and 2) should match (up to the error with which you manage to put your mouse pointer over the pixel center in ds9).

You can use origin=1 to use the FITS convention for numbering pixels. You should be aware that to find the same pixel in your data array, you have to subtract 1 from the pixel values, and swap the order.

For example:

w.wcs_pix2world(np.array([[613.0, 118.0],]), 1)
w.wcs_pix2world(np.array([[612.0, 117.0],]), 0)

will return the same world coordinates. However, to get the value of this pixel in your data array, you must use

data[117,612]

2-D Numpy arrays follow the convention used in C and Java, that the order is row and then column; and additionally, the indices are 0-based. When you look at an image in ds9, you’ll see 1-based indices in the opposite order. 

Regards,
David

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20150318/10c7e1ba/attachment.html>


More information about the AstroPy mailing list