[AstroPy] Running wcs_pix2world for all image pixels

David Berry d.berry at jach.hawaii.edu
Fri Oct 18 09:44:40 EDT 2013


On 18 October 2013 14:01, Thomas Robitaille <thomas.robitaille at gmail.com>wrote:

> In the Astropy routine, you need to take care to set the origin
> correctly (the last argument in the call to all_pix2world) - if it is
> set to zero, the pixel coordinates have to be zero based (the bottom
> left corner of the FITS image is then (0,0)). Tools such as ds9 assume
> the bottom left corner is (1,1). Since you mention a 1 pixel offset, I
> thought it could be related to this.


Thanks for the tip. That indeed clears up the discrepancy.


> Does AST always assume the pixel
> values are 1-based?
>
>
It all depends on the context. The FitsChan class takes in a set of FITS
headers and spits out a network of Frames with interconnecting Mappings
(a.k.a. "FrameSet"). One Frame represents pixel coordinates, and the others
represent the primary and alternate world coordinate systems.  In this
context, a position of (1,1) in the pixel frame corresponds to the first
pixel in the data array, because that's the convention used by FITS.  For
instance, this means that a pixel position of (crpix1,crpix2) gets mapped
onto a world position of (crval1,crval2), as required by the published
FITS-WCS papers.

On the other hand, there is nothing to stop a user from adding a second
pixel frame into this FrameSet to define some alternative pixel coordinate
system that is shifted with respect to FITS pixel coordinates.

Indeed, this is *exactly* what is done by the NDF data format that has been
in use by Starlink for 20 plus years. It defines two pixel coordinate
systems - "GRID" coordinates in which the first pixel has coords (1,1)
(i.e. the usual FITS definition), and "PIXEL" coordinates which is shifted
by an arbitrary amount with respect to GRID coords. The NDF format uses AST
to record the transformation between these two systems, and all the other
coordinate systems it knows about. For instance, this means that if you
take a cut-out of an image, then the user can there-after choose to refer
to pixels within the cut-out using either their offset from first pixel in
the cut-out (i.e. GRID coords), or their offset from the first pixel in the
in the original image (PIXEL coords).

So the bottom line is that AST allows you to put the origin of pixels
coords where ever you want.

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20131018/19f12f24/attachment.html>


More information about the AstroPy mailing list