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

Last change on this file since 579 was 579, checked in by torrento, 13 years ago

version adaptee a grid engin (ana)

  • Property svn:executable set to *
File size: 3.2 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
79. ${SCRIPTPATH}/set_iojobpath.sh
80iojobpath=$(set_iojobpath)
81cd ${iojobpath}
82
83localpath="${sourceRadio}"
84$MKDIR -p ./${localpath}
85cd ./${localpath}
86
87
88#Path of the utility scripts
89scriptpath=${SCRIPTPATH}
90
91OUT1=${publicpath}/baodaqstatus-current.txt
92if [ ! -e ${OUT1}  -o ! -r ${OUT1} ]; then
93    $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
94    exit 1
95fi
96
97
98
99$ECHO "You have selected sourceRadio = ${sourceRadio} [date = ${dateSelected}]"
100tableau=( `$GREP -i "${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
101IFS='
102' 
103tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
104IFS=$DefaultIFS
105
106$ECHO "We are in directory `pwd`"
107
108for i in ${tableau[@]}
109  do
110#
111 
112  $ECHO "DEBUG: (${scriptName}) irods root dir $i"
113
114  #ON-OFF avec les RAW files normalises
115  file=`ils ${i} 2>&1 | $GREP -i "diffOnOffRAw_.*\.ppf"`
116  file=`$ECHO $file`
117  if [ "<${file}>" != "<>" ]; then
118      iget -f -v ${i}/${file} 
119  fi
120
121  #ON & OFF RAW files normalises
122  file=`ils ${i} 2>&1 | $GREP -i "dataRAw_.*\.ppf"`
123  file=`$ECHO $file`
124  if [ "<${file}>" != "<>" ]; then
125      iget -f -v ${i}/${file} 
126  fi
127
128  #fichiers de calibrations BAO
129  calibfiles=( `ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" ` )
130  IFS='
131' 
132  calibfiles=( $( $PRINTF "%s\n" "${calibfiles[@]}" | $AWK 'x[$0]++ == 0' )  )
133  IFS=$DefaultIFS
134
135  for j in ${calibfiles[@]}
136    do
137    file=`$ECHO $j`
138    iget -f -v ${i}/${file}
139  done
140 
141done
142
143exit 0
Note: See TracBrowser for help on using the repository browser.