AST_FINDFITS

Find a FITS card in a FitsChan by keyword

Description:

This function searches for a card in a FitsChan by keyword. The search commences at the current card (identified by the Card attribute) and ends when a card is found whose FITS keyword matches the template supplied, or when the last card in the FitsChan has been searched.

If the search is successful (i.e. a card is found which matches the template), the contents of the card are returned and the Card attribute is adjusted to identify the card found or, if required, the one following it. If the search is not successful, the function returns .FALSE. and the Card attribute is set to the " end-of-file" .

Invocation

RESULT = AST_FINDFITS( THIS, NAME, CARD, INC, STATUS )

Arguments

THIS = INTEGER (Given)
Pointer to the FitsChan.
NAME = CHARACTER ( ) (Given)
A character string containing a template for the keyword to be found. In the simplest case, this should simply be the keyword name (the search is case insensitive and trailing spaces are ignored). However, this template may also contain " field specifiers" which are capable of matching a range of characters (see the " Keyword Templates" section for details). In this case, the first card with a keyword which matches the template will be found. To find the next FITS card regardless of its keyword, you should use the template " %f" .
CARD = CHARACTER ( 80 ) (Returned)
A character variable with at least 80 characters in which the FITS card which is found will be returned. If the search is not successful, a card will not be returned.
INC = LOGICAL (Given)
If this value is .FALSE. (and the search is successful), the FitsChan s Card attribute will be set to the index of the card that was found. If it is .TRUE., however, the Card attribute will be incremented to identify the card which follows the one found.
STATUS = INTEGER (Given and Returned)
The global status.

Returned Value

AST_FINDFITS = LOGICAL
.TRUE. if the search was successful, otherwise .FALSE..

Examples:

RESULT = AST_FINDFITS( FITSCHAN, %f , CARD, .TRUE., STATUS )
Returns the current card in a FitsChan and advances the Card attribute to identify the card that follows (the " %f" template matches any keyword).
RESULT = AST_FINDFITS( FITSCHAN, BITPIX , CARD, .TRUE., STATUS )
Searches a FitsChan for a FITS card with the " BITPIX" keyword and returns that card. The Card attribute is then incremented to identify the card that follows it.
RESULT = AST_FINDFITS( FITSCHAN, COMMENT , CARD, .FALSE., STATUS )
Sets the Card attribute of a FitsChan to identify the next COMMENT card (if any) and returns that card.
RESULT = AST_FINDFITS( FITSCHAN, CRVAL%1d , CARD, .TRUE., STATUS )
Searches a FitsChan for the next card with a keyword of the form " CRVALi" (for example, any of the keywords " CRVAL1" , " CRVAL2" or " CRVAL3" would be matched). The card found (if any) is returned, and the Card attribute is then incremented to identify the following card (ready to search for another keyword with the same form, perhaps).

Notes:

Keyword Templates

The templates used to match FITS keywords are normally composed of literal characters, which must match the keyword exactly (apart from case). However, a template may also contain " field specifiers" which can match a range of possible characters. This allows you to search for keywords that contain (for example) numbers, where the digits comprising the number are not known in advance.

A field specifier starts with a " %" character. This is followed by an optional single digit (0 to 9) specifying a field width. Finally, there is a single character which specifies the

type of character to be matched, as follows:

If the field width is omitted, the field specifier matches one or more characters. If the field width is zero, it matches zero or more characters. Otherwise, it matches exactly the number of

characters specified. In addition to this:

For example: