source: BAORadio/AmasNancay/trunk/getAnalyseFiles.sh@ 629

Last change on this file since 629 was 626, checked in by campagne, 14 years ago

drift scan runs (jec)

  • Property svn:executable set to *
File size: 3.4 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 NGC4383) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
64 *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen"
65 exit 1;;
66esac
67
68srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
69
70#Path to public backupable path
71publicpath="/afs/in2p3.fr/home/c/campagne/public"
72
73
74#temporary files to synchronize scripts
75tmppublicpath=${TMPPUBLICPATH}
76#wakeup the NFS disk
77$LS -l ${tmppublicpath} > /dev/null
78
79#Path where the job will do temporary IO
80. ${SCRIPTPATH}/set_iojobpath.sh
81iojobpath=$(set_iojobpath)
82cd ${iojobpath}
83
84localpath="${sourceRadio}"
85$MKDIR -p ./${localpath}
86cd ./${localpath}
87
88
89#Path of the utility scripts
90scriptpath=${SCRIPTPATH}
91
92OUT1=${publicpath}/baodaqstatus-current.txt
93if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then
94 $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
95 exit 1
96fi
97
98
99
100$ECHO "You have selected sourceRadio = ${sourceRadio} [date = ${dateSelected}]"
101#JEC 14/12/11 One should take care of DR extension for Drift Scan
102#tableau=( `$GREP -i "${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
103tableau=( `$GREP -i "${sourceRadio}/${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
104IFS='
105'
106tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
107IFS=$DefaultIFS
108
109$ECHO "We are in directory `pwd`"
110
111for i in ${tableau[@]}
112 do
113#
114
115 $ECHO "DEBUG: (${scriptName}) irods root dir $i"
116
117 #ON-OFF avec les RAW files normalises
118 file=`ils ${i} 2>&1 | $GREP -i "diffOnOffRAw_.*\.ppf"`
119 file=`$ECHO $file`
120 if [ "<${file}>" != "<>" ]; then
121 iget -f -v ${i}/${file}
122 fi
123
124 #ON & OFF RAW files normalises
125 file=`ils ${i} 2>&1 | $GREP -i "dataRAw_.*\.ppf"`
126 file=`$ECHO $file`
127 if [ "<${file}>" != "<>" ]; then
128 iget -f -v ${i}/${file}
129 fi
130
131 #fichiers de calibrations BAO
132 calibfiles=( `ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" ` )
133 IFS='
134'
135 calibfiles=( $( $PRINTF "%s\n" "${calibfiles[@]}" | $AWK 'x[$0]++ == 0' ) )
136 IFS=$DefaultIFS
137
138 for j in ${calibfiles[@]}
139 do
140 file=`$ECHO $j`
141 iget -f -v ${i}/${file}
142 done
143
144done
145
146exit 0
Note: See TracBrowser for help on using the repository browser.