Changeset 29114 for trunk/tools/czartool
- Timestamp:
- Sep 2, 2010, 3:09:56 PM (16 years ago)
- Location:
- trunk/tools/czartool
- Files:
-
- 2 edited
-
CzarDb.pm (modified) (4 diffs)
-
Czarplot.pm (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/czartool/CzarDb.pm
r29078 r29114 242 242 ########################################################################### 243 243 sub createTimeSeriesData { 244 my ($self, $label, $stage, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff) = @_; 245 246 my $dataFile = "/tmp/czarplot_gnuplot_".$label."_".$stage."_t.dat"; 247 open (GNUDAT, ">$dataFile"); 244 my ($self, $label, $stage, $fromTime, $toTime, $minX, $maxX, $minY, $maxY, $timeDiff, $dataFileLin, $dataFileLog) = @_; 245 246 ${$dataFileLin} = "/tmp/czarplot_gnuplot_lin_".$label."_".$stage."_t.dat"; 247 ${$dataFileLog} = "/tmp/czarplot_gnuplot_log_".$label."_".$stage."_t.dat"; 248 open (GNUDATLIN, ">${$dataFileLin}"); 249 open (GNUDATLOG, ">${$dataFileLog}"); 248 250 249 251 my $query = $self->{_db}->prepare(<<SQL); … … 259 261 SQL 260 262 261 if (!$query->execute) {return undef;}263 if (!$query->execute) {return 0;} 262 264 263 265 my $minProcessed = undef; … … 265 267 ($minProcessed, ${$maxY}, ${$minY}, ${$maxX}, ${$minX}, ${$timeDiff}) = $query->fetchrow_array(); 266 268 267 if (!defined $minProcessed) {return undef;}269 if (!defined $minProcessed) {return 0;} 268 270 269 271 $query = $self->{_db}->prepare(<<SQL); … … 280 282 # loop round results 281 283 while (my @row = $query->fetchrow_array()) { 282 283 284 my ($timestamp, $pending, $faults, $processed) = @row; 285 286 my $processedLog = log($processed + 1); 287 my $pendingLog = log($pending + 1); 288 my $faultsLog = log($faults + 1); 289 284 290 # print "'$timestamp' '$pending' '$faults' '$processed'\n"; 285 print GNUDAT "$timestamp $pending $faults $processed\n"; 286 } 287 close(GNUDAT); 288 289 return $dataFile; 291 print GNUDATLIN "$timestamp $pending $faults $processed\n"; 292 print GNUDATLOG "$timestamp $pendingLog $faultsLog $processedLog\n"; 293 } 294 295 close(GNUDATLIN); 296 close(GNUDATLOG); 297 298 return 1; 290 299 } 291 300 -
trunk/tools/czartool/Czarplot.pm
r29058 r29114 33 33 ########################################################################### 34 34 sub createImageFileName { 35 my ($self, $label, $stage, $suffix ) = @_;35 my ($self, $label, $stage, $suffix, $isLog) = @_; 36 36 37 37 my $prefix = $self->{_outputPath} ? $self->{_outputPath} : "."; 38 38 my $stagePart = $stage ? $stage : "all_stages"; 39 return $prefix . "/czarplot_" . $label . "_" . $stagePart . "_$suffix.png"; 39 my $type = $isLog ? "log" : "linear"; 40 return $prefix . "/czarplot_" . $type . "_" . $label . "_" . $stagePart . "_$suffix.png"; 40 41 } 41 42 … … 46 47 ########################################################################### 47 48 sub createTimeSeries { 48 my ($self, $label, $selectedStage, $beginTime, $endTime) = @_; 49 50 my $outputFile = createImageFileName($self, $label, $selectedStage, "t"); 49 my ($self, $label, $selectedStage, $beginTime, $endTime, $makeLinear, $makeLog) = @_; 51 50 52 51 my ($minX, $maxX, $minY, $maxY, $timeDiff); … … 61 60 else {$stages = ["$selectedStage"]}; 62 61 63 my %gnuplotFiles; 62 my %gnuplotFilesLin; 63 my %gnuplotFilesLog; 64 64 my $stage = undef; 65 my $gnuplotFile = undef; 65 my $gnuplotFileLin = undef; 66 my $gnuplotFileLog = undef; 66 67 foreach $stage (@{$stages}) { 67 68 68 $gnuplotFile = $self->{_czarDb}->createTimeSeriesData($label, $stage, $beginTime, $endTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff); 69 if ($gnuplotFile) {$gnuplotFiles{$stage} = $gnuplotFile;} 69 if($self->{_czarDb}->createTimeSeriesData( 70 $label, 71 $stage, 72 $beginTime, 73 $endTime, 74 \$minX, 75 \$maxX, 76 \$minY, 77 \$maxY, 78 \$timeDiff, 79 \$gnuplotFileLin, 80 \$gnuplotFileLog)) { 81 82 $gnuplotFilesLin{$stage} = $gnuplotFileLin; 83 $gnuplotFilesLog{$stage} = $gnuplotFileLog; 84 } 70 85 71 86 } 72 87 73 my $numOfPlots = keys(%gnuplotFiles );88 my $numOfPlots = keys(%gnuplotFilesLin); 74 89 75 90 if ($numOfPlots == 0 ) { … … 85 100 } 86 101 87 plotTimeSeries($self, \%gnuplotFiles, $outputFile, $label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff); 102 my $outputFile; 103 if ($makeLinear) { 104 105 $outputFile = createImageFileName($self, $label, $selectedStage, "t", 0); 106 $self->plotTimeSeries(\%gnuplotFilesLin, $outputFile, $label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff, 0); 107 } 108 if ($makeLog) { 109 110 $outputFile = createImageFileName($self, $label, $selectedStage, "t", 1); 111 $self->plotTimeSeries(\%gnuplotFilesLog, $outputFile, $label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff, 1); 112 } 88 113 } 89 114 … … 96 121 my ($self, $label, $beginTime, $endTime) = @_; 97 122 98 my $outputFile = createImageFileName($self, $label, undef, "h" );123 my $outputFile = createImageFileName($self, $label, undef, "h", 0); 99 124 100 125 my $inputFile = "/tmp/czarplot_gnuplot_".$label."_h.dat"; # TODO use stage not table 101 open (GNUDAT, ">$inputFile");126 open (GNUDAT, ">$inputFile"); 102 127 103 128 my ($processed, $pending, $faults); … … 216 241 ########################################################################### 217 242 sub plotTimeSeries { 218 my ($self, $gnuplotFiles, $outputFile, $label, $fromTime, $toTime, $maxX, $minX, $maxY, $minY, $timeDiff ) = @_;243 my ($self, $gnuplotFiles, $outputFile, $label, $fromTime, $toTime, $maxX, $minX, $maxY, $minY, $timeDiff, $isLog) = @_; 219 244 220 245 $self->sortOutMaxMinY(\$minY, \$maxY); … … 222 247 my $timeFormat = undef; 223 248 my $divX = undef; 224 249 my $yTitle = undef; 250 if ($isLog) {$yTitle = "Log(Num of Exposures)";} 251 else {$yTitle = "Num of Exposures";} 225 252 $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat); 226 253 … … 245 272 "set xdata time;" . 246 273 "set timefmt \"$self->{_dateFormat}\";" . 247 # "set yrange [\"$minY\":\"$maxY\"];" .274 # "set yrange [\"$minY\":\"$maxY\"];" . 248 275 "set xrange [\"$minX\":\"$maxX\"];" . 249 276 "set format x \"$timeFormat\";" . … … 251 278 "set grid xtics;" . 252 279 "set xlabel \"Time\";" . 253 "set ylabel \" Exposures\";" .280 "set ylabel \"$yTitle\";" . 254 281 "plot "; 255 282 … … 342 369 "set boxwidth;" . 343 370 "set style data histogram;" . 344 "set style histogram rowstacked;" .371 "set style histogram rowstacked;" . 345 372 "set style fill solid border -1;" . 346 373 "set ylabel \"Exposures\";" .
Note:
See TracChangeset
for help on using the changeset viewer.
