IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 21, 2010, 2:45:13 PM (16 years ago)
Author:
eugene
Message:

merge changes from trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20100823/tools/czartool/Plotter.pm

    r29124 r29515  
    3333###########################################################################
    3434sub createImageFileName {
    35     my ($self, $label, $stage, $suffix, $isLog) = @_;
     35    my ($self, $label, $stage, $suffix, $isLog, $isRate) = @_;
    3636
    3737    my $prefix = $self->{_outputPath} ? $self->{_outputPath} : ".";
     
    5555###########################################################################
    5656#
     57# Plots a time series of processing rate for all stages for this label TODO duplication below. combine
     58#
     59###########################################################################
     60sub 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#
    57128# Plots a time series for all stages for this label
    58129#
    59130###########################################################################
    60131sub 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;
    69137
    70138    my $stages = undef;                 
     
    85153                    \$minX,
    86154                    \$maxX,
    87                     \$minY,
    88                     \$maxY,
    89155                    \$timeDiff,
    90156                    \$gnuplotFile,
    91                     $isLog)) {
     157                    $isLog,
     158                    $showCleanup,
     159                    $deriv)) {
    92160
    93161            $gnuplotFiles{$stage} = $gnuplotFile;
     
    118186            $maxX,
    119187            $minX,
    120             $maxY,
    121             $minY,
    122188            $timeDiff,
    123             $isLog);
     189            $isLog,
     190            $deriv);
    124191}                                                   
    125192
     
    161228    close(GNUDAT);
    162229
    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;
    164253    unlink($inputFile);
    165254}
    166 
    167255
    168256###########################################################################
     
    239327###########################################################################
    240328sub 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) = @_;
    242330
    243331    my $timeFormat = undef;
    244332    my $divX = undef;
    245333    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";}
    248337
    249338    $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat);
    250339
    251340    my $numOfPlots = keys %$gnuplotFiles;
    252     my $title = undef;
    253341
    254342    # 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'"}
    257347
    258348    $title .= " for '$label', '$fromTime' to '$toTime'";
     
    283373        if ($numOfPlots == 1) {
    284374
     375            print GP "'" . $gnuplotFiles->{$stage} . "' using 1:2 title \"Pending\" with lines lt 4 lw 2,";
    285376            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,";
    287377            print GP "'" . $gnuplotFiles->{$stage} . "' using 1:3 title \"Faults\" with lines lt 7 lw 2";
    288378        }
     
    346436    close GP;
    347437    unlink($gnuplotFile);
    348 }
    349 
    350 ###########################################################################
    351 #
    352 # Plots a histogram of processed stuff
    353 #
    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 GP
    366         "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;
    381438}
    382439
Note: See TracChangeset for help on using the changeset viewer.