[507] | 1 | #!/bin/sh -xvf |
---|
| 2 | #download SCA file, proceed to introspection, and upload results |
---|
| 3 | DATE=/bin/date |
---|
| 4 | GREP=/bin/grep |
---|
| 5 | AWK=/bin/awk |
---|
| 6 | ECHO=/bin/echo |
---|
| 7 | WC=/usr/bin/wc |
---|
| 8 | CAT=/bin/cat |
---|
| 9 | PRINTF=/usr/bin/printf |
---|
| 10 | FIND=/usr/bin/find |
---|
| 11 | MKDIR=/bin/mkdir |
---|
| 12 | XARGS=/usr/bin/xargs |
---|
| 13 | SORT=/bin/sort |
---|
| 14 | RM=/bin/rm |
---|
| 15 | TR=/usr/bin/tr |
---|
| 16 | CP=/bin/cp |
---|
| 17 | LS=/bin/ls |
---|
| 18 | CHMOD=/bin/chmod |
---|
| 19 | |
---|
| 20 | DefaultIFS=$' \t\n' |
---|
| 21 | IFS=$DefaultIFS |
---|
| 22 | |
---|
| 23 | #set Irods environment |
---|
| 24 | . /usr/local/shared/bin/irods_env.sh -noverbose |
---|
| 25 | |
---|
| 26 | scriptName="`basename $0`" |
---|
| 27 | $ECHO "Processing script ${scriptName} at `date`" |
---|
| 28 | #which source to analyse |
---|
| 29 | |
---|
| 30 | #Process cmd line args: the -src option is mandatory (source name as Abell85) |
---|
| 31 | sourceRadio= |
---|
| 32 | freqBAOCalib=1346 |
---|
| 33 | bwBAOCalib=6.25 |
---|
| 34 | #use -sim option to simulate processing (debug the script as if...) |
---|
| 35 | simulationMode=Off |
---|
| 36 | while [ $# -gt 0 ] |
---|
| 37 | do |
---|
| 38 | case "$1" in |
---|
| 39 | -src) sourceRadio=$2; shift;; |
---|
| 40 | -freq) freqBAOCalib=$2; shift;; |
---|
| 41 | -bwd) bwBAOCalib=$2; shift;; |
---|
| 42 | -sim) simulationMode=On; shift;; |
---|
| 43 | -h) |
---|
| 44 | echo >&2 \ |
---|
| 45 | "usage: $0 -src souce [-freq freq in MHz (default ${freqBAOCalib})] [-bwd bandwidth in MHz (default ${bwBAOCalib})]" |
---|
| 46 | exit 1;; |
---|
| 47 | *) break;; # terminate while loop |
---|
| 48 | esac |
---|
| 49 | shift |
---|
| 50 | done |
---|
| 51 | |
---|
| 52 | if [ ${simulationMode} = "On" ]; then |
---|
| 53 | $ECHO "INFO ${scriptName} running in SIMUL mode" |
---|
| 54 | fi |
---|
| 55 | |
---|
| 56 | if [ "<${sourceRadio}>" = "<>" ]; then |
---|
| 57 | $ECHO "FATAL: You have forgotten to select the source option (-src)" |
---|
| 58 | exit 1 |
---|
| 59 | fi |
---|
| 60 | |
---|
| 61 | case ${sourceRadio} in |
---|
| 62 | Abell85) $ECHO "INFO (${scriptName}): process ${sourceRadio}";; |
---|
| 63 | Abell2440) $ECHO "INFO (${scriptName}): process ${sourceRadio}";; |
---|
| 64 | Abell1205) $ECHO "INFO (${scriptName}): process ${sourceRadio}";; |
---|
| 65 | *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen" |
---|
| 66 | exit 1;; |
---|
| 67 | esac |
---|
| 68 | |
---|
| 69 | srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" ` |
---|
| 70 | |
---|
| 71 | #Path to public backupable path |
---|
| 72 | publicpath="/afs/in2p3.fr/home/c/campagne/public" |
---|
| 73 | |
---|
| 74 | |
---|
| 75 | #temporary files to synchronize scripts |
---|
| 76 | tmppublicpath="/sps/baoradio/AmasNancay" |
---|
| 77 | #wakeup the NFS disk |
---|
| 78 | $LS -l ${tmppublicpath} > /dev/null |
---|
| 79 | #clean previous spurious files |
---|
| 80 | $RM -f ${tmppublicpath}/*.finished |
---|
| 81 | |
---|
| 82 | #Path where the job will do temporary IO |
---|
| 83 | if [ ${ENVIRONMENT} = "INTERACTIVE" ]; then |
---|
| 84 | iojobpath="/sps/baoradio/AmasNancay/JEC" |
---|
| 85 | $MKDIR -p $iojobpath |
---|
| 86 | elif [ ${ENVIRONMENT} = "BATCH" ] ; then |
---|
| 87 | iojobpath=${TMPBATCH} |
---|
| 88 | else |
---|
| 89 | $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed" |
---|
| 90 | exit 1 |
---|
| 91 | fi |
---|
| 92 | cd ${iojobpath} |
---|
| 93 | |
---|
| 94 | localpath="${sourceRadio}" |
---|
| 95 | $MKDIR -p ./${localpath} |
---|
| 96 | cd ./${localpath} |
---|
| 97 | |
---|
| 98 | #save the top directory |
---|
| 99 | topDir=`pwd` |
---|
| 100 | |
---|
| 101 | #Path of the utility scripts |
---|
[510] | 102 | scriptpath="/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay" |
---|
[507] | 103 | |
---|
| 104 | #get the daq current irod status |
---|
| 105 | tag=`${DATE} +%F` |
---|
| 106 | OUT1=${publicpath}/baodaqstatus-${tag}.txt |
---|
| 107 | |
---|
| 108 | if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then |
---|
| 109 | $ECHO "We should bring the DAQ status more up to date, this take 1 or 2sec..." |
---|
| 110 | $RM -f ${tmppublicpath}/statusdaq.finished |
---|
| 111 | ${scriptpath}/statusdaq.sh > ${OUT1} |
---|
| 112 | while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do |
---|
| 113 | sleep 30 |
---|
| 114 | done |
---|
| 115 | $RM ${tmppublicpath}/statusdaq.finished |
---|
| 116 | #protect against remove/rewriting |
---|
| 117 | $CHMOD -v 444 ${OUT1} |
---|
| 118 | fi |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | #Nb: if we want to implement a loop on sources we have to take care of srclower... |
---|
| 122 | |
---|
| 123 | $ECHO "You have selected sourceRadio = $sourceRadio" |
---|
| 124 | tableau=( `$GREP -i ${sourceRadio} ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` ) |
---|
| 125 | IFS=' |
---|
| 126 | ' |
---|
| 127 | tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 128 | IFS=$DefaultIFS |
---|
| 129 | |
---|
| 130 | |
---|
| 131 | for i in ${tableau[@]} |
---|
| 132 | do |
---|
| 133 | # |
---|
| 134 | # start a "fresh" session |
---|
| 135 | cd ${topDir} |
---|
| 136 | $LS | $XARGS -i $RM -rf {} |
---|
| 137 | |
---|
| 138 | $ECHO "DEBUG: (${scriptName}) irods root dir $i" |
---|
| 139 | dateDAQ=`$ECHO ${i} | $AWK '{split($0,a,"/"); print a[6];}' | $AWK "{sub(/${srclower}/,\"\"); print}"` |
---|
| 140 | |
---|
| 141 | $ECHO "DEBUG: (${scriptName}): we are in directory `pwd` the topDir=${topDir}" |
---|
| 142 | $LS -lrt |
---|
| 143 | |
---|
| 144 | |
---|
| 145 | #Look if the date has changed since beginning of the job! |
---|
| 146 | curtag=`${DATE} +%F` |
---|
| 147 | if [ "<${curtag}>" != "<${tag}>" ]; then |
---|
| 148 | tag=${curtag} |
---|
| 149 | #it is necessary to update the daq status as the day has changed during the processing... (batch can take a long time...) |
---|
| 150 | OUT1=${publicpath}/baodaqstatus-${curtag}.txt |
---|
| 151 | $ECHO "We should bring the DAQ status more up to date, this take 1 or 2sec..." |
---|
| 152 | $RM -f ${tmppublicpath}/statusdaq.finished |
---|
| 153 | ${scriptpath}/statusdaq.sh > ${OUT1} |
---|
| 154 | while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do |
---|
| 155 | sleep 30 |
---|
| 156 | done |
---|
| 157 | $RM ${tmppublicpath}/statusdaq.finished |
---|
| 158 | #protect against remove/rewriting |
---|
| 159 | $CHMOD -v 444 ${OUT1} |
---|
| 160 | fi |
---|
| 161 | # |
---|
| 162 | # look if the calibration files already exist |
---|
| 163 | # |
---|
| 164 | alreadyDone=`ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" | $WC -l` |
---|
| 165 | if [ ${alreadyDone} -gt 0 ]; then |
---|
| 166 | $ECHO "INFO (${scriptName}): calibration coef files already exist" |
---|
| 167 | continue |
---|
| 168 | fi |
---|
| 169 | # |
---|
| 170 | somethingTodo=1 |
---|
| 171 | input4calibOff=`ils ${i}/Off 2>&1 | $GREP -i "calibcycle" | $AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.11n` |
---|
| 172 | input4calibOn=`ils ${i}/On 2>&1 | $GREP -i "calibcycle" | $AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.11n` |
---|
| 173 | # |
---|
| 174 | if [ "<${input4calibOff}>" != "<>" -a "<${input4calibOn}>" != "<>" ]; then |
---|
| 175 | #look at the content of the calibcycle directory as may be the previous batch job has crashed |
---|
| 176 | tableauOff=( `$ECHO ${input4calibOff}` ) |
---|
| 177 | IFS=' |
---|
| 178 | ' |
---|
| 179 | tableauOff=( $( $PRINTF "%s\n" "${tableauOff[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 180 | IFS=$DefaultIFS |
---|
| 181 | # |
---|
| 182 | nTotFilesOff=0 |
---|
| 183 | for j in ${tableauOff[@]} |
---|
| 184 | do |
---|
| 185 | nFiles=`ils ${i}/Off/${j} | $GREP -i "medfiltmtx" | $WC -l` |
---|
| 186 | nTotFilesOff=`expr ${nTotFilesOff} + ${nFiles}` |
---|
| 187 | done |
---|
| 188 | # |
---|
| 189 | tableauOn=( `$ECHO ${input4calibOn}` ) |
---|
| 190 | IFS=' |
---|
| 191 | ' |
---|
| 192 | tableauOn=( $( $PRINTF "%s\n" "${tableauOn[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 193 | IFS=$DefaultIFS |
---|
| 194 | # |
---|
| 195 | nTotFilesOn=0 |
---|
| 196 | for j in ${tableauOn[@]} |
---|
| 197 | do |
---|
| 198 | nFiles=`ils ${i}/On/${j} | $GREP -i "medfiltmtx" | $WC -l` |
---|
| 199 | nTotFilesOn=`expr ${nTotFilesOn} + ${nFiles}` |
---|
| 200 | done |
---|
| 201 | diffOnOff=`expr ${nTotFilesOff} - ${nTotFilesOn}` |
---|
| 202 | if [ ${diffOnOff} -lt 0 ]; then |
---|
| 203 | zero=0 |
---|
| 204 | diffOnOff=`expr ${zero} - ${diffOnOff}` |
---|
| 205 | fi |
---|
| 206 | #allow up to 5 files differences |
---|
| 207 | if [ ${nTotFilesOff} -gt 0 -a ${nTotFilesOn} -gt 0 ]; then |
---|
| 208 | somethingTodo=0 |
---|
| 209 | $ECHO "DEBUG (${scriptName}): $sourceRadio $dateDAQ has <${nTotFilesOff}> Off-files and <${nTotFilesOn}> On-files but OK" |
---|
| 210 | else |
---|
| 211 | $ECHO "INFO (${scriptName}): $sourceRadio $dateDAQ has <${nTotFilesOff}> Off-files and <${nTotFilesOn}> On-files => one should rebuild has something is wrong" |
---|
| 212 | fi |
---|
| 213 | # |
---|
| 214 | fi |
---|
| 215 | if [ ${somethingTodo} -eq 1 ]; then |
---|
| 216 | # |
---|
| 217 | $ECHO ">>>>>>>>>>>>>>>> Do $sourceRadio $dateDAQ CALIBOFF" |
---|
| 218 | $RM -f ${tmppublicpath}/proc_script.finished |
---|
| 219 | if [ ${simulationMode} = "On" ]; then |
---|
| 220 | $ECHO "SIMUL: ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ CALIBOFF" |
---|
| 221 | else |
---|
| 222 | ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ CALIBOFF |
---|
| 223 | while [ ! -e "${tmppublicpath}/proc_script.finished" ]; do |
---|
| 224 | $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/proc_script.finished" |
---|
| 225 | date +%T |
---|
| 226 | sleep 60 |
---|
| 227 | done |
---|
| 228 | fi |
---|
| 229 | $ECHO "INFO (${scriptName}): proc_script has finished" |
---|
| 230 | $ECHO ">>>>>>>>>>>> Done $sourceRadio $dateDAQ CALIBOFF" |
---|
| 231 | $ECHO ">>>>>>>>>>>>>>>> Do $sourceRadio $dateDAQ CALIBON" |
---|
| 232 | $RM ${tmppublicpath}/proc_script.finished |
---|
| 233 | |
---|
| 234 | if [ ${simulationMode} = "On" ]; then |
---|
| 235 | $ECHO "SIMUL: ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ CALIBON" |
---|
| 236 | else |
---|
| 237 | ${scriptpath}/proc_script.sh $sourceRadio $dateDAQ CALIBON |
---|
| 238 | while [ ! -e "${tmppublicpath}/proc_script.finished" ]; do |
---|
| 239 | $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/proc_script.finished" |
---|
| 240 | date +%T |
---|
| 241 | sleep 60 |
---|
| 242 | done |
---|
| 243 | fi |
---|
| 244 | $ECHO "INFO (${scriptName}): proc_script has finished" |
---|
| 245 | $RM ${tmppublicpath}/proc_script.finished |
---|
| 246 | #Todo see if there is errors in the log file before copy |
---|
| 247 | $ECHO ">>>>>>>>>>>> Done $sourceRadio $dateDAQ CALIBON" |
---|
| 248 | ###### |
---|
| 249 | else |
---|
| 250 | ###### |
---|
| 251 | $ECHO ">>>>>>>>>>>>> ANALYSIS Part of ${sourceRadio} ${dateDAQ}" |
---|
| 252 | #go to the .../source/date-sourcelowercase directory |
---|
| 253 | #download Off/calibcycle<> and On/calibcycle<> directories |
---|
| 254 | $MKDIR -p ${topDir}/${dateDAQ}${srclower} |
---|
| 255 | cd ${topDir}/${dateDAQ}${srclower} |
---|
| 256 | aboveOnOffDir=`pwd` |
---|
| 257 | $ECHO "DEBUG (${scriptName}): we are in directory: <`pwd`>" |
---|
| 258 | # |
---|
| 259 | mode="Off" |
---|
| 260 | $ECHO "DEBUG (${scriptName}): START download the ${mode} calib fits files" |
---|
| 261 | inFileDirectory="./${mode}" |
---|
| 262 | $MKDIR -p ${inFileDirectory} |
---|
| 263 | listOfCalibCycle=( `ils ${i}/${mode} 2>&1 | $GREP -i "calibcycle"|$AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.11n` ) |
---|
| 264 | IFS=' |
---|
| 265 | ' |
---|
| 266 | listOfCalibCycle=( $( $PRINTF "%s\n" "${listOfCalibCycle[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 267 | IFS=$DefaultIFS |
---|
| 268 | |
---|
| 269 | firstCycleOff=`$ECHO ${listOfCalibCycle[0]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'` |
---|
| 270 | nCyclesOff=`expr ${#listOfCalibCycle[*]} - 1` |
---|
| 271 | |
---|
| 272 | lastCycleOff=`$ECHO ${listOfCalibCycle[${nCyclesOff}]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'` |
---|
| 273 | |
---|
| 274 | listOfCalibCycle=( "${listOfCalibCycle[@]/#/${i}/${mode}/}" ) |
---|
| 275 | |
---|
| 276 | |
---|
| 277 | for j in ${listOfCalibCycle[@]} |
---|
| 278 | do |
---|
| 279 | irodsDownDir="${j}" |
---|
| 280 | OUT=./getInFits.$$ |
---|
| 281 | iget -r -f -K ${irodsDownDir} ${inFileDirectory} > ${OUT} 2>&1 |
---|
| 282 | igetStatus=`$GREP "^ERROR" ${OUT}` |
---|
| 283 | if [ "<$igetStatus>" != "<>" ]; then |
---|
| 284 | $ECHO "FATAL (${scriptName}): error while iget fits files:" |
---|
| 285 | $ECHO $igetStatus |
---|
| 286 | $ECHO " ==> skip this run $sourceRadio $dateDAQ" |
---|
| 287 | continue |
---|
| 288 | fi |
---|
| 289 | $RM -f ${OUT} |
---|
| 290 | done |
---|
| 291 | $ECHO "DEBUG (${scriptName}): END download the ${mode} calib fits files" |
---|
| 292 | # |
---|
| 293 | mode="On" |
---|
| 294 | $ECHO "DEBUG (${scriptName}): START download the ${mode} calib fits files" |
---|
| 295 | inFileDirectory="./${mode}" |
---|
| 296 | $MKDIR -p ${inFileDirectory} |
---|
| 297 | |
---|
| 298 | listOfCalibCycle=( `ils ${i}/${mode} 2>&1 | $GREP -i "calibcycle" |$AWK 'BEGIN{FS="C- "}{print $2}' | $XARGS -i basename {} | $SORT -k1.11n` ) |
---|
| 299 | IFS=' |
---|
| 300 | ' |
---|
| 301 | listOfCalibCycle=( $( $PRINTF "%s\n" "${listOfCalibCycle[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 302 | IFS=$DefaultIFS |
---|
| 303 | |
---|
| 304 | firstCycleOn=`$ECHO ${listOfCalibCycle[0]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'` |
---|
| 305 | nCyclesOn=`expr ${#listOfCalibCycle[*]} - 1` |
---|
| 306 | |
---|
| 307 | lastCycleOn=`$ECHO ${listOfCalibCycle[${nCyclesOn}]} | $AWK '{match($0,"[0-9]+",arr); print arr[0]}'` |
---|
| 308 | |
---|
| 309 | listOfCalibCycle=( "${listOfCalibCycle[@]/#/${i}/${mode}/}" ) |
---|
| 310 | |
---|
| 311 | |
---|
| 312 | # |
---|
| 313 | #Check if there is the same number of cycles in Off and On mode |
---|
| 314 | # |
---|
[511] | 315 | #first cycle = max(firstCycleOn, firstCycleOff) |
---|
| 316 | #last cycle = min(lastCycleOn,lastCycleOff) |
---|
| 317 | |
---|
[507] | 318 | if [ ${firstCycleOn} -eq ${firstCycleOff} -a ${lastCycleOn} -eq ${lastCycleOff} ]; then |
---|
| 319 | firstCycle=${firstCycleOff} |
---|
| 320 | lastCycle=${lastCycleOff} |
---|
| 321 | else |
---|
[511] | 322 | $ECHO "INFO (${scriptName}): missmatch between Off and On mode" |
---|
[507] | 323 | $ECHO "${firstCycleOn} != ${firstCycleOff} OR ${lastCycleOn} != ${lastCycleOff}" |
---|
[511] | 324 | firstCycle=${firstCycleOff} |
---|
| 325 | if [ ${firstCycleOn} -gt ${firstCycle} ]; then |
---|
| 326 | firstCycle=${firstCycleOn} |
---|
| 327 | fi |
---|
| 328 | lastCycle=${lastCycleOff} |
---|
| 329 | if [ ${lastCycleOn} -lt ${lastCycle} ]; then |
---|
| 330 | lastCycle=${lastCycleOn} |
---|
| 331 | fi |
---|
[507] | 332 | fi |
---|
[511] | 333 | $ECHO "INFO (${scriptName}): use cycles [${firstCycle}, ${lastCycle}]" |
---|
| 334 | |
---|
[507] | 335 | |
---|
| 336 | for j in ${listOfCalibCycle[@]} |
---|
| 337 | do |
---|
| 338 | irodsDownDir="${j}" |
---|
| 339 | OUT=./getInFits.$$ |
---|
| 340 | iget -r -f -K ${irodsDownDir} ${inFileDirectory} > ${OUT} 2>&1 |
---|
| 341 | igetStatus=`$GREP "^ERROR" ${OUT}` |
---|
| 342 | if [ "<$igetStatus>" != "<>" ]; then |
---|
| 343 | $ECHO "FATAL (${scriptName}): error while iget fits files:" |
---|
| 344 | $ECHO $igetStatus |
---|
| 345 | $ECHO " ==> skip this run $sourceRadio $dateDAQ" |
---|
| 346 | continue |
---|
| 347 | fi |
---|
| 348 | $RM -f ${OUT} |
---|
| 349 | done |
---|
| 350 | $ECHO "DEBUG (${scriptName}): END download the ${mode} calib fits files" |
---|
| 351 | #Get sca file |
---|
| 352 | $ECHO "DEBUG (${scriptName}): START call getscafiles.sh ${sourceRadio} ${dateDAQ}" |
---|
| 353 | OUT1=./getScaStatus.$$ |
---|
| 354 | $RM -f ${tmppublicpath}/getscafiles.finished |
---|
| 355 | ${scriptpath}/getscafiles.sh ${sourceRadio} ${dateDAQ} > ${OUT1} 2>&1 |
---|
| 356 | while [ ! -f "${tmppublicpath}/getscafiles.finished" ]; do |
---|
| 357 | $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/getscafiles.finished" |
---|
| 358 | date +%T |
---|
| 359 | sleep 30 |
---|
| 360 | done |
---|
| 361 | $RM ${tmppublicpath}/getscafiles.finished |
---|
| 362 | $ECHO "DEBUG (${scriptName}): END" |
---|
| 363 | # |
---|
| 364 | getScaStatus=`$GREP "^\(FATAL\|ERROR\)" ${OUT1}` |
---|
| 365 | # |
---|
| 366 | if [ "<${getScaStatus}>" != "<>" ]; then |
---|
| 367 | $ECHO "FATAL (${scriptName}): error to get sca file for $sourceRadio $dateDAQ" |
---|
| 368 | $ECHO "DEBUG (${scriptName}): START with cat ${OUT1}" |
---|
| 369 | $CAT ${OUT1} |
---|
| 370 | $ECHO "DEBUG (${scriptName}): END" |
---|
| 371 | continue |
---|
| 372 | fi |
---|
| 373 | $RM -f ${OUT1} |
---|
| 374 | |
---|
| 375 | scaFile=`$FIND . -name "sca*.sum.trans" | $XARGS -i basename {}` |
---|
| 376 | |
---|
| 377 | #prepare job submission |
---|
| 378 | cd ${aboveOnOffDir} |
---|
| 379 | #the default spectra name is medfiltmtx, otherwise use -specname <a_string> |
---|
| 380 | |
---|
| 381 | logFile="analyse_CALIB_${sourceRadio}_${dateDAQ}.log" |
---|
| 382 | $ECHO "DEBUG (${scriptName}): execute the analysis... should not take long. `date`" |
---|
| 383 | if [ ${simulationMode} = "On" ]; then |
---|
| 384 | $ECHO "SIMUL: ${scriptpath}/Objs/analyse -act calib -inPath ${iojobpath} -source ${sourceRadio} -date ${dateDAQ} -sca ${scaFile} -specdir calibcycle -numcycle ${firstCycle},${lastCycle} -calibopt mean -debuglev 1 -freqBAOCalib ${freqBAOCalib} -bwBAOCalib ${bwBAOCalib} >& ${logFile}" |
---|
| 385 | cat > ${logFile} <<EOF |
---|
| 386 | Ok calibration finished |
---|
| 387 | EOF |
---|
| 388 | else |
---|
| 389 | ${scriptpath}/Objs/analyse -act calib -inPath ${iojobpath} -source ${sourceRadio} -date ${dateDAQ} -sca ${scaFile} -specdir calibcycle -numcycle ${firstCycle},${lastCycle} -calibopt mean -debuglev 1 -freqBAOCalib ${freqBAOCalib} -bwBAOCalib ${bwBAOCalib} >& ${logFile} |
---|
| 390 | fi |
---|
| 391 | $ECHO "DEBUG (${scriptName}): analysis finished `date`. Look for errors before saving to Irods" |
---|
| 392 | rcstatus=`$GREP -i "Ok calibration finished" ${logFile} | $WC -l` |
---|
| 393 | if [ ${rcstatus} -eq 0 ]; then |
---|
| 394 | $ECHO "INFO (${scriptName}): analysis problem for ${sourceRadio} ${dateDAQ}" |
---|
| 395 | $ECHO " START logfile" |
---|
| 396 | $CAT ${logFile} |
---|
| 397 | $ECHO " END logFile" |
---|
| 398 | #clean and leave |
---|
| 399 | cd ${aboveOnOffDir} |
---|
| 400 | $LS | $XARGS -i $RM -rf {} |
---|
| 401 | continue |
---|
| 402 | fi |
---|
| 403 | #Save into Irods |
---|
| 404 | $ECHO "DEBUG (${scriptName}): START save output files" |
---|
| 405 | $LS ${aboveOnOffDir} |
---|
| 406 | #use -f option for iput ONLY to force override |
---|
| 407 | if [ ${simulationMode} = "On" ]; then |
---|
| 408 | $ECHO "SIMUL: here we look for calib file and put them in Irods" |
---|
| 409 | else |
---|
| 410 | $FIND . -name "calib_*" -print | $XARGS -i iput -v -K {} ${i} |
---|
| 411 | fi |
---|
| 412 | #save analysis logfile |
---|
| 413 | $LS -l ${tmppublicpath} > /dev/null |
---|
| 414 | $CP ${logFile} ${tmppublicpath} |
---|
| 415 | $ECHO "DEBUG (${scriptName}): END save output files" |
---|
| 416 | #clean up to avoid scratch SIZE EXCEED LIMIT |
---|
| 417 | cd ${aboveOnOffDir} |
---|
| 418 | $LS | $XARGS -i $RM -rf {} |
---|
| 419 | fi |
---|
| 420 | done |
---|
| 421 | |
---|
| 422 | exit 0 |
---|