Changeset 19782 for trunk/ippScripts/scripts/detrend_norm_apply.pl
- Timestamp:
- Sep 28, 2008, 11:40:31 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_norm_apply.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_norm_apply.pl
r19374 r19782 16 16 use IPC::Cmd 0.36 qw( can_run run ); 17 17 use PS::IPP::Metadata::Config; 18 use PS::IPP::Metadata::Stats;19 18 use PS::IPP::Config 1.01 qw( :standard ); 20 19 … … 88 87 my $det_type_real = DETTYPE()->{lc($det_type)}; 89 88 90 # values to extract from output metadata and the stats to calculate91 my $STATS =92 [93 # PPSTATS KEYWORD STATISTIC DETTOOL FLAG94 { name => "ROBUST_MEDIAN", type => "clipmean", flag => "-bg", dtype => "float" },95 { name => "ROBUST_MEDIAN", type => "clipstdev", flag => "-bg_mean_stdev", dtype => "float" },96 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" },97 ];98 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser99 100 89 # Look for programs we need 101 90 my $missing_tools; 102 91 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 103 92 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 93 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 104 94 if ($missing_tools) { 105 95 warn("Can't find required tools."); … … 126 116 my $statsName = $ipprc->filename("PPIMAGE.STATS", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 127 117 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id) or &my_die("Missing entry from camera config", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); 118 119 my $cmdflags; 128 120 129 121 # Run normalisation … … 157 149 &my_die("Can't find expected output file: $b1name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($b1name); 158 150 &my_die("Can't find expected output file: $b2name", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($b2name); 159 &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($statsName); 160 161 # Get the statistics on the normalised image 162 my $statsFile; # File handle 163 open $statsFile, $ipprc->file_resolve($statsName) or &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 164 &my_die("Can't open statistics file $statsName: $!\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless defined $statsFile; 165 my @contents = <$statsFile>; # Contents of file 166 close $statsFile; 167 168 # parse the statistics MDC file 169 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 170 my $metadata = $mdcParser->parse(join "", @contents); 171 unless ($metadata) { 172 &my_die("Unable to parse metadata config", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 173 } 174 175 # extract the stats from the metadata 176 unless ($stats->parse($metadata)) { 177 &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 178 } 151 152 my $statsNameReal = $ipprc->file_resolve($statsName); 153 &my_die("Can't find expected output file: $statsName", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $statsNameReal; 154 155 # ppStatsFromMetadata $outputStats - DETREND_RESID_IMFILE 156 $command = "$ppStatsFromMetadata $statsNameReal - DETREND_RESID_IMFILE"; 157 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 158 run(command => $command, verbose => $verbose); 159 unless ($success) { 160 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 161 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code); 162 } 163 foreach my $line (@$stdout_buf) { 164 $cmdflags .= " $line"; 165 } 166 chomp $cmdflags; 179 167 } 180 168 … … 187 175 $command .= " -path_base $outroot"; 188 176 $command .= " -dbname $dbname" if defined $dbname; 189 $command .= $stats->cmdflags();177 $command .= " $cmdflags"; 190 178 191 179 # Add the processed file to the database
Note:
See TracChangeset
for help on using the changeset viewer.
