Wildcard patterns can be used in the list of filenames. The output of the task is a fits file for each reference file in the argument. The names of the output files are generated by appending the filename extension on the root separated by an underscore and adding a new extension of .fits. In the case of images, the last letter of the original extension is also changed to f. Loopfits generates no output messages on its own, all output is generated by the underlying call to stwfits.
The code code consists of two subroutines called in a loop. The first
function, makeoutname
, creates the output filename from the input
filename. Since the rule for generating output filename differs
between tables and images, it calls another subroutine, is_image
to determine if the file is an image. It does this by reading the
first nine characters of the file and if they are SIMPLE =
, it
says the file is an image. The second function, makefits
,
generates a temporary parameter file for stwfits, calls it, deletes
the temporary file, and checks to see if the fits file was created.
The variable fitsio
at the top of the script contains the name of
the executable for stwfits and the assignment statement which sets it
must be modified for the system stwfits is installed on. Similarly the
first line of the script must be set to the Perl interpreter
executable.
The script can be executed on any of the reference files in the
test/data
subdirectory. For example,