Changeset 17231 for trunk/ippScripts/scripts/detrend_stack.pl
- Timestamp:
- Mar 28, 2008, 5:21:54 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/detrend_stack.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/detrend_stack.pl
r16563 r17231 18 18 use PS::IPP::Metadata::Stats; 19 19 use PS::IPP::Metadata::List qw( parse_md_list ); 20 use File::Temp qw( tempfile ); 20 21 21 22 use PS::IPP::Config qw($PS_EXIT_SUCCESS … … 33 34 use Pod::Usage qw( pod2usage ); 34 35 35 my ( $det_id, $iter, $class_id, $det_type, $camera, $outroot, $dbname, $reduction, $verbose, $ no_update,36 $no_ op );36 my ( $det_id, $iter, $class_id, $det_type, $camera, $outroot, $dbname, $reduction, $verbose, $save_temps, 37 $no_update, $no_op ); 37 38 GetOptions( 38 39 'det_id|d=s' => \$det_id, … … 45 46 'reduction=s' => \$reduction, # Reduction class for processing 46 47 'verbose' => \$verbose, # Print to stdout 48 'save-temps' => \$save_temps, # Save temporary files? 47 49 'no-update' => \$no_update, 48 50 'no-op' => \$no_op, … … 72 74 [ 73 75 # KEYWORD STATISTIC CHIPTOOL FLAG 74 { name => "bg", type => "mean", flag => "-bg", dtype => "float" }, 75 { name => "bg", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" }, 76 { name => "bg_stdev", type => "rms", flag => "-bg_stdev", dtype => "float" }, 77 # { name => "bg_mean_stdev", type => "rms", flag => "-bg_mean_stdev" }, 76 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" }, 77 { name => "ROBUST_MEDIAN", type => "stdev", flag => "-bg_mean_stdev", dtype => "float" }, 78 { name => "ROBUST_STDEV", type => "rms", flag => "-bg_stdev", dtype => "float" }, 78 79 ]; 79 80 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 81 82 # The output file rule name depends on the detrend type 83 my $FILERULES = { 'FLATMASK' => 'PPMERGE.OUTPUT.MASK', 84 'DARKMASK' => 'PPMERGE.OUTPUT.MASK', 85 'MASK' => 'PPMERGE.OUTPUT.MASK', 86 'BIAS' => 'PPMERGE.OUTPUT.BIAS', 87 'DARK' => 'PPMERGE.OUTPUT.DARK', 88 'SHUTTER' => 'PPMERGE.OUTPUT.SHUTTER', 89 'FLAT' => 'PPMERGE.OUTPUT.FLAT', 90 'DOMEFLAT' => 'PPMERGE.OUTPUT.FLAT', 91 'SKYFLAT' => 'PPMERGE.OUTPUT.FLAT', 92 'FRINGE' => 'PPMERGE.OUTPUT.FRINGE', 93 }; 94 my $output_filerule = $FILERULES->{$det_type}; # File rule for output 95 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless defined $output_filerule; 80 96 81 97 # Look for programs we need … … 110 126 } 111 127 128 # Generate MDC file with the inputs 129 my ($listFile, $listName) = tempfile( $ipprc->file_resolve("$outroot.$class_id.list.XXXX"), UNLINK => !$save_temps ); 130 my $num = 0; 131 foreach my $file (@$files) { 132 if ($file->{ignored}) { next; } 133 134 print $listFile "INPUT$num\tMETADATA\n"; 135 $num++; 136 137 my $image = $file->{uri}; # Image name 138 my $mask = $ipprc->filename( "PPIMAGE.OUTPUT.MASK", $file->{path_base} ); # Mask name 139 my $weight = $ipprc->filename( "PPIMAGE.OUTPUT.WEIGHT", $file->{path_base} ); # Weight name 140 141 &my_die("Image $image does not exist", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $image ); 142 print $listFile "\tIMAGE\tSTR\t" . $image . "\n"; 143 144 if ($ipprc->file_exists( $mask )) { 145 print $listFile "\tMASK\tSTR\t" . $mask . "\n"; 146 } 147 if ($ipprc->file_exists( $weight )) { 148 print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n"; 149 } 150 151 print $listFile "END\n\n"; 152 } 153 close $listFile; 154 155 112 156 # outroot examples (HOST components must be set) 113 157 # file://data/ipp004.0/gpc1/20080130 … … 118 162 $ipprc->outroot_prepare($outroot); 119 163 120 my $outputStack = $ipprc->filename("PPMERGE.OUTPUT", $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Output name 164 my $outputStack = $ipprc->filename($output_filerule, $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Output name 165 my $outputCount = $ipprc->filename("PPMERGE.OUTPUT.COUNT", $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Count image 166 my $outputSigma = $ipprc->filename("PPMERGE.OUTPUT.SIGMA", $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Stdev image 121 167 my $outputStats = $ipprc->filename("PPIMAGE.STATS", $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Statistics name 122 168 my $traceDest = $ipprc->filename("TRACE.IMFILE", $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Trace messages 123 169 my $logDest = $ipprc->filename("LOG.IMFILE", $outroot, $class_id) or &my_die("Missing entry in file rules", $det_id, $iter, $class_id, $PS_EXIT_CONFIG_ERROR); # Log messages 124 170 125 126 $command = "$ppMerge $outputStack"; # Command to run 127 foreach my $file (@$files) { 128 $command .= ' ' . $file->{uri}; 129 } 171 $command = "$ppMerge $listName $outroot"; # Command to run 130 172 $command .= " -recipe PPMERGE $recipe"; 131 173 $command .= ' -type ' . uc($det_type); # Type of stacking to perform … … 136 178 # Stack the files 137 179 unless ($no_op) { 138 139 ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 180 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 140 181 run(command => $command, verbose => $verbose); 141 182 unless ($success) { … … 144 185 } 145 186 &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); 187 &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); 188 &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); 146 189 &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); 147 190
Note:
See TracChangeset
for help on using the changeset viewer.
