Changeset 17941 for trunk/ippScripts/scripts/detrend_stack.pl
- Timestamp:
- Jun 5, 2008, 11:43:34 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_stack.pl (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_stack.pl
r17762 r17941 36 36 'outroot|w=s' => \$outroot, # output file base name 37 37 'dbname|d=s' => \$dbname, # Database name 38 'reduction=s' => \$reduction, # Reduction class for processing38 'reduction=s' => \$reduction, # Reduction class for processing 39 39 'verbose' => \$verbose, # Print to stdout 40 40 'save-temps' => \$save_temps, # Save temporary files? … … 44 44 45 45 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 46 pod2usage( -msg => "Required options: --det_id --iteration --class_id --det_type --camera --outroot", 47 -exitval => 3) unless 48 defined $det_id and 49 defined $iter and 50 defined $class_id and 51 defined $det_type and 46 pod2usage( -msg => "Required options: --det_id --iteration --class_id --det_type --camera --outroot", 47 -exitval => 3) unless 48 defined $det_id and 49 defined $iter and 50 defined $class_id and 51 defined $det_type and 52 52 defined $camera and 53 53 defined $outroot; … … 64 64 # XXX -bg_mean_stdev should take stdev of bg_mean if bg_mean_stdev == 0 (B) 65 65 # XXX (A) if imfile.Ncomp > 1, (B) if imfile.Ncomp == 1 66 my $STATS = 67 [ 66 my $STATS = 67 [ 68 68 # KEYWORD STATISTIC CHIPTOOL FLAG 69 69 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" }, … … 77 77 my $dettool = can_run('dettool') or (warn "Can't find dettool" and $missing_tools = 1); 78 78 my $ppMerge = can_run('ppMerge') or (warn "Can't find ppMerge" and $missing_tools = 1); 79 if ($missing_tools) { 79 if ($missing_tools) { 80 80 warn("Can't find required tools."); 81 exit($PS_EXIT_CONFIG_ERROR); 81 exit($PS_EXIT_CONFIG_ERROR); 82 82 } 83 83 84 84 # The output file rule name depends on the detrend type 85 85 my $FILERULES = { 'FLATMASK' => 'PPMERGE.OUTPUT.MASK', 86 'DARKMASK' => 'PPMERGE.OUTPUT.MASK',87 'MASK' => 'PPMERGE.OUTPUT.MASK',88 'BIAS' => 'PPMERGE.OUTPUT.BIAS',89 'DARK' => 'PPMERGE.OUTPUT.DARK',90 'SHUTTER' => 'PPMERGE.OUTPUT.SHUTTER',91 'FLAT' => 'PPMERGE.OUTPUT.FLAT',92 'DOMEFLAT' => 'PPMERGE.OUTPUT.FLAT',93 'SKYFLAT' => 'PPMERGE.OUTPUT.FLAT',94 'FRINGE' => 'PPMERGE.OUTPUT.FRINGE',95 };86 'DARKMASK' => 'PPMERGE.OUTPUT.MASK', 87 'MASK' => 'PPMERGE.OUTPUT.MASK', 88 'BIAS' => 'PPMERGE.OUTPUT.BIAS', 89 'DARK' => 'PPMERGE.OUTPUT.DARK', 90 'SHUTTER' => 'PPMERGE.OUTPUT.SHUTTER', 91 'FLAT' => 'PPMERGE.OUTPUT.FLAT', 92 'DOMEFLAT' => 'PPMERGE.OUTPUT.FLAT', 93 'SKYFLAT' => 'PPMERGE.OUTPUT.FLAT', 94 'FRINGE' => 'PPMERGE.OUTPUT.FRINGE', 95 }; 96 96 my $output_filerule = $FILERULES->{$det_type}; # File rule for output 97 97 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless defined $output_filerule; … … 107 107 108 108 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 109 run(command => $command, verbose => $verbose);109 run(command => $command, verbose => $verbose); 110 110 unless ($success) { 111 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);112 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $iter, $class_id, $error_code);113 } 114 115 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files111 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 112 &my_die("Unable to perform dettool -processedimfile: $error_code", $det_id, $iter, $class_id, $error_code); 113 } 114 115 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 116 116 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 117 &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);118 $files = parse_md_list($metadata) or 119 &my_die("Unable to parse metadata list", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR);117 &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 118 $files = parse_md_list($metadata) or 119 &my_die("Unable to parse metadata list", $det_id, $iter, $class_id, $PS_EXIT_PROG_ERROR); 120 120 } 121 121 … … 129 129 $num++; 130 130 131 my $image = $file->{uri}; # Image name131 my $image = $file->{uri}; # Image name 132 132 my $mask = $ipprc->filename( "PPIMAGE.OUTPUT.MASK", $file->{path_base}, $class_id ); # Mask name 133 133 my $weight = $ipprc->filename( "PPIMAGE.OUTPUT.WEIGHT", $file->{path_base}, $class_id ); # Weight name … … 137 137 138 138 if ($ipprc->file_exists( $mask )) { 139 print $listFile "\tMASK\tSTR\t" . $mask . "\n";139 print $listFile "\tMASK\tSTR\t" . $mask . "\n"; 140 140 } 141 141 if ($ipprc->file_exists( $weight )) { 142 print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n";142 print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n"; 143 143 } 144 144 … … 166 166 $command .= " -recipe PPMERGE $recipe"; 167 167 $command .= ' -type ' . uc($det_type); # Type of stacking to perform 168 $command .= " -stats $outputStats"; # Statistics output filename168 $command .= " -stats $outputStats"; # Statistics output filename 169 169 $command .= " -recipe PPSTATS CHIPSTATS"; 170 170 $command .= " -tracedest $traceDest -log $logDest"; 171 $command .= " -dbname $dbname" if defined $dbname; 171 172 172 173 # Stack the files 173 174 unless ($no_op) { 174 175 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 175 run(command => $command, verbose => $verbose);176 run(command => $command, verbose => $verbose); 176 177 unless ($success) { 177 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);178 &my_die("Unable to perform ppMerge: $error_code", $det_id, $iter, $class_id, $error_code);178 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 179 &my_die("Unable to perform ppMerge: $error_code", $det_id, $iter, $class_id, $error_code); 179 180 } 180 181 &my_die("Unable to find expected output file: $outputStack\n", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStack); … … 185 186 # Get the statistics on the stacked image 186 187 open(my $statsFile, $ipprc->file_resolve("$outputStats")) or 187 &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);188 &my_die("Can't open statistics file $outputStats: $!", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 188 189 my $contents = do { local $/; <$statsFile> }; # Contents of file 189 190 close($statsFile); 190 191 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files191 192 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 192 193 my $metadata = $mdcParser->parse($contents) or 193 &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);194 &my_die("Unable to parse metadata config doc", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 194 195 195 196 $stats->parse($metadata) or 196 &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR);197 &my_die("Unable to find all values in statistics output.", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR); 197 198 } 198 199 … … 209 210 unless ($no_update) { 210 211 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 211 run(command => $command, verbose => $verbose);212 run(command => $command, verbose => $verbose); 212 213 unless ($success) { 213 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);214 warn("Unable to perform dettool -addstacked: $error_code\n");215 exit($error_code);214 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 215 warn("Unable to perform dettool -addstacked: $error_code\n"); 216 exit($error_code); 216 217 } 217 218 } else { … … 222 223 { 223 224 my $msg = shift; # Warning message on die 224 my $det_id = shift; # Detrend identifier225 my $iter = shift; # Iteration225 my $det_id = shift; # Detrend identifier 226 my $iter = shift; # Iteration 226 227 my $class_id = shift; # Class identifier 227 228 my $exit_code = shift; # Exit code to add … … 229 230 carp($msg); 230 231 if (defined $det_id and defined $iter and defined $class_id and not $no_update) { 231 my $command = "$dettool -addstacked";232 $command .= " -det_id $det_id";233 $command .= " -iteration $iter";234 $command .= " -class_id $class_id";235 $command .= " -code $exit_code";236 $command .= " -dbname $dbname" if defined $dbname;237 system ($command);232 my $command = "$dettool -addstacked"; 233 $command .= " -det_id $det_id"; 234 $command .= " -iteration $iter"; 235 $command .= " -class_id $class_id"; 236 $command .= " -code $exit_code"; 237 $command .= " -dbname $dbname" if defined $dbname; 238 system ($command); 238 239 } 239 240 exit $exit_code;
Note:
See TracChangeset
for help on using the changeset viewer.
