| 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 | user=`whoami`
|
|---|
| 35 | program=dowebplots
|
|---|
| 36 | source /home/$user/Mars/datacenter/scripts/sourcefile
|
|---|
| 37 |
|
|---|
| 38 | set -C
|
|---|
| 39 |
|
|---|
| 40 | cd $mars
|
|---|
| 41 |
|
|---|
| 42 | datetime=`date +%F-%H-%M-%S`
|
|---|
| 43 | webdir=/www/htdocs/datacenter
|
|---|
| 44 |
|
|---|
| 45 | scriptlogpath=$logpath/run/dowebplots/`date +%Y/%m/%d`
|
|---|
| 46 | makedir $scriptlogpath
|
|---|
| 47 |
|
|---|
| 48 | scriptlog=$scriptlogpath/dowebplots-$datetime.log
|
|---|
| 49 |
|
|---|
| 50 | date >> $scriptlog 2>&1
|
|---|
| 51 |
|
|---|
| 52 | # check if script is already running
|
|---|
| 53 | lockfile=$lockpath/lock-dowebplots.txt
|
|---|
| 54 | checklock >> $scriptlog 2>&1
|
|---|
| 55 |
|
|---|
| 56 | #finding all rootfiles in the webdirectory
|
|---|
| 57 | #this are all statusdisplays
|
|---|
| 58 | rootfiles=`find $webdir/{sinope,callisto,star,ganymed}/ -name '*.root' -maxdepth 10 | grep -v '_I_' | grep -v '_Y_' | grep -v 'subsystemdata' | grep -v 'star_lapalma'`
|
|---|
| 59 |
|
|---|
| 60 | #exit if no rootfiles are found
|
|---|
| 61 | if [ "$rootfiles" = "" ]
|
|---|
| 62 | then
|
|---|
| 63 | echo "nothing to do -> exit" >> $scriptlog 2>&1
|
|---|
| 64 | rm -v $lockfile >> $scriptlog 2>&1
|
|---|
| 65 | date >> $scriptlog 2>&1
|
|---|
| 66 | exit
|
|---|
| 67 | fi
|
|---|
| 68 |
|
|---|
| 69 | #produce plots for each rootfile
|
|---|
| 70 | for rootfile in ${rootfiles[@]}
|
|---|
| 71 | do
|
|---|
| 72 | date >> $scriptlog 2>&1
|
|---|
| 73 | #get names of the psfile and the
|
|---|
| 74 | #pngfiles (1 per tab in the statusdiplay)
|
|---|
| 75 | psfile=`echo $rootfile | sed -e 's/.root$/.ps/g'`
|
|---|
| 76 | tabfile=`echo $rootfile | sed -e 's/.root$/-tab/g'`
|
|---|
| 77 | echo "rootfile: $rootfile" >> $scriptlog 2>&1
|
|---|
| 78 | echo "psfile: $psfile" >> $scriptlog 2>&1
|
|---|
| 79 | echo "tabfile: $tabfile" >> $scriptlog 2>&1
|
|---|
| 80 |
|
|---|
| 81 | #get date of root- and psfile
|
|---|
| 82 | daterootfile=`date +%Y%m%d -r $rootfile` >> $scriptlog 2>&1
|
|---|
| 83 | datepsfile=`date +%Y%m%d -r $psfile` >> $scriptlog 2>&1
|
|---|
| 84 | if [ "$datepsfile" = "" ]
|
|---|
| 85 | then
|
|---|
| 86 | echo "date of psfile is empty -> the file $psfile doesn't exist" >> $scriptlog 2>&1
|
|---|
| 87 | echo " -> setting date to 0 and producing psfile..." >> $scriptlog 2>&1
|
|---|
| 88 | datepsfile=0
|
|---|
| 89 | fi
|
|---|
| 90 |
|
|---|
| 91 | echo "checking date..." >> $scriptlog 2>&1
|
|---|
| 92 | echo "date of rootfile: $daterootfile" >> $scriptlog 2>&1
|
|---|
| 93 | echo "date of psfile: $datepsfile" >> $scriptlog 2>&1
|
|---|
| 94 |
|
|---|
| 95 | #if the psfile is newer than the rootfile
|
|---|
| 96 | #no plots have to be done -> continue
|
|---|
| 97 | if [ "$datepsfile" -gt "$daterootfile" ] >> $scriptlog 2>&1
|
|---|
| 98 | then
|
|---|
| 99 | echo "psfile is older than rootfile -> continue " >> $scriptlog 2>&1
|
|---|
| 100 | continue
|
|---|
| 101 | fi
|
|---|
| 102 |
|
|---|
| 103 | echo "producing psfile..." >> $scriptlog 2>&1
|
|---|
| 104 | ./showplot -b --save-as-ps=$psfile $rootfile >> $scriptlog 2>&1
|
|---|
| 105 |
|
|---|
| 106 | echo "converting plots to png..." >> $scriptlog 2>&1
|
|---|
| 107 | pstoimg -antialias -flip r270 -density 100 -type png -multipage -out=$tabfile $psfile >> $scriptlog 2>&1
|
|---|
| 108 | done
|
|---|
| 109 |
|
|---|
| 110 | echo "removing old files" >> $scriptlog 2>&1
|
|---|
| 111 | #make sure, that old plots of files, that are already removed from disk,
|
|---|
| 112 | # are deleted also in the webdirectory
|
|---|
| 113 | #this has to be done, as ps and png files are excluded from rsync, and
|
|---|
| 114 | #as rsync is done with --delete option (script /home/operator/condor/webupdate)
|
|---|
| 115 |
|
|---|
| 116 | #find all directories with plots
|
|---|
| 117 | dirs=`find $webdir/{star,callisto,ganymed,sinope}/* -type d | grep -v merpplogs`
|
|---|
| 118 |
|
|---|
| 119 | for dir in ${dir[@]}
|
|---|
| 120 | do
|
|---|
| 121 | #find psfiles in directory
|
|---|
| 122 | psfiles=`ls $dir/*.ps`
|
|---|
| 123 | #continue, if there are no psfiles
|
|---|
| 124 | if [ "$psfiles" == "" ]
|
|---|
| 125 | then
|
|---|
| 126 | continue
|
|---|
| 127 | fi
|
|---|
| 128 |
|
|---|
| 129 | for psfile in ${psfiles[@]}
|
|---|
| 130 | do
|
|---|
| 131 | #create name of corresponding rootfile
|
|---|
| 132 | rootfile=`echo $psfile | sed -e 's/.ps$/.root/g'`
|
|---|
| 133 | #delete ps and pngfiles if rootfile is not existing
|
|---|
| 134 | if ! ls $rootfile >> $scriptlog 2>&1
|
|---|
| 135 | then
|
|---|
| 136 | echo "deleting old plots for $rootfile..." >> $scriptlog 2>&1
|
|---|
| 137 | path=`dirname $psfile`
|
|---|
| 138 | rm -v $psfile >> $scriptlog 2>&1
|
|---|
| 139 | rm -v $path/*.png >> $scriptlog 2>&1
|
|---|
| 140 | fi
|
|---|
| 141 | done
|
|---|
| 142 | done
|
|---|
| 143 |
|
|---|
| 144 | rm -v $lockfile >> $scriptlog 2>&1
|
|---|
| 145 |
|
|---|
| 146 | set +C
|
|---|
| 147 |
|
|---|
| 148 | date >> $scriptlog 2>&1
|
|---|
| 149 |
|
|---|