File: zimhead

package info (click to toggle)
wcstools 3.9.7-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,680 kB
  • sloc: ansic: 113,336; sh: 553; makefile: 246; lisp: 86; sed: 1
file content (147 lines) | stat: -rwxr-xr-x 2,778 bytes parent folder | download | duplicates (6)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/sh

# zimhead: Get header from compressed FITS files
# March 31, 2016
# By Jessica Mink (SAO)

if test -z $1
    then
    echo "zimhead: Get header from compressed TRES files"
    echo "         Version 2.0 Jessica Mink (SAO) March 31, 2016"
    echo "	   usage: zimhead [-v][-d directory] fits.file"
    echo "		  zimhead [-v][-d directory] @fits.file.list.file"
    echo "		  -d directory: prepend directory to all filenames"
    echo "                -f: Write exact FITS header"
    echo "                -i: Drop primary header even if inherited"
    echo "                +i: Append primary header even if not inherited"
    echo "		  -v: log processing steps"
    echo "                -z: Set BITPIX to 0 for dataless header"

    exit
    fi

vb=
dir=
datedir=
args=

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

while test $1
    do

    # Check for verbose flag
    if test $1 = "-v"
	then
	#echo verbose mode
	vb=true
	args=`echo $args -v`

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

    # Set full pathname to list of files if list file encountered
    else
	listfile=`isimlist $1`
	isfits=`echo $1 | grep fits`
	if test $listfile
	    then
	    fromfile=$listfile
	    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
	    if test $datedir
		then
		echo $datedir"/"$1 > templist
	    else
		echo $1 > templist
	    fi
	    fromfile=`echo templist`

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

if test $vb
    then
    echo imhead $args "<file>"
    echo "where <file> is"
    cat $fromfile
    fi
    apfib=
    fibkey=

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`

# Prepend directory to file if needed
    if test $dir
	then
	filein=`echo $dir/$file`
    else
	filein=$file
    fi

# Extract header into file yyyy.mmdd.<file>.head
    if test $bzcomp
	then
	if test $vb
	    then
	    echo bzcat $filein to read header
	    fi
	bzcat $filein | imhead $args stdin
    elif test $gzcomp
	then
	if test $vb
	    then
	    echo zcat $filein to read header
	    fi
	zcat $filein | imhead $args stdin
    elif test $zcomp
	then
	if test $vb
	    then
	    echo zcat $filein to read header
	    fi
	zcat $filein | imhead $args stdin
    else
	imhead $args $filein
    fi

    done

if test -e $fromfile
    then
    /bin/rm $fromfile
    fi

# Nov 24 2008	New program
#
# Mar 31 2016	Pass imhead arguments through