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

Last change on this file since 7504 was 7486, checked in by Daniela Dorner, 19 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.6 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#finding all rootfiles in the webdirectory
57#this are all statusdisplays
58rootfiles=`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
61if [ "$rootfiles" = "" ]
62then
63 echo "nothing to do -> exit" >> $scriptlog 2>&1
64 rm -v $lockfile >> $scriptlog 2>&1
65 date >> $scriptlog 2>&1
66 exit
67fi
68
69#produce plots for each rootfile
70for rootfile in ${rootfiles[@]}
71do
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
108done
109
110echo "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
117dirs=`find $webdir/{star,callisto,ganymed,sinope}/* -type d | grep -v merpplogs`
118
119for dir in ${dir[@]}
120do
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
142done
143
144rm -v $lockfile >> $scriptlog 2>&1
145
146set +C
147
148date >> $scriptlog 2>&1
149
Note: See TracBrowser for help on using the repository browser.