| 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 " --cal-rc "
|
|---|
| 63 | echo " giving the rc-file used for the calibration "
|
|---|
| 64 | echo -n " -b "
|
|---|
| 65 | echo " running in non-interactive mode (i.e. you are not asked if the paths are ok)"
|
|---|
| 66 | echo -n " -star "
|
|---|
| 67 | echo " running only star"
|
|---|
| 68 | echo ""
|
|---|
| 69 | echo "Remarks: "
|
|---|
| 70 | echo " - you can set the needed variables also in the script "
|
|---|
| 71 | echo " - you have to set the outpath and either the sequence number or the sequence "
|
|---|
| 72 | echo " file (if both is set, the sequence given by the sequencefile is processed)"
|
|---|
| 73 | echo " - you have to execute the script from your mars directory"
|
|---|
| 74 | echo " - in your outpath a calibration directory (callisto/sequencenumber), a "
|
|---|
| 75 | echo " directory for the image fiels (star/sequencenumber) and a directory for "
|
|---|
| 76 | echo " the merpplogs in the calibration directory are created. "
|
|---|
| 77 | echo ""
|
|---|
| 78 | exit
|
|---|
| 79 | }
|
|---|
| 80 |
|
|---|
| 81 | function checkreturncode()
|
|---|
| 82 | {
|
|---|
| 83 | case $check in
|
|---|
| 84 | 0) echo "$program finished sucessfully"
|
|---|
| 85 | echo ""
|
|---|
| 86 | ;;
|
|---|
| 87 | [1-9]|[0-9][0-9]|1[0-1][0-9]|12[0-7])
|
|---|
| 88 | echo -n "ERROR@$HOSTNAME: $program returned $check - please check the logfile $logfile"
|
|---|
| 89 | if [ "$program" == "callisto" ]
|
|---|
| 90 | then
|
|---|
| 91 | echo -n " - for more details see http://www.astro.uni-wuerzburg.de/datacenter/instructions/intern/errorcoding.txt"
|
|---|
| 92 | fi
|
|---|
| 93 | echo " you executed the following command: "$command
|
|---|
| 94 | exit
|
|---|
| 95 | ;;
|
|---|
| 96 | *) echo -n "ERROR@$HOSTNAME: $program returned $check - please check the logfile $logfile"
|
|---|
| 97 | echo -n " $program returned a signal > 127 ($check)"
|
|---|
| 98 | echo " you executed the following command: "$command
|
|---|
| 99 | exit;;
|
|---|
| 100 | esac
|
|---|
| 101 | }
|
|---|
| 102 |
|
|---|
| 103 | subsystempath=/magic/subsystemdata
|
|---|
| 104 |
|
|---|
| 105 | interactive="yes"
|
|---|
| 106 |
|
|---|
| 107 | while [ "$1" ]
|
|---|
| 108 | do
|
|---|
| 109 | case $1 in
|
|---|
| 110 | --sequ) shift
|
|---|
| 111 | sequence=$1
|
|---|
| 112 | ;;
|
|---|
| 113 | --cal-rc) shift
|
|---|
| 114 | calrc="--config="$1
|
|---|
| 115 | ;;
|
|---|
| 116 | --out) shift
|
|---|
| 117 | outpath=$1
|
|---|
| 118 | ;;
|
|---|
| 119 | -b) interactive='no'
|
|---|
| 120 | ;;
|
|---|
| 121 | -cal) cal='yes'
|
|---|
| 122 | ;;
|
|---|
| 123 | -star) star='yes'
|
|---|
| 124 | ;;
|
|---|
| 125 | --sequ-file) shift
|
|---|
| 126 | sequfile=$1
|
|---|
| 127 | ;;
|
|---|
| 128 | -h) usage
|
|---|
| 129 | ;;
|
|---|
| 130 | *) echo "unknown option $1 "
|
|---|
| 131 | usage
|
|---|
| 132 | exit
|
|---|
| 133 | ;;
|
|---|
| 134 | esac
|
|---|
| 135 | shift
|
|---|
| 136 | done
|
|---|
| 137 |
|
|---|
| 138 | if [ "$outpath" = "" ]
|
|---|
| 139 | then
|
|---|
| 140 | echo "WARNING outpath has not been set"
|
|---|
| 141 | echo ""
|
|---|
| 142 | usage
|
|---|
| 143 | fi
|
|---|
| 144 |
|
|---|
| 145 | if [ "$sequence" = "" ] && [ "$sequfile" = "" ]
|
|---|
| 146 | then
|
|---|
| 147 | echo "WARNING neither sequ nor sequfile has been set"
|
|---|
| 148 | echo ""
|
|---|
| 149 | usage
|
|---|
| 150 | fi
|
|---|
| 151 |
|
|---|
| 152 | echo ""
|
|---|
| 153 | echo "You have set the variables to: "
|
|---|
| 154 | echo " outpath: "$outpath
|
|---|
| 155 |
|
|---|
| 156 | if [ "$sequfile" = "" ]
|
|---|
| 157 | then
|
|---|
| 158 | if ! n8=`printf %08d $sequence`
|
|---|
| 159 | then
|
|---|
| 160 | echo "your sequence number is not valid"
|
|---|
| 161 | usage
|
|---|
| 162 | exit
|
|---|
| 163 | fi
|
|---|
| 164 | no=`echo $n8 | cut -c 1-4`
|
|---|
| 165 | sequfile="/magic/sequences/"$no"/sequence$n8.txt"
|
|---|
| 166 | echo " sequence: "$sequence
|
|---|
| 167 | echo " sequfile: "$sequfile
|
|---|
| 168 | # if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
|---|
| 169 | # then
|
|---|
| 170 | calpath=$outpath"/callisto/$n8"
|
|---|
| 171 | echo " path where calibration files are stored : "$calpath
|
|---|
| 172 | # fi
|
|---|
| 173 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
|---|
| 174 | then
|
|---|
| 175 | starpath=$outpath"/star/$n8"
|
|---|
| 176 | echo " path where star files are stored : "$starpath
|
|---|
| 177 | fi
|
|---|
| 178 | else
|
|---|
| 179 | echo " sequfile: "$sequfile
|
|---|
| 180 | # if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
|---|
| 181 | # then
|
|---|
| 182 | calpath=$outpath"/callisto"
|
|---|
| 183 | echo " path where calibration files are stored : "$calpath
|
|---|
| 184 | # fi
|
|---|
| 185 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
|---|
| 186 | then
|
|---|
| 187 | starpath=$outpath"/star"
|
|---|
| 188 | echo " path where star files are stored : "$starpath
|
|---|
| 189 | fi
|
|---|
| 190 | fi
|
|---|
| 191 | if ! [ "$calrc" = "" ]
|
|---|
| 192 | then
|
|---|
| 193 | echo "using $calrc for calibration"
|
|---|
| 194 | fi
|
|---|
| 195 |
|
|---|
| 196 |
|
|---|
| 197 | if [ "$interactive" = "yes" ]
|
|---|
| 198 | then
|
|---|
| 199 | echo ""
|
|---|
| 200 | echo "paths ok? continue?"
|
|---|
| 201 | echo "please insert y, if you want continue"
|
|---|
| 202 | echo " n, if you want quit"
|
|---|
| 203 |
|
|---|
| 204 | answer=`head -n 1`
|
|---|
| 205 | case $answer in
|
|---|
| 206 | y) echo "continue processing sequence"
|
|---|
| 207 | ;;
|
|---|
| 208 | n) exit
|
|---|
| 209 | ;;
|
|---|
| 210 | *) echo "your answer is not clear -> exit"
|
|---|
| 211 | exit
|
|---|
| 212 | ;;
|
|---|
| 213 | esac
|
|---|
| 214 | fi
|
|---|
| 215 |
|
|---|
| 216 |
|
|---|
| 217 | if ! [ "$star" = "yes" ] || [ "$cal" = "yes" ]
|
|---|
| 218 | then
|
|---|
| 219 | mkdir -pv $calpath
|
|---|
| 220 |
|
|---|
| 221 | program=callisto
|
|---|
| 222 | echo "run $program..."
|
|---|
| 223 | logfile=$calpath/$program$sequence.log
|
|---|
| 224 | command="./$program -b -q -f -v5 --log=$logfile --out=$calpath $calrc $sequfile "
|
|---|
| 225 | echo $command
|
|---|
| 226 | $command
|
|---|
| 227 | check=$?
|
|---|
| 228 | checkreturncode
|
|---|
| 229 |
|
|---|
| 230 | calfiles=`find $calpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*_Y_*.root`
|
|---|
| 231 |
|
|---|
| 232 | echo "run merpp update for calibrated files..."
|
|---|
| 233 | echo "calibrated data files: "$calfiles
|
|---|
| 234 |
|
|---|
| 235 | for calfile in ${calfiles[@]}
|
|---|
| 236 | do
|
|---|
| 237 | echo "calfile: "$calfile
|
|---|
| 238 | outpath=`dirname $calfile`
|
|---|
| 239 |
|
|---|
| 240 | runno=`echo $calfile | cut -d_ -f2 | sed -e 's/^0//' | sed -e 's/^0//' | sed -e 's/^0//' `
|
|---|
| 241 | echo "finding cc and cacofile for run $runno..."
|
|---|
| 242 | date=`date --date \`basename $calfile | cut -d_ -f1\` +%Y/%m/%d`
|
|---|
| 243 | ccpath=$subsystempath/cc/$date
|
|---|
| 244 | cacopath=$subsystempath/caco/$date
|
|---|
| 245 | ccfile=`find $ccpath -name 20[0-2][0-9][01][0-9][0-3][0-9]_*${runno}_[PDCS]_*_S.rep`
|
|---|
| 246 | source=`echo $ccfile | cut -d_ -f4`
|
|---|
| 247 | cacofile=`find $cacopath -name dc_20[0-2][0-9]_[01][0-9]_[0-3][0-9]_*${runno}_${source}.txt`
|
|---|
| 248 | if [ "$cacofile" = "" ]
|
|---|
| 249 | then
|
|---|
| 250 | echo "no cacofile found for run "$runno
|
|---|
| 251 | echo "finding cacofile..."
|
|---|
| 252 | for (( i = 0; i <= 10; i++ ))
|
|---|
| 253 | do
|
|---|
| 254 | newrun=`echo $runno - $i | bc`
|
|---|
| 255 | cacofile=`find $cacopath -name *$newrun*`
|
|---|
| 256 | if [ "$cacofile" = "" ]
|
|---|
| 257 | then
|
|---|
| 258 | continue
|
|---|
| 259 | else
|
|---|
| 260 | break
|
|---|
| 261 | fi
|
|---|
| 262 | done
|
|---|
| 263 | fi
|
|---|
| 264 | if [ "$ccfile" = "" ]
|
|---|
| 265 | then
|
|---|
| 266 | echo "no ccfile found for run "$runno
|
|---|
| 267 | exit
|
|---|
| 268 | fi
|
|---|
| 269 | if [ "$cacofile" = "" ]
|
|---|
| 270 | then
|
|---|
| 271 | echo "no cacofile found for run "$runno
|
|---|
| 272 | exit
|
|---|
| 273 | fi
|
|---|
| 274 | echo "ccfile: "$ccfile
|
|---|
| 275 | echo "cacofile: "$cacofile
|
|---|
| 276 |
|
|---|
| 277 | merpplogpath=$outpath"/merpplogs"
|
|---|
| 278 | mkdir -pv $merpplogpath
|
|---|
| 279 |
|
|---|
| 280 | program=merppccupdate
|
|---|
| 281 | logfile=$merpplogpath/$program$runno.log
|
|---|
| 282 | command="./merpp -u -v5 --log=$logfile --runfile=$runno $ccfile $calfile "
|
|---|
| 283 | echo $command
|
|---|
| 284 | $command
|
|---|
| 285 | check=$?
|
|---|
| 286 | checkreturncode
|
|---|
| 287 |
|
|---|
| 288 | program=merppcacoupdate
|
|---|
| 289 | logfile=$merpplogpath/$program$runno.log
|
|---|
| 290 | command="./merpp -u -v5 --log=$logfile --auto-time $cacofile $calfile"
|
|---|
| 291 | echo $command
|
|---|
| 292 | $command
|
|---|
| 293 | check=$?
|
|---|
| 294 | checkreturncode
|
|---|
| 295 |
|
|---|
| 296 | done
|
|---|
| 297 | echo "merppupdate is finished"
|
|---|
| 298 | echo ""
|
|---|
| 299 | fi
|
|---|
| 300 |
|
|---|
| 301 | if ! [ "$cal" = "yes" ] || [ "$star" = "yes" ]
|
|---|
| 302 | then
|
|---|
| 303 | mkdir -pv $starpath
|
|---|
| 304 |
|
|---|
| 305 | program=star
|
|---|
| 306 | echo "run $program..."
|
|---|
| 307 | logfile=$starpath/$program$sequence.log
|
|---|
| 308 | if ! ls $calpath
|
|---|
| 309 | then
|
|---|
| 310 | echo "couldn't find $calpath => taking standard inpath for $program"
|
|---|
| 311 | command="./$program -b -q -f -v5 --log=$logfile --out=$starpath $sequfile"
|
|---|
| 312 | echo $command
|
|---|
| 313 | $command
|
|---|
| 314 | else
|
|---|
| 315 | command="./$program -b -q -f -v5 --log=$logfile --ind=$calpath --out=$starpath $sequfile"
|
|---|
| 316 | echo $command
|
|---|
| 317 | $command
|
|---|
| 318 | fi
|
|---|
| 319 | check=$?
|
|---|
| 320 | checkreturncode
|
|---|
| 321 | fi
|
|---|
| 322 |
|
|---|