IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 8, 2006, 7:18:17 PM (20 years ago)
Author:
Paul Price
Message:

Adding exposure time, abstracting the p0search options to make change easier.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/phase0imfile.pl

    r8240 r8255  
    1010use constant RECIPE => "PPSTATS_PHASE0_IMFILE"; # Recipe to use for ppStats
    1111
    12 use constant IMFILE_BG => 'background'; # Key for the background out of p0search -pendingimfile
    13 use constant IMFILE_BGSD => 'background_stdev'; # Key for the background standard deviation
     12# Switches for p0search
     13use constant P0SEARCH_MODE => '-updateimfile'; # Mode for p0search
     14use constant P0SEARCH_EXPID => '-exp_id'; # Switch to specify the exposure id
     15use constant P0SEARCH_CLASSID => '-class_id'; # Switch to specify the class id
     16use constant P0SEARCH_BG => '-bg'; # Switch to add the background
     17use constant P0SEARCH_BGSD => '-background_stdev'; # Switch to add the bg stdev
     18use constant P0SEARCH_EXPTIME => '-exp_time'; # Switch to add the exposure time
    1419
    1520if (scalar @ARGV == 0 || scalar @ARGV > 3) {
     
    3540my $parsed;                     # Parsed metadata
    3641{
    37     my $command = "$ppStats $file"; # Command to run ppStats
     42    my $command = "$ppStats $file -recipe PPSTATS " . RECIPE; # Command to run ppStats
    3843    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    39         run(command => $command, verbose => 0);
     44        run(command => $command, verbose => 1);
    4045    die "Unable to perform ppStats on exposure id $expid: $error_code\n" if not $success;
    4146    $parsed = $mdcParser->parse(join "", @$stdout_buf);
     
    4449my $bg = 0;                     # Mean background level
    4550my $sd = 0;                     # Mean standard deviation
     51my $expTime = 0;                # Mean exposure time
    4652my $bgNum = 0;                  # Number of background entries
    4753my $sdNum = 0;                  # Number of standard deviation entries
     54my $expTimeNum = 0;             # Number of exposure time entries
    4855foreach my $fpaItem (@$parsed) {
    4956    if ($fpaItem->{class} eq "metadata") {
     
    6471                            $bgNum++;
    6572                        }
     73                    } elsif ($cellItem->{name} =~ /CELL\.EXPOSURE/) {
     74                        $expTime += $cellItem->{value};
     75                        $expTimeNum++;
    6676                    }
    6777                }
     
    7080    }
    7181}
     82die "Unable to find statistics.\n" if ($bgNum == 0 or $sdNum == 0);
    7283$bg /= $bgNum;
    7384$sd /= $sdNum;
     85die "Unable to find exposure times.\n" if ($expTimeNum == 0);
     86$expTime /= $expTimeNum;
    7487
    7588# Push the results into the database
    7689{
    77     my $command = "$p0search -updateimfile -exp_id $expid -class_id $classid -background $bg " .
    78         "-background_stdev $sd"; # Command to run p0search
     90    my $command = "$p0search " . P0SEARCH_MODE . " " . P0SEARCH_EXPID() . " $expid " .
     91        P0SEARCH_CLASSID() . " $classid " . P0SEARACH_BG() ." $bg " . P0SEARCH_BGSD() ." $sd " .
     92        P0SEARCH_EXPTIME() . " $expTime"; # Command to run p0search
    7993    my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    80         run(command => $command, verbose => 0);
     94        run(command => $command, verbose => 1);
    8195    die "Unable to perform p0search -updateimfile: $error_code\n" if not $success;
    8296}
    83 
Note: See TracChangeset for help on using the changeset viewer.