IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 27, 2010, 2:42:17 PM (16 years ago)
Author:
rhenders
Message:

Loads of stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/czarplot.pl

    r28714 r28719  
    55
    66use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
    7 use File::Temp qw(tempfile);
    87use POSIX qw/strftime/;
    98
    109use czartool::CzarDb;
    11 use czartool::Gnuplot;
    12 
     10use czartool::Czarplot;
    1311
    1412my $czarDbName = "czardb";
     
    1917my $begin = undef;
    2018my $end = undef;
     19my $path = undef;
    2120my $verbose = undef;
    2221my $histogram = undef;
    2322my $timeSeries = undef;
     23my $savingToFile = undef;
    2424
    2525GetOptions (
     
    3030        "begin|b=s" => \$begin,
    3131        "end|e=s" => \$end,
     32        "output|o=s" => \$path,
    3233        "histogram|h" => \$histogram,
    3334        "timeseries|t" => \$timeSeries,
     
    3738print "\n";
    3839if (!$histogram) {
    39     print "* OPTIONAL: plot histogram                  -h                          (default=on)\n";
    40 }
     40    print "* OPTIONAL: plot histogram                  -h                          (default=off)\n";}
    4141if (!$timeSeries) {
    42     print "* OPTIONAL: plot timeseries                 -t                          (default=on)\n";
    43 }
     42    print "* OPTIONAL: plot timeseries                 -t                          (default=on)\n";}
    4443if (!$label) {
    45     print "* OPTIONAL: choose a label                  -l <labellName>             (default='all_labels')\n";
    46 }
     44    print "* OPTIONAL: choose a label                  -l <labellName>             (default='all_labels')\n";}
    4745if (!$stage) {
    48     print "* OPTIONAL: choose a stage                  -s <chip|cam|warp|etc>      (default=none)\n";
    49 }
     46    print "* OPTIONAL: choose a stage                  -s <chip|cam|warp|etc>      (default=none)\n";}
    5047if (!$interval) {
    51     print "* OPTIONAL: choose time interval in past    -i <'1 hour'|'1 day'|etc>   (default=interval since 7am this morning)\n";
    52 }
     48    print "* OPTIONAL: choose time interval in past    -i <'1 hour'|'1 day'|etc>   (default=interval since 7am this morning)\n";}
    5349if (!$begin) {
    54     print "* OPTIONAL: choose a begin time             -d <datetime>               (default=7am this morning)\n";
    55 }
     50    print "* OPTIONAL: choose a begin time             -d <datetime>               (default=7am this morning)\n";}
    5651if (!$end) {
    57     print "* OPTIONAL: choose an end time              -e <datetime>               (default=now)\n";
    58 }
     52    print "* OPTIONAL: choose an end time              -e <datetime>               (default=now)\n";}
     53if (!$path) {
     54    print "* OPTIONAL: choose an output location       -o <path>                   (default=none)\n";}
    5955
    6056print "\n";
     
    6258# default values
    6359if (!$label) {$label = "all_labels";}
    64 if (!$histogram && !$timeSeries) {$timeSeries = 1;}
     60if (!$histogram && !$timeSeries) {$timeSeries = 1; $histogram = 1;}
    6561if (!$verbose) {$verbose = 0;}
    6662if (!$save_temps) {$save_temps = 0;}
     63if (!$path) {$savingToFile = 0; $path = ".";}
     64else {$savingToFile = 1;}
    6765
    6866my $czarDb = new czartool::CzarDb($czarDbName, "ippdb01", "ipp", "ipp", $verbose);
    69 my $gnuplot = new czartool::Gnuplot("%Y%m%d-%H%M%S", "X11", "histo.pbm");
    7067$czarDb->setDateFormat("%Y%m%d-%H%i%s");
     68
     69my $czarplot = new czartool::Czarplot($czarDb, "%Y%m%d-%H%M%S", $savingToFile ? "png" : "X11", $path, $save_temps);
    7170
    7271my @allStages = ("chip", "cam", "fake", "warp", "stack", "diff", "magic", "magicDS", "dist");
     
    7978}
    8079
    81 if ($histogram) {plotHistogram($label, $begin, $end);}
    82 if ($timeSeries) {plotTimeSeries($label, $stage, $begin, $end); }
     80if ($timeSeries) {$czarplot->createTimeSeries($label, $stage, $begin, $end);}
     81if ($histogram) {$czarplot->createHistogram($label, $begin, $end);}
    8382
    84 ###########################################################################
    85 #
    86 # Plots a time series for all stages for this label
    87 #
    88 ###########################################################################
    89 sub plotTimeSeries {
    90     my ($label, $selectedStage, $beginTime, $endTime) = @_;
    91 
    92     my ($minX, $maxX, $minY, $maxY, $timeDiff);
    93     $minX = 999999999;
    94     $maxX = -9999999999;
    95     $minY = 999999999;
    96     $maxY = -99999999;
    97 
    98     my $stages = undef;
    99 
    100     if (!$selectedStage) {$stages = \@allStages;}
    101     else {$stages = ["$selectedStage"]};
    102 
    103     my %gnuplotFiles;
    104     foreach $stage (@{$stages}) {
    105         $gnuplotFiles{$stage} = $czarDb->createTimeSeriesData($save_temps, $label, $stage, $beginTime, $endTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff);
    106     }
    107 
    108     if (!$selectedStage) {$gnuplot->plotAllStagesTimeSeries($label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff, \%gnuplotFiles);}
    109     else {$gnuplot->plotSingleTimeSeries($gnuplotFiles{$selectedStage}, $selectedStage, $label, $beginTime, $endTime, $maxX, $minX, $maxY, $minY, $timeDiff);}
    110 
    111 }
    112 
    113 ###########################################################################
    114 #
    115 # Plots a histogram of stuff processed in provided interval and label for all stages
    116 #
    117 ###########################################################################
    118 sub plotHistogram {
    119     my ($label, $beginTime, $endTime) = @_;
    120 
    121     my ($tempFile, $filePath) = tempfile( "/tmp/czartool_gnuplot_histogram.XXXX", UNLINK => !$save_temps);
    122     my ($processed, $pending, $faults);
    123 
    124     foreach $stage (@allStages) {
    125 
    126         $czarDb->countProcessedPendingAndFaults($label, $stage, $beginTime, $endTime, \$processed, \$pending, \$faults);
    127         print $tempFile "$stage $processed, $pending, $faults\n";
    128     }
    129 
    130     close($tempFile);
    131 
    132     $gnuplot->plotHistogram($filePath, $label, $beginTime, $endTime);
    133 }
    134 
    135 
    136 
Note: See TracChangeset for help on using the changeset viewer.