Subject: little FITS tools

From: sla at umbra.UCSC.EDU (Steve Allen)
Date: 19 Feb 1993 22:54:57 GMT

In playing around with FITS files, I often want to do quick little
manipulations of them.  I have several little shell scripts for
poking at them.  I'm appending one at the end of this message.
(Apologies to VMS users, it's very Un*x.  Also, nobody is allowed to make
rude comments about the little piece of Lick dirty laundry revealed here.)

Does anybody else have such little tools?  Could we start a collection?

I call this "catfits"
---------------------------cut here-------------------------------------
#!/bin/csh
#       A little Cshell script which acts like cat.
#       Author: Steve Allen (sla at lick.ucsc.edu) 1992,1993
#       It takes as input a FITS file, and cats out the headers of
#       the primary HDU and any FITS extensions which may be present.
#
#   Some recent Lick FITS headers have a "comment" as a part of the
#   END card.  This is actually illegal, but by giving the -L switch
#   as the first argument this script will tolerate them.
if ( $1 == -L ) then
    # be compatible with the illegal Lick FITS headers
    set sed1 = '/^SIMPLE  = /,/^END */p'
    # throw away the -L
    shift
else
    # a normal, legal FITS header
    set sed1 = '/^SIMPLE  = /,/^END *$/p'
endif
set sed2 = '/^XTENSION= /,/^END *$/p'
#
if ( $#argv == 0 ) then
    # act like a pipeline element
    dd conv=unblock cbs=80 | sed -n -e "$sed1" -e "$sed2"
else
    foreach file ($*)
	if ($#argv > 1) echo "===> "$file" <==="
	dd conv=unblock cbs=80 if=$file | sed -n -e "$sed1" -e "$sed2"
    end
endif
_______________________________________________________________________________
Steve Allen          | That was the equation!         |   sla at lick.ucsc.edu
UCO/Lick Observatory | Existence!...Survival must     | If the UC were opining,
Santa Cruz, CA 95064 | cancel out programming! -- Ruk | it wouldn't use me.

---

From: dwells at fits.CV.NRAO.EDU (Don Wells)
Date: Sat, 20 Feb 1993 16:37:54 GMT

In article <1m3og1INN3vn at darkstar.UCSC.EDU> sla at umbra.UCSC.EDU (Steve
Allen) writes:

 SA> In playing around with FITS files, I often want to do quick
 SA> little manipulations of them.  I have several little shell
 SA> scripts for poking at them.  I'm appending one at the end of this
 SA> message.  

This script is an elegant testimonial to the power of the Unix
shell(s) and tools. I have placed it in the anonymousFTP directory
fits.cv.nrao.edu [192.33.115.8]:/FITS/OSsupport/Unix/ as the file

  -r--r--r--  1 dwells       2131 Feb 20 11:00 catfits.csh

 SA> .. nobody is allowed to make rude comments about the little piece
 SA> of Lick dirty laundry revealed here..

In March 1979 Eric Greisen and I decided that END cards should have
trailing blanks in order to increase the probability that FITS-readers
would reliably detect the ends of headers; I myself have no regrets
about this design decision. Lick FITS-writer code is certainly not the
first to violate this rule. Practical implementations of FITS-readers
should be forgiving, of course.

 SA> Does anybody else have such little tools?  Could we start a
 SA> collection?  

I will be delighted to add such tools to the anonymousFTP server on
fits.cv.nrao.edu. I myself created one which does almost exactly the
same job as your "catfits"; it is in the same directory on the server:

  -r--r--r--  2 dwells       6300 Jul 28  1991 listfits.c
--

Donald C. Wells             Associate Scientist        dwells at nrao.edu
National Radio Astronomy Observatory                   +1-804-296-0277
520 Edgemont Road                                 Fax= +1-804-296-0278
Charlottesville, Virginia 22903-2475 USA            78:31.1W, 38:02.2N

---

From: dwells at fits.CV.NRAO.EDU (Don Wells)
Date: Sat, 20 Feb 1993 21:56:53 GMT

In article <DWELLS.93Feb20113754 at fits.cv.nrao.edu>
	dwells at fits.cv.nrao.edu (Don Wells) writes:
"... I myself created [a little FITS tool] which does almost exactly the
   same job as your "catfits"; it is in the same directory on the server.."

I apologize to Barry Schlesinger. I neglected to mention that my
listfits.c is based directly on his program headlist.c available via
anonymous-FTP on host nssdca.gsfc.nasa.gov.
--