source: BAORadio/AmasNancay/v6/mkarchive.sh@ 689

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

drift scan runs (jec)

  • Property svn:executable set to *
File size: 4.4 KB
Line 
1#!/bin/sh
2#make an archive of the processing
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=
33prependTag=""
34appendTag=""
35simulationMode=Off
36mvgain=No
37while [ $# -gt 0 ]
38 do
39 case "$1" in
40 -src) sourceRadio=$2; shift;;
41 -date) dateSelected=$2; shift;;
42 -ppTag) prependTag=$2; shift;;
43 -apTag) appendTag=$2; shift;;
44 -sim) simulationMode=On;;
45 -all) mvgain=Yes;;
46 -h)
47 echo >&2 \
48 "usage: $0 -src souce -date YYYYMMDD -ppTag <tag> -apTag <tag> [-sim to trig simulation mode]"
49 exit 1;;
50 *) break;; # terminate while loop
51 esac
52 shift
53done
54
55
56if [ ${simulationMode} = "On" ]; then
57 $ECHO "INFO ${scriptName} running in SIMUL mode"
58fi
59
60if [ "<${sourceRadio}>" = "<>" ]; then
61 $ECHO "FATAL: You have forgotten to select the source option (-src)"
62 exit 1
63fi
64
65if [ "<${prependTag}>" = "<>" -a "<${appendTag}>" = "<>" ]; then
66 $ECHO "FATAL: choose either a prepend Tag or a append Tag"
67 exit
68fi
69
70
71case ${sourceRadio} in
72 Abell85) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
73 Abell2440) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
74 Abell1205) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
75 NGC4383) $ECHO "INFO (${scriptName}): process ${sourceRadio}";;
76 *) ECHO "FATAL (${scriptName}): process ${sourceRadio} not yet foreseen"
77 exit 1;;
78esac
79
80srclower=`${ECHO} ${sourceRadio} | ${TR} "[:upper:]" "[:lower:]" `
81
82#Path to public backupable path
83publicpath="/afs/in2p3.fr/home/c/campagne/public"
84
85
86#temporary files to synchronize scripts
87tmppublicpath=${TMPPUBLICPATH}
88#wakeup the NFS disk
89$LS -l ${tmppublicpath} > /dev/null
90
91#Path where the job will do temporary IO
92. ${SCRIPTPATH}/set_iojobpath.sh
93iojobpath=$(set_iojobpath)
94cd ${iojobpath}
95
96localpath="${sourceRadio}"
97$MKDIR -p ./${localpath}
98cd ./${localpath}
99
100
101#Path of the utility scripts
102scriptpath=${SCRIPTPATH}
103
104OUT1=${publicpath}/baodaqstatus-current.txt
105if [ ! -e ${OUT1} -o ! -r ${OUT1} ]; then
106 $ECHO "FATAL (${scriptName}): ${OUT1} has a problem"
107 exit 1
108fi
109
110
111
112$ECHO "You have selected sourceRadio = ${sourceRadio} [date = ${dateSelected}]"
113#JEC 14/12/11 One should take care of DR extension for Drift Scan
114#tableau=( `$GREP -i "${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
115tableau=( `$GREP -i "${sourceRadio}/${dateSelected}${srclower}" ${OUT1} | $AWK '( NF==4 ) { print $2 }' ` )
116IFS='
117'
118tableau=( $( $PRINTF "%s\n" "${tableau[@]}" | $AWK 'x[$0]++ == 0' ) )
119IFS=$DefaultIFS
120
121$ECHO "We are in directory `pwd`"
122
123for i in ${tableau[@]}
124 do
125#
126
127 $ECHO "DEBUG: (${scriptName}) irods root dir $i"
128
129
130
131 #make a new archive directory
132 archiveDir=${prependTag}Arch${appendTag}
133
134 archExist=`ils ${i} 2>&1 | $GREP -i ".*C-.*${archiveDir}"| $WC -l`
135 if [ ${archExist} -gt 0 ]; then
136 $ECHO "FATAL: ${archiveDir} already exit in ${i}"
137 exit 1
138 fi
139
140 imkdir -v ${i}/${archiveDir}
141
142 #Move the Off and On directory
143 imv -v ${i}/Off ${i}/${archiveDir}/Off
144 imv -v ${i}/On ${i}/${archiveDir}/On
145
146 #recreate On and Off directories
147 imkdir -v ${i}/Off
148 imkdir -v ${i}/On
149
150 #mv the fichiers de calibrations BAO
151 calibfiles=( `ils ${i} 2>&1 | $GREP -i "calib_.*\.txt" ` )
152 IFS='
153'
154 calibfiles=( $( $PRINTF "%s\n" "${calibfiles[@]}" | $AWK 'x[$0]++ == 0' ) )
155 IFS=$DefaultIFS
156
157 for j in ${calibfiles[@]}
158 do
159 file=`$ECHO $j`
160 imv -v ${i}/${file} ${i}/${archiveDir}/${file}
161 done
162
163 #mv the ppf files
164 ppffiles=( `ils ${i} 2>&1 | $GREP -i ".*\.ppf" ` )
165 IFS='
166'
167 ppffiles=( $( $PRINTF "%s\n" "${ppffiles[@]}" | $AWK 'x[$0]++ == 0' ) )
168 IFS=$DefaultIFS
169
170 for j in ${ppffiles[@]}
171 do
172 file=`$ECHO $j`
173 imv -v ${i}/${file} ${i}/${archiveDir}/${file}
174 done
175
176 #save the gain file
177 gainfile=`ils ${i} 2>&1 | $GREP -i "gain.*\.fits"`
178 file=`$ECHO ${gainfile}`
179 if [ "<${mvgain}>" = "<No>" ]; then
180 icp -v ${i}/${file} ${i}/${archiveDir}/${file}
181 else
182 imv -v ${i}/${file} ${i}/${archiveDir}/${file}
183 fi
184
185done
186
187exit 0
Note: See TracBrowser for help on using the repository browser.