fitsfile.c
WCSTools
subroutines
to read and write FITS image and table files
Subroutines
- fitsropen (inpath)
opens a FITS file for reading, returning a FILE pointer
- fitsrhead (filename, lhead, nbhead)
reads FITS header and returns it as a string
- fitsrsect (filename, nbhead, header, fd, x0, y0, nx, ny)
reads a section of a FITS image, having already read the header
- fitsrimage (filename, nbhead, header)
reads a FITS image, having already ready the header
- fitsrfull (filename, nbhead, header)
reads a FITS image of any dimension
- fitswhead (filename, header)
writes a FITS header and keeps the file open for further writing
- fitsrtopen (inpath, nk, kw, nrows, nchar, nbhead)
opens a FITS table file for reading, returning header information
- fitsrthead (header, nk, kw, nrows, nchar, nbhead)
extracts FITS table information from a FITS header
- fitsrtline (fd, nbhead, lbuff, tbuff, irow, nbline, line)
reads the next line of FITS table file
- ftgetr8 (entry, kw)
extracts a column from a FITS table line as double
- ftgetr4 (entry, kw)
extracts a column from a FITS table line as float
- ftgeti4 (entry, kw)
extracts a column from a FITS table line as int
- ftgeti2 (entry, kw)
extracts a column from a FITS table line as short
- ftgetc (entry, kw, string, maxchar)
extracts a column from a FITS table line as a character string
- fitswimage (filename, header, image)
writes a FITS header and image
- fitswext (filename, header, image)
writes a FITS header and image as an extension to an existing FITS file
- fitswhdu (fd, filename, header, image)
writes a FITS header and image as an extension to file descriptor
- fitscimage (filename, header, filename0)
writes a FITS header and copies a FITS image
- fitswexhead (filename, header)
writes a FITS header only to a FITS extension without writing data
- isfits (filename)
returns a 1 if a file is a FITS file, else 0
- fitsheadsize (header)
returns the size of a FITS header in bytes
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
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)