IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 13, 2008, 11:36:56 AM (18 years ago)
Author:
eugene
Message:

converting to ppStatsFromMetadata

File:
1 edited

Legend:

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

    r20062 r20101  
    1818use IPC::Cmd 0.36 qw( can_run run );
    1919use PS::IPP::Metadata::Config;
    20 use PS::IPP::Metadata::Stats;
    2120use PS::IPP::Metadata::List qw( parse_md_list );
    2221use Data::Dumper;
     
    5352$ipprc->redirect_output($logDest) if $redirect;
    5453
    55 my $STATS =
    56    [
    57        #          PPSTATS KEYWORD         STATISTIC          DIFFTOOL FLAG
    58        { name => "ROBUST_MEDIAN",        type => "mean", flag => "-bg",          dtype => "float" },
    59        { name => "ROBUST_STDEV",         type => "rms",  flag => "-bg_stdev",    dtype => "float" },
    60        { name => "TIME_SUB",             type => "sum",  flag => "-dtime_diff",  dtype => "float" },
    61        { name => "TIME_MATCH",           type => "sum",  flag => "-dtime_match", dtype => "float" },
    62        { name => "TIME_PHOT",            type => "sum",  flag => "-dtime_phot",  dtype => "float" },
    63        { name => "SUBTRACTION.STAMPS",   type => "mean", flag => "-stamps_num",  dtype => "int" },
    64        { name => "SUBTRACTION.DEV.MEAN", type => "mean", flag => "-stamps_mean", dtype => "float" },
    65        { name => "SUBTRACTION.DEV.RMS",  type => "mean", flag => "-stamps_rms",  dtype => "float" },
    66        { name => "SUBTRACTION.NORM",     type => "mean", flag => "-norm",        dtype => "float" },
    67        { name => "SUBTRACTION.BGDIFF",   type => "mean", flag => "-bg_diff",     dtype => "float" },
    68        { name => "SUBTRACTION.MX",       type => "mean", flag => "-kernel_x",    dtype => "float" },
    69        { name => "SUBTRACTION.MY",       type => "mean", flag => "-kernel_y",    dtype => "float" },
    70        { name => "SUBTRACTION.MXX",      type => "mean", flag => "-kernel_xx",   dtype => "float" },
    71        { name => "SUBTRACTION.MXY",      type => "mean", flag => "-kernel_xy",   dtype => "float" },
    72        { name => "SUBTRACTION.MYY",      type => "mean", flag => "-kernel_yy",   dtype => "float" },
    73        { name => "NUM_SOURCES",          type => "sum",  flag => "-sources",     dtype => "int" },
    74        { name => "GOOD_PIXEL_FRAC",      type => "mean", flag => "-good_frac",   dtype => "float" },
    75    ];
    76 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
    77 
    7854# Look for programs we need
    7955my $missing_tools;
    8056my $difftool = can_run('difftool') or (warn "Can't find difftool" and $missing_tools = 1);
    8157my $ppSub = can_run('ppSub') or (warn "Can't find ppSub" and $missing_tools = 1);
     58my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    8259if ($missing_tools) {
    8360    warn("Can't find required tools.");
     
    204181my $traceDest = $ipprc->filename("TRACE.EXP", $outroot);
    205182
     183my $cmdflags;
     184
    206185# Perform subtraction
    207186unless ($no_op) {
     
    233212#    &my_die("Couldn't find expected output file: $bin1Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name);
    234213#    &my_die("Couldn't find expected output file: $bin2Name",    $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name);
    235     &my_die("Couldn't find expected output file: $outputStats", $diff_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats);
    236 
    237     # Get the statistics on the residual image
    238     my $statsFile;              # File handle
    239     open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $diff_id, $PS_EXIT_SYS_ERROR);
    240     my @contents = <$statsFile>; # Contents of file
    241     close $statsFile;
    242     my $metadata = $mdcParser->parse(join "", @contents) or
    243         &my_die("Unable to parse metadata config doc", $diff_id, $PS_EXIT_PROG_ERROR);
    244     $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $diff_id, $PS_EXIT_PROG_ERROR);
     214
     215    my $outputStatsReal = $ipprc->file_resolve($outputStats);
     216    &my_die("Couldn't find expected output file: $outputStats", $diff_id, $PS_EXIT_SYS_ERROR) unless unless -f $outputStatsReal;
     217
     218    # measure chip stats
     219    $command = "$ppStatsFromMetadata $outputStatsReal - DIFF_SKYCELL";
     220    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     221        run(command => $command, verbose => $verbose);
     222    unless ($success) {
     223        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     224        &my_die("Unable to perform ppStatsFromMetadata: $error_code", $diff_id, $error_code);
     225    }
     226    foreach my $line (@$stdout_buf) {
     227        $cmdflags .= " $line";
     228    }
     229    chomp $cmdflags;
    245230}
    246231
     
    250235    {
    251236        my $command = "$difftool -adddiffskyfile -diff_id $diff_id -uri $outputName -path_base $outroot";
    252         $command .= $stats->cmdflags();
     237        $command .= " $cmdflags";
    253238        $command .= (" -dtime_script " . ((DateTime->now->mjd - $mjd_start) * 86400));
    254239        $command .= " -hostname $host" if defined $host;
Note: See TracChangeset for help on using the changeset viewer.