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

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