- Timestamp:
- 09/01/21 07:56:42 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/hawc/processing/DiskToDB/extract-raw-header2.sh
r20093 r20103 45 45 usage() 46 46 { 47 echo "usage: $PROGRAM [-hir ] [-o outfile] [Telescope Directory Night]"47 echo "usage: $PROGRAM [-hird] [-o outfile] [Telescope Directory Night]" 48 48 echo " -h display help" 49 49 echo " -i query ignores already existing rows" 50 echo " -r query replaces already existing rows (overwrites -i)"50 echo " -r query replaces already existing rows (overwrites -i)" 51 51 echo " -d delete all entries for a given Night and Telescope" 52 52 echo " -o outfile name of the SQL query file" … … 92 92 readonly CNTLONG=35 93 93 94 function InsertRaw() 95 { 96 local res="${1}" 97 98 echo "${INSERT} RawData SET" >> ${OUTPUT} 99 echo Telescope=${TEL}, >> ${OUTPUT} 100 echo "${res}" >> ${OUTPUT} 101 echo ";" >> ${OUTPUT} 102 } 103 104 function SetRawStatus() 105 { 106 local root="${1}" 107 local runid="${2}" 108 local stat="${3}" 109 110 echo "${root} header not valid!" 111 echo "UPDATE DataOnDisk SET" >> ${OUTPUT} 112 echo "header=${stat} " >> ${OUTPUT} 113 echo "WHERE NIGHT = ${NIGHT}" >> ${OUTPUT} 114 echo "AND Telescope = ${TEL}" >> ${OUTPUT} 115 echo "AND RUNID = ${runid}" >> ${OUTPUT} 116 echo ";" >> ${OUTPUT} 117 } 94 118 95 119 echo \ … … 156 180 then 157 181 echo "${ROOT}" 182 RUNID=`basename "${ROOT}" .fits.fz | cut -f2 -d "_"` 158 183 else 159 184 echo "${ROOT} has wrong file extension and will not be processed." 160 185 continue 161 186 fi 187 EXT=0 162 188 163 189 # Extract the header from the fits file with fitsdump, … … 183 209 | sed 's/^DATE[^-]/\`DATE\`/' \ 184 210 | sed "s/^\(.*\)'\(0x[0-9a-f]*\)'\(.*\)$/\1\2\3/g" \ 185 | sed '$!s/$/,/'` 211 | sed '$!s/$/,/'` || EXT=1 212 213 if [ $EXT -ne 0 ] 214 then 215 SetRawStatus "${ROOT}" ${RUNID} "1" 216 continue 217 fi 186 218 187 219 # compare to refference header and count commas … … 194 226 [ "${CNTCHECK}" == "${CNTLONG}" ] 195 227 then 196 echo "${INSERT} RawData SET" >> ${OUTPUT} 197 echo Telescope=${TEL}, >> ${OUTPUT} 198 echo ${RESULT} >> ${OUTPUT} 199 echo ";" >> ${OUTPUT} 228 InsertRaw "${RESULT}" 229 SetRawStatus "${ROOT}" ${RUNID} "0" 200 230 elif [ "${CHECKSHORT}" == "${REFSHORT}" ] && 201 231 [ "${CNTCHECK}" == "${CNTSHORT}" ] 202 232 then 203 echo "${INSERT} RawData SET" >> ${OUTPUT} 204 echo Telescope=${TEL}, >> ${OUTPUT} 205 echo ${RESULT} >> ${OUTPUT} 206 echo ";" >> ${OUTPUT} 233 InsertRaw "${RESULT}" 234 SetRawStatus "${ROOT}" ${RUNID} "0" 207 235 else 208 echo "${ROOT} header not valid!"236 SetRawStatus "${ROOT}" ${RUNID} "2" 209 237 fi 210 238
Note:
See TracChangeset
for help on using the changeset viewer.