source: trunk/MagicSoft/Mars/datacenter/scripts/dowebplots@ 7562

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