Changeset 17803 for trunk/ippScripts/scripts/stack_skycell.pl
- Timestamp:
- May 23, 2008, 5:10:21 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/stack_skycell.pl (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/stack_skycell.pl
r17671 r17803 32 32 'outroot=s' => \$outroot, # Output root name 33 33 'verbose' => \$verbose, # Print to stdout 34 'no-update' => \$no_update, # Don't update the database?34 'no-update' => \$no_update, # Don't update the database? 35 35 'no-op' => \$no_op, # Don't do any operations? 36 36 'save-temps' => \$save_temps, # Save temporary files? … … 41 41 -msg => "Required options: --stack_id --outroot", 42 42 -exitval => 3, 43 ) unless defined $stack_id43 ) unless defined $stack_id 44 44 and defined $outroot; 45 45 46 my $STATS = 47 [ 46 my $STATS = 47 [ 48 48 # PPSTATS KEYWORD STATISTIC STACKTOOL FLAG 49 49 { name => "ROBUST_MEDIAN", type => "mean", flag => "-bg", dtype => "float" }, … … 58 58 my $stacktool = can_run('stacktool') or (warn "Can't find stacktool" and $missing_tools = 1); 59 59 my $ppStack = can_run('ppStack') or (warn "Can't find ppStack" and $missing_tools = 1); 60 if ($missing_tools) { 60 if ($missing_tools) { 61 61 warn("Can't find required tools."); 62 exit($PS_EXIT_CONFIG_ERROR); 62 exit($PS_EXIT_CONFIG_ERROR); 63 63 } 64 64 65 65 # Get list of components for stacking 66 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files66 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 67 67 my $files; 68 68 { … … 70 70 $command .= " -dbname $dbname" if defined $dbname; 71 71 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 72 run(command => $command, verbose => $verbose);72 run(command => $command, verbose => $verbose); 73 73 unless ($success) { 74 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);75 &my_die("Unable to perform stacktool -inputskyfile: $error_code", $stack_id, $error_code);74 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 75 &my_die("Unable to perform stacktool -inputskyfile: $error_code", $stack_id, $error_code); 76 76 } 77 77 78 78 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 79 &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);80 $files = parse_md_list($metadata) or 81 &my_die("Unable to parse metadata list", $stack_id, $PS_EXIT_PROG_ERROR);79 &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR); 80 $files = parse_md_list($metadata) or 81 &my_die("Unable to parse metadata list", $stack_id, $PS_EXIT_PROG_ERROR); 82 82 } 83 83 … … 86 86 87 87 # Parse the list of input files to get the tesselation, skycell identifiers and camera 88 my $skycell_id; # Skycell identifier89 my $tess_id; # Tesselation identifier90 my $camera; # Camera88 my $skycell_id; # Skycell identifier 89 my $tess_id; # Tesselation identifier 90 my $camera; # Camera 91 91 foreach my $file (@$files) { 92 92 # skip warps which are speicified as 'ignored' 93 93 if ($file->{ignored}) { next; } 94 94 if (defined $tess_id) { 95 &my_die("Tesselation identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless96 $file->{tess_id} eq $tess_id;95 &my_die("Tesselation identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless 96 $file->{tess_id} eq $tess_id; 97 97 } else { 98 $tess_id = $file->{tess_id};98 $tess_id = $file->{tess_id}; 99 99 } 100 100 if (defined $skycell_id) { 101 &my_die("Skycell identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless102 $file->{skycell_id} eq $skycell_id;101 &my_die("Skycell identifiers don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless 102 $file->{skycell_id} eq $skycell_id; 103 103 } else { 104 $skycell_id = $file->{skycell_id};104 $skycell_id = $file->{skycell_id}; 105 105 } 106 106 if (defined $camera) { 107 &my_die("Cameras don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera;107 &my_die("Cameras don't match", $stack_id, $PS_EXIT_SYS_ERROR) unless $file->{camera} eq $camera; 108 108 } else { 109 $camera = $file->{camera};109 $camera = $file->{camera}; 110 110 } 111 111 } … … 116 116 # Generate MDC file with the inputs 117 117 my ($listFile, $listName) = tempfile( "$tess_id.$skycell_id.stk$stack_id.list.XXXX", 118 UNLINK => !$save_temps );118 UNLINK => !$save_temps ); 119 119 my $num = 0; 120 my $inputSources; # Sources to use as stamps120 my $inputSources; # Sources to use as stamps 121 121 foreach my $file (@$files) { 122 122 if ($file->{ignored}) { next; } … … 125 125 $num++; 126 126 127 my $image = $file->{uri}; # Image name127 my $image = $file->{uri}; # Image name 128 128 my $mask = $ipprc->filename( "PSWARP.OUTPUT.MASK", $file->{path_base} ); # Mask name 129 129 my $weight = $ipprc->filename( "PSWARP.OUTPUT.WEIGHT", $file->{path_base} ); # Weight name … … 134 134 &my_die("Weight $weight does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $weight ); 135 135 &my_die("PSF $psf does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $psf ); 136 136 137 137 print $listFile "\tIMAGE\tSTR\t" . $image . "\n"; 138 print $listFile "\tMASK\tSTR\t" . $mask . "\n"; 139 print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n"; 138 print $listFile "\tMASK\tSTR\t" . $mask . "\n"; 139 print $listFile "\tWEIGHT\tSTR\t" . $weight . "\n"; 140 140 print $listFile "\tPSF\tSTR\t" . $psf . "\n"; 141 141 … … 147 147 # XXX details about supplying sources, etc, need to be specified in the libraries 148 148 unless (defined $inputSources) { 149 $inputSources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $file->{path_base});150 &my_die("Source file $inputSources does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $inputSources );151 } 152 149 $inputSources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $file->{path_base}); 150 &my_die("Source file $inputSources does not exist", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists( $inputSources ); 151 } 152 153 153 } 154 154 … … 175 175 176 176 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 177 run(command => $command, verbose => $verbose);177 run(command => $command, verbose => $verbose); 178 178 unless ($success) { 179 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);180 &my_die("Unable to perform ppStack: $error_code", $stack_id, $error_code);179 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 180 &my_die("Unable to perform ppStack: $error_code", $stack_id, $error_code); 181 181 } 182 182 &my_die("Couldn't find expected output file: $outputName", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName); … … 189 189 190 190 # Get the statistics on the stacked image 191 my $statsFile; # File handle191 my $statsFile; # File handle 192 192 open $statsFile, $ipprc->file_resolve($outputStats) or &my_die("Can't open statistics file $outputStats: $!", $stack_id, $PS_EXIT_SYS_ERROR); 193 193 my @contents = <$statsFile>; # Contents of file 194 194 close $statsFile; 195 195 my $metadata = $mdcParser->parse(join "", @contents) or 196 &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR);196 &my_die("Unable to parse metadata config doc", $stack_id, $PS_EXIT_PROG_ERROR); 197 197 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $stack_id, $PS_EXIT_PROG_ERROR); 198 198 } … … 202 202 # Add the stack result 203 203 { 204 my $command = "$stacktool -addsumskyfile -stack_id $stack_id -uri $outputName -path_base $outroot"; 205 $command .= $stats->cmdflags(); 206 $command .= " -dbname $dbname" if defined $dbname; 207 208 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 209 run(command => $command, verbose => $verbose); 210 unless ($success) { 211 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 212 &my_die("Unable to perform stacktool -addsumskyfile: $error_code", $stack_id, $error_code); 213 } 204 my $command = "$stacktool -addsumskyfile -stack_id $stack_id -uri $outputName -path_base $outroot"; 205 $command .= $stats->cmdflags(); 206 $command .= " -hostname $host" if defined $host; 207 $command .= " -dbname $dbname" if defined $dbname; 208 209 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 210 run(command => $command, verbose => $verbose); 211 unless ($success) { 212 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 213 &my_die("Unable to perform stacktool -addsumskyfile: $error_code", $stack_id, $error_code); 214 } 214 215 } 215 216 216 217 # Register the run as completed 217 218 { 218 my $command = "$stacktool -updaterun -stack_id $stack_id -state stop"; # Command to run stacktool219 $command .= " -dbname $dbname" if defined $dbname;220 221 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =222 run(command => $command, verbose => $verbose);223 unless ($success) {224 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);225 warn("Unable to perform stacktool -updaterun: $error_code\n");226 exit($error_code);227 }219 my $command = "$stacktool -updaterun -stack_id $stack_id -state stop"; # Command to run stacktool 220 $command .= " -dbname $dbname" if defined $dbname; 221 222 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 223 run(command => $command, verbose => $verbose); 224 unless ($success) { 225 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 226 warn("Unable to perform stacktool -updaterun: $error_code\n"); 227 exit($error_code); 228 } 228 229 } 229 230 } … … 232 233 sub my_die 233 234 { 234 my $msg = shift; # Warning message on die235 my $stack_id = shift; # Stack identifier236 my $exit_code = shift; # Exit code to add235 my $msg = shift; # Warning message on die 236 my $stack_id = shift; # Stack identifier 237 my $exit_code = shift; # Exit code to add 237 238 238 239 warn($msg); 239 240 if (defined $stack_id and not $no_update) { 240 my $command = "$stacktool -addsumskyfile -stack_id $stack_id -code $exit_code"; 241 $command .= " -dbname $dbname" if defined $dbname; 241 my $command = "$stacktool -addsumskyfile -stack_id $stack_id -code $exit_code"; 242 $command .= " -hostname $host" if defined $host; 243 $command .= " -dbname $dbname" if defined $dbname; 242 244 system ($command); 243 245 }
Note:
See TracChangeset
for help on using the changeset viewer.
