- Timestamp:
- Mar 27, 2008, 2:20:17 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_080320/ippScripts/scripts/detrend_stack.pl
r16563 r17156 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, … … 79 81 my $stats = PS::IPP::Metadata::Stats->new($STATS); # Stats parser 80 82 83 # The output file rule name depends on the detrend type 84 my %FILERULES = { 'FLATMASK' => 'PPMERGE.OUTPUT.MASK', 85 'DARKMASK' => 'PPMERGE.OUTPUT.MASK', 86 'MASK' => 'PPMERGE.OUTPUT.MASK', 87 'BIAS' => 'PPMERGE.OUTPUT.BIAS', 88 'DARK' => 'PPMERGE.OUTPUT.DARK', 89 'SHUTTER' => 'PPMERGE.OUTPUT.SHUTTER', 90 'FLAT' => 'PPMERGE.OUTPUT.FLAT', 91 'DOMEFLAT' => 'PPMERGE.OUTPUT.FLAT', 92 'SKYFLAT' => 'PPMERGE.OUTPUT.FLAT', 93 'FRINGE' => 'PPMERGE.OUTPUT.FRINGE', 94 }; 95 my $output_filerule = $FILERULES{$det_type}; # File rule for output 96 &my_die("Unrecognised detrend type: $det_type", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless defined $output_filerule; 97 81 98 # Look for programs we need 82 99 my $missing_tools; … … 110 127 } 111 128 129 # Generate MDC file with the inputs 130 my ($listFile, $listName) = tempfile( "$outroot.$class_id.list.XXXX", UNLINK => !$save_temps ); 131 my $num = 0; 132 foreach my $file (@$files) { 133 if ($file->{ignored}) { next; } 134 135 print $listFile "INPUT$num\tMETADATA\n"; 136 $num++; 137 138 my $image = $file->{uri}; # Image name 139 my $mask = $ipprc->filename( "PPIMAGE.OUTPUT.MASK", $file->{path_base} ); # Mask name 140 my $weight = $ipprc->filename( "PPIMAGE.OUTPUT.WEIGHT", $file->{path_base} ); # Weight name 141 142 &my_die("Image $image does not exist", $det_id, $iter, $class_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $image ); 143 print $listFile "\tIMAGE\tSTR\t" . $image . "\n"; 144 145 if ($ipprc->file_exists( $mask )) { 146 print $listFile "\tMASK\tSTR\t" . $mask . "\n"; 147 } 148 if ($ipprc->file_exists( $weight )) { 149 print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n"; 150 } 151 152 print $listFile "END\n\n"; 153 } 154 close $listFile; 155 156 112 157 # outroot examples (HOST components must be set) 113 158 # file://data/ipp004.0/gpc1/20080130 … … 118 163 $ipprc->outroot_prepare($outroot); 119 164 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 165 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 166 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 167 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 168 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 169 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 170 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 171 125 126 $command = "$ppMerge $outputStack"; # Command to run 127 foreach my $file (@$files) { 128 $command .= ' ' . $file->{uri}; 129 } 172 $command = "$ppMerge $listName $outputStack"; # Command to run 130 173 $command .= " -recipe PPMERGE $recipe"; 131 174 $command .= ' -type ' . uc($det_type); # Type of stacking to perform … … 144 187 } 145 188 &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); 189 &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); 190 &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 191 &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 192
Note:
See TracChangeset
for help on using the changeset viewer.
