Changeset 20104
- Timestamp:
- 09/05/21 07:13:17 (3 years ago)
- Location:
- trunk/Mars/hawc/processing/DiskToDB
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/hawc/processing/DiskToDB/extract-aux-data2.sh
r20103 r20104 30 30 # File to which the queries are written 31 31 OUTPUT="insert-aux.sql" 32 TMPOUT="./tmpAuxOut.sql"33 32 # The Mars build directory 34 readonly MARS="/home/ frankm/Dateien/Mars-6.24.00/build4/"33 readonly MARS="/home/hawc/Desktop/Mars/" 35 34 # The path to your Mars/build directory where the processing macros are stored 36 # MACROS="/home/frankm/Dateien/Mars/hawc/processing" 37 readonly MACROS="/home/frankm/Dateien/Mars-6.24.00/build/Masterarbeit/Datenbank/HE01/Mexico/Cfiles/" 35 readonly MACROS="/home/hawc/Desktop/Mars-src/hawc/processing/" 38 36 readonly PROGRAM=$0 39 37 INSERT="INSERT INTO" … … 96 94 NIGHT="${4}" 97 95 96 TMPOUT="./tmpAuxOut-${TEL}.sql" 98 97 ERRCODE= 99 98 … … 318 317 319 318 # Delete last comma and replace it with closing parintheses 320 sed -i '$s/,/)/' "${OUTPUT}" 321 322 # Finish the query file with defining the column names 323 echo "\ 319 if [ -f "${TMPOUT}" ] 320 then 321 sed -i '$s/,/)/' "${OUTPUT}" 322 323 # Finish the query file with defining the column names 324 echo "\ 324 325 AS 325 326 v( … … 337 338 "\ >> ${OUTPUT} 338 339 339 cat ${TMPOUT} >> ${OUTPUT} 340 else 341 head -n -4 "${OUTPUT}" > out.sql.new && mv out.sql.new "${OUTPUT}" 342 fi 343 344 if [ -f "${TMPOUT}" ] 345 then 346 cat ${TMPOUT} >> ${OUTPUT} 347 fi 340 348 341 349 rm -f ${TMPOUT} -
trunk/Mars/hawc/processing/DiskToDB/extract-raw-header2.sh
r20103 r20104 32 32 # define variables 33 33 OUTPUT=insert-raw.sql 34 readonly FITSDUMP="/home/ frankm/Dateien/FACT++/build/fitsdump"34 readonly FITSDUMP="/home/hawc/Desktop/FACT++/fitsdump" 35 35 readonly PROGRAM=$0 36 36 INSERT="INSERT INTO" … … 108 108 local stat="${3}" 109 109 110 echo "${root} header not valid!"111 110 echo "UPDATE DataOnDisk SET" >> ${OUTPUT} 112 111 echo "header=${stat} " >> ${OUTPUT} … … 213 212 if [ $EXT -ne 0 ] 214 213 then 214 echo "${ROOT} Fitsdump failed!" 215 215 SetRawStatus "${ROOT}" ${RUNID} "1" 216 216 continue … … 234 234 SetRawStatus "${ROOT}" ${RUNID} "0" 235 235 else 236 echo "${ROOT} header not valid!" 236 237 SetRawStatus "${ROOT}" ${RUNID} "2" 237 238 fi -
trunk/Mars/hawc/processing/DiskToDB/run-callisto2.sh
r20103 r20104 32 32 readonly STAR=star 33 33 # Directory to Mars environment (usually Mars/build) 34 readonly MARS="/home/ frankm/Dateien/Mars-6.24.00/build4/"34 readonly MARS="/home/hawc/Desktop/Mars/" 35 35 # Absolut path to macros 36 readonly MACROS="/home/ frankm/Dateien/Mars-6.24.00/hawc"36 readonly MACROS="/home/hawc/Desktop/Mars-src/hawc" 37 37 readonly PROGRAM=$0 38 38 REPLACE=false … … 139 139 --compress \ 140 140 | \ 141 while read -r -a LINE 142 do 143 # Extract night/runid for data file and calibration file 144 DATNIGHT=${LINE[0]} 145 DATRUNID=${LINE[1]} 146 DRSNIGHT=${LINE[2]} 147 DRSRUNID=${LINE[3]} 148 149 # Formatting of the file paths and names 150 DATPATH=${DATNIGHT:0:4}/${DATNIGHT:4:2}/${DATNIGHT:6:2} 151 DRSPATH=${DRSNIGHT:0:4}/${DRSNIGHT:4:2}/${DRSNIGHT:6:2} 152 153 PREFIX=`printf ${DATNIGHT}_%03d ${DATRUNID}` 154 155 DATNAME=`printf ${DATNIGHT}_%03d.fits.fz ${DATRUNID}` 156 DRSNAME=`printf ${DRSNIGHT}_%03d.drs.fits ${DRSRUNID}` 157 158 OUT="${DATA}"/../${CALLISTO}/${DATPATH} 159 160 echo DAT=${DATNAME} [${DATPATH}] 161 echo DRS=${DRSNAME} [${DRSPATH}] 162 163 164 if [ ${REPLACE} = true ] 165 then 166 echo "deleting ${OUT}/.${PREFIX}.succsess !!!" 167 rm -f "${OUT}"/.${PREFIX}.success 168 fi 169 170 # Check if not yet successfully processed 171 # Removing this file can be used to trigger a re-processing 172 # the next time this script is executed 173 if [ ! -f "${OUT}/.${PREFIX}.success" ] 174 then 175 176 cd ${MARS} 177 178 mkdir -p "${OUT}" 179 180 # Trigger reprocessing of the process-fils in the star directory 181 rm -f "${DATA}/${STAR}/${DATPATH}/.${PREFIX}.*" 182 183 # Flag that a process is running 184 rm -f "${OUT}"/.${PREFIX}.done 185 rm -f "${OUT}"/.${PREFIX}.success 186 187 touch "${OUT}"/.${PREFIX}.running 188 189 echo ${DATA} 190 191 # Execute the calibration and write output to log-file 192 root -b -q -l ${MACROS}/callisto.C'("'"${DATA}"/${DATPATH}/${DATNAME}'","'"${DATA}"/${DRSPATH}/${DRSNAME}'", 0 ,"'"${OUT}"'")' \ 193 2>&1 | tee "${OUT}"/${PREFIX}.log 194 195 RC=${PIPESTATUS[0]} 196 197 198 # Remember exit status of callisto 199 echo RC=${RC} | tee -a "${OUT}"/${PREFIX}.log 200 echo ${RC} > "${OUT}"/.${PREFIX}.done 201 # Processing is finished 202 rm -f "${OUT}"/.${PREFIX}.running 203 204 # If processing was successfull write corresponding flag 205 if [ "${RC}" == "0" ] 206 then 141 while read -r -a LINE 142 do 143 # Extract night/runid for data file and calibration file 144 DATNIGHT=${LINE[0]} 145 DATRUNID=${LINE[1]} 146 DRSNIGHT=${LINE[2]} 147 DRSRUNID=${LINE[3]} 148 149 # Formatting of the file paths and names 150 DATPATH=${DATNIGHT:0:4}/${DATNIGHT:4:2}/${DATNIGHT:6:2} 151 DRSPATH=${DRSNIGHT:0:4}/${DRSNIGHT:4:2}/${DRSNIGHT:6:2} 152 153 PREFIX=`printf ${DATNIGHT}_%03d ${DATRUNID}` 154 155 DATNAME=`printf ${DATNIGHT}_%03d.fits.fz ${DATRUNID}` 156 DRSNAME=`printf ${DRSNIGHT}_%03d.drs.fits ${DRSRUNID}` 157 158 OUT="${DATA}"/../${CALLISTO}/${DATPATH} 159 160 echo DAT=${DATNAME} [${DATPATH}] 161 echo DRS=${DRSNAME} [${DRSPATH}] 162 163 164 if [ ${REPLACE} = true ] 165 then 166 echo "deleting ${OUT}/.${PREFIX}.succsess !!!" 167 rm -f "${OUT}"/.${PREFIX}.success 168 fi 169 170 # Check if not yet successfully processed 171 # Removing this file can be used to trigger a re-processing 172 # the next time this script is executed 173 if [ ! -f "${OUT}/.${PREFIX}.success" ] 174 then 175 176 cd ${MARS} 177 178 mkdir -p "${OUT}" 179 180 # Trigger reprocessing of the process-fils in the star directory 181 rm -f "${DATA}/${STAR}/${DATPATH}/.${PREFIX}.*" 182 183 # Flag that a process is running 184 rm -f "${OUT}"/.${PREFIX}.done 185 rm -f "${OUT}"/.${PREFIX}.success 186 187 touch "${OUT}"/.${PREFIX}.running 188 189 echo ${DATA} 190 191 RC=0 192 # Execute the calibration and write output to log-file 193 root -b -q -l ${MACROS}/callisto.C'("'"${DATA}"/${DATPATH}/${DATNAME}'","'"${DATA}"/${DRSPATH}/${DRSNAME}'", 0 ,"'"${OUT}"'")' \ 194 2>&1 | tee "${OUT}"/${PREFIX}.log || RC=1 195 196 # Remember exit status of callisto 197 echo RC=${RC} | tee -a "${OUT}"/${PREFIX}.log 198 echo ${RC} > "${OUT}"/.${PREFIX}.done 199 # Processing is finished 200 rm -f "${OUT}"/.${PREFIX}.running 201 202 # If processing was successfull write corresponding flag 203 if [ "${RC}" == "0" ] 204 then 207 205 touch "${OUT}"/.${PREFIX}.success 208 else 209 UpdateStatus ${TEL} ${NIGHT} ${DATRUNID} 1 210 fi 211 212 cd - 213 214 echo "-----End of first iteration-----" 215 else 216 echo Skipped. 217 fi 218 219 done 206 fi 207 208 cd - 209 210 echo "-----End of first iteration-----" 211 else 212 echo Skipped. 213 fi 214 215 done -
trunk/Mars/hawc/processing/DiskToDB/run-root2sql2.sh
r20103 r20104 28 28 29 29 # Path to the executable 30 readonly ROOT2SQL="/home/ frankm/Dateien/FACT++/build/root2sql"30 readonly ROOT2SQL="/home/hawc/Desktop/FACT++/root2sql" 31 31 readonly PROGRAM=${0} 32 32 … … 128 128 fi 129 129 130 mysql --defaults-file=${CRED} \ 131 --compress \ 132 -e "UPDATE DataOnDisk \ 133 SET DataOnDisk.${col} = 6 \ 134 WHERE DataOnDisk.Telescope = ${tel} \ 135 AND DataOnDisk.NIGHT = ${night} \ 136 AND DataOnDisk.calibration != 0;" 137 130 # Set col to 3 if the file is a DRS run 138 131 mysql --defaults-file=${CRED} \ 139 132 --compress \ -
trunk/Mars/hawc/processing/DiskToDB/run-scripts.sh
r20103 r20104 36 36 37 37 38 39 function LockExit() 40 { 41 echo "ERROR: One instance of ${SCRPTN} already running" >&2 42 exit 1 43 } 44 45 function DescExit() 46 { 47 echo "ERROR: Filedescriptor 200 already taken" >&2 48 exit 1 49 } 50 51 function ErrExit() 52 { 53 echo "ERROR: Line `caller`: ${BASH_COMMAND}" >&2 54 exit 1 55 } 56 57 function StrgCExit() 58 { 59 echo " " 60 echo "$0 was forcefully terminated" >&2 61 exit 1 62 } 63 64 trap ErrExit ERR 65 trap StrgCExit INT 66 67 # Telescope for which to process 68 readonly TEL="${1}" 69 if [ ${TEL} = "1" ] 70 then 71 echo "Processing for Telescope 1" 72 elif [ ${TEL} = "2" ] 73 then 74 echo "Processing for Telescope 2" 75 else 76 echo "No valid Telescope selected!" >&2 77 exit 1 78 fi 79 38 80 # Filename 39 81 readonly SCRPTN=`basename $0 .sh` 40 82 41 83 # For lockfile 42 readonly LOCK="/tmp/${SCRPTN}.lock" 43 44 function LockExit() 45 { 46 echo "ERROR: One instance of ${SCRPTN} already running" >&2 47 exit 1 48 } 49 50 function DescExit() 51 { 52 echo "ERROR: Filedescriptor 200 already taken" >&2 53 exit 1 54 } 55 56 function ErrExit() 57 { 58 echo "ERROR: Line `caller`: ${BASH_COMMAND}" >&2 59 exit 1 60 } 61 62 function StrgCExit() 63 { 64 echo " " 65 echo "$0 was forcefully terminated" >&2 66 exit 1 67 } 68 69 trap ErrExit ERR 70 trap StrgCExit INT 71 72 exec 200>${LOCK} || DescExit 73 flock -n 200 || LockExit 84 readonly LOCK="/tmp/${SCRPTN}${TEL}.lock" 85 86 eval "exec 20${TEL}>${LOCK}" || DescExit 87 flock -n "20${TEL}" || LockExit 88 89 cd /home/hawc/Desktop/DiskToDB/ 74 90 75 91 # For logfile 76 92 mkdir -p log 77 93 readonly DATE=`date +%Y%m%d_%H%M` 78 readonly LOG="./log/${SCRPTN}_${DATE}.log" 79 # exec 3>&1 1>>${LOG} 80 # exec 4>>${LOG} 81 exec 3>&1 82 exec 4>&1 94 readonly LOG="./log/${SCRPTN}_${DATE}_${TEL}.log" 95 exec 3>&1 1>>${LOG} 96 exec 4>>${LOG} 97 exec 5>&2 2>>${LOG} 98 # exec 3>&1 99 # exec 4>&1 83 100 84 101 echo "Start processing data" … … 188 205 } 189 206 190 191 207 # Define variables 192 # Telescope for which to process 193 readonly TEL=1 194 # Directory in which the raw data is located 195 readonly DIR='/run/media/frankm/Neuer Datenträger/data/DATA/HE0'${TEL} 208 # Directory in which the raw directory is located 209 readonly DIR="/media/DATA/HAWCsEYE0${TEL}/" 196 210 # Credentials for the SQL database 197 readonly CRED='../ credentials-read-only.cnf'211 readonly CRED='../Credentials/credentials-read-only.cnf' 198 212 # Credentials for root2sql for callisto 199 readonly CALLISTORC='../ root2sql-callisto.rc'213 readonly CALLISTORC='../Credentials/root2sql-callisto.rc' 200 214 # Credentials for root2sql for star 201 readonly STARRC='../root2sql-star.rc' 215 readonly STARRC='../Credentials/root2sql-star.rc' 216 # ROOT init path 217 readonly RPATH='../root-6.24.02/bin/thisroot.sh' 218 219 echo "Processing data from ${DIR}" 202 220 203 221 # Check if variable paths point to something sensible … … 206 224 DoesFileExists "${CALLISTORC}" 207 225 DoesFileExists "${STARRC}" 226 DoesFileExists "${RPATH}" 208 227 209 228 # SQL outputs 210 229 mkdir -p ./queries 211 readonly ONDISK='./queries/insert-OnDisk.sql' 212 readonly RAW='./queries/insert-raw.sql' 213 readonly CALIB='./queries/find-calibration2.sql' 214 readonly AUX='./queries/insert-aux.sql' 230 readonly ONDISK="./queries/insert-OnDisk-${TEL}.sql" 231 readonly RAW="./queries/insert-raw-${TEL}.sql" 232 readonly CALIB="./queries/find-calibration2-${TEL}.sql" 233 readonly AUX="./queries/insert-aux-${TEL}.sql" 234 235 # Init ROOT 236 set +o nounset 237 . "${RPATH}" 238 set -o nounset 215 239 216 240 # Create Database of existing files … … 247 271 echo "Updating database" 248 272 249 NIGHTS=20201111250 251 273 echo "Nights to process:" 252 274 echo "${NIGHTS}" -
trunk/Mars/hawc/processing/DiskToDB/run-star2.sh
r20103 r20104 32 32 readonly STAR=star 33 33 # Directory to Mars environment (usually Mars/build) 34 readonly MARS="/home/ frankm/Dateien/Mars-6.24.00/build4/"34 readonly MARS="/home/hawc/Desktop/Mars/" 35 35 # Absolut path to macros 36 readonly MACROS="/home/ frankm/Dateien/Mars-6.24.00/hawc"36 readonly MACROS="/home/hawc/Desktop/Mars-src/hawc" 37 37 readonly PROGRAM=$0 38 38 REPLACE=false … … 110 110 "\ 111 111 SELECT 112 NIGHT, RUNID 112 Calibration.NIGHT, 113 Calibration.RUNID 113 114 FROM 114 Calibration 115 Calibration 116 INNER JOIN 117 DataOnDisk 118 ON 119 DataOnDisk.Telescope = Calibration.Telescope 120 AND 121 DataOnDisk.NIGHT = Calibration.NIGHT 122 AND 123 DataOnDisk.RUNID = Calibration.RUNID 115 124 WHERE 116 Telescope=${TEL} 125 Calibration.Telescope = ${TEL} 126 AND 127 Calibration.NIGHT = ${NIGHT} 117 128 AND 118 NIGHT=${NIGHT}129 DataOnDisk.callisto = 0 119 130 ORDER BY 120 NIGHT,RUNID\131 Calibration.NIGHT, Calibration.RUNID\ 121 132 "\ 122 133 | mysql \ … … 165 176 touch "${OUT}"/.${PREFIX}.running 166 177 178 RC=0 179 # set +o pipefail 167 180 # Execute image parameter calculation and write log-file 168 181 root -b -q -l ${MACROS}/star.C'("'"${IN}"/${DATNAME}'","'"${OUT}"'")' \ 169 2>&1 | tee "${OUT}"/${PREFIX}.log 170 171 # Remember exit status of callisto 172 RC=${PIPESTATUS[0]} 182 2>&1 | tee "${OUT}"/${PREFIX}.log || RC=1 183 184 # RC=$? 185 # set -o pipefail 186 187 # Remember exit status of star 188 # RC=${PIPESTATUS[0]} 173 189 174 190 echo RC=${RC} | tee -a "${OUT}"/${PREFIX}.log … … 182 198 then 183 199 touch "${OUT}"/.${PREFIX}.success 184 else185 UpdateStatus ${TEL} ${NIGHT} ${DATRUNID} 1186 200 fi 187 201 -
trunk/Mars/hawc/processing/DiskToDB/update-file-table2.sh
r20103 r20104 169 169 ) SELECT * FROM DataOnDisk 170 170 WHERE (Telescope, NIGHT, RUNID, ISDRSFILE) NOT IN 171 (SELECT Telescope, NIGHT, RUNID, ISDRSFILE FROM DataOnDisk_tmp); 171 (SELECT Telescope, NIGHT, RUNID, ISDRSFILE FROM DataOnDisk_tmp) 172 AND Telescope=${TEL}; 172 173 173 UPDATE DataOnDisk SET star = NULL WHERE NIGHT IN 174 (SELECT NIGHT FROM TableNotDisk); 174 UPDATE DataOnDisk SET header = NULL WHERE NIGHT IN 175 (SELECT NIGHT FROM TableNotDisk) 176 AND Telescope=${TEL}; 175 177 176 178 DELETE FROM DataOnDisk 177 179 WHERE (Telescope, NIGHT, RUNID, ISDRSFILE) NOT IN 178 (SELECT Telescope, NIGHT, RUNID, ISDRSFILE FROM DataOnDisk_tmp); 180 (SELECT Telescope, NIGHT, RUNID, ISDRSFILE FROM DataOnDisk_tmp) 181 AND Telescope=${TEL}; 179 182 180 183 ${INSERT} DataOnDisk (SELECT * FROM DataOnDisk_tmp); -
trunk/Mars/hawc/processing/DiskToDB/write-calibration-query.sh
r20103 r20104 97 97 UPDATE DataOnDisk 98 98 SET DataOnDisk.calibration = 6 99 WHERE DataOnDisk.header != 0; 99 WHERE DataOnDisk.header != 0 100 AND NIGHT=${NIGHT} 101 AND Telescope=${TEL}; 100 102 101 103 CREATE TEMPORARY TABLE Calibration_tmp … … 205 207 UPDATE DataOnDisk 206 208 SET DataOnDisk.calibration = 0 207 WHERE DataOnDisk.header = 0; 209 WHERE DataOnDisk.header = 0 210 AND NIGHT=${NIGHT} 211 AND Telescope=${TEL}; 208 212 209 213 -- Set Status to 2 if there was no drs file with step = 1 in the NIGHT 210 214 UPDATE DataOnDisk 211 215 SET DataOnDisk.calibration = 2 212 WHERE EXISTS(SELECT * FROM Calibration WHERE NIGHT=${NIGHT}) = 0; 216 WHERE EXISTS( 217 SELECT * FROM Calibration 218 WHERE NIGHT=${NIGHT} 219 AND Telescope=${TEL} 220 ) = 0; 213 221 "\ >> ${OUTPUT}
Note:
See TracChangeset
for help on using the changeset viewer.