IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 4, 2007, 2:25:37 PM (19 years ago)
Author:
eugene
Message:

calculate and supply the binned stdev

File:
1 edited

Legend:

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

    r13552 r13618  
    105105my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
    106106my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1);
     107my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1);
    107108if ($missing_tools) {
    108109    warn("Can't find required tools.");
     
    123124my $bin2Name =  $ipprc->filename("PPIMAGE.BIN2", $outputRoot, $class_id);
    124125my $outputStats = $outputRoot . '.' . $class_id . '.stats';
     126my $outputBinnedStats = $outputRoot . '.' . $class_id . '.bin.stats';
    125127
    126128# Run ppImage
    127129my $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
     130my $binnedStats = PS::IPP::Metadata::Stats->new(); # Stats parser
    128131unless ($no_op) {
    129132    my $command = "$ppImage -file $input_uri $outputRoot -recipe PPIMAGE $recipe" .
     
    154157    close $statsFile;
    155158    my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
    156     my $metadata = $mdcParser->parse(join "", @contents) or
    157         &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
    158     $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
     159    my $metadata = $mdcParser->parse(join "", @contents) or &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
     160    # $stats = PS::IPP::Metadata::Stats->new(); # Stats parser
    159161    $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
     162
     163    # run ppStats on the binned image
     164    $command = "$ppStats $bin2Name $outputBinnedStats";
     165    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     166        run(command => $command, verbose => 1);
     167
     168    unless ($success) {
     169        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     170        &my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_tag, $class_id, $error_code);
     171    }
     172
     173    &my_die("Couldn't find expected output file: $outputBinnedStats", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBinnedStats);
     174
     175    open $statsFile, $ipprc->file_resolve($outputBinnedStats) or &my_die("Can't open statistics file $outputBinnedStats: $!", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_SYS_ERROR);
     176    @contents = <$statsFile>; # Contents of file
     177    close $statsFile;
     178    my $binnedMetadata = $mdcParser->parse(join "", @contents) or &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
     179    # $binnedStats = PS::IPP::Metadata::Stats->new(); # Stats parser
     180    $binnedStats->parse($binnedMetadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_tag, $class_id, $PS_EXIT_PROG_ERROR);
    160181}
    161182
     
    164185my $bg_stdev = ($stats->bg_stdev() or 'NAN');
    165186my $bg_mean_stdev = ($stats->bg_mean_stdev() or 'NAN');
     187my $bin_stdev = ($binnedStats->bg_stdev() or 'NAN');
    166188
    167189unless ($no_update) {
    168     my $command = "$dettool -addresidimfile -det_id $det_id -iteration $iter -exp_tag $exp_tag " .
    169         "-class_id $class_id -recip $recipe -uri $outputName -path_base $outputRoot"; # Command to run dettool
     190    my $command = "$dettool -addresidimfile -det_id $det_id -iteration $iter";
     191    $command .= " -exp_tag $exp_tag -class_id $class_id";
     192    $command .= " -recip $recipe -uri $outputName -path_base $outputRoot";
    170193    $command .= " -bg $bg -bg_stdev $bg_stdev -bg_mean_stdev $bg_mean_stdev";
     194    $command .= " -bin_stdev $bin_stdev";
    171195    $command .= " -dbname $dbname" if defined $dbname;
    172196
     
    179203    }
    180204}
    181 
    182 
    183205
    184206sub my_die
Note: See TracChangeset for help on using the changeset viewer.