Precisely how you extract world coordinate system (WCS) information from a dataset obviously depends on what type of dataset it is. Usually, however, you should be able to obtain a set of FITS header cards which contain the WCS information (and probably much more besides). Suppose that ``cards'' is a pointer to a string containing a complete set of concatenated FITS header cards (such as produced by the CFITSIO function fits_hdr2str). Then proceed as follows:
fitsfile *fptr; AstFitsChan *fitschan; AstFrameSet *wcsinfo; char *header; int nkeys, status; ... /* Obtain all the cards in the header concatenated into a single dynamically allocated null-terminated character string. Note, we do not exclude any cards since we may later modify the WCS information within the header and consequently want to write the entire header out again. */ if( fits_hdr2str( fptr, 0, NULL, 0, &header, &nkeys, &status ) ) printf(" Error getting header\n"); ... /* Header obtained succesfully... */ } else { /* Create a FitsChan and fill it with FITS header cards. */ fitschan = astFitsChan( NULL, NULL, "" ); astPutCards( fitschan, header ); /* Free the memory holding the concatenated header cards. */ header = free( header ); /* Read WCS information from the FitsChan. */ wcsinfo = astRead( fitschan ); ...
The result should be a pointer, ``wcsinfo'', to a FrameSetFrameSet which contains the WCS information. This pointer can now be used to perform many useful tasks, some of which are illustrated in the following recipes.
Some datasets which do not easily yield FITS header cards may require a different approach, possibly involving use of a ChannelChannel or XmlChanXmlChan (15) rather than a FitsChanFitsChan. In the case of the Starlink NDF data format, for example, all the above may be replaced by a single call to the function ndfGtwcssun33ndfGtwcs--see SUN/33sun33. The whole process can probably be encapsulated in a similar way for most data systems, whether they use FITS header cards or not.
For more details about reading WCS information from datasets, see 17.3 and 17.4. For a more general description of FitsChans and their use with FITS header cards, see 16 and 17. For more details about FrameSets, see 13 and 14.