This program will show the FITS header from any file, or any extension within the file (by using a feature of fh_file() which searches for an extension when the filename contains ``fitsfile[extname]''.)
This small program is also a good way to test the behavior of fh_file().
When there is a separate FITS file for each amplifier, finding the names of all the ``extensions'' is as easy as listing all the files in a subdirectory. Here's a utility which generates an equivalent list of names for MEF Files. The output from this program can be used as the arguments to a pipeline program which uses fh_file() to open one file or extension each time it is run. Multiple FITS files may be given on the command line. In this example, the `fhextname' program is used just as `ls' would have been with basic FITS files:
#!/bin/sh for i in `fhextname *.fits` do reduce "$i" done
Note that this also works for split files, since `fhextname' just prints the name of the fits file itself, if there are no extensions.
Here is the source code for `fhextname':
Here is the source code for `fhset', a command line utility which sets arbitrary keywords and comment fields in a FITS file (and extension units, if it has any.) The following would cause this tool to update/add GAIN (a float value), OBSID (an integer), CCD (a string) and INHERIT (boolean).
Here is the source for the fhset.c program:
This one still has to be written . . .
In this example, the keyword WEATHER may or may not exist.
This example is not a complete program, but a function within a larger program which has its own way of opening a file descriptor (and thus, does not want to use fh_file.)
Here a complete FITS file is built from scratch, using routines in libfh. It demonstrates several other things which the examples above do not:
Source code follows:
The fh_ehu*() functions are only used to access extensions within an already existing MEF. The are not used when building an MEF File for the first time. This task must be done by writing the appropriate interleaved header units and image data manually.
The following example constructs a very minimal MEF File with only two extensions. For a more comprehensive example, see the source code of DetCom, /cfht/src/medusa/detcom/detcom/det_data.c.