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/stack_skycell.pl

    r19938 r20101  
    1919use IPC::Cmd 0.36 qw( can_run run );
    2020use PS::IPP::Metadata::Config;
    21 use PS::IPP::Metadata::Stats;
    2221use PS::IPP::Metadata::List qw( parse_md_list );
    2322use Data::Dumper;
     
    6766$ipprc->redirect_output($logDest) if $redirect;
    6867
    69 my $STATS =
    70    [
    71        #          PPSTATS KEYWORD         STATISTIC          STACKTOOL FLAG
    72        { name => "ROBUST_MEDIAN",   type => "mean",  flag => "-bg",                dtype => "float" },
    73        { name => "ROBUST_STDEV",    type => "rms",   flag => "-bg_stdev",          dtype => "float" },
    74        { name => "TIME_STACK",      type => "sum",   flag => "-dtime_stack",       dtype => "float" },
    75        { name => "TIME_MATCH",      type => "mean",  flag => "-dtime_match_mean",  dtype => "float" },
    76        { name => "TIME_MATCH",      type => "stdev", flag => "-dtime_match_stdev", dtype => "float" },
    77        { name => "TIME_INITIAL",    type => "sum",   flag => "-dtime_initial",     dtype => "float" },
    78        { name => "TIME_REJECT",     type => "sum",   flag => "-dtime_reject",      dtype => "float" },
    79        { name => "TIME_FINAL",      type => "sum",   flag => "-dtime_final",       dtype => "float" },
    80        { name => "TIME_PHOT",       type => "sum",   flag => "-dtime_phot",        dtype => "float" },
    81        { name => "STAMP.MEAN",      type => "mean",  flag => "-match_mean",        dtype => "float" },
    82        { name => "STAMP.MEAN",      type => "stdev", flag => "-match_stdev",       dtype => "float" },
    83        { name => "STAMP.RMS",       type => "rms",   flag => "-match_rms",         dtype => "float" },
    84        { name => "STAMP.NUM",       type => "mean",  flag => "-stamps_mean",       dtype => "float" },
    85        { name => "STAMP.NUM",       type => "stdev", flag => "-stamps_stdev",      dtype => "float" },
    86        { name => "STAMP.NUM",       type => "min",   flag => "-stamps_min",        dtype => "int" },
    87        { name => "TIME_PHOT",       type => "sum",   flag => "-dtime_phot",        dtype => "float" },
    88        { name => "REJECT_IMAGES",   type => "sum",   flag => "-reject_images",     dtype => "int" },
    89        { name => "REJECT_PIXELS",   type => "mean",  flag => "-reject_pix_mean",   dtype => "float" },
    90        { name => "REJECT_PIXELS",   type => "stdev", flag => "-reject_pix_stdev",  dtype => "float" },
    91        { name => "NUM_SOURCES",     type => "sum",   flag => "-sources",           dtype => "int" },
    92        { name => "GOOD_PIXEL_FRAC", type => "mean",  flag => "-good_frac",         dtype => "float" },
    93    ];
    94 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
    95 
    9668# Look for programs we need
    9769my $missing_tools;
    9870my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1);
    9971my $ppStack = can_run('ppStack') or (warn "Can't find ppStack" and $missing_tools = 1);
     72my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    10073if ($missing_tools) {
    10174    warn("Can't find required tools.");
     
    208181# doesn't know how to resolve paths. (The information is stored in the configuration file)
    209182$configuration = $ipprc->file_resolve($configuration) if ($run_state eq 'update');
     183
     184my $cmdflags;
    210185
    211186# Perform stacking
     
    244219
    245220    if ($do_stats) {
    246         &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR)
    247             unless $ipprc->file_exists($outputStats);
    248         # Get the statistics on the stacked image
    249         my $statsFile;              # File handle
    250         open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR);
    251         my @contents = <$statsFile>; # Contents of file
    252         close $statsFile;
    253         my $metadata = $mdcParser->parse(join "", @contents) or
    254             &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);
    255         $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $stack_id, $PS_EXIT_PROG_ERROR);
     221        my $outputStatsReal = $ipprc->file_resolve($outputStats);
     222        &my_die("Couldn't find expected output file: $outputStats", $stack_id, $PS_EXIT_SYS_ERROR) unless unless -f $outputStatsReal;
     223
     224        # measure chip stats
     225        $command = "$ppStatsFromMetadata $outputStatsReal - STACK_SKYCELL";
     226        ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     227            run(command => $command, verbose => $verbose);
     228        unless ($success) {
     229            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     230            &my_die("Unable to perform ppStatsFromMetadata: $error_code", $stack_id, $error_code);
     231        }
     232        foreach my $line (@$stdout_buf) {
     233            $cmdflags .= " $line";
     234        }
     235        chomp $cmdflags;
    256236    }
    257237}
     
    272252        }
    273253        $command .= " $mode -stack_id $stack_id";
    274         $command .= $stats->cmdflags() if $do_stats;
     254        $command .= " $cmdflags" if $do_stats;
    275255        $command .= " -dbname $dbname" if defined $dbname;
    276256
Note: See TracChangeset for help on using the changeset viewer.