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 | . ${SCRIPTPATH}/set_iojobpath.sh |
---|
27 | iojobpath=$(set_iojobpath) |
---|
28 | cd ${iojobpath} |
---|
29 | |
---|
30 | |
---|
31 | OUT1=./baoils.$$ |
---|
32 | ils /baoradio/data/AmasNancay/ > ${OUT1} |
---|
33 | OUT2=./baoawk1.$$ |
---|
34 | $AWK '($1=="C-") {print $2}' ${OUT1} > ${OUT2} |
---|
35 | $RM $OUT1 |
---|
36 | #Sequence |
---|
37 | listeSources=( `$CAT $OUT2 | $AWK '{print $1}'` ) |
---|
38 | IFS=' |
---|
39 | ' |
---|
40 | listeSources=( $( $PRINTF "%s\n" "${listeSources[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
41 | IFS=$DefaultIFS |
---|
42 | $RM $OUT2 |
---|
43 | |
---|
44 | for i in ${listeSources[@]} |
---|
45 | do |
---|
46 | #nb: $i contains the full path |
---|
47 | $ECHO "source ${i}" |
---|
48 | sourceName=`basename ${i}` |
---|
49 | listeDates=( `ils $i | $AWK '($1=="C-"){print $2}'`) |
---|
50 | IFS=' |
---|
51 | ' |
---|
52 | listeDates=( $( $PRINTF "%s\n" "${listeDates[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
53 | IFS=$DefaultIFS |
---|
54 | |
---|
55 | for j in ${listeDates[@]} |
---|
56 | do |
---|
57 | #nb: $j contains the full path |
---|
58 | # $ECHO "run ${j}" |
---|
59 | # |
---|
60 | #Off directory |
---|
61 | # |
---|
62 | dateField=`basename ${j}` |
---|
63 | sourceDate="${sourceName}-${dateField}" |
---|
64 | #look if final calibration files exist |
---|
65 | calibOk=`ils ${j} | $GREP -i "calib_" | $WC -l` |
---|
66 | |
---|
67 | offDirExist=`ils ${j} | $GREP -i "Off" | $WC -l` |
---|
68 | if [ ${offDirExist} != 0 ]; then |
---|
69 | listeCyclesOff=( `ils ${j}/Off | $GREP -i "calibcycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` ) |
---|
70 | IFS=' |
---|
71 | ' |
---|
72 | listeCyclesOff=( $( $PRINTF "%s\n" "${listeCyclesOff[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
73 | IFS=$DefaultIFS |
---|
74 | |
---|
75 | if [ ${#listeCyclesOff[*]} != 0 ]; then |
---|
76 | for c in ${listeCyclesOff[@]} |
---|
77 | do |
---|
78 | #nb: $c has the format of calibcycle<number> |
---|
79 | nFiles=`ils ${j}/Off/${c} | $GREP -i "medfiltmtx" | $WC -l` |
---|
80 | if [ ${nFiles} != 0 ]; then |
---|
81 | $ECHO "${sourceDate}/Off/${c}: ${nFiles} spectra (${calibOk} calib)" |
---|
82 | else |
---|
83 | $ECHO "${sourceDate}/Off/${c}: Calibration failed" |
---|
84 | fi |
---|
85 | #end of loop on cycles |
---|
86 | done |
---|
87 | else |
---|
88 | $ECHO "${sourceDate} : No Calibration done for Off Directory" |
---|
89 | fi |
---|
90 | #end of Off exist |
---|
91 | else |
---|
92 | $ECHO "${sourceDate} : No Off Directory" |
---|
93 | fi |
---|
94 | # |
---|
95 | #On directory |
---|
96 | # |
---|
97 | dateField=`basename ${j}` |
---|
98 | sourceDate="${sourceName}-${dateField}" |
---|
99 | #look if final calibration files exist |
---|
100 | calibOk=`ils ${j} | $GREP -i "calib_" | $WC -l` |
---|
101 | onDirExist=`ils ${j} | $GREP -i "On" | $WC -l` |
---|
102 | if [ ${onDirExist} != 0 ]; then |
---|
103 | listeCyclesOn=( `ils ${j}/On | $GREP -i "calibcycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` ) |
---|
104 | IFS=' |
---|
105 | ' |
---|
106 | listeCyclesOn=( $( $PRINTF "%s\n" "${listeCyclesOn[@]}" | $AWK 'x[$0]++ == 0' ) ) |
---|
107 | IFS=$DefaultIFS |
---|
108 | |
---|
109 | if [ ${#listeCyclesOn[*]} != 0 ]; then |
---|
110 | for c in ${listeCyclesOn[@]} |
---|
111 | do |
---|
112 | #nb: $c has the format of calibcycle<number> |
---|
113 | nFiles=`ils ${j}/On/${c} | $GREP -i "medfiltmtx" | $WC -l` |
---|
114 | if [ ${nFiles} != 0 ]; then |
---|
115 | $ECHO "${sourceDate}/On/${c}: ${nFiles} spectra (${calibOk} calib)" |
---|
116 | else |
---|
117 | $ECHO "${sourceDate}/On/${c}: Calibration failed" |
---|
118 | fi |
---|
119 | #end of loop on cycles |
---|
120 | done |
---|
121 | else |
---|
122 | $ECHO "${sourceDate} : No Calibration done for On Directory" |
---|
123 | fi |
---|
124 | #end of On exist |
---|
125 | else |
---|
126 | $ECHO "${sourceDate} : No On Directory" |
---|
127 | fi |
---|
128 | #end of loop on dates |
---|
129 | done |
---|
130 | #end of loop on sources |
---|
131 | done |
---|