IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29114


Ignore:
Timestamp:
Sep 2, 2010, 3:09:56 PM (16 years ago)
Author:
rhenders
Message:

Added log plots for timeseries

Location:
trunk/tools
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/czarplot.pl

    r29057 r29114  
    2323my $nebulous = undef;
    2424my $savingToFile = undef;
     25my $log = undef;
    2526
    2627GetOptions (
     
    3637        "timeseries|t" => \$timeSeries,
    3738        "verbose|v" => \$verbose,
     39        "log|g" => \$log,
    3840        );
    39 
    4041
    4142print "\n*******************************************************************************\n";
     
    5051if (!$timeSeries) {
    5152    print "* OPTIONAL: plot timeseries                 -t                          (default=on)\n";}
     53if (!$log) {
     54    $log = 0;
     55    print "* OPTIONAL: use log plots                   -g                          (default=$log\n";}
    5256if (!$nebulous) {
    5357    print "* OPTIONAL: plot nebulous disk space        -n                          (default=off)\n";}
    5458if (!$label) {
    55     print "* OPTIONAL: choose a label                  -l <labellName>             (default='all_stdscience_labels')\n";}
     59    $label = "all_stdscience_labels";
     60    print "* OPTIONAL: choose a label                  -l <labellName>             (default=$label)\n";}
    5661if (!$stage) {
    5762    print "* OPTIONAL: choose a stage                  -s <chip|cam|warp|etc>      (default=none)\n";}
     
    6368    print "* OPTIONAL: choose an end time              -e <datetime>               (default=now)\n";}
    6469if (!$path) {
    65     print "* OPTIONAL: choose an output location       -o <path>                   (default=none)\n";}
     70    print "* OPTIONAL: choose an output location       -o <path>                   (default=none)\n";
     71}
    6672print "*\n*******************************************************************************\n";
    6773
     
    6975
    7076# default values
    71 if (!$label) {$label = "all_stdscience_labels";}
    7277if (!$nebulous && !$histogram && !$timeSeries) {$timeSeries = 1; $histogram = 0;}
    7378if (!$verbose) {$verbose = 0;}
     
    9297my $diskUsage = 1; # TODO
    9398
    94 if (!$nebulous && $timeSeries) {$czarplot->createTimeSeries($label, $stage, $begin, $end);}
     99if (!$nebulous && $timeSeries) {$czarplot->createTimeSeries($label, $stage, $begin, $end, !$log, $log);}
    95100if ($histogram) {$czarplot->createHistogram($label, $begin, $end);}
    96101if ($nebulous && $timeSeries) {$czarplot->plotStorageTimeSeries($begin, $end);}
  • trunk/tools/czartool/CzarDb.pm

    r29078 r29114  
    242242###########################################################################
    243243sub 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}");
    248250
    249251    my $query = $self->{_db}->prepare(<<SQL);
     
    259261SQL
    260262
    261     if (!$query->execute) {return undef;}
     263    if (!$query->execute) {return 0;}
    262264
    263265    my $minProcessed = undef;
     
    265267    ($minProcessed, ${$maxY}, ${$minY}, ${$maxX}, ${$minX}, ${$timeDiff}) = $query->fetchrow_array();
    266268
    267     if (!defined $minProcessed) {return undef;}
     269    if (!defined $minProcessed) {return 0;}
    268270
    269271    $query = $self->{_db}->prepare(<<SQL);
     
    280282    # loop round results
    281283    while (my @row = $query->fetchrow_array()) {
    282 
    283284        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
    284290    #    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;
    290299}
    291300
  • trunk/tools/czartool/Czarplot.pm

    r29058 r29114  
    3333###########################################################################
    3434sub createImageFileName {
    35     my ($self, $label, $stage, $suffix) = @_;
     35    my ($self, $label, $stage, $suffix, $isLog) = @_;
    3636
    3737    my $prefix = $self->{_outputPath} ? $self->{_outputPath} : ".";
    3838    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";
    4041}
    4142
     
    4647###########################################################################
    4748sub 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) = @_;
    5150
    5251    my ($minX, $maxX, $minY, $maxY, $timeDiff);
     
    6160    else {$stages = ["$selectedStage"]};       
    6261
    63     my %gnuplotFiles;
     62    my %gnuplotFilesLin;
     63    my %gnuplotFilesLog;
    6464    my $stage = undef;
    65     my $gnuplotFile = undef;
     65    my $gnuplotFileLin = undef;
     66    my $gnuplotFileLog = undef;
    6667    foreach $stage (@{$stages}) {
    6768
    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        }
    7085
    7186    }                                                           
    7287
    73     my $numOfPlots =  keys(%gnuplotFiles);
     88    my $numOfPlots =  keys(%gnuplotFilesLin);
    7489
    7590    if ($numOfPlots == 0 ) {
     
    85100    }
    86101
    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    }
    88113}                                                   
    89114
     
    96121    my ($self, $label, $beginTime, $endTime) = @_;
    97122
    98     my $outputFile = createImageFileName($self, $label, undef, "h");
     123    my $outputFile = createImageFileName($self, $label, undef, "h", 0);
    99124
    100125    my $inputFile = "/tmp/czarplot_gnuplot_".$label."_h.dat"; # TODO use stage not table
    101     open (GNUDAT, ">$inputFile");
     126        open (GNUDAT, ">$inputFile");
    102127
    103128    my ($processed, $pending, $faults);
     
    216241###########################################################################
    217242sub 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) = @_;
    219244
    220245    $self->sortOutMaxMinY(\$minY, \$maxY);
     
    222247    my $timeFormat = undef;
    223248    my $divX = undef;
    224 
     249    my $yTitle = undef;
     250    if ($isLog) {$yTitle = "Log(Num of Exposures)";}
     251    else {$yTitle = "Num of Exposures";}
    225252    $self->getTimeSpacing($timeDiff, \$divX, \$timeFormat);
    226253
     
    245272        "set xdata time;" .
    246273        "set timefmt \"$self->{_dateFormat}\";" .
    247     #    "set yrange [\"$minY\":\"$maxY\"];" .
     274        #    "set yrange [\"$minY\":\"$maxY\"];" .
    248275        "set xrange [\"$minX\":\"$maxX\"];" .
    249276        "set format x \"$timeFormat\";" .
     
    251278        "set grid xtics;" .
    252279        "set xlabel \"Time\";" .
    253         "set ylabel \"Exposures\";" .
     280        "set ylabel \"$yTitle\";" .
    254281        "plot ";
    255282
     
    342369        "set boxwidth;" .
    343370        "set style data histogram;" .
    344  "set style histogram rowstacked;" .
     371        "set style histogram rowstacked;" .
    345372        "set style fill solid border -1;" .
    346373        "set ylabel \"Exposures\";" .
  • trunk/tools/roboczar.pl

    r29079 r29114  
    186186
    187187            chomp($label);
    188             $czarplot->createTimeSeries($label,  $stage, $begin, $end);
     188            $czarplot->createTimeSeries($label,  $stage, $begin, $end, 1, 1);
    189189        }
    190190    }
     
    194194        my ($label) = @{$row};
    195195
    196         $czarplot->createTimeSeries($label, undef, $begin, $end);
     196        $czarplot->createTimeSeries($label, undef, $begin, $end, 1, 1);
    197197        $czarplot->createHistogram($label, $begin, $end);
    198198
    199199        #routineChecks($label, "1 HOUR");
    200200    }
    201     $czarplot->createTimeSeries("all_".$server."_labels", undef, $begin, $end);
     201    $czarplot->createTimeSeries("all_".$server."_labels", undef, $begin, $end, 1, 1);
    202202    $czarplot->createHistogram("all_".$server."_labels", $begin, $end);
    203203    foreach $stage (@stages) {
    204204
    205         $czarplot->createTimeSeries("all_".$server."_labels",  $stage, $begin, $end); # TODO must be a neater way...
     205        $czarplot->createTimeSeries("all_".$server."_labels",  $stage, $begin, $end, 1, 1); # TODO must be a neater way...
    206206    }
    207207}
Note: See TracChangeset for help on using the changeset viewer.