Changeset 19627 for trunk/ippScripts/scripts/detrend_resid_imfile.pl
- Timestamp:
- Sep 21, 2008, 5:31:39 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_resid_imfile.pl (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_resid_imfile.pl
r19621 r19627 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 ); 19 20 # XXX drop (moved to ppStatsFromMetadata) 21 # use PS::IPP::Metadata::Stats; 20 22 21 23 my $ipprc = PS::IPP::Config->new(); # IPP configuration … … 88 90 print "real recipe: $recipe\n"; 89 91 90 # values to extract from output metadata and the stats to calculate91 my $STATS =92 [93 # PPSTATS KEYWORD STATISTIC CHIPTOOL FLAG94 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" },95 { name => "ROBUST_MEDIAN", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" },96 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" },97 { name => "SAMPLE_SKEWNESS", type => "mean", flag => "-bg_skewness", dtype => "float" },98 { name => "SAMPLE_KURTOSIS", type => "mean", flag => "-bg_kurtosis", dtype => "float" },99 { name => "FRINGE_0", type => "mean", flag => "-fringe_0", dtype => "float" },100 { name => "FRINGE_ERR_0", type => "rms", flag => "-fringe_1", dtype => "float" },101 { name => "FRINGE_0", type => "stdev", flag => "-fringe_2", dtype => "float" },102 { name => "FRINGE_RESID_0", type => "mean", flag => "-fringe_resid_0", dtype => "float" },103 { name => "FRINGE_RESID_ERR_0", type => "rms", flag => "-fringe_resid_1", dtype => "float" },104 { name => "FRINGE_RESID_0", type => "stdev", flag => "-fringe_resid_2", dtype => "float" },105 ];106 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser107 108 my $BINNED_STATS =109 [110 { name => "ROBUST_STDEV", type => "rms", flag => "-bin_stdev" },111 ];112 my $binnedStats = PS::IPP::Metadata::Stats->new($BINNED_STATS); # Stats parser113 114 92 # Flags to specify the particular detrend to use 115 93 use constant DETRENDS => { … … 140 118 my $ppImage = can_run('ppImage') or (warn "Can't find ppImage" and $missing_tools = 1); 141 119 my $ppStats = can_run('ppStats') or (warn "Can't find ppStats" and $missing_tools = 1); 120 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 142 121 if ($missing_tools) { 143 122 warn("Can't find required tools."); … … 161 140 my $outputStats = $ipprc->filename("PPIMAGE.STATS", $outroot, $class_id); 162 141 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id); 142 143 my $cmdflags; 163 144 164 145 # Run ppImage & ppStats … … 184 165 &my_die("Unable to perform ppImage: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code); 185 166 } 167 186 168 &my_die("Couldn't find expected output file: $outputName", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputName); 187 &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);188 169 &my_die("Couldn't find expected output file: $bin1Name", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin1Name); 189 170 &my_die("Couldn't find expected output file: $bin2Name", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($bin2Name); 190 171 191 # Load the raw output stats file192 my $statsFile; # File handle193 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR); 194 my @contents = <$statsFile>; # Contents of file195 close $statsFile;196 197 # Parse the stats file contents into a metadata198 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files199 my $metadata = $mdcParser->parse(join "", @contents) or &my_die("Unable to parse metadata config doc", $det_id, $iter, $exp_id, $class_id,$PS_EXIT_PROG_ERROR);200 201 # Parse the statistics on the residual image202 $ stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR);172 my $outputStatsReal = $ipprc->file_resolve($outputStats); 173 &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal; 174 175 # ppStatsFromMetadata $outputStats - DETREND_RESID_IMFILE 176 $command = "$ppStatsFromMetadata $outputStatsReal - DETREND_RESID_IMFILE"; 177 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 178 run(command => $command, verbose => $verbose); 179 unless ($success) { 180 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 181 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code); 182 } 183 $cmdflags = $stdout_buf; chomp $cmdflags; 203 184 204 185 # run ppStats on the binned image 205 $command = "$ppStats -recipe PPSTATS RESIDUAL $bin2Name ";186 $command = "$ppStats -recipe PPSTATS RESIDUAL $bin2Name | $ppStatsFromMetadata - - DETREND_RESID_IMFILE_BINNED"; 206 187 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 207 188 run(command => $command, verbose => $verbose); … … 210 191 &my_die("Unable to perform ppStats: $error_code", $det_id, $iter, $exp_id, $class_id, $error_code); 211 192 } 212 213 # Parse the output contents into a metadata 214 my $binnedMetadata = $mdcParser->parse(join "", @$stdout_buf) or &my_die("Unable to parse metadata output", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 215 216 # parse the binned image statistics 217 $binnedStats->parse($binnedMetadata) or &my_die("Unable to find all values in statistics output.", $det_id, $iter, $exp_id, $class_id, $PS_EXIT_PROG_ERROR); 193 $cmdflags .= $stdout_buf; chomp $cmdflags; 218 194 } 219 195 … … 230 206 $command .= " -path_base $outroot"; 231 207 $command .= " -dbname $dbname" if defined $dbname; 232 $command .= $stats->cmdflags(); 233 $command .= $binnedStats->cmdflags(); 208 $command .= $cmdflags; 234 209 235 210 # Add the processed file to the database
Note:
See TracChangeset
for help on using the changeset viewer.
