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

Last change on this file since 9086 was 9074, checked in by Daniela Dorner, 16 years ago
*** empty log message ***
  • Property svn:executable set to *
File size: 4.5 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-2007
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
34source `dirname $0`/sourcefile
35printprocesslog "INFO starting $0"
36program=dowebplots
37
38set -C
39
40scriptlog=$runlogpath/$program-$datetime.log
41date >> $scriptlog 2>&1
42
43while getopts p: opts
44do
45 case $opts in
46 p) type=$OPTARG
47 echo "got programname: $type" >> $scriptlog 2>&1
48 ;;
49 ?) echo "usage: $(basename $0) -p programname" >> $scriptlog 2>&1
50 ;;
51 esac
52done
53
54if [ "$type" = "" ]
55then
56 echo "no program name given -> exit" >> $scriptlog 2>&1
57 echo "usage: $(basename $0) -p programname" >> $scriptlog 2>&1
58 date >> $scriptlog 2>&1
59 printprocesslog "INFO finished $0"
60 exit
61fi
62
63# check if script is already running
64lockfile=$lockpath/lock-$program-$type.txt
65checklock >> $scriptlog 2>&1
66
67#finding all rootfiles in the data directory, that were modified in the last 3 days
68#this are all statusdisplays
69rootfiles=`find $datapath/$type/ -maxdepth 10 -name '*.root' -mtime -3 | grep -v '_I_' | grep -v '_Y_' | grep -v 'summary'`
70
71#exit if no rootfiles are found
72if [ "$rootfiles" = "" ]
73then
74 echo "nothing to do -> exit" >> $scriptlog 2>&1
75 finish >> $scriptlog 2>&1
76fi
77
78
79cd $mars
80
81#produce plots for each rootfile
82printprocesslog "INFO procduing plots for each $type rootfile"
83for rootfile in ${rootfiles[@]}
84do
85 date >> $scriptlog 2>&1
86 #get names of the psfile and the
87 #pngfiles (1 per tab in the statusdiplay)
88 psfile=`echo $rootfile | sed -e 's/.root$/.ps/g'`
89 tabfile=`echo $rootfile | sed -e 's/.root$/-tab/g'`
90 echo "rootfile: $rootfile" >> $scriptlog 2>&1
91 echo "psfile: $psfile" >> $scriptlog 2>&1
92 echo "tabfile: $tabfile" >> $scriptlog 2>&1
93
94 #get date of root- and psfile
95 daterootfile=`date +%Y%m%d -r $rootfile` >> $scriptlog 2>&1
96 datepsfile=`date +%Y%m%d -r $psfile` >> $scriptlog 2>&1
97 if [ "$datepsfile" = "" ]
98 then
99 echo "date of psfile is empty, i.e. the file $psfile doesn't exist" >> $scriptlog 2>&1
100 echo " -> setting date to 0 and producing psfile..." >> $scriptlog 2>&1
101 datepsfile=0
102 fi
103
104 echo "checking date..." >> $scriptlog 2>&1
105 echo "date of rootfile: $daterootfile" >> $scriptlog 2>&1
106 echo "date of psfile: $datepsfile" >> $scriptlog 2>&1
107 #if the psfile is newer than the rootfile
108 #no plots have to be done -> continue
109 if [ "$datepsfile" -gt "$daterootfile" ] >> $scriptlog 2>&1
110 then
111 echo "psfile is newer than rootfile -> continue " >> $scriptlog 2>&1
112 continue
113 fi
114
115 printprocesslog "INFO procduing plots for $rootfile"
116 echo "producing psfile..." >> $scriptlog 2>&1
117 ./showplot -b --save-as-ps=$psfile $rootfile >> $scriptlog 2>&1
118
119 echo "creating temporary dir for pstoimg..." >> $scriptlog 2>&1
120 temppath=`dirname $rootfile | sed -e 's/\/magic\/data//'`
121 tempwebplotspath=/tmp/pstoimgtmp$temppath
122 makedir $tempwebplotspath >> $scriptlog 2>&1
123
124 echo "converting plots to png..." >> $scriptlog 2>&1
125 pstoimg -antialias -aaliastext -interlaced -flip r270 -density 100 -tmp $tempwebplotspath -type png -multipage -out=$tabfile $psfile >> $scriptlog 2>&1
126
127 echo "removing temporary dir..." >> $scriptlog 2>&1
128 rmdir -pv $tempwebplotspath >> $scriptlog 2>&1
129
130 echo "converting $psfile to pdf..." >> $scriptlog 2>&1
131 if ps2pdf $psfile >> $scriptlog 2>&1
132 then
133 rm -v $psfile >> $scriptlog 2>&1
134 else
135 printprocesslog "WARN could not convert $psfile to pdf"
136 fi
137done
138
139finish >> $scriptlog 2>&1
140
Note: See TracBrowser for help on using the repository browser.