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