Skip to content
gostevehoward edited this page Apr 12, 2017 · 4 revisions

Pixel coordinates and world coordinates

Every FITS image involves two coordinate systems:

  1. Pixel coordinates or image coordinates index pixels in the image as an array with integral indices. Pixel coordinates are given as a tuple (X, Y). Pixel coordinates typically start at (1, 1), which is the center of the pixel typically plotted at the lower-left corner of the image, with the X coordinate increasing to the right and the Y coordinate increasing upwards. (So the lower-left-most corner of the image is at pixel coordinate (0.5, 0.5).

  2. World coordinates denote a common coordinate system across images, generically denoted as a tuple (u, v).

In a particular image, the two coordinate systems are connected by what is called the world coordinate system or WCS. There are many different, complicated forms of WCS, but we never go more complicated than an affine transformation applied to pixel coordinates: (u, v in world coordinates) = A * (x,y in pixel coordinates) + b, where A is a 2x2 (invertible) matrix and b is a 2x1 vector. The values of A and b are encoded in the FITS header in a standard way. Though this is not sufficient to connect pixel coordinates to equatorial coordinates in general, our images always cover such a small piece of the sky that this affine approximation suffices.

We always use world coordinates to denote a unique point in the celestial sphere, in terms of right ascension (sometime denoted by alpha) and declination (sometimes denoted by delta). This is known as the Equatorial coordinate system. So we interpret world coordinates (u, v) as (right ascension, declination), both in degrees, because that's what SDSS uses.

However, a confusing point does arise: SDSS maps right ascension to the Y pixel axis, and declination to the X pixel axis. In other words, the matrix A above looks like

[ 0   dudy;
 dvdx  0  ]

where dudy gives the increment in right ascension for each one-pixel step in the +y direction, and dvdx gives the increment in declination for each one-pixel step in the +x direction.

This means the "first" axis in terms of (u, v) world coordinates is not the same as the "first" axis in terms of (x, y) pixel coordinates. So be careful. (Also see below for notes on the interpretation of "first" and "second" axis, "horizontal" vs. "vertical", etc.)

In order to be consistent with SDSS imagery, we use this convention in all synthetic imagery (see Accuracy benchmarks).

"Width" and "height"

One other confusing point: suppose we have a 2000 x 1000 image. These two numbers have an unambiguous meaning: the first axis (by indexing order) has length 2000, the second axis (by indexing order) has length 1000. (When I say "by indexing order", I mean when I write image[x, y], the variable x indexes the "first" axis and the variable y indexes the "second" axis.)

We commonly refer to these sizes as "width" and "height", but these terms are not unambiguous, and unfortunately they are used differently in different parts of this project.

The "computer graphics" convention is that the first axis (by indexing order) is denoted "x", interpreted as the "horizontal" axis, and thus sized by "width". The second axis (by indexing order) is denoted "y", interpreted as the "vertical" axis, and sized by "height".

The "matrix" convention is that the first axis (by indexing order) is interpreted as indexing "rows" and sized by "height", while the second axis (by indexing order) is interpreted as indexing "columns" and sized by "width".

In FITS viewing software such as fv or ds9, the computer graphics convention generally holds. So our 2000 x 1000 image would by 2000 pixels wide and 1000 pixels high, and would be plotted that way, with the (0, 0) pixel at the lower-right corner of the image.

In the Celeste code, the matrix convention holds. So our 2000 x 1000 image is called 2000 pixels high and 1000 pixels wide (e.g., in the H and W fields of Model.Image).

Remember, indexing order is unambiguous (but be mindful of the switch between pixel and world coordinates, above!), but terms like "horizontal" vs. "vertical" and "width" vs. "height" can be ambiguous.