IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

Added log plots for timeseries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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\";" .
Note: See TracChangeset for help on using the changeset viewer.