File: zgethead

package info (click to toggle)
wcstools 3.9.6-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 14,556 kB
  • sloc: ansic: 107,711; sh: 511; makefile: 241; lisp: 86; sed: 1
file content (131 lines) | stat: -rwxr-xr-x 2,415 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/bin/sh

# zgethead:
# Get header parameters from compressed FITS files
# By Jessica Mink, November 12, 2008

if test -z $1
    then
    echo zgethead: Get header parameters from compressed FITS files
    echo "	  usage: zgethead [-v] fits.file keyword1 ... keywordn"
    echo "		 zgethead [-v] @fits.file.list.file keyword1 ..."
    echo "		 -v: list file names as they are read"
    exit
    fi

# Check for verbose flag as first argument
if test $1 = "-v"
    then
    #echo verbose mode
    vb=true
    shift
else
    #echo quiet mode
    vb=
fi
dir=

# Loop through arguments
if test -r templist
    then
    /bin/rm templist
    fi

args=
while test $1
    do

    # Set full pathname to list of files if list file encountered
    fromfile=`isimlist $1`
    isfits=`echo $1 | grep fits`
    if test $fromfile
	then
	if test $vb
	    then
	    echo Reading from list of FITS files in $fromfile
	    fi

    # If FITS file, add to list of files to check
    elif test $isfits
	then
	echo $1 > templist

    # Save directory path if present
    elif test $1 = "-d"
	then
	shift
	dir=$1
	if test $vb
	    then
	    echo Reading from directory $dir
	    fi

    # Add argument to list
    else
	args=`echo $args $1`

    fi
    shift
    done

if test $vb
    then
    echo gethead "<file>" $args
    fi

for file in `cat $fromfile`
    do
    if test $vb
	then
	echo File is \"$file\"
	fi
    bzcomp=`echo $file | grep \.bz2`
    gzcomp=`echo $file | grep \.gz`
    zcomp=`echo $file | grep \.Z`
    if test $bzcomp
	then
	if test $dir
	   then
	   filein=`echo $dir/$file`
	else
	   filein=$file
	fi
#	file=`echo $file | sed s/\.bz2//`
#	file=`echo $file | sed s/\\\//_/`
#	sedarg1=`echo -e s/stdin/$file/`
#	sedarg2=`echo -e s/_/\\\//`
	if test $vb
	    then
	    echo bzcat $filein to read header
#	    echo sed $sedarg before writing output
	    fi
#	bzcat $filein | gethead stdin $args | sed $sedarg1 | sed $sedarg2
	bzcat $filein | gethead stdin $args
    elif test $gzcomp
	then
	if test $dir
	   then
	   file=`echo $dir/$file`
	   fi
	if test $vb
	    then
	    echo zcat $file to read header
	    fi
	zcat $file | gethead stdin $args
    elif test $zcomp
	then
	if test $dir
	   then
	   file=`echo $dir/$file`
	   fi
	if test $vb
	    then
	    echo zcat $file to read header
	    fi
	zcat $file | gethead stdin $args
    else
	gethead $file $args
    fi
    args=`echo $args | sed s/-h//`
    done