[519] | 1 | #!/bin/sh |
---|
| 2 | #Status de l'etat de la production des fichiers INPUT de calibrations |
---|
| 3 | GREP=/bin/grep |
---|
| 4 | AWK=/bin/awk |
---|
| 5 | ECHO=/bin/echo |
---|
| 6 | MKDIR=/bin/mkdir |
---|
| 7 | CAT=/bin/cat |
---|
| 8 | PRINTF=/usr/bin/printf |
---|
| 9 | RM=/bin/rm |
---|
| 10 | SORT=/bin/sort |
---|
| 11 | XARGS=/usr/bin/xargs |
---|
| 12 | WC=/usr/bin/wc |
---|
| 13 | DefaultIFS=$' \t\n' |
---|
| 14 | IFS=$DefaultIFS |
---|
| 15 | |
---|
| 16 | # Irods environment settings |
---|
| 17 | . /usr/local/shared/bin/irods_env.sh -noverbose |
---|
| 18 | |
---|
| 19 | scriptName="`basename $0`" |
---|
| 20 | $ECHO "Processing script ${scriptName} at `date`" |
---|
| 21 | |
---|
| 22 | #Path to public backupable path |
---|
| 23 | publicpath="/afs/in2p3.fr/home/c/campagne/public" |
---|
| 24 | |
---|
| 25 | #Path where the job will do temporary IO |
---|
| 26 | if [ ${ENVIRONMENT} == "INTERACTIVE" ]; then |
---|
| 27 | iojobpath="/sps/baoradio/AmasNancay/JEC" |
---|
| 28 | $MKDIR -p $iojobpath |
---|
| 29 | elif [ ${ENVIRONMENT} == "BATCH" ] ; then |
---|
| 30 | iojobpath=${TMPBATCH} |
---|
| 31 | else |
---|
| 32 | $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed" |
---|
| 33 | exit 1 |
---|
| 34 | fi |
---|
| 35 | cd ${iojobpath} |
---|
| 36 | |
---|
| 37 | |
---|
| 38 | OUT1=./baoils.$$ |
---|
| 39 | ils /baoradio/data/AmasNancay/ > ${OUT1} |
---|
| 40 | OUT2=./baoawk1.$$ |
---|
| 41 | $AWK '($1=="C-") {print $2}' ${OUT1} > ${OUT2} |
---|
| 42 | $RM $OUT1 |
---|
| 43 | #Sequence |
---|
| 44 | listeSources=( `$CAT $OUT2 | $AWK '{print $1}'` ) |
---|
| 45 | IFS=' |
---|
| 46 | ' |
---|
| 47 | listeSources=( $( $PRINTF "%s\n" "${listeSources[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 48 | IFS=$DefaultIFS |
---|
| 49 | $RM $OUT2 |
---|
| 50 | |
---|
| 51 | for i in ${listeSources[@]} |
---|
| 52 | do |
---|
| 53 | #nb: $i contains the full path |
---|
| 54 | $ECHO "source ${i}" |
---|
| 55 | sourceName=`basename ${i}` |
---|
| 56 | listeDates=( `ils $i | $AWK '($1=="C-"){print $2}'`) |
---|
| 57 | IFS=' |
---|
| 58 | ' |
---|
| 59 | listeDates=( $( $PRINTF "%s\n" "${listeDates[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 60 | IFS=$DefaultIFS |
---|
| 61 | |
---|
| 62 | for j in ${listeDates[@]} |
---|
| 63 | do |
---|
| 64 | #nb: $j contains the full path |
---|
| 65 | # $ECHO "run ${j}" |
---|
| 66 | # |
---|
| 67 | #Off directory |
---|
| 68 | # |
---|
| 69 | dateField=`basename ${j}` |
---|
| 70 | sourceDate="${sourceName}-${dateField}" |
---|
| 71 | #look if final data processing files exist |
---|
[531] | 72 | onOffOk=`ils ${j} | $GREP -i "data.*\.ppf\|diff.*\.ppf" | $WC -l` |
---|
[519] | 73 | offDirExist=`ils ${j} | $GREP -i "Off" | $WC -l` |
---|
| 74 | if [ ${offDirExist} != 0 ]; then |
---|
| 75 | listeCyclesOff=( `ils ${j}/Off | $GREP -i "datacycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` ) |
---|
| 76 | IFS=' |
---|
| 77 | ' |
---|
| 78 | listeCyclesOff=( $( $PRINTF "%s\n" "${listeCyclesOff[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 79 | IFS=$DefaultIFS |
---|
| 80 | |
---|
| 81 | if [ ${#listeCyclesOff[*]} != 0 ]; then |
---|
| 82 | for c in ${listeCyclesOff[@]} |
---|
| 83 | do |
---|
| 84 | #nb: $c has the format of datacycle<number> |
---|
| 85 | nFiles=`ils ${j}/Off/${c} | $GREP -i "medfiltmtx" | $WC -l` |
---|
| 86 | if [ ${nFiles} != 0 ]; then |
---|
| 87 | $ECHO "${sourceDate}/Off/${c}: ${nFiles} spectra (${onOffOk} ana)" |
---|
| 88 | else |
---|
| 89 | $ECHO "${sourceDate}/Off/${c}: ON-OFF failed" |
---|
| 90 | fi |
---|
| 91 | #end of loop on cycles |
---|
| 92 | done |
---|
| 93 | else |
---|
| 94 | $ECHO "${sourceDate} : No ON-OFF done for Off Diectory" |
---|
| 95 | fi |
---|
| 96 | #end of Off exist |
---|
| 97 | else |
---|
| 98 | $ECHO "${sourceDate} : No Off Diectory" |
---|
| 99 | fi |
---|
| 100 | # |
---|
| 101 | #On directory |
---|
| 102 | # |
---|
| 103 | dateField=`basename ${j}` |
---|
| 104 | sourceDate="${sourceName}-${dateField}" |
---|
| 105 | #look if final calibration files exist |
---|
[531] | 106 | onOnOk=`ils ${j} | $GREP -i "data.*\.ppf\|diff.*\.ppf" | $WC -l` |
---|
[519] | 107 | onDirExist=`ils ${j} | $GREP -i "On" | $WC -l` |
---|
| 108 | if [ ${onDirExist} != 0 ]; then |
---|
| 109 | listeCyclesOn=( `ils ${j}/On | $GREP -i "datacycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` ) |
---|
| 110 | IFS=' |
---|
| 111 | ' |
---|
| 112 | listeCyclesOn=( $( $PRINTF "%s\n" "${listeCyclesOn[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 113 | IFS=$DefaultIFS |
---|
| 114 | |
---|
| 115 | if [ ${#listeCyclesOn[*]} != 0 ]; then |
---|
| 116 | for c in ${listeCyclesOn[@]} |
---|
| 117 | do |
---|
| 118 | #nb: $c has the format of datacycle<number> |
---|
| 119 | nFiles=`ils ${j}/On/${c} | $GREP -i "medfiltmtx" | $WC -l` |
---|
| 120 | if [ ${nFiles} != 0 ]; then |
---|
[531] | 121 | $ECHO "${sourceDate}/On/${c}: ${nFiles} spectra (${onOnOk} ana)" |
---|
[519] | 122 | else |
---|
| 123 | $ECHO "${sourceDate}/On/${c}: ON-OFF failed" |
---|
| 124 | fi |
---|
| 125 | #end of loop on cycles |
---|
| 126 | done |
---|
| 127 | else |
---|
| 128 | $ECHO "${sourceDate} : No ON-OFF done for On Diectory" |
---|
| 129 | fi |
---|
| 130 | #end of On exist |
---|
| 131 | else |
---|
| 132 | $ECHO "${sourceDate} : No On Diectory" |
---|
| 133 | fi |
---|
| 134 | #end of loop on dates |
---|
| 135 | done |
---|
| 136 | #end of loop on sources |
---|
| 137 | done |
---|