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 AST_CLEAR. The following loop would do:

      CHARACTER * ( 80 ) CARD

      ...

      CALL AST_CLEAR( FITSCHAN, 'Card', STATUS )

 2    CONTINUE
      IF ( AST_FINDFITS( FITSCHAN, '%f', CARD, .TRUE., STATUS ) ) THEN
         WRITE ( *, '(A)' ) CARD
         GO TO 2
      END IF

Here, we have used the AST_FINDFITS 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 .TRUE., to indicate that the Card attribute should be incremented afterwards so that the following card will be found the next time around the loop. AST_FINDFITS returns .FALSE. 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 the WRITE statement with a call to a suitable data access routine to store the header card. This would only be necessary if we had not provided a sink routine 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 210
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