1 | #!/bin/sh
|
---|
2 | #
|
---|
3 | # ========================================================================
|
---|
4 | #
|
---|
5 | # *
|
---|
6 | # * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
7 | # * Software. It is distributed to you in the hope that it can be a useful
|
---|
8 | # * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
9 | # * It is distributed WITHOUT ANY WARRANTY.
|
---|
10 | # *
|
---|
11 | # * Permission to use, copy, modify and distribute this software and its
|
---|
12 | # * documentation for any purpose is hereby granted without fee,
|
---|
13 | # * provided that the above copyright notice appear in all copies and
|
---|
14 | # * that both that copyright notice and this permission notice appear
|
---|
15 | # * in supporting documentation. It is provided "as is" without express
|
---|
16 | # * or implied warranty.
|
---|
17 | # *
|
---|
18 | #
|
---|
19 | #
|
---|
20 | # Author(s): Daniela Dorner 10/2006 <mailto:dorner@astro.uni-wuerzburg.de>
|
---|
21 | #
|
---|
22 | # Copyright: MAGIC Software Development, 2000-2007
|
---|
23 | #
|
---|
24 | #
|
---|
25 | # ========================================================================
|
---|
26 | #
|
---|
27 | #
|
---|
28 | #
|
---|
29 | ##############################################################################
|
---|
30 | #
|
---|
31 | # This script can be used to run the following steps for one sequence:
|
---|
32 | # - callisto
|
---|
33 | # - merppupdate
|
---|
34 | # - star
|
---|
35 | #
|
---|
36 | # You have to set the path, where your Mars version can be found, the outpath,
|
---|
37 | # where you want to store the output and the sequencenumber of the sequence
|
---|
38 | # you want to process
|
---|
39 | #
|
---|
40 | ##############################################################################
|
---|
41 |
|
---|
42 | #to be set by the user (if you don't use the command-line options)
|
---|
43 | #path of your output directory
|
---|
44 | #outpath=/home/dorner/ToO
|
---|
45 | outpath=
|
---|
46 | #give either sequence number or sequence file (including path)
|
---|
47 | sequence=
|
---|
48 | sequfile=""
|
---|
49 |
|
---|
50 | function usage()
|
---|
51 | {
|
---|
52 | echo "Usage: $0 [options]"
|
---|
53 | echo "options:"
|
---|
54 | echo -n " --sequ sequence# "
|
---|
55 | echo " giving number of sequence which shall be processed "
|
---|
56 | echo -n " --sequ-file sequfile "
|
---|
57 | echo " giving sequencfile (including path) of sequence which shall be processed "
|
---|
58 | echo -n " --out outpath "
|
---|
59 | echo " giving the path where all outputfiles are stored "
|
---|
60 | echo -n " -cal "
|
---|
61 | echo " running only calibration"
|
---|
62 | echo -n " -b "
|
---|
63 | echo " running in non-interactive mode (i.e. you are not asked if the paths are ok)"
|
---|
64 | echo -n " -star "
|
---|
65 | echo " running only star"
|
---|
66 | echo ""
|
---|
67 | echo "Remarks: "
|
---|
68 | echo " - you can set the needed variables also in the script "
|
---|
69 | echo " - you have to set the outpath and either the sequence number or the sequence "
|
---|
70 | echo " file (if both is set, the sequence given by the sequencefile is processed)"
|
---|
71 | echo " - you have to execute the script from your mars directory"
|
---|
72 | echo " - in your outpath a calibration directory (callisto/sequencenumber), a "
|
---|
73 | echo " directory for the image fiels (star/sequencenumber) and a directory for "
|
---|
74 | echo " the merpplogs in the calibration directory are created. "
|
---|
75 | echo ""
|
---|
76 | exit
|
---|
77 | }
|
---|
78 |
|
---|
79 | function checkreturncode()
|
---|
80 | {
|
---|
81 | case $check in
|
---|
82 | 0) echo "$program finished sucessfully"
|
---|
83 | echo ""
|
---|
84 | ;;
|
---|
85 | [1-9]|[0-9][0-9]|1[0-1][0-9]|12[0-7])
|
---|
86 | echo -n "ERROR@$HOSTNAME: $program returned $check - please check the logfile $logfile"
|
---|
87 | if [ "$program" == "callisto" ]
|
---|
88 | then
|
---|
89 | echo -n " - for more details see http://www.astro.uni-wuerzburg.de/datacenter/instructions/intern/errorcoding.txt"
|
---|
90 | fi
|
---|
91 | echo " you executed the following command: "$command
|
---|
92 | exit
|
---|
93 | ;;
|
---|
94 | *) echo -n "ERROR@$HOSTNAME: $program returned $check - please check the logfile $logfile"
|
---|
95 | echo -n " $program returned a signal > 127 ($check)"
|
---|
96 | echo " you executed the following command: "$command
|
---|
97 | exit;;
|
---|
98 | esac
|
---|
99 | }
|
---|
100 |
|
---|
101 | subsystempath=/magic/subsystemdata
|
---|
102 |
|
---|
103 | interactive="yes"
|
---|
104 |
|
---|
105 | while [ "$1" ]
|
---|
106 | do
|
---|
107 | case $1 in
|
---|
108 | --sequ) shift
|
---|
109 | sequence=$1
|
---|
110 | ;;
|
---|
111 | --out) shift
|
---|
112 | outpath=$1
|
---|
113 | ;;
|
---|
114 | -b) interactive='no'
|
---|
115 | ;;
|
---|
116 | -cal) cal='yes'
|
---|
117 | ;;
|
---|
118 | -star) star='yes'
|
---|
119 | ;;
|
---|
120 | --sequ-file) shift
|
---|
121 | sequfile=$1
|
---|
122 | ;;
|
---|
123 | -h) usage
|
---|
124 | ;;
|
---|
125 | *) echo "unknown option $1 "
|
---|
126 | usage
|
---|
127 | exit
|
---|
128 | ;;
|
---|
129 | esac
|
---|
130 | shift
|
---|
131 | done
|
---|
132 |
|
---|
133 | if [ "$outpath" = "" ]
|
---|
134 | then
|
---|
135 | echo "WARNING outpath has not been set"
|
---|
136 | echo ""
|
---|
137 | usage
|
---|
138 | fi
|
---|
139 |
|
---|
140 | if [ "$sequence" = "" ] && [ "$sequfile" = "" ]
|
---|
141 | then
|
---|
142 | echo "WARNING neither sequ nor sequfile has been set"
|
---|
143 | echo ""
|
---|
144 | usage
|
---|
145 | fi
|
---|
146 |
|
---|
147 | echo ""
|
---|
148 | echo "You have set the variables to: "
|
---|
149 | echo " outpath: "$outpath
|
---|
150 |
|
---|
151 | if [ "$sequfile" = "" ]
|
---|
152 | then
|
---|
153 | if ! n8=`printf %08d $sequence`
|
---|
154 | then
|
---|
155 | echo "your sequence number is not valid"
|
---|
156 | usage
|
---|
157 | exit
|
---|
158 | fi
|
---|
159 | no=`echo $n8 | cut -c 1-4`
|
---|
160 | sequfile="/magic/sequences/"$no"/sequence$n8.txt"
|
---|
161 | echo " sequence: "$sequence
|
---|
162 | echo " sequfile: "$sequfile
|
---|
163 | # if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
---|
164 | # then
|
---|
165 | calpath=$outpath"/callisto/$n8"
|
---|
166 | echo " path where calibration files are stored : "$calpath
|
---|
167 | # fi
|
---|
168 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
---|
169 | then
|
---|
170 | starpath=$outpath"/star/$n8"
|
---|
171 | echo " path where star files are stored : "$starpath
|
---|
172 | fi
|
---|
173 | else
|
---|
174 | echo " sequfile: "$sequfile
|
---|
175 | # if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
---|
176 | # then
|
---|
177 | calpath=$outpath"/callisto"
|
---|
178 | echo " path where calibration files are stored : "$calpath
|
---|
179 | # fi
|
---|
180 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
---|
181 | then
|
---|
182 | starpath=$outpath"/star"
|
---|
183 | echo " path where star files are stored : "$starpath
|
---|
184 | fi
|
---|
185 | fi
|
---|
186 |
|
---|
187 |
|
---|
188 | if [ "$interactive" = "yes" ]
|
---|
189 | then
|
---|
190 | echo ""
|
---|
191 | echo "paths ok? continue?"
|
---|
192 | echo "please insert y, if you want continue"
|
---|
193 | echo " n, if you want quit"
|
---|
194 |
|
---|
195 | answer=`head -n 1`
|
---|
196 | case $answer in
|
---|
197 | y) echo "continue processing sequence"
|
---|
198 | ;;
|
---|
199 | n) exit
|
---|
200 | ;;
|
---|
201 | *) echo "your answer is not clear -> exit"
|
---|
202 | exit
|
---|
203 | ;;
|
---|
204 | esac
|
---|
205 | fi
|
---|
206 |
|
---|
207 |
|
---|
208 | if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
---|
209 | then
|
---|
210 | mkdir -pv $calpath
|
---|
211 |
|
---|
212 | program=callisto
|
---|
213 | echo "run $program..."
|
---|
214 | logfile=$calpath/$program$sequence.log
|
---|
215 | command="./$program -b -q -f --log=$logfile --out=$calpath $sequfile "
|
---|
216 | echo $command
|
---|
217 | $command
|
---|
218 | check=$?
|
---|
219 | checkreturncode
|
---|
220 |
|
---|
221 | calfiles=`find $calpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*_Y_*.root`
|
---|
222 |
|
---|
223 | echo "run merpp update for calibrated files..."
|
---|
224 | echo "calibrated data files: "$calfiles
|
---|
225 |
|
---|
226 | for calfile in ${calfiles[@]}
|
---|
227 | do
|
---|
228 | echo "calfile: "$calfile
|
---|
229 | outpath=`dirname $calfile`
|
---|
230 |
|
---|
231 | runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
|
---|
232 | echo "finding cc and cacofile for run $runno..."
|
---|
233 | date=`date --date \`basename $calfile | cut -d_ -f1\` +%Y/%m/%d`
|
---|
234 | ccpath=$subsystempath/cc/$date
|
---|
235 | cacopath=$subsystempath/caco/$date
|
---|
236 | ccfile=`find $ccpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*${runno}_[PDCS]_*_S.rep`
|
---|
237 | source=`echo $ccfile | cut -d_ -f4`
|
---|
238 | cacofile=`find $cacopath -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
|
---|
239 | if [ "$cacofile" = "" ]
|
---|
240 | then
|
---|
241 | echo "no cacofile found for run "$runno
|
---|
242 | echo "finding cacofile..."
|
---|
243 | for (( i = 0; i <= 10; i++ ))
|
---|
244 | do
|
---|
245 | newrun=`echo $runno - $i | bc`
|
---|
246 | cacofile=`find $cacopath -name *$newrun*`
|
---|
247 | if [ "$cacofile" = "" ]
|
---|
248 | then
|
---|
249 | continue
|
---|
250 | else
|
---|
251 | break
|
---|
252 | fi
|
---|
253 | done
|
---|
254 | fi
|
---|
255 | if [ "$ccfile" = "" ]
|
---|
256 | then
|
---|
257 | echo "no ccfile found for run "$runno
|
---|
258 | exit
|
---|
259 | fi
|
---|
260 | if [ "$cacofile" = "" ]
|
---|
261 | then
|
---|
262 | echo "no cacofile found for run "$runno
|
---|
263 | exit
|
---|
264 | fi
|
---|
265 | echo "ccfile: "$ccfile
|
---|
266 | echo "cacofile: "$cacofile
|
---|
267 |
|
---|
268 | merpplogpath=$outpath"/merpplogs"
|
---|
269 | mkdir -pv $merpplogpath
|
---|
270 |
|
---|
271 | program=merppccupdate
|
---|
272 | logfile=$merpplogpath/$program$runno.log
|
---|
273 | command="./merpp -u --log=$logfile --runfile=$runno $ccfile $calfile "
|
---|
274 | echo $command
|
---|
275 | $command
|
---|
276 | check=$?
|
---|
277 | checkreturncode
|
---|
278 |
|
---|
279 | program=merppcacoupdate
|
---|
280 | logfile=$merpplogpath/$program$runno.log
|
---|
281 | command="./merpp -u --log=$logfile --auto-time $cacofile $calfile"
|
---|
282 | echo $command
|
---|
283 | $command
|
---|
284 | check=$?
|
---|
285 | checkreturncode
|
---|
286 |
|
---|
287 | done
|
---|
288 | echo "merppupdate is finished"
|
---|
289 | echo ""
|
---|
290 | fi
|
---|
291 |
|
---|
292 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
---|
293 | then
|
---|
294 | mkdir -pv $starpath
|
---|
295 |
|
---|
296 | program=star
|
---|
297 | echo "run $program..."
|
---|
298 | logfile=$starpath/$program$sequence.log
|
---|
299 | if ! ls $calpath
|
---|
300 | then
|
---|
301 | echo "couldn't find $calpath => taking standard inpath for $program"
|
---|
302 | command="./$program -b -q -f --log=$logfile --out=$starpath $sequfile"
|
---|
303 | echo $command
|
---|
304 | $command
|
---|
305 | else
|
---|
306 | command="./$program -b -q -f --log=$logfile --ind=$calpath --out=$starpath $sequfile"
|
---|
307 | echo $command
|
---|
308 | $command
|
---|
309 | fi
|
---|
310 | check=$?
|
---|
311 | checkreturncode
|
---|
312 | fi
|
---|
313 |
|
---|