[507] | 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 calibration files exist |
---|
| 72 | calibOk=`ils ${j} | $GREP -i "calib_" | $WC -l` |
---|
| 73 | |
---|
| 74 | offDirExist=`ils ${j} | $GREP -i "Off" | $WC -l` |
---|
| 75 | if [ ${offDirExist} != 0 ]; then |
---|
| 76 | listeCyclesOff=( `ils ${j}/Off | $GREP -i "calibcycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` ) |
---|
| 77 | IFS=' |
---|
| 78 | ' |
---|
| 79 | listeCyclesOff=( $( $PRINTF "%s\n" "${listeCyclesOff[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 80 | IFS=$DefaultIFS |
---|
| 81 | |
---|
| 82 | if [ ${#listeCyclesOff[*]} != 0 ]; then |
---|
| 83 | for c in ${listeCyclesOff[@]} |
---|
| 84 | do |
---|
| 85 | #nb: $c has the format of calibcycle<number> |
---|
| 86 | nFiles=`ils ${j}/Off/${c} | $GREP -i "medfiltmtx" | $WC -l` |
---|
| 87 | if [ ${nFiles} != 0 ]; then |
---|
| 88 | $ECHO "${sourceDate}/Off/${c}: ${nFiles} spectra (${calibOk} calib)" |
---|
| 89 | else |
---|
| 90 | $ECHO "${sourceDate}/Off/${c}: Calibration failed" |
---|
| 91 | fi |
---|
| 92 | #end of loop on cycles |
---|
| 93 | done |
---|
| 94 | else |
---|
| 95 | $ECHO "${sourceDate} : No Calibration done for Off Diectory" |
---|
| 96 | fi |
---|
| 97 | #end of Off exist |
---|
| 98 | else |
---|
| 99 | $ECHO "${sourceDate} : No Off Diectory" |
---|
| 100 | fi |
---|
| 101 | # |
---|
| 102 | #On directory |
---|
| 103 | # |
---|
| 104 | dateField=`basename ${j}` |
---|
| 105 | sourceDate="${sourceName}-${dateField}" |
---|
[510] | 106 | #look if final calibration files exist |
---|
| 107 | calibOk=`ils ${j} | $GREP -i "calib_" | $WC -l` |
---|
[507] | 108 | onDirExist=`ils ${j} | $GREP -i "On" | $WC -l` |
---|
| 109 | if [ ${onDirExist} != 0 ]; then |
---|
| 110 | listeCyclesOn=( `ils ${j}/On | $GREP -i "calibcycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` ) |
---|
| 111 | IFS=' |
---|
| 112 | ' |
---|
| 113 | listeCyclesOn=( $( $PRINTF "%s\n" "${listeCyclesOn[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
| 114 | IFS=$DefaultIFS |
---|
| 115 | |
---|
| 116 | if [ ${#listeCyclesOn[*]} != 0 ]; then |
---|
| 117 | for c in ${listeCyclesOn[@]} |
---|
| 118 | do |
---|
| 119 | #nb: $c has the format of calibcycle<number> |
---|
| 120 | nFiles=`ils ${j}/On/${c} | $GREP -i "medfiltmtx" | $WC -l` |
---|
| 121 | if [ ${nFiles} != 0 ]; then |
---|
[510] | 122 | $ECHO "${sourceDate}/On/${c}: ${nFiles} spectra (${calibOk} calib)" |
---|
[507] | 123 | else |
---|
| 124 | $ECHO "${sourceDate}/On/${c}: Calibration failed" |
---|
| 125 | fi |
---|
| 126 | #end of loop on cycles |
---|
| 127 | done |
---|
| 128 | else |
---|
| 129 | $ECHO "${sourceDate} : No Calibration done for On Diectory" |
---|
| 130 | fi |
---|
| 131 | #end of On exist |
---|
| 132 | else |
---|
| 133 | $ECHO "${sourceDate} : No On Diectory" |
---|
| 134 | fi |
---|
| 135 | #end of loop on dates |
---|
| 136 | done |
---|
| 137 | #end of loop on sources |
---|
| 138 | done |
---|