Changeset 19942 for trunk/ippScripts/scripts/detrend_stack.pl
- Timestamp:
- Oct 7, 2008, 9:56:11 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_stack.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_stack.pl
r19374 r19942 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::Metadata::List qw( parse_md_list ); 20 19 use PS::IPP::Config 1.01 qw( :standard ); … … 67 66 my $recipe = $ipprc->reduction($reduction, $det_type . '_STACK'); # Recipe name to use 68 67 69 # values to extract from output metadata and the stats to calculate70 # XXX -bg_mean_stdev should take rms of bg_mean_stdev if bg_mean_stdev != 0 (A)71 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0 (B)72 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 173 my $STATS =74 [75 # KEYWORD STATISTIC DETTOOL FLAG76 { name => "ROBUST_MEDIAN", type => "clipmean", flag => "-bg", dtype => "float" },77 { name => "ROBUST_MEDIAN", type => "clipstdev", flag => "-bg_mean_stdev", dtype => "float" },78 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" },79 ];80 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser81 82 68 # Look for programs we need 83 69 my $missing_tools; 84 70 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 85 71 my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1); 72 my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1); 86 73 if ($missing_tools) { 87 74 warn("Can't find required tools."); … … 112 99 113 100 # The stats recipe depends on the detrend type 114 my $STATRECIPES = {'FLATMASK' => ' CHIPSTATS',115 'DARKMASK' => ' CHIPSTATS',116 'MASK' => ' CHIPSTATS',117 'BIAS' => ' CHIPSTATS',101 my $STATRECIPES = {'FLATMASK' => 'DETSTATS', 102 'DARKMASK' => 'DETSTATS', 103 'MASK' => 'DETSTATS', 104 'BIAS' => 'DETSTATS', 118 105 'DARK' => 'DARKSTATS', 119 106 'DARK_PREMASK' => 'DARKSTATS', 120 107 'SHUTTER' => 'DARKSTATS', 121 'FLAT_PREMASK' => ' CHIPSTATS',122 'DOMEFLAT_PREMASK' => ' CHIPSTATS',123 'SKYFLAT_PREMASK' => ' CHIPSTATS',124 'FLAT_RAW' => ' CHIPSTATS',125 'DOMEFLAT_RAW' => ' CHIPSTATS',126 'SKYFLAT_RAW' => ' CHIPSTATS',127 'FLAT' => ' CHIPSTATS',128 'DOMEFLAT' => ' CHIPSTATS',129 'SKYFLAT' => ' CHIPSTATS',130 'FRINGE' => ' CHIPSTATS',108 'FLAT_PREMASK' => 'DETSTATS', 109 'DOMEFLAT_PREMASK' => 'DETSTATS', 110 'SKYFLAT_PREMASK' => 'DETSTATS', 111 'FLAT_RAW' => 'DETSTATS', 112 'DOMEFLAT_RAW' => 'DETSTATS', 113 'SKYFLAT_RAW' => 'DETSTATS', 114 'FLAT' => 'DETSTATS', 115 'DOMEFLAT' => 'DETSTATS', 116 'SKYFLAT' => 'DETSTATS', 117 'FRINGE' => 'DETSTATS', 131 118 }; 132 119 my $statrecipe = $STATRECIPES->{$det_type}; # File rule for output 120 121 my $cmdflags; 133 122 134 123 # Get list of files to stack … … 217 206 &my_die("Unable to find expected output file: $outputCount\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputCount); 218 207 &my_die("Unable to find expected output file: $outputSigma\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputSigma); 219 &my_die("Unable to find expected output file: $outputStats\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats); 220 221 # Get the statistics on the stacked image 222 open(my $statsFile, $ipprc->file_resolve("$outputStats")) or 223 &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 224 my $contents = do { local $/; <$statsFile> }; # Contents of file 225 close($statsFile); 226 227 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 228 my $metadata = $mdcParser->parse($contents) or 229 &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 230 231 $stats->parse($metadata) or 232 &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 208 209 my $outputStatsReal = $ipprc->file_resolve($outputStats); 210 &my_die("Couldn't find expected output file: $outputStats", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $outputStatsReal; 211 212 # parse stats from metadata 213 $command = "$ppStatsFromMetadata $outputStatsReal - DETREND_STACK"; 214 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 215 run(command => $command, verbose => $verbose); 216 unless ($success) { 217 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 218 &my_die("Unable to perform ppStatsFromMetadata: $error_code", $det_id, $iter, $class_id, $error_code); 219 } 220 foreach my $line (@$stdout_buf) { 221 $cmdflags .= " $line"; 222 } 223 chomp $cmdflags; 233 224 } 234 225 … … 241 232 $command .= " -recip $recipe"; 242 233 $command .= " -dbname $dbname" if defined $dbname; 243 $command .= $stats->cmdflags();234 $command .= " $cmdflags"; 244 235 245 236 # Add the resultant into the database
Note:
See TracChangeset
for help on using the changeset viewer.
