- Timestamp:
- Mar 30, 2011, 9:36:02 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20110213/ippScripts/scripts/stack_skycell.pl
r30676 r31083 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 my $configuration = prepare_output("PPSTACK.CONFIG", $outroot, 1); 259 if ($run_state eq 'new') { 260 $outputStats = prepare_output("SKYCELL.STATS", $outroot, 1); 261 $traceDest = prepare_output("TRACE.EXP", $outroot, 1); 262 push @outputFiles, $configuration; 263 push @outputFiles, $outputStats; 264 } else { 265 # we need to do stats regardless because we need the quality flag 266 # $do_stats = 0; 267 $outputStats = prepare_output("SKYCELL.STATS.UPDATE", $outroot, 1) if $do_stats; 268 $traceDest = prepare_output("TRACE.EXP.UPDATE", $outroot, 1); 269 } 270 227 271 $temp_images_exist = 1; # failures after this point should attempt to delete the temp images 228 272 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 273 my $cmdflags; 234 235 274 236 275 # Perform stacking 237 276 unless ($no_op) { 238 277 my $command = "$ppStack -input $listName $outroot"; 239 $command .= " -stats $outputStats" if $do_stats; ;278 $command .= " -stats $outputStats" if $do_stats; 240 279 $command .= " -recipe PPSTACK $recipe_ppStack"; 241 280 $command .= " -recipe PPSUB $recipe_ppSub"; … … 311 350 312 351 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 } 319 if ($run_state eq 'new') { 320 &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 check_outputs(\@outputFiles, $replicate_outputs); 324 353 } 325 354 … … 357 386 } 358 387 359 print "I've updated t ehdatabase: $stack_id\n";388 print "I've updated the database: $stack_id\n"; 360 389 361 390 … … 423 452 } 424 453 } 454 sub prepare_output 455 { 456 my $filerule = shift; 457 my $outroot = shift; 458 my $delete = shift; 459 $delete = 0 if !defined $delete; 460 461 my $error; 462 my $output = $ipprc->prepare_output($filerule, $outroot, undef, $delete, \$error) 463 or &my_die("failed to prepare output file for: $filerule", $stack_id, $error); 464 return $output; 465 } 466 467 sub prepare_outputs 468 { 469 my $fileList = shift; 470 my $ruleList = shift; 471 my $outroot = shift; 472 473 foreach my $rule (@$ruleList) { 474 push @$fileList, prepare_output($rule, $outroot, 1); 475 } 476 } 477 478 sub check_output 479 { 480 my $file = shift; 481 my $replicate = shift; 482 483 if (!defined $file) { 484 return; 485 } 486 487 &my_die("Couldn't find expected output file: $file", $stack_id, $PS_EXIT_SYS_ERROR) unless $ipprc->file_exists($file); 488 489 if ($replicate and $neb) { 490 $ipprc->replicate_file($file) or &my_die("failed to replicate: $file\n", $stack_id, $PS_EXIT_SYS_ERROR); 491 } 492 } 493 494 sub check_outputs 495 { 496 my $fileList = shift; 497 my $replicate = shift; 498 foreach my $file (@$fileList) { 499 check_output($file, $replicate); 500 } 501 } 425 502 426 503 print "I've reached the end of processing with a code of $?: $stack_id\n"; … … 432 509 } 433 510 511 434 512 __END__
Note:
See TracChangeset
for help on using the changeset viewer.
