##
Extracting Individual Cards from a FitsChan

To examine the contents of the FitsChanFitsChan after writing the SkyFrameSkyFrame above (§16.5), 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 astClearastClear. The following loop would do:

257#257

Here, we have used the astFindFitsastFindFits 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 CardCard 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 (§16.14).