C Standard Library Extensions  6.2.0
Functions
Simple FITS access routines

Functions

char * qfits_query_hdr (const char *filename, const char *keyword)
 Retrieve the value of a key in a FITS header.
char * qfits_query_ext (const char *filename, const char *keyword, int xtnum)
 Retrieve the value of a keyin a FITS extension header.
int qfits_query_n_ext (const char *filename)
 Counts the number of extensions in a FITS file.
int qfits_query_nplanes (const char *filename, int extnum)
 Counts the number of planes in a FITS extension.
char * qfits_pretty_string (const char *s)
 Clean out a FITS string value.
int qfits_is_boolean (const char *s)
 Identify if a FITS value is boolean.
int qfits_is_int (const char *s)
 Identify if a FITS value is an int.
int qfits_is_float (const char *s)
 Identify if a FITS value is float.
int qfits_is_complex (const char *s)
 Identify if a FITS value is complex.
int qfits_is_string (const char *s)
 Identify if a FITS value is string.
int qfits_get_type (const char *s)
 Identify the type of a FITS value given as a string.
char * qfits_query_card (const char *filename, const char *keyword)
 Query a card in a FITS (main) header by a given key.
int qfits_replace_card (const char *filename, const char *keyword, const char *substitute)
 Replace a card in a FITS (main) header by a given card.
const char * qfits_version (void)
 Return the current QFITS version.

Detailed Description

This module offers a number of very basic low-level FITS access routines.


Function Documentation

int qfits_get_type ( const char *  s)

Identify the type of a FITS value given as a string.

Parameters:
sFITS value as a string
Returns:
integer naming the FITS type

Returns the following value:

  • QFITS_UNKNOWN (0) for an unknown type.
  • QFITS_BOOLEAN (1) for a boolean type.
  • QFITS_INT (2) for an integer type.
  • QFITS_FLOAT (3) for a floating-point type.
  • QFITS_COMPLEX (4) for a complex number.
  • QFITS_STRING (5) for a FITS string.

References qfits_is_boolean(), qfits_is_complex(), qfits_is_float(), and qfits_is_int().

int qfits_is_boolean ( const char *  s)

Identify if a FITS value is boolean.

Parameters:
sFITS value as a string
Returns:
int 0 or 1

Identifies if a FITS value is boolean.

Referenced by qfits_card_build(), and qfits_get_type().

int qfits_is_complex ( const char *  s)

Identify if a FITS value is complex.

Parameters:
sFITS value as a string
Returns:
int 0 or 1

Identifies if a FITS value is complex.

Referenced by qfits_card_build(), and qfits_get_type().

int qfits_is_float ( const char *  s)

Identify if a FITS value is float.

Parameters:
sFITS value as a string
Returns:
int 0 or 1

Identifies if a FITS value is float.

Referenced by qfits_card_build(), and qfits_get_type().

int qfits_is_int ( const char *  s)

Identify if a FITS value is an int.

Parameters:
sFITS value as a string
Returns:
int 0 or 1

Identifies if a FITS value is an integer.

Referenced by qfits_card_build(), and qfits_get_type().

int qfits_is_string ( const char *  s)

Identify if a FITS value is string.

Parameters:
sFITS value as a string
Returns:
int 0 or 1

Identifies if a FITS value is a string.

char* qfits_pretty_string ( const char *  s)

Clean out a FITS string value.

Parameters:
spointer to allocated FITS value string.
Returns:
pointer to statically allocated character string

From a string FITS value like 'marvin o''hara', remove head and tail quotes, replace double '' with simple ', trim blanks on each side, and return the result in a statically allocated area.

Examples:

  • ['o''hara'] becomes [o'hara]
  • [' H '] becomes [H]
  • ['1.0 '] becomes [1.0]

Referenced by qfits_card_build(), qfits_is_table(), qfits_table_open(), and qfitsloader_init().

char* qfits_query_card ( const char *  filename,
const char *  keyword 
)

Query a card in a FITS (main) header by a given key.

Parameters:
filenameName of the FITS file to check.
keywordWhere to read a card in the header.
Returns:
Allocated string containing the card or NULL

References qfits_expand_keyword(), and qfits_get_hdrinfo().

char* qfits_query_ext ( const char *  filename,
const char *  keyword,
int  xtnum 
)

Retrieve the value of a keyin a FITS extension header.

Parameters:
filenamename of the FITS file to browse.
keywordname of the FITS key to look for.
xtnumxtension number
Returns:
pointer to statically allocated character string

Same as qfits_query_hdr but for extensions. xtnum starts from 1 to the number of extensions. If xtnum is zero, this function is strictly identical to qfits_query_hdr().

References qfits_expand_keyword(), qfits_get_hdrinfo(), and qfits_getvalue().

Referenced by qfits_is_table(), qfits_query_hdr(), qfits_query_nplanes(), and qfits_table_open().

char* qfits_query_hdr ( const char *  filename,
const char *  keyword 
)

Retrieve the value of a key in a FITS header.

Parameters:
filenameName of the FITS file to browse
keywordName of the keyword to find
Returns:
pointer to statically allocated character string

Provide the name of a FITS file and a keyword to look for. The input file is memory-mapped and the first keyword matching the requested one is located. The value corresponding to this keyword is copied to a statically allocated area, so do not modify it or free it.

The input keyword is first converted to upper case and expanded to the HIERARCH scheme if given in the shortFITS notation.

This function is pretty fast due to the mmapping. Due to buffering on most Unixes, it is possible to call many times this function in a row on the same file and do not suffer too much from performance problems. If the file contents are already in the cache, the file will not be re-opened every time.

It is possible, though, to modify this function to perform several searches in a row. See the source code.

Returns NULL in case the requested keyword cannot be found.

References qfits_query_ext().

int qfits_query_n_ext ( const char *  filename)

Counts the number of extensions in a FITS file.

Parameters:
filenameName of the FITS file to browse.
Returns:
int Counts how many extensions are in the file. Returns 0 if no extension is found, and -1 if an error occurred.

References qfits_query().

Referenced by qfits_header_readext(), qfits_query_nplanes(), and qfitsloader_init().

int qfits_query_nplanes ( const char *  filename,
int  extnum 
)

Counts the number of planes in a FITS extension.

Parameters:
filenameName of the FITS file to browse.
extnumExtensin number
Returns:
int Counts how many planes are in the extension. Returns 0 if no plane is found, and -1 if an error occurred.

References qfits_query_ext(), and qfits_query_n_ext().

int qfits_replace_card ( const char *  filename,
const char *  keyword,
const char *  substitute 
)

Replace a card in a FITS (main) header by a given card.

Parameters:
filenameName of the FITS file to modify.
keywordWhere to substitute a card in the header.
substituteWhat to replace the line with.
Returns:
int 0 if Ok, -1 otherwise

Replaces a whole card (80 chars) in a FITS header by a given FITS line (80 chars). The replacing line is assumed correctly formatted and containing at least 80 characters. The file is modified: it must be accessible in read/write mode.

The input keyword is first converted to upper case and expanded to the HIERARCH scheme if given in the shortFITS notation.

Returns 0 if everything worked Ok, -1 otherwise.

References qfits_expand_keyword(), and qfits_get_hdrinfo().

Referenced by qfits_save_table_hdrdump().

const char* qfits_version ( void  )

Return the current QFITS version.

Returns:
the QFITS version