Changeset 36018 for trunk/pstamp/scripts/pstamp_job_run.pl
- Timestamp:
- Aug 23, 2013, 1:31:54 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_job_run.pl (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_job_run.pl
r35903 r36018 62 62 $options &= ~($PSTAMP_REQUEST_UNCENSORED | $PSTAMP_REQUIRE_UNCENSORED); 63 63 64 64 65 my $ipprc = PS::IPP::Config->new(); # IPP Configuration 65 66 if ($redirect_output) { … … 95 96 my $argString; 96 97 $argString = $params->{job_args}; 98 99 my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString; 100 97 101 my $stage = $params->{stage}; 98 99 # XXX: should we do any other sanity checking? 100 my_die("argument list is empty", $job_id, $PS_EXIT_DATA_ERROR) if !$argString; 102 my_die("stage is not defined", $job_id, $PS_EXIT_DATA_ERROR) if !$stage; 103 104 if ($stage eq 'stack_summary') { 105 106 # remove options not supported by stack summary 107 $options &= ~($PSTAMP_SELECT_SOURCES | $PSTAMP_SELECT_BACKMDL | $PSTAMP_SELECT_INVERSE 108 | $PSTAMP_RESTORE_BACKGROUND); 109 110 # stackSummary outputs do not follow the usual IPP conventions for file names. 111 # The parser (actually Job.pm) has deferred handling this until here 112 update_stack_summary_filenames($params); 113 114 } elsif ($stage ne 'stack') { 115 # ignore options only supported by stack and stack_summary 116 $options &= ~($PSTAMP_SELECT_EXP | $PSTAMP_SELECT_NUM); 117 } 118 101 119 102 120 if ($stage eq "raw") { … … 181 199 } 182 200 183 # my ($tmpImage, $tmpMask, $tmpVariance, $tmproot); 184 185 my $command = "$ppstamp $outputBase $argString $fileArgs"; 186 $command .= " -write_jpeg" if ($options & $PSTAMP_SELECT_JPEG); 187 $command .= " -nocompress" if ($options & $PSTAMP_SELECT_UNCOMPRESSED); 188 $command .= " -stage $stage"; 189 $command .= " -forheader $calibfile" if $calibfile; 190 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 191 run(command => $command, verbose => $verbose); 201 # unless the stage is stack_summary we use ppstamp to make postage stamps (including -wholefile) 202 # otherwise we make copies of the input files to the outputs 203 my $use_ppstamp = ($stage ne 'stack_summary'); 192 204 193 205 my $exitStatus; 194 if (WIFEXITED($error_code)) { 195 $exitStatus = WEXITSTATUS($error_code); 196 } else { 197 print STDERR "ppstamp failed error_code: $error_code\n"; 198 $exitStatus = $PS_EXIT_SYS_ERROR; 206 if ($use_ppstamp) { 207 my $command = "$ppstamp $outputBase $argString $fileArgs"; 208 $command .= " -write_jpeg" if ($options & $PSTAMP_SELECT_JPEG); 209 $command .= " -nocompress" if ($options & $PSTAMP_SELECT_UNCOMPRESSED); 210 $command .= " -stage $stage"; 211 $command .= " -forheader $calibfile" if $calibfile; 212 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 213 run(command => $command, verbose => $verbose); 214 215 if (WIFEXITED($error_code)) { 216 $exitStatus = WEXITSTATUS($error_code); 217 } else { 218 print STDERR "ppstamp failed error_code: $error_code\n"; 219 $exitStatus = $PS_EXIT_SYS_ERROR; 220 } 221 # XXX: if stage is stack deal with EXP and NUM images if selected 222 } else { 223 $exitStatus = justCopyFiles($outputBase, \$options, $params); 199 224 } 200 225 … … 208 233 209 234 # Note: we are assuming the contents of the PSTAMP filerules here. 210 my %extensions = ( $PSTAMP_SELECT_IMAGE => "fits", 211 $PSTAMP_SELECT_MASK => "mk.fits", 212 $PSTAMP_SELECT_VARIANCE => "wt.fits", 213 $PSTAMP_SELECT_SOURCES => "cmf", 214 $PSTAMP_SELECT_JPEG => "jpg"); 215 216 my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_VARIANCE | $PSTAMP_SELECT_JPEG | $PSTAMP_SELECT_SOURCES); 235 my %extensions = ( $PSTAMP_SELECT_IMAGE => 'fits', 236 $PSTAMP_SELECT_MASK => 'mk.fits', 237 $PSTAMP_SELECT_VARIANCE => 'wt.fits', 238 $PSTAMP_SELECT_SOURCES => 'cmf', 239 $PSTAMP_SELECT_JPEG => 'jpg', 240 $PSTAMP_SELECT_EXP => 'exp.fits', 241 $PSTAMP_SELECT_NUM => 'num.fits'); 242 243 my $output_mask = $options & ($PSTAMP_SELECT_IMAGE | $PSTAMP_SELECT_MASK | $PSTAMP_SELECT_VARIANCE 244 | $PSTAMP_SELECT_JPEG | $PSTAMP_SELECT_SOURCES | $PSTAMP_SELECT_EXP | $PSTAMP_SELECT_NUM); 217 245 218 246 foreach my $key (keys (%extensions)) { … … 534 562 } 535 563 564 sub update_stack_summary_filenames { 565 my $params = shift; 566 567 my $path_base = $params->{path_base}; 568 569 $params->{image} = $path_base . ".image.b1.fits"; 570 $params->{mask} = $path_base . ".mask.b1.fits"; 571 $params->{weight} = $path_base . ".variance.b1.fits"; 572 $params->{exp} = $path_base . ".exp.b1.fits"; 573 $params->{num} = $path_base . ".num.b1.fits"; 574 575 } 576 577 sub myCopy { 578 my ($dest, $src, $type, $dieOnFail) = @_; 579 580 my $result; 581 my $resolved = $ipprc->file_resolve($src); 582 if ($ipprc->file_exists($resolved)) { 583 $result = copy($resolved, $dest); 584 } else { 585 my $msg = "Specified source $type image $src not found."; 586 if ($dieOnFail) { 587 $msg .= "\n"; 588 } else { 589 $msg .= " ignoring\n"; 590 } 591 carp $msg; 592 $result = 0; 593 } 594 595 if (!$result and $dieOnFail) { 596 &my_die("Unable to copy $type image", $job_id, $PS_EXIT_SYS_ERROR, 'run'); 597 } 598 return $result; 599 } 600 601 sub justCopyFiles { 602 my ($outputBase, $r_options, $params) = @_; 603 604 my $options = $$r_options; 605 if ($options & $PSTAMP_SELECT_IMAGE) { 606 myCopy("$outputBase.fits", $params->{image}, 'image', 1); 607 } 608 if ($options & $PSTAMP_SELECT_MASK) { 609 if (!myCopy("$outputBase.mk.fits", $params->{mask}, 'mask', 0)) { 610 $options &= ~$PSTAMP_SELECT_MASK; 611 } 612 } 613 if ($options & $PSTAMP_SELECT_VARIANCE) { 614 if (!myCopy("$outputBase.wt.fits", $params->{weight}, 'variance', 0)) { 615 $options = ~$PSTAMP_SELECT_VARIANCE; 616 } 617 } 618 if ($options & $PSTAMP_SELECT_EXP) { 619 if (!myCopy("$outputBase.exp.fits", $params->{exp}, 'exp', 0)) { 620 $options &= ~$PSTAMP_SELECT_EXP; 621 } 622 } 623 if ($options & $PSTAMP_SELECT_NUM) { 624 if (!myCopy("$outputBase.num.fits", $params->{num}, 'num', 0)) { 625 $options &= ~$PSTAMP_SELECT_NUM; 626 } 627 } 628 629 $$r_options = $options; 630 631 return 0; 632 } 633 536 634 sub my_die 537 635 {
Note:
See TracChangeset
for help on using the changeset viewer.
