int xypix( double xpos, double ypos, double xref, double yref, double xrefpix, double yrefpix, double xinc, double yinc, double rot, char *type, double *xpix, double *ypix);
worldpos() converts from pixel location to RA,Dec xypix() converts from RA,Dec to pixel locationwhere "(RA,Dec)" are more generically (long,lat). These functions are based on the WCS implementation of Classic AIPS, an implementation which has been in production use for more than ten years. See the two memos by Eric Greisen
for descriptions of the 8 projective geometries and the algorithms. Footnotes in these two documents describe the differences between these algorithms and the 1993-94 WCS draft proposal (see URL below). In particular, these algorithms support ordinary field rotation, but not skew geometries (CD or PC matrix cases). Also, the MER and AIT algorithms work correctly only for CRVALi=(0,0). Users should note that GLS projections with yref!=0 will behave differently in this code than in the draft WCS proposal. The NCP projection is now obsolete (it is a special case of SIN). WCS syntax and semantics for various advanced features is discussed in the draft WCS proposal by Greisen and Calabretta at:
worldpos determines accurate position for pixel coordinates. It returns
0 if successful, 1 if the angle too large for projection.
Input: xpix x pixel number (RA or long without rotation) ypiy y pixel number (dec or lat without rotation) xref x reference coordinate value (deg) yref y reference coordinate value (deg) xrefpix x reference pixel yrefpix y reference pixel xinc x coordinate increment (deg) yinc y coordinate increment (deg) rot rotation (deg) (from N through E) *type projection type code e.g. "-SIN" Valid are: -SIN, -TAN, -ARC, -NCP, -GLS, -MER, -AIT projections, anything else is linear. Output: *xpos x (RA) coordinate (deg) *ypos y (dec) coordinate (deg)
xypix determines accurate pixel coordinates for an RA and Dec. It returns 0 if successful otherwise: 1 if the angle too large for projection; 2 if bad values Input: xpos x (RA) coordinate (deg) ypos y (dec) coordinate (deg) xref x reference coordinate value (deg) yref y reference coordinate value (deg) xrefpix x reference pixel yrefpix y reference pixel xinc x coordinate increment (deg) yinc y coordinate increment (deg) rot rotation (deg) (from N through E) *type projection type code e.g. "-SIN"; Valid are: -SIN, -TAN, -ARC, -NCP, -GLS, -MER, -AIT projections, anything else is linear. Output: *xpix x pixel number (RA or long without rotation) *ypiy y pixel number (dec or lat without rotation)
1) added GNU license and header comments 2) added testpos.c program to perform extensive circularity tests 3) changed float-->double to get more than 7 significant figures 4) testpos.c circularity test failed on MER and AIT. B.Cotton found that "..there were a couple of lines of code [in] the wrong place as a result of merging several Fortran routines." 5) testpos.c found 0h wraparound in xypix() and worldpos(). 6) E.Greisen recommended removal of various redundant if-statements, and addition of a 360d difference test to MER case of
0 no error -1 -2 Coordinate SystemsThe following table is a list of the currently described coordinate systems. The ones implements in these routines are marked with a *. FITS Number Name Comments code code ---- ------ ----------------------- ----------------------------------- DEF 0 Default = Cartesian AZP 1 Zenithal perspective projp1 required TAN* 2 Gnomic AZP w/ projp1 = 0 SIN* 3 Orthographic AZP w/ projp1 = Infinity (>10^14) STG* 4 Stereographic AZP w/ projp1 = 1 ARC* 5 Zenithal Equidistant ZPN 6 Zenithal polynomial prop1-projp9 required, useless ZEA 7 Zenithal equal area AIR 8 Airy projp1 required CYP 9 Cylindrical perspective projp1 and projp2 required CAR 10 Cartesian MER* 11 Mercator CEA 12 Cylindrical equal area projp1 required COP 13 Conical perspective projp1 and projp2 required COD 14 Conical equidistant projp1 and projp2 required COE 15 Conical equal area projp1 and projp2 required COO 16 Conical orthomorphic projp1 and projp2 required BON 17 Bonne’s equal area projp1 required PCO 18 Polyconic GLS* 19 Sinusoidal PAR 20 Parabolic AIT* 21 Hammer-Aitoff MOL 22 Mollweide CSC 23 Cobe Quadrilateralized convergence of inverse is poor Spherical Cube QSC 24 Quadrilateralized Spherical Cube TSC 25 Tangential Spherical Cube Copyright Copyright (C) 1994 Associated Universities, Inc. Washington DC, USA.
AIPS should be addressed as follows:
Internet email: firstname.lastname@example.org Postal address: AIPS Group National Radio Astronomy Observatory 520 Edgemont Road Charlottesville, VA 22903-2475 USA
Mark Calabretta’s WCSLIB: http://www.atnf.csiro.au/people/mcalabre/WCS/index.html
13-oct-94 doc written PJT
Table of Contents