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

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

add NGC4383 src (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    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}]"
101tableau=( `$GREP -i "${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
102IFS='
103' 
104tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
105IFS=$DefaultIFS
106
107$ECHO "We are in directory `pwd`"
108
109for i in ${tableau[@]}
110  do
111#
112 
113  $ECHO "DEBUG: (${scriptName}) irods root dir $i"
114
115  #ON-OFF avec les RAW files normalises
116  file=`ils ${i} 2>&1 | $GREP -i "diffOnOffRAw_.*\.ppf"`
117  file=`$ECHO $file`
118  if [ "<${file}>" != "<>" ]; then
119      iget -f -v ${i}/${file} 
120  fi
121
122  #ON & OFF RAW files normalises
123  file=`ils ${i} 2>&1 | $GREP -i "dataRAw_.*\.ppf"`
124  file=`$ECHO $file`
125  if [ "<${file}>" != "<>" ]; then
126      iget -f -v ${i}/${file} 
127  fi
128
129  #fichiers de calibrations BAO
130  calibfiles=( `ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" ` )
131  IFS='
132' 
133  calibfiles=( $( $PRINTF "%s\n" "${calibfiles[@]}" | $AWK 'x[$0]++ == 0' )  )
134  IFS=$DefaultIFS
135
136  for j in ${calibfiles[@]}
137    do
138    file=`$ECHO $j`
139    iget -f -v ${i}/${file}
140  done
141 
142done
143
144exit 0
Note: See TracBrowser for help on using the repository browser.