next up previous
Next: The Native FitsChan Output Format
Up: Storing AST Objects in FITS Headers (FitsChans)
Previous: Writing Native Objects to a FitsChan

Extracting Individual Cards from a FitsChan  

To examine the contents of the FitsChan after writing the SkyFrame above ([*]), we must write a simple loop to extract each card in turn and print it out. We must also remember to rewind the FitsChan first, e.g. using astClear. The following loop would do:

#include <stdio.h>
char card[ 81 ];

...

astClear( fitschan, "Card" );
while ( astFindFits( fitschan, "%f", card, 1 ) ) (void) printf( "%s\n", card );

Here, we have used the astFindFits function to find a FITS card by keyword. It is given a keyword template of ``%f'', which matches any FITS keyword, so it always finds the current card, which it returns. Its fourth argument is set to 1, to indicate that the Card attribute should be incremented afterwards so that the following card will be found the next time around the loop. astFindFits returns zero when it reaches the end-of-file and this terminates the loop.

If we were storing the FITS headers in an output FITS file instead of printing them out, we might use a loop like this but replace ``printf'' with a suitable data storage operation. This would only be necessary if we had not provided a sink function for the FitsChan ([*]).



next up previous
Next: The Native FitsChan Output Format
Up: Storing AST Objects in FITS Headers (FitsChans)
Previous: Writing Native Objects to a FitsChan

AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 211
R.F. Warren-Smith & D.S. Berry
30th April 2003
E-mail:ussc@star.rl.ac.uk

Copyright (C) 2003 Central Laboratory of the Research Councils