| 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 08/2005 <mailto:dorner@astro.uni-wuerzburg.de>
|
|---|
| 21 | #
|
|---|
| 22 | # Copyright: MAGIC Software Development, 2000-2006
|
|---|
| 23 | #
|
|---|
| 24 | #
|
|---|
| 25 | # ========================================================================
|
|---|
| 26 | #
|
|---|
| 27 | # This script produces the plots from all root-files in the web directory
|
|---|
| 28 | #
|
|---|
| 29 | # After checking, if the script is already running, the plots are produced:
|
|---|
| 30 | # With the programm showplot a ps-file is written, from which the png
|
|---|
| 31 | # files are produced.
|
|---|
| 32 | #
|
|---|
| 33 |
|
|---|
| 34 | program=dowebplots
|
|---|
| 35 | source `dirname $0`/sourcefile
|
|---|
| 36 |
|
|---|
| 37 | set -C
|
|---|
| 38 |
|
|---|
| 39 | cd $mars
|
|---|
| 40 |
|
|---|
| 41 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 42 |
|
|---|
| 43 | scriptlogpath=$logpath/run/dowebplots/`date +%Y/%m/%d`
|
|---|
| 44 | makedir $scriptlogpath
|
|---|
| 45 |
|
|---|
| 46 | scriptlog=$scriptlogpath/dowebplots-$datetime.log
|
|---|
| 47 |
|
|---|
| 48 | date >> $scriptlog 2>&1
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | while getopts p: opts
|
|---|
| 52 | do
|
|---|
| 53 | case $opts in
|
|---|
| 54 | p) type=$OPTARG
|
|---|
| 55 | echo "got programname: $type" >> $scriptlog 2>&1
|
|---|
| 56 | ;;
|
|---|
| 57 | ?) echo "usage: $(basename $0) -p programname" >> $scriptlog 2>&1
|
|---|
| 58 | ;;
|
|---|
| 59 | esac
|
|---|
| 60 | done
|
|---|
| 61 |
|
|---|
| 62 | if [ "$type" = "" ]
|
|---|
| 63 | then
|
|---|
| 64 | echo "no program name given -> exit" >> $scriptlog 2>&1
|
|---|
| 65 | echo "usage: $(basename $0) -p programname" >> $scriptlog 2>&1
|
|---|
| 66 | date >> $scriptlog 2>&1
|
|---|
| 67 | exit
|
|---|
| 68 | fi
|
|---|
| 69 |
|
|---|
| 70 | # check if script is already running
|
|---|
| 71 | lockfile=$lockpath/lock-dowebplots-$type.txt
|
|---|
| 72 | checklock >> $scriptlog 2>&1
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 | #finding all rootfiles in the data directory, that were modified in the last 3 days
|
|---|
| 76 | #this are all statusdisplays
|
|---|
| 77 | rootfiles=`find $datapath/$type/ -maxdepth 10 -name '*.root' -mtime -3 | grep -v '_I_' | grep -v '_Y_' | grep -v 'summary'`
|
|---|
| 78 |
|
|---|
| 79 | #exit if no rootfiles are found
|
|---|
| 80 | if [ "$rootfiles" = "" ]
|
|---|
| 81 | then
|
|---|
| 82 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 83 | rm -v $lockfile >> $scriptlog 2>&1
|
|---|
| 84 | date >> $scriptlog 2>&1
|
|---|
| 85 | exit
|
|---|
| 86 | fi
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | #produce plots for each rootfile
|
|---|
| 90 | for rootfile in ${rootfiles[@]}
|
|---|
| 91 | do
|
|---|
| 92 | date >> $scriptlog 2>&1
|
|---|
| 93 | #get names of the psfile and the
|
|---|
| 94 | #pngfiles (1 per tab in the statusdiplay)
|
|---|
| 95 | psfile=`echo $rootfile | sed -e 's/.root$/.ps/g'`
|
|---|
| 96 | tabfile=`echo $rootfile | sed -e 's/.root$/-tab/g'`
|
|---|
| 97 | echo "rootfile: $rootfile" >> $scriptlog 2>&1
|
|---|
| 98 | echo "psfile: $psfile" >> $scriptlog 2>&1
|
|---|
| 99 | echo "tabfile: $tabfile" >> $scriptlog 2>&1
|
|---|
| 100 |
|
|---|
| 101 | #get date of root- and psfile
|
|---|
| 102 | daterootfile=`date +%Y%m%d -r $rootfile` >> $scriptlog 2>&1
|
|---|
| 103 | datepsfile=`date +%Y%m%d -r $psfile` >> $scriptlog 2>&1
|
|---|
| 104 | if [ "$datepsfile" = "" ]
|
|---|
| 105 | then
|
|---|
| 106 | echo "date of psfile is empty, i.e. the file $psfile doesn't exist" >> $scriptlog 2>&1
|
|---|
| 107 | echo " -> setting date to 0 and producing psfile..." >> $scriptlog 2>&1
|
|---|
| 108 | datepsfile=0
|
|---|
| 109 | fi
|
|---|
| 110 |
|
|---|
| 111 | echo "checking date..." >> $scriptlog 2>&1
|
|---|
| 112 | echo "date of rootfile: $daterootfile" >> $scriptlog 2>&1
|
|---|
| 113 | echo "date of psfile: $datepsfile" >> $scriptlog 2>&1
|
|---|
| 114 | #if the psfile is newer than the rootfile
|
|---|
| 115 | #no plots have to be done -> continue
|
|---|
| 116 | if [ "$datepsfile" -gt "$daterootfile" ] >> $scriptlog 2>&1
|
|---|
| 117 | then
|
|---|
| 118 | echo "psfile is newer than rootfile -> continue " >> $scriptlog 2>&1
|
|---|
| 119 | continue
|
|---|
| 120 | fi
|
|---|
| 121 |
|
|---|
| 122 | echo "producing psfile..." >> $scriptlog 2>&1
|
|---|
| 123 | ./showplot -b --save-as-ps=$psfile $rootfile >> $scriptlog 2>&1
|
|---|
| 124 |
|
|---|
| 125 | echo "creating temporary dir for pstoimg..." >> $scriptlog 2>&1
|
|---|
| 126 | temppath=`dirname $rootfile`
|
|---|
| 127 | tempwebplotspath=$temppath/tempwebplots
|
|---|
| 128 | makedir $tempwebplotspath >> $scriptlog 2>&1
|
|---|
| 129 |
|
|---|
| 130 | echo "converting plots to png..." >> $scriptlog 2>&1
|
|---|
| 131 | pstoimg -antialias -flip r270 -density 100 -tmp $tempwebplotspath -type png -multipage -out=$tabfile $psfile >> $scriptlog 2>&1
|
|---|
| 132 |
|
|---|
| 133 | echo "removing temporary dir..." >> $scriptlog 2>&1
|
|---|
| 134 | rmdir -v $tempwebplotspath >> $scriptlog 2>&1
|
|---|
| 135 | done
|
|---|
| 136 |
|
|---|
| 137 | rm -v $lockfile >> $scriptlog 2>&1
|
|---|
| 138 |
|
|---|
| 139 | set +C
|
|---|
| 140 |
|
|---|
| 141 | date >> $scriptlog 2>&1
|
|---|
| 142 |
|
|---|