IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

converting to ppStatsFromMetadata

File:
1 edited

Legend:

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

    r19658 r19942  
    1616use IPC::Cmd 0.36 qw( can_run run );
    1717use PS::IPP::Metadata::Config;
    18 use PS::IPP::Metadata::Stats;
    1918use PS::IPP::Config 1.01 qw( :standard );
    2019use PS::IPP::Metadata::List qw( parse_md_list );
     
    6867&my_die("Unrecognised detrend type: $det_type", $det_id, $exp_id, $PS_EXIT_PROG_ERROR) unless defined $recipe;
    6968
    70 # values to extract from output metadata and the stats to calculate
    71 # XXX -bg_mean_stdev should take rms of bg_mean_stdev if bg_mean_stdev != 0 (A)
    72 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0     (B)
    73 # XXX  (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1
    74 my $STATS =
    75    [
    76        #          KEYWORD                 STATISTIC          CHIPTOOL FLAG
    77        { name => "bg",             type => "mean",  flag => "-bg",            dtype => "float" },
    78        { name => "bg",             type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },
    79        { name => "bg_stdev",       type => "rms",   flag => "-bg_stdev",      dtype => "float" },
    80        # { name => "bg_mean_stdev",  type => "rms",   flag => "-bg_mean_stdev" },
    81    ];
    82 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
    83 
    8469# Look for programs we need
    8570my $missing_tools;
    8671my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
    8772my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     73my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    8874if ($missing_tools) {
    8975    warn("Can't find required tools.");
    9076    exit($PS_EXIT_CONFIG_ERROR);
    9177}
     78
     79my $cmdflags;
    9280
    9381# Get list of component files
     
    112100        &my_die("Unable to parse metadata list", $det_id, $exp_id, $PS_EXIT_PROG_ERROR);
    113101
    114     # parse the stats in the metadata
    115     unless ($stats->parse($metadata)) {
    116         &my_die("Unable to find all values in statistics output.\n", $det_id, $exp_id, $PS_EXIT_PROG_ERROR);
     102    # since I can't figure out how to do input and output within PERL, I'm writing to a temp file
     103    my ($statFile, $statName) = tempfile( "/tmp/$exp_tag.detproc.$det_id.stats.XXXX", UNLINK => !$save_temps );
     104    print "saving stats to $statName\n";
     105    foreach my $line (@$stdout_buf) {
     106        print $statFile $line;
     107    }
     108    close $statFile;
     109
     110    # parse the stats in the metadata file
     111    $command = "$ppStatsFromMetadata $statName - DETREND_PROCESS_EXP";
     112    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     113        run(command => $command, verbose => $verbose);
     114    unless ($success) {
     115        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     116        warn("Unable to perform ppStatsFromMetadata: $error_code\n");
     117        exit($error_code);
     118    }
     119
     120    foreach my $line (@$stdout_buf) {
     121        $cmdflags .= " $line";
    117122    }
    118123}
     
    173178$command .= " -recip $recipe -path_base $outroot";
    174179$command .= " -dbname $dbname" if defined $dbname;
    175 $command .= $stats->cmdflags();
     180$command .= " $cmdflags";
    176181
    177182# Add the processed file to the database
Note: See TracChangeset for help on using the changeset viewer.