-
Notifications
You must be signed in to change notification settings - Fork 1
/
getcorners.sh
executable file
·67 lines (53 loc) · 1.87 KB
/
getcorners.sh
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
#!/bin/bash
#call as: getcorners.sh $EXPNUM $DATADIR $CORNERDIR [ $CCDNUM ]
if [ $# -eq 3 ]; then
echo "three arguments were passed; no ccdnum"
# assign arguments
CORNERDIR=$3
DATADIR=$2
e=$1
outfile=${e}.out
immaskfiles=$(ls ${DATADIR}/D$(printf %08d ${e})*_immask.fits.fz)
# prefer .fz files, but if none found, try .fits file
if [ -z "${immaskfiles}" ]; then
immaskfiles=$(ls ${DATADIR}/D$(printf %08d ${e})*_immask.fits)
fi
elif [ $# -eq 4 ]; then
echo "four arguments were passed; running with ccdnum"
# reassign arguments
CCD=$4
CORNERDIR=$3
DATADIR=$2
e=$1
outfile=${e}_${CCD}.out
immaskfiles=$(ls ${DATADIR}/D$(printf %08d ${e})*_$(printf %02d ${CCD})*_immask.fits.fz)
if [ -z "$immaskfiles" ]; then
immaskfiles=$(ls ${DATADIR}/D$(printf %08d ${e})*_$(printf %02d ${CCD})*_immask.fits)
fi
fi
AWK=/bin/awk
get_corners ()
{
echo Getting corner coordinates for exposure ${thisinfo[$ii]} ...
rm -f ${CORNERDIR}/$outfile
for f in $immaskfiles
#for f in ${DATADIR}/DECam_${e}/DECam*[0-9][0-9].fits
do
echo f is $f
filt=`gethead FILTER ${f} | cut -c1`
ccd=`gethead CCDNUM ${f}`
echo "16 16" > cornerxy.dat
echo "16 4081" >> cornerxy.dat
echo "2033 16" >> cornerxy.dat
echo "2033 4081" >> cornerxy.dat
${WCSTOOLS_DIR}/bin/xy2sky -d ${f} @cornerxy.dat > tmp.tmp${e}
coord=( `${AWK} '{printf "%10.5f %10.5f ",$1,$2}' tmp.tmp${e}` )
# output = ( Expo Band CCD RA1 Dec1 RA2 Dec2 RA3 Dec3 RA4 Dec4 )
echo ${e} ${filt} ${ccd} ${coord[0]} ${coord[1]} ${coord[2]} ${coord[3]} ${coord[4]} ${coord[5]} ${coord[6]} ${coord[7]} | \
${AWK} '{printf "%8d %s %2d %10.5f %10.5f %10.5f %10.5f %10.5f %10.5f %10.5f %10.5f\n",$1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11}' >> ${CORNERDIR}/$outfile
done
rm -f tmp.tmp${e}
hascorners[$i]=1
}
get_corners $1 $2
#ifdh cp -D