Conversion between world and image coordinates is handled by the WCS and related classes. Class WCS is a reference counted class that manages a pointer to a subclass of the abstract base class WCSrep . SAOWCS is a subclass of WCSRep , which is based on Doug Mink's wcssubs package (also used by saoimage ) 1 . This class is initialized with a FITS image header and can then be used to convert coordinates and distances on the image.
WCS wcs(new SAOWCS(fitsHeaderString)); double x, y, ra, dec; ... // convert x,y to world coords if (wcs.pix2wcs(x, y, ra, dec) != 0) { return ERROR; } // convert ra,dec to image coords if (wcs.wcs2pix(ra, dec, x, y) != 0) { return ERROR; }
The WCS class uses reference counting in order to make it easy to share an instance of the class among other classes. In the above example, the memory allocated for the SAOWCS object is managed by the WCS class and deleted when there are no more references to it.
WCS wcs2 = wcs; // both are reference counted copies of the same object !
The WCS class also has support for setting up world coordinates without a FITS header, with the wcs method:
wcs.set(ra, dec, secpix, xrefpix, yrefpix, nxpix, nypix, rotate, equinox, epoch, proj);
Epoch of coordinates, used for FK4/FK5 conversion no effect if 0. |
|
For changing the center of the projection, you can use the shift method:
wcs.shift(ra, dec, equinox);
The leaves all of the other parameters the same, but changes the center reference position. More information can be found in the man page WCS(3) .
Please send questions or comments to abrighto@eso.org.
Copyright © 1998 ESO - European Southern Observatory