[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}";; |
---|
[635] | 64 | 3C273) $ECHO "INFO (${scriptName}): process ${sourceRadio}";; |
---|
[543] | 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=${TMPPUBLICPATH} |
---|
| 77 | #wakeup the NFS disk |
---|
| 78 | $LS -l ${tmppublicpath} > /dev/null |
---|
| 79 | |
---|
| 80 | #Path where the job will do temporary IO |
---|
[579] | 81 | . ${SCRIPTPATH}/set_iojobpath.sh |
---|
| 82 | iojobpath=$(set_iojobpath) |
---|
[543] | 83 | cd ${iojobpath} |
---|
| 84 | |
---|
| 85 | localpath="${sourceRadio}" |
---|
| 86 | $MKDIR -p ./${localpath} |
---|
| 87 | cd ./${localpath} |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | #Path of the utility scripts |
---|
[575] | 91 | scriptpath=${SCRIPTPATH} |
---|
[543] | 92 | |
---|
| 93 | OUT1=${publicpath}/baodaqstatus-current.txt |
---|
| 94 | if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then |
---|
| 95 | $ECHO "FATAL (${scriptName}): ${OUT1} has a problem" |
---|
| 96 | exit 1 |
---|
| 97 | fi |
---|
| 98 | |
---|
| 99 | |
---|
| 100 | |
---|
| 101 | $ECHO "You have selected sourceRadio = ${sourceRadio} [date = ${dateSelected}]" |
---|
[626] | 102 | #JEC 14/12/11 One should take care of DR extension for Drift Scan |
---|
| 103 | #tableau=( `$GREP -i "${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` ) |
---|
| 104 | tableau=( `$GREP -i "${sourceRadio}/${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` ) |
---|
[543] | 105 | IFS=' |
---|
| 106 | ' |
---|
| 107 | tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 108 | IFS=$DefaultIFS |
---|
| 109 | |
---|
| 110 | $ECHO "We are in directory `pwd`" |
---|
| 111 | |
---|
| 112 | for i in ${tableau[@]} |
---|
| 113 | do |
---|
| 114 | # |
---|
| 115 | |
---|
| 116 | $ECHO "DEBUG: (${scriptName}) irods root dir $i" |
---|
| 117 | |
---|
[557] | 118 | #ON-OFF avec les RAW files normalises |
---|
[543] | 119 | file=`ils ${i} 2>&1 | $GREP -i "diffOnOffRAw_.*\.ppf"` |
---|
| 120 | file=`$ECHO $file` |
---|
| 121 | if [ "<${file}>" != "<>" ]; then |
---|
[557] | 122 | iget -f -v ${i}/${file} |
---|
[543] | 123 | fi |
---|
| 124 | |
---|
[557] | 125 | #ON & OFF RAW files normalises |
---|
[543] | 126 | file=`ils ${i} 2>&1 | $GREP -i "dataRAw_.*\.ppf"` |
---|
| 127 | file=`$ECHO $file` |
---|
| 128 | if [ "<${file}>" != "<>" ]; then |
---|
[557] | 129 | iget -f -v ${i}/${file} |
---|
[543] | 130 | fi |
---|
| 131 | |
---|
[557] | 132 | #fichiers de calibrations BAO |
---|
| 133 | calibfiles=( `ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" ` ) |
---|
| 134 | IFS=' |
---|
| 135 | ' |
---|
| 136 | calibfiles=( $( $PRINTF "%s\n" "${calibfiles[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 137 | IFS=$DefaultIFS |
---|
[543] | 138 | |
---|
[557] | 139 | for j in ${calibfiles[@]} |
---|
| 140 | do |
---|
| 141 | file=`$ECHO $j` |
---|
| 142 | iget -f -v ${i}/${file} |
---|
| 143 | done |
---|
[543] | 144 | |
---|
| 145 | done |
---|
| 146 | |
---|
| 147 | exit 0 |
---|