Changeset 30840
- Timestamp:
- Mar 9, 2011, 3:07:11 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/stack_skycell.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/stack_skycell.pl
r30636 r30840 65 65 and defined $run_state; 66 66 67 # lists of file rules which we expect to produce output output 68 my @outputList = qw( 69 PPSTACK.OUTPUT 70 PPSTACK.OUTPUT.MASK 71 PPSTACK.OUTPUT.VARIANCE 72 PPSTACK.OUTPUT.EXP 73 PPSTACK.OUTPUT.EXPNUM 74 PPSTACK.OUTPUT.EXPWT 75 PPSTACK.TARGET.PSF 76 PPSTACK.OUTPUT.JPEG1 77 PPSTACK.OUTPUT.JPEG2 78 PPSTACK.CONFIG 79 ); 80 # produced if we run photometry 81 my @outputListPhotom = qw( 82 PSPHOT.OUT.CMF.MEF 83 ); 84 # extra outputs when convolving 85 my @outputListUnconv = qw( 86 PPSTACK.UNCONV 87 PPSTACK.UNCONV.MASK 88 PPSTACK.UNCONV.VARIANCE 89 PPSTACK.UNCONV.EXP 90 PPSTACK.UNCONV.EXPNUM 91 PPSTACK.UNCONV.EXPWT 92 ); 93 67 94 my $ipprc = PS::IPP::Config->new() or my_die( "Unable to set up", $stack_id, $PS_EXIT_CONFIG_ERROR ); # IPP configuration 68 95 $| = 1; … … 73 100 my $logDest = "$outroot.log"; 74 101 75 my $do_stats; 76 if ($run_state eq 'new') { 77 $do_stats = 1; 78 } else { 102 if ($run_state eq 'update') { 79 103 $logDest .= ".update"; 80 104 } 81 105 82 106 $ipprc->redirect_output($logDest) or my_die( "Unable to redirect output", $stack_id, $PS_EXIT_SYS_ERROR ) if $redirect; 107 108 my $neb; 109 my $scheme = file_scheme($outroot); 110 if ($scheme and $scheme eq 'neb') { 111 $neb = $ipprc->nebulous(); 112 } 113 83 114 84 115 my $temp_images_exist = 0; … … 173 204 my $output_nocomp = metadataLookupBool($recipe, 'OUTPUT.NOCOMP'); # change filerules to produced uncompressed output images 174 205 my $output_logflux = metadataLookupBool($recipe, 'OUTPUT.LOGFLUX'); # change filerules to produce logflux compressed output images. 175 206 my $replicate_outputs = (defined($neb) and metadataLookupBool($recipe, 'OUTPUT.REPLICATE')); # replicate output images 176 207 if ($output_nocomp and $output_logflux) { 177 208 &my_die("Unable to not compress and logflux compress simultaneously. Check config.",$stack_id, $PS_EXIT_CONFIG_ERROR); … … 212 243 print "I've checked everything: $stack_id\n"; 213 244 214 # Get the output filenames 215 my $outputName = $ipprc->filename("PPSTACK.OUTPUT", $outroot); 216 my $outputMask = $ipprc->filename("PPSTACK.OUTPUT.MASK", $outroot); 217 my $outputWeight = $ipprc->filename("PPSTACK.OUTPUT.VARIANCE", $outroot); 218 my $outputSources = $photometry ? $ipprc->filename("PSPHOT.OUT.CMF.MEF", $outroot) : undef; ## this must be consistent with the value in diff_skycell.pl:101 245 # Prepare the output files 246 my @outputFiles; 247 prepare_outputs(\@outputFiles, \@outputList, $outroot); 248 prepare_outputs(\@outputFiles, \@outputListPhotom, $outroot) if $photometry; 249 prepare_outputs(\@outputFiles, \@outputListUnconv, $outroot) if $convolve; 250 251 # we need the output image name for the database 252 my $outputName = $outputFiles[0]; 219 253 220 254 ## use an explicit stack name for psphot output objects 221 #my $bin1Name = $ipprc->filename("PPSTACK.BIN1", $outroot); 222 #my $bin2Name = $ipprc->filename("PPSTACK.BIN2", $outroot); 223 my $outputStats = $ipprc->filename("SKYCELL.STATS", $outroot); 224 my $traceDest = $ipprc->filename("TRACE.EXP", $outroot); 225 $traceDest .= ".update" if $run_state eq 'update'; 226 my $configuration = $ipprc->filename("PPSTACK.CONFIG", $outroot); 255 my $do_stats = 1; 256 my $outputStats; 257 my $traceDest; 258 if ($run_state eq 'new') { 259 $outputStats = prepare_output("SKYCELL.STATS", $outroot, 1); 260 $traceDest = prepare_output("TRACE.EXP", $outroot, 1); 261 } else { 262 # we need to do stats regardless because we need the quality flag 263 # $do_stats = 0; 264 $outputStats = prepare_output("SKYCELL.STATS.UPDATE", $outroot, 1) if $do_stats; 265 $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, 1); 266 } 267 my $configuration = prepare_output("PPSTACK.CONFIG", $outroot, 1); 227 268 $temp_images_exist = 1; # failures after this point should attempt to delete the temp images 228 269 229 # for update we need to resolve the config filename here because the code that reads it230 # doesn't know how to resolve paths. (The information is stored in the configuration file)231 $configuration = $ipprc->file_resolve($configuration) if ($run_state eq 'update');232 233 270 my $cmdflags; 234 235 271 236 272 # Perform stacking 237 273 unless ($no_op) { 238 274 my $command = "$ppStack -input $listName $outroot"; 239 $command .= " -stats $outputStats" if $do_stats; ;275 $command .= " -stats $outputStats" if $do_stats; 240 276 $command .= " -recipe PPSTACK $recipe_ppStack"; 241 277 $command .= " -recipe PPSUB $recipe_ppSub"; … … 311 347 312 348 if (!$quality) { 313 &my_die("Couldn't find expected output file: $outputName", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputName); 314 &my_die("Couldn't find expected output file: $outputMask", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputMask); 315 &my_die("Couldn't find expected output file: $outputWeight", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputWeight); 316 if ($photometry) { 317 &my_die("Couldn't find expected output file: $outputSources", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($outputSources); 318 } 349 check_outputs(\@outputFiles, $replicate_outputs); 319 350 if ($run_state eq 'new') { 320 351 &my_die("Couldn't find expected output file: $configuration", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($configuration); 321 } 322 # &my_die("Couldn't find expected output file: $bin1Name", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin1Name); 323 # &my_die("Couldn't find expected output file: $bin2Name", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($bin2Name); 352 $ipprc->replicate_file($outputStats) if $neb; 353 } 324 354 } 325 355 … … 357 387 } 358 388 359 print "I've updated t ehdatabase: $stack_id\n";389 print "I've updated the database: $stack_id\n"; 360 390 361 391 … … 423 453 } 424 454 } 455 sub prepare_output 456 { 457 my $filerule = shift; 458 my $outroot = shift; 459 my $delete = shift; 460 $delete = 0 if !defined $delete; 461 462 my $error; 463 my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error) 464 or &my_die("failed to prepare output file for: $filerule", $stack_id, $error); 465 return $output; 466 } 467 468 sub prepare_outputs 469 { 470 my $fileList = shift; 471 my $ruleList = shift; 472 my $outroot = shift; 473 474 foreach my $rule (@$ruleList) { 475 push @$fileList, prepare_output($rule, $outroot, 1); 476 } 477 } 478 479 sub check_output 480 { 481 my $file = shift; 482 my $replicate = shift; 483 484 if (!defined $file) { 485 return; 486 } 487 488 &my_die("Couldn't find expected output file: $file", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file); 489 490 if ($replicate and $neb) { 491 $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n", $stack_id, $PS_EXIT_SYS_ERROR); 492 } 493 } 494 495 sub check_outputs 496 { 497 my $fileList = shift; 498 my $replicate = shift; 499 foreach my $file (@$fileList) { 500 check_output($file, $replicate); 501 } 502 } 425 503 426 504 print "I've reached the end of processing with a code of $?: $stack_id\n"; … … 432 510 } 433 511 512 434 513 __END__
Note:
See TracChangeset
for help on using the changeset viewer.
