- Timestamp:
- 09/01/21 07:56:42 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/hawc/processing/DiskToDB/extract-aux-data2.sh
r20091 r20103 12 12 { 13 13 echo "ERROR: Line `caller`: ${BASH_COMMAND}" >&2 14 rm -f ${TMPOUT} 14 15 exit 1 15 16 } … … 19 20 echo " " 20 21 echo "$0 was forcefully terminated" >&2 22 rm -f ${TMPOUT} 21 23 exit 1 22 24 } … … 28 30 # File to which the queries are written 29 31 OUTPUT="insert-aux.sql" 32 TMPOUT="./tmpAuxOut.sql" 30 33 # The Mars build directory 31 readonly MARS="/home/frankm/Dateien/Mars /build/"34 readonly MARS="/home/frankm/Dateien/Mars-6.24.00/build4/" 32 35 # The path to your Mars/build directory where the processing macros are stored 33 36 # MACROS="/home/frankm/Dateien/Mars/hawc/processing" 34 readonly MACROS="/home/frankm/Dateien/Mars /build/Masterarbeit/Datenbank/HE01/Mexico/Cfiles/"37 readonly MACROS="/home/frankm/Dateien/Mars-6.24.00/build/Masterarbeit/Datenbank/HE01/Mexico/Cfiles/" 35 38 readonly PROGRAM=$0 36 39 INSERT="INSERT INTO" … … 93 96 NIGHT="${4}" 94 97 95 98 ERRCODE= 96 99 97 100 # Open the query-file with the create table statement … … 140 143 "\ > ${OUTPUT} 141 144 145 # Set previous fail stats to also be fail here 146 echo "UPDATE DataOnDisk" >> ${OUTPUT} 147 echo "SET DataOnDisk.auxiliary = 6" >> ${OUTPUT} 148 echo "WHERE (DataOnDisk.calibration != 0" >> ${OUTPUT} 149 echo "OR DataOnDisk.header != 0)" >> ${OUTPUT} 150 echo "AND DataOnDisk.Telescope = ${TEL}" >> ${OUTPUT} 151 echo "AND DataOnDisk.NIGHT = ${NIGHT};" >> ${OUTPUT} 152 142 153 if [ ${DELETE} = "true" ] 143 154 then … … 159 170 echo \ 160 171 "\ 161 SELECT 162 NIGHT, RUNID, TSTARTI+TSTARTF, TSTOPI+TSTOPF 163 FROM 164 RawData 165 WHERE 166 Telescope=${TEL} 167 AND 168 NIGHT=${NIGHT}\ 172 SELECT RawData.NIGHT, 173 RawData.RUNID, 174 RawData.TSTARTI + RawData.TSTARTF, 175 RawData.TSTOPI + RawData.TSTOPF 176 FROM RawData 177 INNER JOIN DataOnDisk 178 ON DataOnDisk.Telescope = RawData.Telescope 179 AND DataOnDisk.NIGHT = RawData.NIGHT 180 AND DataOnDisk.RUNID = RawData.RUNID 181 WHERE RawData.Telescope=${TEL} 182 AND RawData.NIGHT=${NIGHT} 183 AND DataOnDisk.ISDRSFILE = 0 184 AND DataOnDisk.header = 0 185 AND DataOnDisk.calibration = 0\ 169 186 "\ 170 187 | mysql \ … … 176 193 while read -r -a LINE 177 194 do 178 # Extract night, runid, begin and end 179 NIGHT=${LINE[0]} 180 RUNID=${LINE[1]} 181 BEG=${LINE[2]} 182 END=${LINE[3]} 183 184 # Split night into year, month, day 185 # Base path for the night 186 FNAME="${DIR}"/${NIGHT:0:4}/${NIGHT:4:2}/${NIGHT:6:2}/${NIGHT} 187 188 echo ${FNAME} 189 190 cd ${MARS} 191 192 # Return corresponding data for DRS temperatures from FAD_CONTROL_TEMPEREATURE 193 DRS_TEMP=`root -b -q -l "${MACROS}"/drstemp.C\(\""${FNAME}".FAD_CONTROL_TEMPERATURE.fits\","${BEG}","${END}"\) | grep result | cut -f2- -d" "` 194 if [ ! -n "${DRS_TEMP}" ] 195 then 196 DRS_TEMP="NULL, NULL" 197 fi 198 echo ${DRS_TEMP} 199 200 # Return corresponding data for currents from BIAS_CONTROL_DYNAMIC_DATA 201 BIAS_DATA=`root -b -q -l "${MACROS}"/currents.C\(\""${FNAME}".BIAS_CONTROL_DYNAMIC_DATA.fits\","${BEG}","${END}"\) | grep result | cut -f2- -d" "` 202 if [ ! -n "${BIAS_DATA}" ] 203 then 204 BIAS_DATA="NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL" 205 fi 206 echo ${BIAS_DATA} 207 208 # Return corresponding data for trigger information from FTM_CONTROL_DATA 209 FTM_DATA=`root -b -q -l "${MACROS}"/trigger.C\(\""${FNAME}".FTM_CONTROL_DATA.fits\","${BEG}","${END}"\) | grep result | cut -f2- -d" "` 210 if [ ! -n "${FTM_DATA}" ] 211 then 212 FTM_DATA="NULL, NULL, NULL, NULL" 213 fi 214 echo ${FTM_DATA} 215 216 # Return corresponding data for threshold seeting from FTU_CONTROL_DATA 217 FTU_DATA=`root -b -q -l "${MACROS}"/threshold.C\(\""${FNAME}".FTU_CONTROL_DATA.fits\","${BEG}","${END}"\) | grep result | cut -f2- -d" "` 218 if [ ! -n "${FTU_DATA}" ] 219 then 220 FTU_DATA="NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL" 221 fi 222 echo ${FTU_DATA} 223 224 cd - 225 226 # Write the result as one row to the query file 227 echo "/* "${FNAME}" */" >> ${OUTPUT} 228 echo "ROW(" >> ${OUTPUT} 229 echo " "${TEL}, ${NIGHT}, ${RUNID}, >> ${OUTPUT} 230 echo " "${DRS_TEMP}, >> ${OUTPUT} 231 echo " "${BIAS_DATA}, >> ${OUTPUT} 232 echo " "${FTM_DATA}, >> ${OUTPUT} 233 echo " "${FTU_DATA} >> ${OUTPUT} 234 echo ")," >> ${OUTPUT} 195 # Extract night, runid, begin and end 196 NIGHT=${LINE[0]} 197 RUNID=${LINE[1]} 198 BEG=${LINE[2]} 199 END=${LINE[3]} 200 201 # Split night into year, month, day 202 # Base path for the night 203 FNAME="${DIR}"/${NIGHT:0:4}/${NIGHT:4:2}/${NIGHT:6:2}/${NIGHT} 204 205 echo ${FNAME} 206 207 cd ${MARS} 208 209 TNAME="${FNAME}".FAD_CONTROL_TEMPERATURE.fits 210 if [ ! -f "${TNAME}" ] 211 then 212 DRS_TEMP="NULL, NULL" 213 DRS_TEMP_ERR=2 214 else 215 # Return corresponding data for DRS temperatures from 216 # FAD_CONTROL_TEMPEREATURE 217 DRS_TEMP=`root -b -q -l \ 218 "${MACROS}"/drstemp.C\(\""${TNAME}"\","${BEG}","${END}"\) \ 219 | grep result \ 220 | cut -f2- -d" "` 221 222 if [ ! -n "${DRS_TEMP}" ] 223 then 224 DRS_TEMP="NULL, NULL" 225 DRS_TEMP_ERR=1 226 else 227 DRS_TEMP_ERR=0 228 fi 229 echo ${DRS_TEMP} 230 fi 231 232 # Return corresponding data for currents from BIAS_CONTROL_DYNAMIC_DATA 233 BNAME="${FNAME}".BIAS_CONTROL_DYNAMIC_DATA.fits 234 if [ ! -f "${BNAME}" ] 235 then 236 BIAS_DATA="NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL" 237 BIAS_DATA_ERR=20 238 else 239 BIAS_DATA=`root -b -q -l \ 240 "${MACROS}"/currents.C\(\""${BNAME}"\","${BEG}","${END}"\) \ 241 | grep result \ 242 | cut -f2- -d" "` 243 244 if [ ! -n "${BIAS_DATA}" ] 245 then 246 BIAS_DATA="NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL" 247 BIAS_DATA_ERR=10 248 else 249 BIAS_DATA_ERR=0 250 fi 251 echo ${BIAS_DATA} 252 fi 253 254 # Return corresponding data for trigger information from FTM_CONTROL_DATA 255 MNAME="${FNAME}".FTM_CONTROL_DATA.fits 256 if [ ! -f "${MNAME}" ] 257 then 258 FTM_DATA="NULL, NULL, NULL, NULL" 259 FTM_DATA_ERR=200 260 else 261 FTM_DATA=`root -b -q -l \ 262 "${MACROS}"/trigger.C\(\""${MNAME}"\","${BEG}","${END}"\) \ 263 | grep result \ 264 | cut -f2- -d" "` 265 266 if [ ! -n "${FTM_DATA}" ] 267 then 268 FTM_DATA="NULL, NULL, NULL, NULL" 269 FTM_DATA_ERR=100 270 else 271 FTM_DATA_ERR=0 272 fi 273 echo ${FTM_DATA} 274 fi 275 276 # Return corresponding data for threshold seeting from FTU_CONTROL_DATA 277 UNAME="${FNAME}".FTU_CONTROL_DATA.fits 278 if [ ! -f "${UNAME}" ] 279 then 280 FTU_DATA="NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL" 281 FTU_DATA_ERR=2000 282 else 283 FTU_DATA=`root -b -q -l \ 284 "${MACROS}"/threshold.C\(\""${UNAME}"\","${BEG}","${END}"\) \ 285 | grep result \ 286 | cut -f2- -d" "` 287 288 if [ ! -n "${FTU_DATA}" ] 289 then 290 FTU_DATA="NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL" 291 FTU_DATA_ERR=1000 292 else 293 FTU_DATA_ERR=0 294 fi 295 echo ${FTU_DATA} 296 fi 297 298 cd - 299 300 # Write the result as one row to the query file 301 echo "/* "${FNAME}" */" >> ${OUTPUT} 302 echo "ROW(" >> ${OUTPUT} 303 echo " "${TEL}, ${NIGHT}, ${RUNID}, >> ${OUTPUT} 304 echo " "${DRS_TEMP}, >> ${OUTPUT} 305 echo " "${BIAS_DATA}, >> ${OUTPUT} 306 echo " "${FTM_DATA}, >> ${OUTPUT} 307 echo " "${FTU_DATA} >> ${OUTPUT} 308 echo ")," >> ${OUTPUT} 309 310 ERRCODE=$((DRS_TEMP_ERR + BIAS_DATA_ERR + FTM_DATA_ERR + FTU_DATA_ERR)) 311 312 echo "UPDATE DataOnDisk SET auxiliary=${ERRCODE}" >> ${TMPOUT} 313 echo "WHERE NIGHT=${NIGHT}" >> ${TMPOUT} 314 echo "AND Telescope=${TEL}" >> ${TMPOUT} 315 echo "AND RUNID=${RUNID};" >> ${TMPOUT} 235 316 236 317 done … … 255 336 ); 256 337 "\ >> ${OUTPUT} 338 339 cat ${TMPOUT} >> ${OUTPUT} 340 341 rm -f ${TMPOUT}
Note:
See TracChangeset
for help on using the changeset viewer.