Changeset 30955
- Timestamp:
- Mar 17, 2011, 4:28:59 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/tools/czartool/Plotter.pm (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/czartool/Plotter.pm
r30918 r30955 146 146 # 147 147 ########################################################################### 148 sub createRate TimeSeries{149 my ($self, $label, $selectedStage, $beginTime, $endTime, $interval ) = @_;148 sub createRatePlot { 149 my ($self, $label, $selectedStage, $beginTime, $endTime, $interval, $histogram, $timeSeries) = @_; 150 150 151 151 # stages … … 164 164 my $stage = undef; 165 165 my $gnuplotFile = undef; 166 my $outputFile = createImageFileName($self, $label, $selectedStage, "r", 0); 166 my $minX = 999999999; 167 my $maxX = -9999999999; 168 my $timeDiff = 0; 169 170 foreach $stage (@{$stages}) { 171 172 if ($self->{_czarDb}->createProcessingRateData( 173 $stage, 174 $label, 175 $beginTime, 176 $endTime, 177 $interval, 178 \$gnuplotFile, 179 \$minX, \$maxX, \$timeDiff)) { 180 181 $gnuplotFiles{$stage} = $gnuplotFile; 182 #print "$minX, $maxX, $timeDiff\n"; 183 } 184 } 185 186 if ($histogram) { 187 188 my $outputFile = createImageFileName($self, $label, $selectedStage, "rh", 0); 189 $self->plotRateStackedHistogram(\%gnuplotFiles, $outputFile, $label, $selectedStage, $beginTime, $endTime, $interval); 190 } 191 if ($timeSeries) { 192 193 my $outputFile = createImageFileName($self, $label, $selectedStage, "rt", 0); 194 $self->plotTimeSeries(\%gnuplotFiles, $outputFile, $label, $beginTime, $endTime, $maxX, $minX, $timeDiff, "", "Exposures processed per $interval"); 195 } 196 197 # now delete temp dat files 198 foreach my $stage (keys %gnuplotFiles) {unlink($gnuplotFiles{$stage});} 199 200 return 1; 201 } 202 203 ########################################################################### 204 # 205 # Plots a stacked histogram of rate data for one or more stages 206 # 207 ########################################################################### 208 sub plotRateStackedHistogram { 209 my ($self, $gnuplotFiles, $outputFile, $label, $selectedStage, $beginTime, $endTime, $interval) = @_; 210 167 211 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 168 212 use FileHandle; … … 173 217 print GP 174 218 "set term $self->{_outputFormat};" . 175 "set title \"'$label' ,'$selectedStage'\\nFrom '$beginTime' to '$endTime' HST\";" .219 "set title \"'$label' for '$selectedStage'\\nFrom '$beginTime' to '$endTime' HST\";" . 176 220 "set boxwidth;" . 177 221 "set xtic rotate by -90 scale 0;" . … … 184 228 185 229 my $first = 1; 186 foreach $stage (@{$stages}) { 187 188 if ($self->{_czarDb}->createProcessingRateData( 189 $stage, 190 $label, 191 $beginTime, 192 $endTime, 193 $interval, 194 \$gnuplotFile)) { 195 196 $gnuplotFiles{$stage} = $gnuplotFile; 197 198 if (!$first) { print GP ","; } 199 print GP "'$gnuplotFile' using 2:xtic(1) title \"$stage\" "; 200 $first = 0; 201 } 230 foreach my $stage (@allStages) { 231 232 233 if(!$gnuplotFiles->{$stage}) {next;} 234 235 if (!$first) { print GP ","; } 236 print GP "'" . $gnuplotFiles->{$stage}. "' using 4:xtic(1) title \"$stage\" "; 237 $first = 0; 202 238 } 203 239 204 240 print GP ";\n"; 205 241 close GP; 206 207 # now delete temp dat files208 foreach my $stage (keys %gnuplotFiles) {unlink($gnuplotFiles{$stage});}209 242 210 243 return 1; … … 265 298 266 299 my $outputFile = createImageFileName($self, $label, $selectedStage, "t", $isLog); 300 my $yTitle; 301 if ($isLog) {$yTitle = "Log(Exposures)";} 302 elsif ($deriv) {$yTitle = "dExposures/dTime(secs)";} 303 else {$yTitle = "Exposures";} 267 304 $self->plotTimeSeries( 268 305 \%gnuplotFiles, … … 274 311 $minX, 275 312 $timeDiff, 276 $isLog,277 $ deriv);313 "", 314 $yTitle); 278 315 } 279 316 … … 365 402 ########################################################################### 366 403 # 367 # Figures out suitable spacing for time tics on time-series pl iots404 # Figures out suitable spacing for time tics on time-series plots 368 405 # 369 406 ########################################################################### … … 427 464 ########################################################################### 428 465 sub plotTimeSeries { 429 my ($self, $gnuplotFiles, $outputFile, $label, $fromTime, $toTime, $maxX, $minX, $timeDiff, $ isLog, $isDeriv) = @_;466 my ($self, $gnuplotFiles, $outputFile, $label, $fromTime, $toTime, $maxX, $minX, $timeDiff, $title, $yTitle) = @_; 430 467 431 468 my $timeFormat = undef; 432 469 my $divX = undef; 433 my $yTitle = undef;434 if ($isLog) {$yTitle = "Log( Exposures )";}435 elsif ($isDeriv) {$yTitle = "dExposures/dTime(secs)";}436 else {$yTitle = "Exposures";}470 #my $yTitle = undef; 471 #if ($isLog) {$yTitle = "Log( Exposures )";} 472 #elsif ($isDeriv) {$yTitle = "dExposures/dTime(secs)";} 473 #else {$yTitle = "Exposures";} 437 474 438 475 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); … … 441 478 442 479 # sort out plot title 443 my $title = "";444 if ($isDeriv) {$title .= "First derivatives of "}480 #my $title = ""; 481 #if ($isDeriv) {$title .= "First derivatives of "} 445 482 if ($numOfPlots == 1) {foreach my $stage (keys %$gnuplotFiles) {$title .= "'".$stage."'";}} 446 483 else {$title .= "'all stages'"} … … 462 499 "set xtics \"$minX\", $divX, \"$maxX\";" . 463 500 "set grid xtics;" . 501 "set grid ytics;" . 464 502 "set xlabel \"Time\";" . 465 503 "set ylabel \"$yTitle\";" .
Note:
See TracChangeset
for help on using the changeset viewer.
