- Timestamp:
- Oct 21, 2010, 2:45:13 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20100823/tools/czartool/Plotter.pm
r29124 r29515 33 33 ########################################################################### 34 34 sub createImageFileName { 35 my ($self, $label, $stage, $suffix, $isLog ) = @_;35 my ($self, $label, $stage, $suffix, $isLog, $isRate) = @_; 36 36 37 37 my $prefix = $self->{_outputPath} ? $self->{_outputPath} : "."; … … 55 55 ########################################################################### 56 56 # 57 # Plots a time series of processing rate for all stages for this label TODO duplication below. combine 58 # 59 ########################################################################### 60 sub createRateTimeSeries { 61 my ($self, $label, $selectedStage, $beginTime, $endTime, $interval, $isLog) = @_; 62 63 my $minX = 999999999; 64 my $maxX = -9999999999; 65 my $timeDiff = -1; 66 67 my $stages = undef; 68 69 if (!$selectedStage) {$stages = \@allStages;} 70 else {$stages = ["$selectedStage"]}; 71 72 $self->{_czarDb}->getTimeMinMaxDiff($label, $selectedStage, $beginTime, $endTime, \$minX, \$maxX, \$timeDiff); 73 74 my $divX; 75 my $timeFormat; 76 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 77 78 my %gnuplotFiles; 79 my $stage = undef; 80 my $gnuplotFile = undef; 81 my $outputFile = createImageFileName($self, $label, $selectedStage, "r", $isLog); 82 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 83 use FileHandle; 84 GP->autoflush(1); 85 print GP 86 "set term $self->{_outputFormat};" . 87 "set output \"$outputFile\";" . 88 "set title \"'$label', '$selectedStage' during '$beginTime' to '$endTime'\";" . 89 #"set xdata time;" . 90 "set timefmt \"$self->{_dateFormat}\";" . 91 "set format x \"$timeFormat\";" . 92 "set xtics \"$minX\", $divX, \"$maxX\";" . 93 # "set xrange [\"$minX\":\"$maxX\"];" . 94 "set grid;" . 95 "set boxwidth;" . 96 "set style data histogram;" . 97 "set style histogram rowstacked;" . 98 "set style fill solid border -1;" . 99 "set ylabel \"Exposures processed per $interval\";" . 100 "set boxwidth 0.75;" . 101 "plot "; 102 103 my $first = 1; 104 foreach $stage (@{$stages}) { 105 106 if ($self->{_czarDb}->createProcessingRateData( 107 $stage, 108 $label, 109 $beginTime, 110 $endTime, 111 $interval, 112 \$gnuplotFile, 113 $isLog)) { 114 115 $gnuplotFiles{$stage} = $gnuplotFile; 116 117 if (!$first) { print GP ","; } 118 print GP "'$gnuplotFile' using 2:xtic(1) title \"$stage\" "; 119 $first = 0; 120 } 121 } 122 123 print GP ";\n"; 124 close GP; 125 } 126 ########################################################################### 127 # 57 128 # Plots a time series for all stages for this label 58 129 # 59 130 ########################################################################### 60 131 sub createTimeSeries { 61 my ($self, $label, $selectedStage, $beginTime, $endTime, $isLog) = @_; 62 63 my ($minX, $maxX, $minY, $maxY, $timeDiff); 64 $minX = 999999999; 65 $maxX = -9999999999; 66 $minY = 999999999; 67 $maxY = -99999999; 68 $timeDiff = 0; 132 my ($self, $label, $selectedStage, $beginTime, $endTime, $isLog, $showCleanup, $deriv) = @_; 133 134 my $minX = 999999999; 135 my $maxX = -9999999999; 136 my $timeDiff = 0; 69 137 70 138 my $stages = undef; … … 85 153 \$minX, 86 154 \$maxX, 87 \$minY,88 \$maxY,89 155 \$timeDiff, 90 156 \$gnuplotFile, 91 $isLog)) { 157 $isLog, 158 $showCleanup, 159 $deriv)) { 92 160 93 161 $gnuplotFiles{$stage} = $gnuplotFile; … … 118 186 $maxX, 119 187 $minX, 120 $maxY,121 $minY,122 188 $timeDiff, 123 $isLog); 189 $isLog, 190 $deriv); 124 191 } 125 192 … … 161 228 close(GNUDAT); 162 229 163 plotHistogram($self, $inputFile, $outputFile, $label, $beginTime, $endTime, $maxY); 230 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 231 use FileHandle; 232 GP->autoflush(1); 233 234 if ($maxY == 0) {$maxY = 1;} 235 else {$maxY = $maxY*1.1;} 236 237 print GP 238 "set term $self->{_outputFormat};" . 239 "set output \"$outputFile\";" . 240 "set title \"'$label', '$beginTime' to '$endTime'\";" . 241 "set grid;" . 242 "set boxwidth;" . 243 "set yrange [\"0\":\"$maxY\"];" . 244 "set style data histogram;" . 245 "set style histogram rowstacked;" . 246 "set style fill solid border -1;" . 247 "set ylabel \"Exposures\";" . 248 "set boxwidth 0.75;" . 249 "plot '$inputFile' using 2:xtic(1) title \"Faults\" lt 1, '' using 3 title \"Processed\" lt 2, '' using 4 title \"Pending\" lt 7;" . 250 "\n"; 251 252 close GP; 164 253 unlink($inputFile); 165 254 } 166 167 255 168 256 ########################################################################### … … 239 327 ########################################################################### 240 328 sub plotTimeSeries { 241 my ($self, $gnuplotFiles, $outputFile, $label, $fromTime, $toTime, $maxX, $minX, $ maxY, $minY, $timeDiff, $isLog) = @_;329 my ($self, $gnuplotFiles, $outputFile, $label, $fromTime, $toTime, $maxX, $minX, $timeDiff, $isLog, $isDeriv) = @_; 242 330 243 331 my $timeFormat = undef; 244 332 my $divX = undef; 245 333 my $yTitle = undef; 246 if ($isLog) {$yTitle = "Log( numExposures )";} 247 else {$yTitle = "numExposures";} 334 if ($isLog) {$yTitle = "Log( Exposures )";} 335 elsif ($isDeriv) {$yTitle = "dExposures/dTime";} 336 else {$yTitle = "Exposures";} 248 337 249 338 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 250 339 251 340 my $numOfPlots = keys %$gnuplotFiles; 252 my $title = undef;253 341 254 342 # sort out plot title 255 if ($numOfPlots == 1) {foreach my $stage (keys %$gnuplotFiles) {$title = "'".$stage."'";}} 256 else {$title = "'All stages'"} 343 my $title = ""; 344 if ($isDeriv) {$title .= "First derivatives of "} 345 if ($numOfPlots == 1) {foreach my $stage (keys %$gnuplotFiles) {$title .= "'".$stage."'";}} 346 else {$title .= "'all stages'"} 257 347 258 348 $title .= " for '$label', '$fromTime' to '$toTime'"; … … 283 373 if ($numOfPlots == 1) { 284 374 375 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \"Pending\" with lines lt 4 lw 2,"; 285 376 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:4 title \"Processed\" with lines lt 2 lw 2,"; 286 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \"Pending\" with lines lt 4 lw 2,";287 377 print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \"Faults\" with lines lt 7 lw 2"; 288 378 } … … 346 436 close GP; 347 437 unlink($gnuplotFile); 348 }349 350 ###########################################################################351 #352 # Plots a histogram of processed stuff353 #354 ###########################################################################355 sub plotHistogram {356 my ($self, $inputFile, $outputFile, $label, $fromTime, $toTime, $maxY) = @_;357 358 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";359 use FileHandle;360 GP->autoflush(1);361 362 if ($maxY == 0) {$maxY = 1;}363 else {$maxY = $maxY*1.1;}364 365 print GP366 "set term $self->{_outputFormat};" .367 "set output \"$outputFile\";" .368 "set title \"'$label', '$fromTime' to '$toTime'\";" .369 "set grid;" .370 "set boxwidth;" .371 "set yrange [\"0\":\"$maxY\"];" .372 "set style data histogram;" .373 "set style histogram rowstacked;" .374 "set style fill solid border -1;" .375 "set ylabel \"Exposures\";" .376 "set boxwidth 0.75;" .377 "plot '$inputFile' using 2:xtic(1) title \"Faults\" lt 1, '' using 3 title \"Processed\" lt 2, '' using 4 title \"Pending\" lt 7;" .378 "\n";379 380 close GP;381 438 } 382 439
Note:
See TracChangeset
for help on using the changeset viewer.
