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_imfile.pl

    r19652 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 );
    2019
     
    6867my $jpeg_recipe = $ipprc->reduction($reduction, uc($det_type) . '_JPEG_IMAGE'); # Recipe name for JPEG
    6968
    70 # values to extract from output metadata and the stats to calculate
    71 my $STATS =
    72    [
    73        #          PPSTATS KEYWORD         STATISTIC          CHIPTOOL FLAG
    74        { name => "ROBUST_MEDIAN",  type => "mean",  flag => "-bg",            dtype => "float" },
    75        { name => "ROBUST_MEDIAN",  type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },
    76        { name => "ROBUST_STDEV",   type => "rms",   flag => "-bg_stdev",      dtype => "float" },
    77    ];
    78 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser
    79 
    8069# Look for programs we need
    8170my $missing_tools;
    8271my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1);
    8372my $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);
    8474if ($missing_tools) {
    8575    warn("Can't find required tools.");
     
    9787$ipprc->outroot_prepare($outroot);
    9888
     89my $cmdflags;
     90
    9991my $outputImage = $ipprc->filename("PPIMAGE.OUTPUT", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
    10092my $outputBin1  = $ipprc->filename("PPIMAGE.BIN1",   $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
     
    10799    $command .= " -recipe PPIMAGE $ppimage_recipe";
    108100    $command .= " -recipe JPEG $jpeg_recipe";
    109     $command .= " -recipe PPSTATS CHIPSTATS";
     101    $command .= " -recipe PPSTATS DETSTATS";
    110102    $command .= " -stats $outputStats";
    111103    $command .= " -tracedest $traceDest -log $logDest";
     
    121113
    122114    &my_die("Couldn't find expected output file: $outputImage", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage);
    123     &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
    124115    &my_die("Couldn't find expected output file: $outputBin1",  $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1);
    125116    &my_die("Couldn't find expected output file: $outputBin2",  $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2);
    126117
    127     # Get the statistics on the processed image
    128     my $statsFile;              # File handle
    129     open $statsFile, $ipprc->file_resolve("$outputStats") or die "Can't open statistics file $outputStats: $!\n";
    130     my @contents = <$statsFile>; # Contents of file
    131     close $statsFile;
     118    my $outputStatsReal = $ipprc->file_resolve($outputStats);
     119    &my_die("Couldn't find expected output file: $outputStats", $det_id, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal;
    132120
    133     # parse the statistics MDC file
    134     my $mdcParser = PS::IPP::Metadata::Config->new;     # Parser for metadata config files
    135     my $metadata = $mdcParser->parse(join "", @contents)
    136         or &my_die("Unable to parse metadata config", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
    137 
    138     # extract the stats from the metadata
    139     $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);
     121    # parse stats from metadata
     122    $command = "$ppStatsFromMetadata $outputStatsReal - DETREND_PROCESS_IMFILE";
     123    ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     124        run(command => $command, verbose => $verbose);
     125    unless ($success) {
     126        $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     127        &my_die("Unable to perform ppStatsFromMetadata: $error_code", $det_id, $exp_id, $class_id, $error_code);
     128    }
     129    foreach my $line (@$stdout_buf) {
     130        $cmdflags .= " $line";
     131    }
     132    chomp $cmdflags;
    140133}
    141134
     
    148141$command .= " -uri $outputImage -path_base $outroot";
    149142$command .= " -dbname $dbname" if defined $dbname;
    150 $command .= $stats->cmdflags();
     143$command .= " $cmdflags";
    151144
    152145# Add the processed file to the database
Note: See TracChangeset for help on using the changeset viewer.