source: BAORadio/AmasNancay/statuscalib.sh @ 535

Last change on this file since 535 was 510, checked in by campagne, 13 years ago

change scriptpath (general) + minor things

File size: 3.6 KB
Line 
1#!/bin/sh
2#Status de l'etat de la production des fichiers INPUT de calibrations
3GREP=/bin/grep
4AWK=/bin/awk
5ECHO=/bin/echo
6MKDIR=/bin/mkdir
7CAT=/bin/cat
8PRINTF=/usr/bin/printf
9RM=/bin/rm
10SORT=/bin/sort
11XARGS=/usr/bin/xargs
12WC=/usr/bin/wc
13DefaultIFS=$' \t\n'
14IFS=$DefaultIFS
15
16# Irods environment settings
17. /usr/local/shared/bin/irods_env.sh -noverbose
18
19scriptName="`basename $0`"
20$ECHO "Processing script ${scriptName} at `date`"
21
22#Path to public backupable path
23publicpath="/afs/in2p3.fr/home/c/campagne/public"
24
25#Path where the job will do temporary IO
26if [ ${ENVIRONMENT} == "INTERACTIVE" ]; then
27    iojobpath="/sps/baoradio/AmasNancay/JEC"
28    $MKDIR -p $iojobpath
29elif [ ${ENVIRONMENT} == "BATCH" ] ; then
30    iojobpath=${TMPBATCH}
31else
32    $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed"
33    exit 1
34fi
35cd ${iojobpath}
36
37
38OUT1=./baoils.$$
39ils /baoradio/data/AmasNancay/ > ${OUT1}
40OUT2=./baoawk1.$$
41$AWK '($1=="C-") {print $2}' ${OUT1} > ${OUT2}
42$RM $OUT1
43#Sequence
44listeSources=( `$CAT $OUT2 | $AWK '{print $1}'` )
45IFS='
46'
47listeSources=( $( $PRINTF "%s\n" "${listeSources[@]}" | $AWK 'x[$0]++ == 0' ) )
48IFS=$DefaultIFS
49$RM $OUT2
50
51for i in ${listeSources[@]}
52do
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}"
106#look if final calibration files exist
107    calibOk=`ils ${j} | $GREP -i "calib_" | $WC -l`
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
122                 $ECHO "${sourceDate}/On/${c}: ${nFiles} spectra (${calibOk} calib)"
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
138done
Note: See TracBrowser for help on using the repository browser.