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

Last change on this file since 7912 was 7902, checked in by Daniela Dorner, 18 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.3 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
34program=dowebplots
35source `dirname $0`/sourcefile
36
37set -C
38
39cd $mars
40
41datetime=`date +%F-%H-%M-%S`
42
43scriptlogpath=$logpath/run/dowebplots/`date +%Y/%m/%d`
44makedir $scriptlogpath
45
46scriptlog=$scriptlogpath/dowebplots-$datetime.log
47
48date >> $scriptlog 2>&1
49
50
51while getopts p: opts
52do
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
60done
61
62if [ "$type" = "" ]
63then
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
68fi
69
70# check if script is already running
71lockfile=$lockpath/lock-dowebplots-$type.txt
72checklock >> $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
77rootfiles=`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
80if [ "$rootfiles" = "" ]
81then
82 echo "nothing to do -> exit" >> $scriptlog 2>&1
83 rm -v $lockfile >> $scriptlog 2>&1
84 date >> $scriptlog 2>&1
85 exit
86fi
87
88
89#produce plots for each rootfile
90for rootfile in ${rootfiles[@]}
91do
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
135done
136
137rm -v $lockfile >> $scriptlog 2>&1
138
139set +C
140
141date >> $scriptlog 2>&1
142
Note: See TracBrowser for help on using the repository browser.