fitsfile.c

WCSTools subroutines to read and write FITS image and table files

Subroutines

char *fitsrhead (char *filename, int *lhead, int *nbhead)

Read a FITS header and return it as a single character string. If the input file is not standard input, the file is closed after the header is read. Values of keywords in the header string can be extracted by the subroutines in hget.c and changed by the subroutines in hput.c. filename,extension reads the named or numbered (starting with 0 for the primary header) extension header. Inheritance is assumed; all headers returned include the primary header information at the end. Only the first instance of a keyword is recognized by the hget subroutines, so extension header keyword values override primary header values for identically-named keywords.
filename
Name of FITS image file
lhead
Allocated length of FITS header in bytes (returned)
nbhead
Number of bytes before start of data, including all skipped FITS extensions (returned)

char *fitsrsect (char *filename, char *header, int nbhead, int x0, int y0, int nx, int ny, int nlog)

Read a piece of a FITS image, having already read the header. The requested part of the FITS file is returned as a single vector with ny rows of nx pixels each, with pixel size determined by the header BITPIX keyword. If nx is greater than the value of the header keyword NAXIS1, NAXIS1 pixels per row are returned.
filename
Name of FITS image file
header
character string containing FITS header information in the format keyword= value [/comment]
nbhead
Actual length of image header(s) in bytes
x0,y0
FITS image coordinate of first pixel, lower left pixel of image = (1,1)
nx
Number of columns to read (less than NAXIS1)
ny
Number of rows to read (less than NAXIS2)
nlog
Note progress mod this rows

char *fitsrimage (char *filename, int nbhead, char *header)

The image part of the FITS file is returned as a single vector with ny rows of nx pixels each, with pixel size determined by the header BITPIX keyword. Extract short value for variable from FITS header string
Return int 1 if keyword is found, else int 0
hstring
character string containing FITS header information in the format keyword= value [/comment]
keyword
Character string containing the name of the header keyword for which to return the value. if "[n]" is present, the n'th token in the value is returned. The first 8 characters must be unique.
ival
short value (returned if keyword is found)

Last updated 13 October 2005 by Doug Mink Telescope Data Center

[WCSTools] [WCSTools Subroutines] [WCS Subroutines]