Changeset 29864
- Timestamp:
- Nov 26, 2010, 3:24:30 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/tools/czartool/Plotter.pm (modified) (23 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/czartool/Plotter.pm
r29802 r29864 1 1 #!/usr/bin/perl -w 2 2 3 package czartool::Plotter; 3 4 … … 56 57 } 57 58 58 59 59 ########################################################################### 60 60 # … … 67 67 68 68 my $timeDiff = $self->{_czarDb}->diffTimes($end, $begin); 69 70 69 71 70 if ($self->{_czarDb}->isBefore($timeDiff, "00:00:01")) {return 0;} 72 71 elsif ($self->{_czarDb}->isBefore($timeDiff, "03:00:00")) {${$interval} = "15 MINUTE";} 73 72 elsif ($self->{_czarDb}->isBefore($timeDiff, "10:00:00")) {${$interval} = "30 MINUTE";} 74 elsif ($self->{_czarDb}->isBefore($timeDiff, "2 4:00:00")) {${$interval} = "1 HOUR";} # under 1 day73 elsif ($self->{_czarDb}->isBefore($timeDiff, "26:00:00")) {${$interval} = "1 HOUR";} # under 1 day 75 74 elsif ($self->{_czarDb}->isBefore($timeDiff, "36:00:00")) {${$interval} = "2 HOUR";} # under 1.5 days 76 75 elsif ($self->{_czarDb}->isBefore($timeDiff, "48:00:00")) {${$interval} = "3 HOUR";} # under 2 days … … 83 82 else {${$interval} = "1 MONTH";} 84 83 84 # ${$interval} = "2 HOUR"; 85 85 86 return 1; 86 87 } … … 92 93 ########################################################################### 93 94 sub createRateTimeSeries { 94 my ($self, $label, $selectedStage, $beginTime, $endTime, $interval , $isLog) = @_;95 my ($self, $label, $selectedStage, $beginTime, $endTime, $interval) = @_; 95 96 96 97 # stages … … 109 110 my $stage = undef; 110 111 my $gnuplotFile = undef; 111 my $outputFile = createImageFileName($self, $label, $selectedStage, "r", $isLog);112 my $outputFile = createImageFileName($self, $label, $selectedStage, "r", 0); 112 113 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 113 114 use FileHandle; … … 118 119 print GP 119 120 "set term $self->{_outputFormat};" . 120 "set title \"'$label', '$selectedStage' during '$beginTime' to '$endTime'\";" .121 "set title \"'$label', '$selectedStage'\\nFrom '$beginTime' to '$endTime' HST\";" . 121 122 "set boxwidth;" . 122 123 "set xtic rotate by -90 scale 0;" . … … 137 138 $endTime, 138 139 $interval, 139 \$gnuplotFile, 140 $isLog)) { 140 \$gnuplotFile)) { 141 141 142 142 $gnuplotFiles{$stage} = $gnuplotFile; … … 251 251 \$faults)) {next;} 252 252 253 $pendingMinusFaults = $pending - $faults; 253 $pendingMinusFaults = $pending - $faults; 254 254 print GNUDAT "$stage $faults $processed $pendingMinusFaults\n"; 255 255 } … … 264 264 print GP 265 265 "set term $self->{_outputFormat};" . 266 "set title \"'$label' , '$beginTime' to '$endTime'\";" .266 "set title \"'$label'\\nFrom '$beginTime' to '$endTime' HST\";" . 267 267 "set grid;" . 268 268 "set boxwidth;" . … … 379 379 my $yTitle = undef; 380 380 if ($isLog) {$yTitle = "Log( Exposures )";} 381 elsif ($isDeriv) {$yTitle = "dExposures/dTime ";}381 elsif ($isDeriv) {$yTitle = "dExposures/dTime(secs)";} 382 382 else {$yTitle = "Exposures";} 383 383 … … 392 392 else {$title .= "'all stages'"} 393 393 394 $title .= " for '$label' , '$fromTime' to '$toTime'";394 $title .= " for '$label'\\nFrom '$fromTime' to '$toTime' HST"; 395 395 396 396 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; … … 454 454 455 455 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;} 457 457 458 458 my $timeFormat = undef; … … 468 468 print GP 469 469 "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\";" . 471 471 "set key left top;" . 472 472 "set xdata time;" . … … 482 482 print GP "\n"; 483 483 close GP; 484 485 return 1; 484 486 } 485 487 … … 530 532 ########################################################################### 531 533 # 532 # Generates 3D plot of magic mask fraction for provided exposure ID534 # Generates 2D plot of magic mask fraction for provided exposure ID 533 535 # 534 536 ########################################################################### … … 546 548 open (GNUDAT, ">".$tmpFile->filename); 547 549 550 # missing corner chip 548 551 print GNUDAT "0 0 0.0\n"; 549 552 foreach my $row ( @{$fracs} ) { … … 551 554 if (@{$row}[0] =~ m/XY([0-9])([0-9])/) { 552 555 print GNUDAT "$1 $2 @{$row}[1]\n"; 556 # missing corner chips 553 557 if($1 == 0 && $2 == 6) {print GNUDAT "0 7 0.0\n";} 554 558 if($1 == 6 && $2 == 7) {print GNUDAT "7 0 0.0\n";} 555 559 } 556 560 } 561 # missing corner chip 557 562 print GNUDAT "7 7 0.0\n"; 558 563 … … 596 601 # 597 602 ########################################################################### 598 sub plotMagicMaskFraction Histogram{603 sub plotMagicMaskFraction { 599 604 my ($self, $begin, $end) = @_; 600 605 … … 623 628 } 624 629 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 625 638 # get mask for each exposure, and bin 626 my $mask = undef;627 my $expCount = 0;628 639 foreach my $row ( @{$exp_ids} ) { 629 640 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"; 633 648 $expCount++; 649 $totalMask += $sumMask; 650 $totalChipCount += $chipCount; 634 651 635 652 foreach my $bin (@bins) { 636 if ($m ask <= ($bin+$interval)) {653 if ($meanMask <= ($bin+$interval)) { 637 654 638 655 $histogram{$bin}++; … … 640 657 } 641 658 } 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"; 642 670 } 643 671 … … 655 683 close(GNUDAT); 656 684 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 658 692 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 659 693 use FileHandle; 660 694 GP->autoflush(1); 661 662 $maxBin = $maxBin * 1.1;663 $accum = $accum * 1.1;664 665 695 if ($self->{_outputFormat} ne "X11") {print GP "set output \"$histoOutputFile\";";} 666 696 print GP 667 697 "set term $self->{_outputFormat};" . 668 "set title \" Magic mask fraction for $expCount exposures between '$begin' and '$end'\";" .698 "set title \"$title\";" . 669 699 "set grid;" . 670 700 "set boxwidth;" . … … 682 712 close GP; 683 713 684 714 # make cumulative distribution 685 715 open (GP, "|/usr/bin/gnuplot -persist") or die "no gnuplot"; 686 716 use FileHandle; 687 717 GP->autoflush(1); 688 689 718 if ($self->{_outputFormat} ne "X11") {print GP "set output \"$distOutputFile\";";} 690 719 print GP 691 720 "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\";" . 693 722 "set yrange [0:$accum];" . 694 723 "set key left top;" .
Note:
See TracChangeset
for help on using the changeset viewer.
