source: BAORadio/AmasNancay/statuscalib.sh @ 509

Last change on this file since 509 was 507, checked in by campagne, 13 years ago

New import

File size: 3.5 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    onDirExist=`ils ${j} | $GREP -i "On" | $WC -l`
107    if [ ${onDirExist} != 0 ]; then
108        listeCyclesOn=( `ils ${j}/On | $GREP -i "calibcycle" | $AWK '($1=="C-"){print $2}' | $XARGS -i basename {} | $SORT -k1.11n` )
109        IFS='
110  '
111        listeCyclesOn=( $( $PRINTF "%s\n" "${listeCyclesOn[@]}" | $AWK 'x[$0]++ == 0' ) )
112        IFS=$DefaultIFS
113       
114        if [ ${#listeCyclesOn[*]} != 0 ]; then   
115           for c in ${listeCyclesOn[@]}
116           do
117#nb: $c has the format of calibcycle<number>
118             nFiles=`ils ${j}/On/${c} | $GREP -i "medfiltmtx" | $WC -l`
119             if [ ${nFiles} != 0 ]; then
120                 $ECHO "${sourceDate}/On/${c}: ${nFiles} files"
121             else
122                 $ECHO "${sourceDate}/On/${c}: Calibration failed"
123             fi
124#end of loop on cycles
125           done
126        else
127            $ECHO "${sourceDate} : No Calibration done for On Diectory"
128        fi
129#end of On exist
130    else
131        $ECHO "${sourceDate} : No On Diectory"
132    fi
133#end of loop on dates
134  done 
135#end of loop on sources
136done
Note: See TracBrowser for help on using the repository browser.