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