next up previous 231
Next: Special behaviour of FITS headers
Up: More advanced header access
Previous: Using header items from different sources


Accessing header items by index

There are two HDR routines that allow you to access header items using an index number. Header item index numbers run from 1 through to the maximum number of items available. These facilities can be used to list all the header items, or to test for the existence of items with particular names.

The following program snippet shows how to list all the header items associated with an image. It uses the HDR_NUMB subroutine to query the number of items. The complete example is called hdrlist.f - see §[*].

*  See how many header items are available.
      CALL HDR_NUMB( 'IN', ' ', '*', N, ISTAT )            [1]
      DO 1 I = 1, N

*  Get the name of the I'th header item.
         CALL HDR_NAME( 'IN', ' ', I, ITEM, ISTAT )        [2]

*  Get its value.
         CALL HDR_IN( 'IN', ' ', ITEM, 1, VALUE, ISTAT )   [3]

*  And write it out.
         WRITE( *, '( 1X, 3A )' ) ITEM ,' = ', VALUE       [4]
 1    CONTINUE
The following notes refer to the numbered statements:
1.
The subroutine HDR_NUMB counts the number of header items or the number of occurrences of an item. The '*' argument indicates that all the header items are to be counted. If an item name was given the number of occurrences of that item would be returned (zero if none exist).

2.
Item names may be queried by using an index number. This provides a method of getting all the names when the exact contents of a header item source are not known.

3.
HDR_IN returns the value of the header item as a character string.

4.
The name and value of the header item are written out.



next up previous 231
Next: Special behaviour of FITS headers
Up: More advanced header access
Previous: Using header items from different sources

IMG Simple Image Data Access
Starlink User Note 160
P.W. Draper
R.F. Warren-Smith
3 March 2003
E-mail:P.W.Draper@durham.ac.uk

Copyright © 2000-2003 Council for the Central Laboratory of the Research Councils