source: BAORadio/AmasNancay/v4/getAnalyseFiles.sh@ 616

Last change on this file since 616 was 575, checked in by campagne, 14 years ago

introduce SCRIPTPATH environment variable (jec)

  • Property svn:executable set to *
File size: 3.3 KB
Line 
1#!/bin/sh -xvf
2#Perform the ON-OFF analysis
3DATE=/bin/date
4GREP=/bin/grep
5AWK=/bin/awk
6ECHO=/bin/echo
7WC=/usr/bin/wc
8CAT=/bin/cat
9PRINTF=/usr/bin/printf
10FIND=/usr/bin/find
11MKDIR=/bin/mkdir
12XARGS=/usr/bin/xargs
13SORT=/bin/sort
14RM=/bin/rm
15TR=/usr/bin/tr
16CP=/bin/cp
17LS=/bin/ls
18CHMOD=/bin/chmod
19
20DefaultIFS=$' \t\n'
21IFS=$DefaultIFS
22
23#set Irods environment
24. /usr/local/shared/bin/irods_env.sh -noverbose
25
26scriptName="`basename $0`"
27$ECHO "Processing script ${scriptName} at `date`"
28#which source to analyse
29
30#Process cmd line args: the -src option is mandatory (source name as Abell85)
31sourceRadio=
32dateSelected=
33simulationMode=Off
34while [ $# -gt 0 ]
35 do
36 case "$1" in
37 -src) sourceRadio=$2; shift;;
38 -date) dateSelected=$2; shift;;
39 -sim) simulationMode=On;;
40 -h)
41 echo >&2 \
42 "usage: $0 -src souce -date YYYYMMDD [-sim to trig simulation mode]"
43 exit 1;;
44 *) break;; # terminate while loop
45 esac
46 shift
47done
48
49
50if [ ${simulationMode} = "On" ]; then
51 $ECHO "INFO ${scriptName} running in SIMUL mode"
52fi
53
54if [ "<${sourceRadio}>" = "<>" ]; then
55 $ECHO "FATAL: You have forgotten to select the source option (-src)"
56 exit 1
57fi
58
59case ${sourceRadio} in
60 Abell85) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
61 Abell2440) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
62 Abell1205) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
63 *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen"
64 exit 1;;
65esac
66
67srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
68
69#Path to public backupable path
70publicpath="/afs/in2p3.fr/home/c/campagne/public"
71
72
73#temporary files to synchronize scripts
74tmppublicpath=${TMPPUBLICPATH}
75#wakeup the NFS disk
76$LS -l ${tmppublicpath} > /dev/null
77
78#Path where the job will do temporary IO
79if [ ${ENVIRONMENT} = "INTERACTIVE" ]; then
80 iojobpath="/sps/baoradio/AmasNancay/JEC"
81 $MKDIR -p $iojobpath
82else
83 $ECHO "FATAL (${scriptName}): environment is ${ENVIRONMENT} not allowed"
84 exit 1
85fi
86cd ${iojobpath}
87
88localpath="${sourceRadio}"
89$MKDIR -p ./${localpath}
90cd ./${localpath}
91
92
93#Path of the utility scripts
94scriptpath=${SCRIPTPATH}
95
96OUT1=${publicpath}/baodaqstatus-current.txt
97if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then
98 $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
99 exit 1
100fi
101
102
103
104$ECHO "You have selected sourceRadio = ${sourceRadio} [date = ${dateSelected}]"
105tableau=( `$GREP -i "${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
106IFS='
107'
108tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
109IFS=$DefaultIFS
110
111$ECHO "We are in directory `pwd`"
112
113for i in ${tableau[@]}
114 do
115#
116
117 $ECHO "DEBUG: (${scriptName}) irods root dir $i"
118
119 #ON-OFF avec les RAW files normalises
120 file=`ils ${i} 2>&1 | $GREP -i "diffOnOffRAw_.*\.ppf"`
121 file=`$ECHO $file`
122 if [ "<${file}>" != "<>" ]; then
123 iget -f -v ${i}/${file}
124 fi
125
126 #ON & OFF RAW files normalises
127 file=`ils ${i} 2>&1 | $GREP -i "dataRAw_.*\.ppf"`
128 file=`$ECHO $file`
129 if [ "<${file}>" != "<>" ]; then
130 iget -f -v ${i}/${file}
131 fi
132
133 #fichiers de calibrations BAO
134 calibfiles=( `ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" ` )
135 IFS='
136'
137 calibfiles=( $( $PRINTF "%s\n" "${calibfiles[@]}" | $AWK 'x[$0]++ == 0' ) )
138 IFS=$DefaultIFS
139
140 for j in ${calibfiles[@]}
141 do
142 file=`$ECHO $j`
143 iget -f -v ${i}/${file}
144 done
145
146done
147
148exit 0
Note: See TracBrowser for help on using the repository browser.