IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 29864


Ignore:
Timestamp:
Nov 26, 2010, 3:24:30 PM (15 years ago)
Author:
rhenders
Message:

improvements to titles of mask plots; now including total mask fraction in mask plot titles; labelling time as HST throughout

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/czartool/Plotter.pm

    r29802 r29864  
    11#!/usr/bin/perl -w
     2
    23package czartool::Plotter;
    34
     
    5657}
    5758
    58 
    5959###########################################################################
    6060#
     
    6767
    6868    my $timeDiff = $self->{_czarDb}->diffTimes($end, $begin);
    69 
    7069
    7170    if ($self->{_czarDb}->isBefore($timeDiff, "00:00:01")) {return 0;}
    7271    elsif ($self->{_czarDb}->isBefore($timeDiff, "03:00:00")) {${$interval} = "15 MINUTE";}
    7372    elsif ($self->{_czarDb}->isBefore($timeDiff, "10:00:00")) {${$interval} = "30 MINUTE";}
    74     elsif ($self->{_czarDb}->isBefore($timeDiff, "24:00:00")) {${$interval} = "1 HOUR";} # under 1 day
     73    elsif ($self->{_czarDb}->isBefore($timeDiff, "26:00:00")) {${$interval} = "1 HOUR";} # under 1 day
    7574    elsif ($self->{_czarDb}->isBefore($timeDiff, "36:00:00")) {${$interval} = "2 HOUR";} # under 1.5 days
    7675    elsif ($self->{_czarDb}->isBefore($timeDiff, "48:00:00")) {${$interval} = "3 HOUR";} # under 2 days
     
    8382    else {${$interval} = "1 MONTH";}
    8483
     84# ${$interval} = "2 HOUR";
     85
    8586    return 1;
    8687}
     
    9293###########################################################################
    9394sub createRateTimeSeries {
    94     my ($self, $label, $selectedStage, $beginTime, $endTime, $interval, $isLog) = @_;
     95    my ($self, $label, $selectedStage, $beginTime, $endTime, $interval) = @_;
    9596
    9697    # stages
     
    109110    my $stage = undef;
    110111    my $gnuplotFile = undef;
    111     my $outputFile = createImageFileName($self, $label, $selectedStage, "r", $isLog);
     112    my $outputFile = createImageFileName($self, $label, $selectedStage, "r", 0);
    112113    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
    113114    use FileHandle;
     
    118119    print GP
    119120        "set term $self->{_outputFormat};" .
    120         "set title \"'$label', '$selectedStage' during '$beginTime' to '$endTime'\";" .
     121        "set title \"'$label', '$selectedStage'\\nFrom '$beginTime' to '$endTime' HST\";" .
    121122        "set boxwidth;" .
    122123        "set xtic rotate by -90 scale 0;" .
     
    137138                    $endTime,
    138139                    $interval,
    139                     \$gnuplotFile,
    140                     $isLog)) {
     140                    \$gnuplotFile)) {
    141141
    142142            $gnuplotFiles{$stage} = $gnuplotFile;
     
    251251                \$faults)) {next;}
    252252
    253         $pendingMinusFaults = $pending - $faults;
     253        $pendingMinusFaults = $pending - $faults; 
    254254        print GNUDAT "$stage $faults $processed $pendingMinusFaults\n";
    255255    }
     
    264264    print GP
    265265        "set term $self->{_outputFormat};" .
    266         "set title \"'$label', '$beginTime' to '$endTime'\";" .
     266        "set title \"'$label'\\nFrom '$beginTime' to '$endTime' HST\";" .
    267267        "set grid;" .
    268268        "set boxwidth;" .
     
    379379    my $yTitle = undef;
    380380    if ($isLog) {$yTitle = "Log( Exposures )";}
    381     elsif ($isDeriv) {$yTitle = "dExposures/dTime";}
     381    elsif ($isDeriv) {$yTitle = "dExposures/dTime(secs)";}
    382382    else {$yTitle = "Exposures";}
    383383
     
    392392    else {$title .= "'all stages'"}
    393393
    394     $title .= " for '$label', '$fromTime' to '$toTime'";
     394    $title .= " for '$label'\\nFrom '$fromTime' to '$toTime' HST";
    395395
    396396    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
     
    454454
    455455    my $tmpFile = File::Temp->new( TEMPLATE => "czarplot_gnuplot_storage_timeseries.XXXXX", DIR => '/tmp', SUFFIX => 'dat');
    456     $self->{_czarDb}->createStorageTimeSeriesData($tmpFile, $fromTime, $toTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff);
     456    if (!$self->{_czarDb}->createStorageTimeSeriesData($tmpFile, $fromTime, $toTime, \$minX, \$maxX, \$minY, \$maxY, \$timeDiff)) {return 0;}
    457457
    458458    my $timeFormat = undef;
     
    468468    print GP
    469469        "set term $self->{_outputFormat};" .
    470         "set title \"Total available cluster space over time\";" .
     470        "set title \"Total available cluster space over time\\nFrom $fromTime to $toTime HST\";" .
    471471        "set key left top;" .
    472472        "set xdata time;" .
     
    482482    print GP "\n";
    483483    close GP;
     484
     485    return 1;
    484486}
    485487
     
    530532###########################################################################
    531533#
    532 # Generates 3D plot of magic mask fraction for provided exposure ID
     534# Generates 2D plot of magic mask fraction for provided exposure ID
    533535#
    534536###########################################################################
     
    546548    open (GNUDAT, ">".$tmpFile->filename);
    547549
     550    # missing corner chip
    548551    print GNUDAT "0 0 0.0\n";
    549552    foreach my $row ( @{$fracs} ) {
     
    551554        if (@{$row}[0] =~ m/XY([0-9])([0-9])/) {
    552555            print GNUDAT "$1 $2 @{$row}[1]\n";
     556            # missing corner chips
    553557            if($1 == 0 && $2 == 6) {print GNUDAT "0 7 0.0\n";}
    554558            if($1 == 6 && $2 == 7) {print GNUDAT "7 0 0.0\n";}
    555559        }
    556560    }
     561    # missing corner chip
    557562    print GNUDAT "7 7 0.0\n";
    558563
     
    596601#
    597602###########################################################################
    598 sub plotMagicMaskFractionHistogram {
     603sub plotMagicMaskFraction {
    599604    my ($self, $begin, $end) = @_;
    600605
     
    623628    }
    624629
     630    my $meanMask = undef;
     631    my $sumMask = undef;
     632    my $chipCount = undef;
     633    my $expCount = 0;
     634    my $totalChipCount = 0;
     635    my $totalMask = 0;
     636    my $exp_id = undef;
     637
    625638    # get mask for each exposure, and bin
    626     my $mask = undef;
    627     my $expCount = 0;
    628639    foreach my $row ( @{$exp_ids} ) {
    629640
    630         $mask = $self->{_gpc1Db}->getAverageMagicMaskFraction(@{$row}[0]);
    631 
    632         if (!$mask) {next;}
     641        $exp_id = @{$row}[0];
     642
     643        if (!$self->{_gpc1Db}->getMagicMaskStats($exp_id, \$meanMask, \$sumMask, \$chipCount )) {next;}
     644
     645
     646        if (!$meanMask) {next;}
     647        #print "expId=$exp_id meanMask=$meanMask sumMask=$sumMask nChips=$chipCount\n";
    633648        $expCount++;
     649        $totalMask += $sumMask;
     650        $totalChipCount += $chipCount;
    634651
    635652        foreach my $bin (@bins) {
    636             if ($mask <= ($bin+$interval)) {
     653            if ($meanMask <= ($bin+$interval)) {
    637654
    638655                $histogram{$bin}++;
     
    640657            }
    641658        }
     659    }
     660
     661    my $totalMaskFrac;
     662   
     663    if ($totalChipCount > 0) {
     664
     665        $totalMaskFrac = sprintf( "%.1f", ($totalMask/$totalChipCount) * 100.0);
     666    }
     667    else {
     668
     669        $totalMaskFrac = "NA";
    642670    }
    643671
     
    655683    close(GNUDAT);
    656684
    657     # now plot
     685
     686    $maxBin = $maxBin * 1.1;
     687    $accum = $accum * 1.1;
     688
     689    my $title = "Magic Mask Fraction for $expCount exposures\\nData taken between '$begin' and '$end'\\nTotal masked fraction is $totalMaskFrac%";
     690
     691    # make histogram
    658692    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
    659693    use FileHandle;
    660694    GP->autoflush(1);
    661 
    662     $maxBin = $maxBin * 1.1;
    663     $accum = $accum * 1.1;
    664 
    665695    if ($self->{_outputFormat} ne "X11") {print GP "set output \"$histoOutputFile\";";}
    666696    print GP
    667697        "set term $self->{_outputFormat};" .
    668         "set title \"Magic mask fraction for $expCount exposures between '$begin' and '$end'\";" .
     698        "set title \"$title\";" .
    669699        "set grid;" .
    670700        "set boxwidth;" .
     
    682712    close GP;
    683713
    684 
     714    # make cumulative distribution
    685715    open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot";
    686716    use FileHandle;
    687717    GP->autoflush(1);
    688 
    689718    if ($self->{_outputFormat} ne "X11") {print GP "set output \"$distOutputFile\";";}
    690719    print GP
    691720        "set term $self->{_outputFormat};" .
    692         "set title \"Cumulative distribution of magic streaks per image between '$begin' and '$end'\";" .
     721        "set title \"Cumulative distribution of $title\";" .
    693722        "set yrange [0:$accum];" .
    694723        "set key left top;" .
Note: See TracChangeset for help on using the changeset viewer.