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

Last change on this file since 673 was 635, checked in by campagne, 14 years ago

first introduction of DRIFT data (jec)

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