Changeset 19561 for trunk/ippScripts/scripts/warp_skycell.pl
- Timestamp:
- Sep 15, 2008, 2:24:27 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/warp_skycell.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/warp_skycell.pl
r19396 r19561 25 25 my $ipprc = PS::IPP::Config->new(); # IPP configuration 26 26 27 my ($warp_id, $skycell_id, $tess_dir, $camera, $dbname, $outroot, $threads, $ verbose, $no_update, $no_op, $redirect, $save_temps);27 my ($warp_id, $skycell_id, $tess_dir, $camera, $dbname, $outroot, $threads, $run_state, $verbose, $no_update, $no_op, $redirect, $save_temps); 28 28 GetOptions( 29 29 'warp_id|i=s' => \$warp_id, # Warp identifier … … 33 33 'dbname|d=s' => \$dbname, # Database name 34 34 'outroot=s' => \$outroot, # Output root name 35 'threads=s' => \$threads, # Number of threads to use for ppImage 35 'threads=s' => \$threads, # Number of threads to use for pswarp 36 'run-state=s' => \$run_state, # 'new' or 'update' 36 37 'verbose' => \$verbose, # Print to stdout 37 38 'no-update' => \$no_update, # Don't update the database? … … 43 44 pod2usage( -msg => "Unknown option: @ARGV", -exitval => 2 ) if @ARGV; 44 45 pod2usage( 45 -msg => "Required options: --warp_id --skycell_id --tess_dir --camera --outroot ",46 -msg => "Required options: --warp_id --skycell_id --tess_dir --camera --outroot --run-state", 46 47 -exitval => 3, 47 48 ) unless defined $warp_id … … 49 50 and defined $tess_dir 50 51 and defined $camera 51 and defined $outroot; 52 and defined $outroot 53 and defined $run_state; 52 54 53 55 $ipprc->define_camera($camera); 54 56 55 57 my $logDest = $ipprc->filename("LOG.EXP", $outroot, $skycell_id); 58 $logDest .= ".update" if ($run_state eq 'update'); 56 59 57 60 $ipprc->redirect_output($logDest) if $redirect; … … 127 130 my $configuration = $ipprc->filename("PSWARP.CONFIG", $outroot, $skycell_id); 128 131 132 if ($run_state eq 'update') { 133 $traceDest .= ".update"; 134 $outputStats .= ".update"; 135 } 136 129 137 my $skyFile = $ipprc->filename("SKYCELL.TEMPLATE", $outroot, $skycell_id ); 130 138 $ipprc->skycell_file( $tess_dir, $skycell_id, $skyFile, $verbose ) or &my_die("Unable to generate template skycell", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR); … … 170 178 # Run pswarp 171 179 my $accept = 1; # Accept the skycell? 180 my $do_stats; 172 181 unless ($no_op) { 173 182 my $command = "$pswarp"; … … 177 186 $command .= " -astromlist $astromName"; 178 187 $command .= " $outroot $skyFile"; 179 $command .= " -stats $outputStats";180 $command .= " -recipe PPSTATS WARPSTATS";181 188 $command .= " -F PSPHOT.PSF.SAVE PSPHOT.PSF.SKY.SAVE"; 182 189 $command .= " -F PSPHOT.OUTPUT PSPHOT.OUT.CMF.MEF"; … … 185 192 $command .= " -tracedest $traceDest -log $logDest"; 186 193 $command .= " -threads $threads" if defined $threads; 187 $command .= " -dumpconfig $configuration";188 194 $command .= " -dbname $dbname" if defined $dbname; 195 if ($run_state eq 'new') { 196 $command .= " -dumpconfig $configuration"; 197 $do_stats = 1; 198 } else { 199 $command .= " -ipprc $configuration"; 200 } 201 if ($do_stats) { 202 $command .= " -recipe PPSTATS WARPSTATS"; 203 $command .= " -stats $outputStats"; 204 } 189 205 190 206 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = … … 195 211 } 196 212 197 # Check first for the stats file, and if the ACCEPT flag is set. 198 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats); 199 # Get the statistics on the warped image 200 my $statsFile; # File handle 201 open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n"; 202 my @contents = <$statsFile>; # Contents of file 203 close $statsFile; 204 my $contents = join "", @contents; 205 206 my $metadata = $mdcParser->parse($contents) 207 or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR); 208 $accept = metadataLookupBool($metadata, "ACCEPT"); 209 210 # $accept is set above based on the fraction of lit pixels 211 # XXX for some files, there may not be enough stars to find a good psf. these should be dropped as well 212 if ($accept && !$ipprc->file_exists($outputPSF)) { 213 $accept = 0; 214 } 215 216 if ($accept) { 217 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR); 218 219 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage); 220 &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 221 &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight); 222 &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 223 # &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF); 224 # &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin1); 225 # &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin2); 226 } 227 } 228 229 unless ($no_update) { 230 # XXX change -tess_id to -tess_dir when db is updated 231 my $command = "$warptool -addwarped"; 232 $command .= " -warp_id $warp_id"; 233 $command .= " -skycell_id $skycell_id"; 234 $command .= " -tess_id $tess_dir"; 235 $command .= " -path_base $outroot"; # needed for logfile lookups 236 $command .= " -ignore" if not $accept; # Completed succesfully, but can't produce product 237 $command .= " -uri $outputImage" if $accept; 238 $command .= $stats->cmdflags() if $accept; 239 $command .= " -hostname $host" if defined $host; 240 $command .= " -dbname $dbname" if defined $dbname; 241 242 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 243 run(command => $command, verbose => $verbose); 244 unless ($success) { 245 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 246 warn("Unable to perform warptool -addwarped: $error_code\n"); 247 exit($error_code); 213 if ($do_stats) { 214 # Check first for the stats file, and if the ACCEPT flag is set. 215 &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputStats); 216 # Get the statistics on the warped image 217 my $statsFile; # File handle 218 open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n"; 219 my @contents = <$statsFile>; # Contents of file 220 close $statsFile; 221 my $contents = join "", @contents; 222 223 my $metadata = $mdcParser->parse($contents) 224 or &my_die("Unable to parse metadata config", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR); 225 $accept = metadataLookupBool($metadata, "ACCEPT"); 226 227 # $accept is set above based on the fraction of lit pixels 228 # XXX for some files, there may not be enough stars to find a good psf. these should be dropped as well 229 if ($accept && !$ipprc->file_exists($outputPSF)) { 230 $accept = 0; 231 } 232 233 if ($accept) { 234 $stats->parse($metadata) or &my_die("Unable to find all values in statistics output.", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_PROG_ERROR); 235 236 &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputImage); 237 &my_die("Couldn't find expected output file: $outputMask", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 238 &my_die("Couldn't find expected output file: $outputWeight", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight); 239 &my_die("Couldn't find expected output file: $outputSources", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 240 # &my_die("Couldn't find expected output file: $outputPSF", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputPSF); 241 # &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin1); 242 # &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_dir, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputBin2); 243 } 244 245 unless ($no_update) { 246 # XXX change -tess_id to -tess_dir when db is updated 247 my $command = "$warptool -addwarped"; 248 $command .= " -warp_id $warp_id"; 249 $command .= " -skycell_id $skycell_id"; 250 $command .= " -tess_id $tess_dir"; 251 $command .= " -path_base $outroot"; # needed for logfile lookups 252 $command .= " -ignore" if not $accept; # Completed succesfully, but can't produce product 253 $command .= " -uri $outputImage" if $accept; 254 $command .= $stats->cmdflags() if $accept; 255 $command .= " -hostname $host" if defined $host; 256 $command .= " -dbname $dbname" if defined $dbname; 257 258 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 259 run(command => $command, verbose => $verbose); 260 unless ($success) { 261 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 262 warn("Unable to perform warptool -addwarped: $error_code\n"); 263 exit($error_code); 264 } 265 } 266 } else { 267 # $run_state eq 'update' 268 unless ($no_update) { 269 my $command = "$warptool -tofullskyfile"; 270 $command .= " -warp_id $warp_id"; 271 $command .= " -skycell_id $skycell_id"; 272 $command .= " -dbname $dbname" if defined $dbname; 273 274 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 275 run(command => $command, verbose => $verbose); 276 unless ($success) { 277 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 278 warn("Unable to perform warptool -addwarped: $error_code\n"); 279 exit($error_code); 280 } 281 } 248 282 } 249 283 } … … 260 294 if (defined $warp_id and defined $skycell_id and defined $tess_dir and not $no_update) { 261 295 # XXX change -tess_id to -tess_dir when db is updated 262 my $command = "$warptool -addwarped"; 296 my $command = "$warptool"; 297 if ($run_state eq 'new') { 298 $command .= " -addwarped"; 299 $command .= " -tess_id $tess_dir"; 300 $command .= " -path_base $outroot"; 301 $command .= " -hostname $host" if defined $host; 302 } else { 303 $command .= " -updateskyfile"; 304 } 263 305 $command .= " -warp_id $warp_id"; 264 306 $command .= " -skycell_id $skycell_id"; 265 $command .= " -tess_id $tess_dir";266 307 $command .= " -code $exit_code"; 267 $command .= " -path_base $outroot";268 $command .= " -hostname $host" if defined $host;269 308 $command .= " -dbname $dbname" if defined $dbname; 270 309 run(command => $command, verbose => $verbose);
Note:
See TracChangeset
for help on using the changeset viewer.
