[535] | 1 | #!/bin/sh -xvf
|
---|
| 2 | #Basic tuning of system fuction used.
|
---|
| 3 | AWK=/bin/awk
|
---|
| 4 | SED=/bin/sed
|
---|
| 5 | GREP=/bin/grep
|
---|
| 6 | WC=/usr/bin/wc
|
---|
| 7 | RM=/bin/rm
|
---|
| 8 | CAT=/bin/cat
|
---|
| 9 | TOUCH=/bin/touch
|
---|
| 10 | DATE=/bin/date
|
---|
| 11 | ECHO=/bin/echo
|
---|
| 12 | LS=/bin/ls
|
---|
| 13 | MKDIR=/bin/mkdir
|
---|
| 14 | TR=/usr/bin/tr
|
---|
| 15 | FIND=/usr/bin/find
|
---|
| 16 | PRINTF=/usr/bin/printf
|
---|
| 17 | XARGS=/usr/bin/xargs
|
---|
| 18 | SORT=/bin/sort
|
---|
| 19 | QSUB=qsub
|
---|
| 20 |
|
---|
| 21 | DefaultIFS=$' \t\n'
|
---|
| 22 | IFS=$DefaultIFS
|
---|
| 23 |
|
---|
| 24 |
|
---|
| 25 | scriptName="`basename $0`"
|
---|
| 26 | $ECHO "Processing script ${scriptName} at `date`"
|
---|
| 27 | ######
|
---|
| 28 | # Local functions
|
---|
| 29 | ######
|
---|
| 30 | usage() {
|
---|
| 31 | echo "usage: $scriptName <source> <YYYYMMDD-directory> <type of process>"
|
---|
| 32 | echo " -<source> as Abell85"
|
---|
| 33 | echo " -<YYYYMMDD-directory> as 20110428"
|
---|
| 34 | echo " -<type of process> as GAIN|CALIBON|CALIBOFF|ON|OFF"
|
---|
| 35 | }
|
---|
| 36 | ######
|
---|
| 37 | # argument test
|
---|
| 38 | ######
|
---|
| 39 |
|
---|
| 40 | #Process cmd line args: the -src option is mandatory (source name as Abell85)
|
---|
| 41 | sourceRadio=
|
---|
| 42 | dateSelected=
|
---|
| 43 | typeofproc=
|
---|
| 44 | #use -sim option to simulate processing (debug the script as if...)
|
---|
| 45 | simulationMode=Off
|
---|
| 46 | #
|
---|
| 47 | #first and last cycle to process
|
---|
| 48 | #
|
---|
| 49 | firstCycle=
|
---|
| 50 | lastCycle=
|
---|
| 51 | while [ $# -gt 0 ]
|
---|
| 52 | do
|
---|
| 53 | case "$1" in
|
---|
| 54 | -src) sourceRadio=$2; shift;;
|
---|
| 55 | -date) dateSelected=$2; shift;;
|
---|
| 56 | -type) typeofproc=$2; shift;;
|
---|
| 57 | -fcycle) firstCycle=$2; shift;;
|
---|
| 58 | -lcycle) lastCycle=$2; shift;;
|
---|
| 59 | -sim) simulationMode=On;;
|
---|
| 60 | -h)
|
---|
| 61 | echo >&2 \
|
---|
| 62 | "usage: $0 -src souce -date YYYYMMDD -type type [-fcycle firstCycle] [-lcycle lastCycle] [-sim to trig simulation mode]"
|
---|
| 63 | exit 1;;
|
---|
| 64 | *) break;; # terminate while loop
|
---|
| 65 | esac
|
---|
| 66 | shift
|
---|
| 67 | done
|
---|
| 68 |
|
---|
| 69 | #Check input
|
---|
| 70 |
|
---|
| 71 | if [ "<${sourceRadio}>" = "<>" ]; then
|
---|
| 72 | $ECHO "FATAL: You have forgotten to select the source option (-src)"
|
---|
| 73 | exit 1
|
---|
| 74 | fi
|
---|
| 75 |
|
---|
| 76 | if [ "<${dateSelected}>" = "<>" ]; then
|
---|
| 77 | $ECHO "FATAL: You have forgotten to select the date option (-date)"
|
---|
| 78 | exit 1
|
---|
| 79 | fi
|
---|
| 80 |
|
---|
| 81 | if [ "<${typeofproc}>" = "<>" ]; then
|
---|
| 82 | $ECHO "FATAL: You have forgotten to select the type option (-type)"
|
---|
| 83 | exit 1
|
---|
| 84 | fi
|
---|
| 85 |
|
---|
| 86 |
|
---|
| 87 |
|
---|
| 88 | srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
|
---|
| 89 |
|
---|
| 90 |
|
---|
| 91 | #Path to public backupable path
|
---|
| 92 | publicpath="/afs/in2p3.fr/home/c/campagne/public"
|
---|
| 93 |
|
---|
| 94 | #temporary files to synchronize scripts
|
---|
| 95 | tmppublicpath=${TMPPUBLICPATH}
|
---|
| 96 | $LS -l ${tmppublicpath} > /dev/null
|
---|
| 97 |
|
---|
| 98 |
|
---|
| 99 | #Path where the job will do temporary IO
|
---|
| 100 | if [ ${ENVIRONMENT} = "INTERACTIVE" ]; then
|
---|
| 101 | iojobpath="/sps/baoradio/AmasNancay/JEC"
|
---|
| 102 | $MKDIR -p $iojobpath
|
---|
| 103 | elif [ ${ENVIRONMENT} = "BATCH" ] ; then
|
---|
| 104 | iojobpath=${TMPBATCH}
|
---|
| 105 | else
|
---|
| 106 | $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed"
|
---|
| 107 | touch ${tmppublicpath}/proc_script.finished
|
---|
| 108 | exit 1
|
---|
| 109 | fi
|
---|
| 110 | cd ${iojobpath}
|
---|
| 111 |
|
---|
| 112 | localpath="${sourceRadio}/${dateSelected}${srclower}"
|
---|
| 113 | $MKDIR -p ./${localpath}
|
---|
| 114 | cd ./${localpath}
|
---|
| 115 | mainDirectory=`pwd`
|
---|
| 116 |
|
---|
| 117 |
|
---|
| 118 | #Path of the utility scripts
|
---|
| 119 | scriptpath="/afs/in2p3.fr/home/c/campagne/private/work/AmasNancay"
|
---|
| 120 |
|
---|
| 121 |
|
---|
| 122 | #select file per cycle
|
---|
| 123 | #$ECHO "Select files process..."
|
---|
| 124 | #keep only lines with structure: cycle_number first,last,step
|
---|
| 125 | #Get sca files
|
---|
| 126 | $ECHO "DEBUG (${scriptName}): START call getscafiles.sh ${sourceRadio} ${dateSelected}"
|
---|
| 127 | OUT1=./getScaStatus.$$
|
---|
[540] | 128 | #JEC 29/9/11 avoid finished stuff
|
---|
| 129 | #$RM -f ${tmppublicpath}/getscafiles.finished
|
---|
[535] | 130 | ${scriptpath}/getscafiles.sh ${sourceRadio} ${dateSelected} > ${OUT1} 2>&1
|
---|
[540] | 131 | #while [ ! -f "${tmppublicpath}/getscafiles.finished" ]; do
|
---|
| 132 | # $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/getscafiles.finished"
|
---|
| 133 | # date +%T
|
---|
| 134 | # sleep 30
|
---|
| 135 | #done
|
---|
| 136 | #$RM -f ${tmppublicpath}/getscafiles.finished
|
---|
[535] | 137 | $ECHO "DEBUG (${scriptName}): END"
|
---|
| 138 |
|
---|
| 139 |
|
---|
| 140 | getScaStatus=`$GREP "^\(FATAL\|ERROR\)" ${OUT1}`
|
---|
| 141 |
|
---|
| 142 | if [ "<${getScaStatus}>" != "<>" ]; then
|
---|
| 143 | $ECHO "FATAL (${scriptName}): error to get sca file for $sourceRadio $dateSelected"
|
---|
| 144 | $ECHO "DEBUG (${scriptName}): START with cat ${OUT1}"
|
---|
| 145 | $CAT ${OUT1}
|
---|
| 146 | $ECHO "DEBUG (${scriptName}): END"
|
---|
[540] | 147 | #JEC 29/9/11 avoid finished stuff
|
---|
| 148 | # touch ${tmppublicpath}/proc_script.finished
|
---|
[535] | 149 | exit 1
|
---|
| 150 | fi
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 | scaFileSummarized=`$FIND . -name "sca*.sum" -print`
|
---|
| 154 | if [ "<${scaFileSummarized}>" = "<>" ]; then
|
---|
| 155 | $ECHO "FATAL (${scriptName}): strange sca file summarized not available: $sourceRadio $dateSelected"
|
---|
| 156 | $ECHO "DEBUG (${scriptName}): START with cat ${OUT1}"
|
---|
| 157 | $CAT ${OUT1}
|
---|
| 158 | $ECHO "DEBUG (${scriptName}): END"
|
---|
[540] | 159 | #JEC 29/9/11 avoid finished stuff
|
---|
| 160 | # touch ${tmppublicpath}/proc_script.finished
|
---|
[535] | 161 | exit 1
|
---|
| 162 | fi
|
---|
| 163 | $RM ${OUT1}
|
---|
| 164 |
|
---|
| 165 | scaFileSummarized=`basename $scaFileSummarized`
|
---|
| 166 |
|
---|
| 167 | #set Irods environment
|
---|
| 168 | . /usr/local/shared/bin/irods_env.sh -noverbose
|
---|
| 169 | #download header files to be used for signal files selction
|
---|
| 170 | $MKDIR -p ./Fiber1
|
---|
| 171 | dirFiberfile=`pwd`/Fiber1
|
---|
| 172 |
|
---|
| 173 | dirIrods="/baoradio/data/AmasNancay/${sourceRadio}/${dateSelected}${srclower}/Fiber1"
|
---|
| 174 |
|
---|
| 175 | listOfFiles=( `ils ${dirIrods} | $GREP -i "header" | $XARGS -i basename {} | $SORT -k1.7n` )
|
---|
| 176 | IFS='
|
---|
| 177 | '
|
---|
| 178 | listOfFiles=( $( $PRINTF "%s\n" "${listOfFiles[@]}" | $AWK 'x[$0]++ == 0' ) )
|
---|
| 179 | IFS=$DefaultIFS
|
---|
| 180 |
|
---|
| 181 | #
|
---|
| 182 | $ECHO "DEBUG (${scriptName}): Download if necessary the headers"
|
---|
| 183 | #
|
---|
| 184 | for ifile in ${listOfFiles[@]}
|
---|
| 185 | do
|
---|
| 186 | #test if the headers have not yet been downloaded
|
---|
| 187 | if [ ! -e ${dirFiberfile}/${ifile} ]; then
|
---|
| 188 | OUT2=./getheaders.$$
|
---|
| 189 | iget -f -K ${dirIrods}/${ifile} ${dirFiberfile} >${OUT2} 2>&1
|
---|
| 190 | igetStatus=`$GREP "^ERROR" ${OUT2}`
|
---|
| 191 | if [ "<$igetStatus>" != "<>" ]; then
|
---|
| 192 | $ECHO "FATAL (${scriptName}): error while iget:"
|
---|
| 193 | $ECHO $igetStatus
|
---|
[540] | 194 | #JEC 29/9/11 avoid finished stuff
|
---|
| 195 | # touch ${tmppublicpath}/proc_script.finished
|
---|
[535] | 196 | exit 1
|
---|
| 197 | fi
|
---|
| 198 | $RM -f $OUT2
|
---|
| 199 | fi
|
---|
| 200 | done
|
---|
| 201 | #
|
---|
| 202 | $ECHO "DEBUG (${scriptName}): START call select.sh ${scaFileSummarized} ${dirFiberfile} ${typeofproc}"
|
---|
| 203 | #
|
---|
| 204 | #Get list of file to process
|
---|
| 205 | headerFileSelected=./selectSignal.$$
|
---|
[540] | 206 | #JEC 29/9/11 avoid finished stuff
|
---|
| 207 | #$RM -f ${tmppublicpath}/select.finished
|
---|
[535] | 208 | ${scriptpath}/select.sh ${scaFileSummarized} ${dirFiberfile} ${typeofproc} | $GREP "^#[0-9]" | $SED "s/^#//" > $headerFileSelected
|
---|
[540] | 209 | #while [ ! -f "${tmppublicpath}/select.finished" ]; do
|
---|
| 210 | # $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/select.finished"
|
---|
| 211 | # date +%T
|
---|
| 212 | # sleep 30
|
---|
| 213 | #done
|
---|
| 214 | #$RM ${tmppublicpath}/select.finished
|
---|
[535] | 215 | #
|
---|
| 216 | $ECHO "DEBUG (${scriptName}): END"
|
---|
| 217 | #
|
---|
| 218 | $ECHO "DEBUG (${scriptName}): START filling cycleArray, filesArray"
|
---|
| 219 | #
|
---|
| 220 | declare -a cycleArray
|
---|
| 221 | declare -a filesArray
|
---|
| 222 | $ECHO "DEBUG (${scriptName}): IFS value between<>: <$IFS>"
|
---|
| 223 | IFS=$DefaultIFS
|
---|
| 224 | $ECHO "DEBUG (${scriptName}): START cat $headerFileSelected"
|
---|
| 225 | $CAT $headerFileSelected
|
---|
| 226 | $ECHO "DEBUG (${scriptName}): END cat $headerFileSelected"
|
---|
| 227 |
|
---|
| 228 | while read v1 v2
|
---|
| 229 | do
|
---|
| 230 | cycleArray[${#cycleArray[*]}]=$v1
|
---|
| 231 | filesArray[${#filesArray[*]}]=$v2
|
---|
| 232 | done < $headerFileSelected
|
---|
| 233 |
|
---|
| 234 | if [ ${#cycleArray[*]} -eq 0 -o ${#filesArray[*]} -eq 0 ]; then
|
---|
| 235 | $ECHO "FATAL (${scriptName}): no header file selected (${#cycleArray[*]}, ${#filesArray[*]})"
|
---|
[540] | 236 | #JEC 29/9/11 avoid finished stuff
|
---|
| 237 | # touch ${tmppublicpath}/proc_script.finished
|
---|
[535] | 238 | exit 1
|
---|
| 239 | else
|
---|
| 240 | $ECHO "DEBUG (${scriptName}): non zero elements found for cycleArray and filesArray"
|
---|
| 241 | fi
|
---|
| 242 |
|
---|
| 243 | #
|
---|
| 244 | $ECHO "DEBUG (${scriptName}): number of elements <${#cycleArray[*]}> <${#filesArray[*]}>"
|
---|
| 245 | $ECHO "DEBUG (${scriptName}): END"
|
---|
| 246 | #
|
---|
| 247 | # (timeShift)
|
---|
| 248 | #Add 3sec to start ON / OFF
|
---|
| 249 | #Substract 4sec to start DAB ON / OFF
|
---|
| 250 | #
|
---|
| 251 | #Take care: Cycle numbering starts at 1 in SCAFiles while Arrays index start at 0
|
---|
| 252 | #
|
---|
| 253 | #for GAIN the reference cycle takes the middle of the run
|
---|
| 254 | #
|
---|
| 255 | #nwinmean donne le nombre de fenetre tspwin utilise pour faire calculer la moyenne des medianes de chaque fenetre
|
---|
| 256 | #This is the nimber of paquets of the time window which change according to processing type
|
---|
| 257 | $ECHO "DEBUG (${scriptName}): START switch on $typeofproc"
|
---|
| 258 | #
|
---|
| 259 | case "$typeofproc" in
|
---|
| 260 | GAIN)
|
---|
| 261 | $ECHO "process signal files for GAIN phase"
|
---|
| 262 | ingain=""
|
---|
| 263 | freqfilter="-freqfilter -"
|
---|
| 264 | nwinmean="1"
|
---|
| 265 | tspwin="5120"
|
---|
| 266 | dirName="Off"
|
---|
| 267 | cyclebasename="gaincycle"
|
---|
| 268 | indexStartHour="6"
|
---|
| 269 | timeShift="-4"
|
---|
| 270 | timeDuration="14"
|
---|
| 271 | firstCycleId=`expr ${#cycleArray[*]} / 2`
|
---|
| 272 | firstCycleId=`expr ${firstCycleId} - 1`
|
---|
| 273 | lastp1CycleId=`expr ${firstCycleId} + 1`
|
---|
| 274 | ;;
|
---|
| 275 | ON)
|
---|
| 276 | $ECHO "process signal files for ON phases"
|
---|
| 277 | ingain="-gain gain_${dateSelected}_${srclower}.fits"
|
---|
| 278 | freqfilter="-freqfilter 16"
|
---|
| 279 | nwinmean="5"
|
---|
| 280 | tspwin="5120"
|
---|
| 281 | dirName="On"
|
---|
| 282 | cyclebasename="datacycle"
|
---|
| 283 | indexStartHour="4"
|
---|
| 284 | timeShift="3"
|
---|
| 285 | timeDuration="30"
|
---|
| 286 | firstCycleId="0"
|
---|
| 287 | lastp1CycleId="${#cycleArray[@]}"
|
---|
| 288 | ;;
|
---|
| 289 | OFF)
|
---|
| 290 | $ECHO "process signal files for OFF phases"
|
---|
| 291 | ingain="-gain gain_${dateSelected}_${srclower}.fits"
|
---|
| 292 | freqfilter="-freqfilter 16"
|
---|
| 293 | nwinmean="5"
|
---|
| 294 | tspwin="5120"
|
---|
| 295 | dirName="Off"
|
---|
| 296 | cyclebasename="datacycle"
|
---|
| 297 | indexStartHour="8"
|
---|
| 298 | timeShift="3"
|
---|
| 299 | timeDuration="30"
|
---|
| 300 | firstCycleId="0"
|
---|
| 301 | lastp1CycleId="${#cycleArray[@]}"
|
---|
| 302 | ;;
|
---|
| 303 | CALIBON)
|
---|
| 304 | $ECHO "process signal files for CALIBRATION ON phases"
|
---|
| 305 | ingain="-gain gain_${dateSelected}_${srclower}.fits"
|
---|
| 306 | freqfilter="-freqfilter 16"
|
---|
| 307 | nwinmean="1"
|
---|
| 308 | tspwin="1024"
|
---|
| 309 | dirName="On"
|
---|
| 310 | cyclebasename="calibcycle"
|
---|
| 311 | indexStartHour="2"
|
---|
| 312 | timeShift="-4"
|
---|
| 313 | timeDuration="14"
|
---|
| 314 | firstCycleId="0"
|
---|
| 315 | lastp1CycleId="${#cycleArray[@]}"
|
---|
| 316 | ;;
|
---|
| 317 | CALIBOFF)
|
---|
| 318 | $ECHO "process signal files for CALIBRATION OFF phases"
|
---|
| 319 | ingain="-gain gain_${dateSelected}_${srclower}.fits"
|
---|
| 320 | freqfilter="-freqfilter 16"
|
---|
| 321 | nwinmean="1"
|
---|
| 322 | tspwin="1024"
|
---|
| 323 | dirName="Off"
|
---|
| 324 | cyclebasename="calibcycle"
|
---|
| 325 | indexStartHour="6"
|
---|
| 326 | timeShift="-4"
|
---|
| 327 | timeDuration="14"
|
---|
| 328 | firstCycleId="0"
|
---|
| 329 | lastp1CycleId="${#cycleArray[@]}"
|
---|
| 330 | ;;
|
---|
| 331 | *)
|
---|
| 332 | $ECHO "FATAL (${scriptName}): type of processing"
|
---|
| 333 | usage
|
---|
[540] | 334 | #JEC 29/9/11 avoid finished stuff
|
---|
| 335 | # touch ${tmppublicpath}/proc_script.finished
|
---|
[535] | 336 | exit 1
|
---|
| 337 | ;;
|
---|
| 338 | esac
|
---|
| 339 | #
|
---|
| 340 | $ECHO "DEBUG (${scriptName}): END"
|
---|
| 341 | #
|
---|
| 342 | #
|
---|
| 343 | #Compute time windows (Warning usage of GMT date)
|
---|
| 344 | #
|
---|
| 345 | $ECHO "DEBUG (${scriptName}): START compute time windows"
|
---|
| 346 | OUT=./baotiming.$$
|
---|
| 347 | ${AWK} -v datesys=${DATE} -v type=${indexStartHour} -v shift=${timeShift} '
|
---|
| 348 | BEGIN {FS=","}
|
---|
| 349 | {
|
---|
| 350 | phaseStart=$type
|
---|
| 351 | cmd=sprintf("%s +%%s -d \"%s\" ",datesys,phaseStart);
|
---|
| 352 | (cmd | getline phstart);
|
---|
| 353 | close(cmd);
|
---|
| 354 | newstart = phstart+shift;
|
---|
| 355 | cmd=sprintf("%s +%%T -d \"1970-01-01 %s sec GMT\"",datesys,newstart);
|
---|
| 356 | (cmd | getline newStart);
|
---|
| 357 | close(cmd);
|
---|
| 358 | print $1,newStart,phaseStart;
|
---|
| 359 | }
|
---|
| 360 | ' ${scaFileSummarized} > ${OUT}
|
---|
| 361 | #
|
---|
| 362 | $ECHO "DEBUG (${scriptName}): END"
|
---|
| 363 | #
|
---|
| 364 | $ECHO "DEBUG (${scriptName}): START cat ${OUT}"
|
---|
| 365 | $CAT ${OUT}
|
---|
| 366 | $ECHO "DEBUG (${scriptName}): END cat ${OUT}"
|
---|
| 367 | #
|
---|
| 368 | $ECHO "DEBUG (${scriptName}): START filling cylceArrayBis timeArray"
|
---|
| 369 | #
|
---|
| 370 | declare -a cycleArrayBis
|
---|
| 371 | declare -a timeArray
|
---|
| 372 | $ECHO "DEBUG (${scriptName}): IFS value between<>: <$IFS>"
|
---|
| 373 | IFS=$DefaultIFS
|
---|
| 374 | #select the selected cycles
|
---|
| 375 | idtofind="0"
|
---|
| 376 | while read v1 v2 v3
|
---|
| 377 | do
|
---|
| 378 | if [ ${idtofind} -lt ${#cycleArray[*]} ]; then
|
---|
| 379 | if [ ${v1} = ${cycleArray[${idtofind}]} ]; then
|
---|
| 380 | cycleArrayBis[${#cycleArrayBis[*]}]=$v1
|
---|
| 381 | timeArray[${#timeArray[*]}]=$v2
|
---|
| 382 | idtofind=`expr ${idtofind} + 1`
|
---|
| 383 | fi
|
---|
| 384 | fi
|
---|
| 385 | done < ${OUT}
|
---|
| 386 | $ECHO "DEBUG (${scriptName}): number of elements ${#cycleArrayBis[*]} ${#timeArray[*]}"
|
---|
| 387 | $ECHO "DEBUG (${scriptName}): END"
|
---|
| 388 |
|
---|
| 389 |
|
---|
| 390 | #########################
|
---|
| 391 | # specmfib exe
|
---|
| 392 | #########################
|
---|
| 393 | prg="/afs/in2p3.fr/throng/baoradio/Library/Progs/TAcq/Objs/specmfib"
|
---|
| 394 | if [ ! -e $prg ]; then
|
---|
| 395 | $ECHO "FATAL (${scriptName}): $prg not found"
|
---|
[540] | 396 | #JEC 29/9/11 avoid finished stuff
|
---|
| 397 | # touch ${tmppublicpath}/proc_script.finished
|
---|
[535] | 398 | exit 1
|
---|
| 399 | fi
|
---|
| 400 |
|
---|
| 401 |
|
---|
| 402 | dirFiberfile=${iojobpath}/${localpath}
|
---|
| 403 |
|
---|
| 404 | curDir=`pwd`
|
---|
| 405 | #
|
---|
| 406 | $ECHO "DEBUG (${scriptName}): in principle $dirFiberfile == $curDir "
|
---|
| 407 | #
|
---|
| 408 | #force single channel
|
---|
| 409 | forceSingle="-singlechan"
|
---|
| 410 | #debug
|
---|
| 411 | prtlevel="1"
|
---|
| 412 |
|
---|
| 413 |
|
---|
| 414 | #Loop on cycles
|
---|
| 415 | ##
|
---|
| 416 | $ECHO "DEBUG (${scriptName}): START loop on cycles Ids ${firstCycleId} to ${lastp1CycleId}"
|
---|
| 417 |
|
---|
| 418 | #write the script to be send to Batch
|
---|
| 419 | #get gain file if necessary
|
---|
| 420 | if [ ${typeofproc} != "GAIN" ]; then
|
---|
| 421 | OUT2=./igetStatus.$$
|
---|
| 422 | iget /baoradio/data/AmasNancay/${localpath}/gain_${dateSelected}_${srclower}.fits >${OUT2} 2>&1
|
---|
| 423 | igetStatus=`$GREP "^ERROR" ${OUT2}`
|
---|
| 424 | if [ "<${igetStatus}>" != "<>" ]; then
|
---|
| 425 | $ECHO "FATAL (${scriptName}): error while iget:"
|
---|
| 426 | $ECHO $igetStatus
|
---|
[540] | 427 | #JEC 29/9/11 avoid finished stuff
|
---|
| 428 | # touch ${tmppublicpath}/${jobBatchName}.finished
|
---|
[535] | 429 | exit 1
|
---|
| 430 | fi
|
---|
| 431 | $RM ${OUT2}
|
---|
| 432 | fi
|
---|
| 433 |
|
---|
| 434 |
|
---|
| 435 | for ((i=${firstCycleId};i<${lastp1CycleId};i++)); do
|
---|
| 436 | #
|
---|
[540] | 437 |
|
---|
| 438 | ####
|
---|
| 439 | # Check daq status
|
---|
| 440 | #JEC 1/10/11 Use generic baodaqstatus name
|
---|
| 441 | ####
|
---|
| 442 | #get the daq current irod status
|
---|
| 443 | #tag=`${DATE} +%F`
|
---|
| 444 | #OUT1=${publicpath}/baodaqstatus-${tag}.txt
|
---|
| 445 | OUT1=${publicpath}/baodaqstatus-current.txt
|
---|
| 446 |
|
---|
| 447 | if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then
|
---|
| 448 | $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
|
---|
| 449 | exit 1
|
---|
| 450 | # $ECHO "We should bring the DAQ status more up to date, this take 1 or 2min..."
|
---|
| 451 | #JEC 29/9/11 avoid finished stuff
|
---|
| 452 | # $RM -f ${tmppublicpath}/statusdaq.finished
|
---|
| 453 | # ${scriptpath}/statusdaq.sh > ${OUT1}
|
---|
| 454 | # while [ ! -f "${tmppublicpath}/statusdaq.finished" ]; do
|
---|
| 455 | # sleep 30
|
---|
| 456 | # done
|
---|
| 457 | # $RM ${tmppublicpath}/statusdaq.finished
|
---|
| 458 | #protect against remove/rewriting
|
---|
| 459 | # $CHMOD -v 444 ${OUT1}
|
---|
| 460 | fi
|
---|
| 461 |
|
---|
[535] | 462 | #time window selection
|
---|
| 463 | tmproc="-tmproc ${timeArray[${i}]},${timeDuration}"
|
---|
| 464 | #cycle <number>
|
---|
| 465 | cycle="${cycleArray[${i}]}"
|
---|
| 466 | if [ "<${firstCycle}>" != "<>" -a "<${lastCycle}>" != "<>" ]; then
|
---|
| 467 | if [ ${cycle} -lt ${firstCycle} -o ${cycle} -gt ${lastCycle} ]; then
|
---|
| 468 | continue
|
---|
| 469 | fi
|
---|
| 470 | fi
|
---|
| 471 | $ECHO "DEBUG (${scriptName}): process cycle $cycle"
|
---|
| 472 |
|
---|
| 473 | #cycle <name><number>
|
---|
| 474 | cycle="${cyclebasename}${cycleArray[${i}]}"
|
---|
| 475 | #signal files selection
|
---|
| 476 | infiles="${filesArray[${i}]}"
|
---|
| 477 | #
|
---|
| 478 | #Prepare BQS parameters: MEMORY, CPU...#
|
---|
| 479 | infilesArray=( `$ECHO $infiles | $AWK 'BEGIN {FS=","} {for(i=1;i<NF;i++)print $i;}'` )
|
---|
| 480 | IFS='
|
---|
| 481 | '
|
---|
| 482 | infilesArray=( $( printf "%s\n" "${infilesArray[@]}" | awk 'x[$0]++ == 0' ) )
|
---|
| 483 | IFS=$DefaultIFS
|
---|
| 484 | firstFile=${infilesArray[0]}
|
---|
| 485 | lastFile=${infilesArray[1]}
|
---|
| 486 | #
|
---|
| 487 | #
|
---|
| 488 | #
|
---|
| 489 | #get signals files
|
---|
| 490 | OUT3=./getsignals.$$
|
---|
[540] | 491 | #JEC 29/9/11 avoid finished stuff
|
---|
| 492 | # $RM -f ${tmppublicpath}/getsignalfiles.finished
|
---|
[535] | 493 | ${scriptpath}/getsignalfiles.sh ${sourceRadio} ${dateSelected} ${firstFile} ${lastFile} > ${OUT3} 2>&1
|
---|
[540] | 494 | # while [ ! -f "${tmppublicpath}/getsignalfiles.finished" ]; do
|
---|
| 495 | # $ECHO "INFO (${scriptName}): waiting for ${tmppublicpath}/getsignalfiles.finished"
|
---|
| 496 | # date +%T
|
---|
| 497 | # sleep 30
|
---|
| 498 | # done
|
---|
| 499 | # $RM ${tmppublicpath}/getsignalfiles.finished
|
---|
[535] | 500 |
|
---|
| 501 | getSignals=`$GREP "^FATAL" ${OUT3}`
|
---|
| 502 | if [ "<$getSignals>" != "<>" ]; then
|
---|
| 503 | $ECHO "FATAL (${scriptName}): error while get signals"
|
---|
| 504 | $ECHO $getSignals
|
---|
[540] | 505 | #JEC 29/9/11 avoid finished stuff
|
---|
| 506 | # touch ${tmppublicpath}/${jobBatchName}.finished
|
---|
[535] | 507 | exit 1
|
---|
| 508 | fi
|
---|
| 509 | $RM ${OUT3}
|
---|
| 510 |
|
---|
| 511 | #location of the signal file
|
---|
| 512 | fibfile="${curDir} 1,2"
|
---|
| 513 | #
|
---|
| 514 | outDir=${curDir}/${dirName}/${cycle}
|
---|
| 515 | $MKDIR -p ${outDir}
|
---|
| 516 |
|
---|
| 517 | #
|
---|
| 518 | # where ami...
|
---|
| 519 | #
|
---|
| 520 | $ECHO "We are here `pwd`"
|
---|
| 521 | $LS -lrth
|
---|
| 522 | $FIND . -name "igetStatus.*" | $XARGS -i $CAT {}
|
---|
| 523 | $LS ./Fiber1 | $WC -l
|
---|
| 524 | $LS ./Fiber2 | $WC -l
|
---|
| 525 | $LS -lR ${outDir}
|
---|
| 526 |
|
---|
| 527 | #Note: here act=gain means only that specmfib will use median-like algorithms (not only for gains...)
|
---|
| 528 | $prg -act gain $forceSingle $freqfilter -prt $prtlevel -out ${outDir} -nmean $nwinmean $ingain $tmproc -tspwin ${tspwin},0,0 -in $infiles ${fibfile}
|
---|
| 529 |
|
---|
| 530 | $ECHO ${outDir}
|
---|
| 531 | $LS -lrt ${outDir}
|
---|
| 532 |
|
---|
| 533 | #save results to Irods (use option -f ONLY to force override)
|
---|
| 534 | iput -v -K -r ${curDir}/${dirName} /baoradio/data/AmasNancay/${localpath}
|
---|
| 535 | #
|
---|
| 536 | #clean the signal files which can at the end of the day fill completly the scratch directory of the batch work/AmasNancayer
|
---|
| 537 | $RM -rf ${iojobpath}/${localpath}/Fiber1
|
---|
| 538 | $RM -rf ${iojobpath}/${localpath}/Fiber2
|
---|
| 539 | $RM -rf ${iojobpath}/${localpath}/${typeofproc}
|
---|
| 540 |
|
---|
| 541 | #
|
---|
| 542 | #
|
---|
| 543 |
|
---|
| 544 | #end loop on cycles
|
---|
| 545 | done
|
---|
| 546 | #
|
---|
| 547 | $ECHO "DEBUG (${scriptName}): END loop on cycles"
|
---|
| 548 | #
|
---|
[540] | 549 | #JEC 29/9/11 avoid finished stuff
|
---|
| 550 | #touch ${tmppublicpath}/proc_script.finished
|
---|
[535] | 551 | exit 0
|
---|