[543] | 1 | #!/bin/sh -xvf |
---|
| 2 | #Perform the ON-OFF analysis |
---|
| 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 | dateSelected= |
---|
| 33 | simulationMode=Off |
---|
| 34 | while [ $# -gt 0 ] |
---|
| 35 | do |
---|
| 36 | case "$1" in |
---|
| 37 | -src) sourceRadio=$2; shift;; |
---|
| 38 | -date) dateSelected=$2; shift;; |
---|
| 39 | -sim) simulationMode=On;; |
---|
| 40 | -h) |
---|
| 41 | echo >&2 \ |
---|
| 42 | "usage: $0 -src souce -date YYYYMMDD [-sim to trig simulation mode]" |
---|
| 43 | exit 1;; |
---|
| 44 | *) break;; # terminate while loop |
---|
| 45 | esac |
---|
| 46 | shift |
---|
| 47 | done |
---|
| 48 | |
---|
| 49 | |
---|
| 50 | if [ ${simulationMode} = "On" ]; then |
---|
| 51 | $ECHO "INFO ${scriptName} running in SIMUL mode" |
---|
| 52 | fi |
---|
| 53 | |
---|
| 54 | if [ "<${sourceRadio}>" = "<>" ]; then |
---|
| 55 | $ECHO "FATAL: You have forgotten to select the source option (-src)" |
---|
| 56 | exit 1 |
---|
| 57 | fi |
---|
| 58 | |
---|
| 59 | case ${sourceRadio} in |
---|
| 60 | Abell85) $ECHO "INFO (${scriptName}): process ${sourceRadio}";; |
---|
| 61 | Abell2440) $ECHO "INFO (${scriptName}): process ${sourceRadio}";; |
---|
| 62 | Abell1205) $ECHO "INFO (${scriptName}): process ${sourceRadio}";; |
---|
[601] | 63 | NGC4383) $ECHO "INFO (${scriptName}): process ${sourceRadio}";; |
---|
[543] | 64 | *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen" |
---|
| 65 | exit 1;; |
---|
| 66 | esac |
---|
| 67 | |
---|
| 68 | srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" ` |
---|
| 69 | |
---|
| 70 | #Path to public backupable path |
---|
| 71 | publicpath="/afs/in2p3.fr/home/c/campagne/public" |
---|
| 72 | |
---|
| 73 | |
---|
| 74 | #temporary files to synchronize scripts |
---|
| 75 | tmppublicpath=${TMPPUBLICPATH} |
---|
| 76 | #wakeup the NFS disk |
---|
| 77 | $LS -l ${tmppublicpath} > /dev/null |
---|
| 78 | |
---|
| 79 | #Path where the job will do temporary IO |
---|
[579] | 80 | . ${SCRIPTPATH}/set_iojobpath.sh |
---|
| 81 | iojobpath=$(set_iojobpath) |
---|
[543] | 82 | cd ${iojobpath} |
---|
| 83 | |
---|
| 84 | localpath="${sourceRadio}" |
---|
| 85 | $MKDIR -p ./${localpath} |
---|
| 86 | cd ./${localpath} |
---|
| 87 | |
---|
| 88 | |
---|
| 89 | #Path of the utility scripts |
---|
[575] | 90 | scriptpath=${SCRIPTPATH} |
---|
[543] | 91 | |
---|
| 92 | OUT1=${publicpath}/baodaqstatus-current.txt |
---|
| 93 | if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then |
---|
| 94 | $ECHO "FATAL (${scriptName}): ${OUT1} has a problem" |
---|
| 95 | exit 1 |
---|
| 96 | fi |
---|
| 97 | |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | $ECHO "You have selected sourceRadio = ${sourceRadio} [date = ${dateSelected}]" |
---|
[626] | 101 | #JEC 14/12/11 One should take care of DR extension for Drift Scan |
---|
| 102 | #tableau=( `$GREP -i "${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` ) |
---|
| 103 | tableau=( `$GREP -i "${sourceRadio}/${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` ) |
---|
[543] | 104 | IFS=' |
---|
| 105 | ' |
---|
| 106 | tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 107 | IFS=$DefaultIFS |
---|
| 108 | |
---|
| 109 | $ECHO "We are in directory `pwd`" |
---|
| 110 | |
---|
| 111 | for i in ${tableau[@]} |
---|
| 112 | do |
---|
| 113 | # |
---|
| 114 | |
---|
| 115 | $ECHO "DEBUG: (${scriptName}) irods root dir $i" |
---|
| 116 | |
---|
[557] | 117 | #ON-OFF avec les RAW files normalises |
---|
[543] | 118 | file=`ils ${i} 2>&1 | $GREP -i "diffOnOffRAw_.*\.ppf"` |
---|
| 119 | file=`$ECHO $file` |
---|
| 120 | if [ "<${file}>" != "<>" ]; then |
---|
[557] | 121 | iget -f -v ${i}/${file} |
---|
[543] | 122 | fi |
---|
| 123 | |
---|
[557] | 124 | #ON & OFF RAW files normalises |
---|
[543] | 125 | file=`ils ${i} 2>&1 | $GREP -i "dataRAw_.*\.ppf"` |
---|
| 126 | file=`$ECHO $file` |
---|
| 127 | if [ "<${file}>" != "<>" ]; then |
---|
[557] | 128 | iget -f -v ${i}/${file} |
---|
[543] | 129 | fi |
---|
| 130 | |
---|
[557] | 131 | #fichiers de calibrations BAO |
---|
| 132 | calibfiles=( `ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" ` ) |
---|
| 133 | IFS=' |
---|
| 134 | ' |
---|
| 135 | calibfiles=( $( $PRINTF "%s\n" "${calibfiles[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 136 | IFS=$DefaultIFS |
---|
[543] | 137 | |
---|
[557] | 138 | for j in ${calibfiles[@]} |
---|
| 139 | do |
---|
| 140 | file=`$ECHO $j` |
---|
| 141 | iget -f -v ${i}/${file} |
---|
| 142 | done |
---|
[543] | 143 | |
---|
| 144 | done |
---|
| 145 | |
---|
| 146 | exit 0 |
---|