Changeset 37318 for trunk/pstamp/scripts/pstamp_job_run.pl
- Timestamp:
- Aug 27, 2014, 8:17:01 AM (12 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/scripts/pstamp_job_run.pl (modified) (4 diffs, 1 prop)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/scripts/pstamp_job_run.pl
- Property svn:mergeinfo set to
r36812 r37318 91 91 my $ppBackgroundStack = can_run('ppBackgroundStack') or (warn "Can't find ppBackgroundStack" and $missing_tools = 1); 92 92 my $stack_bkg_mk_mdc = can_run('stack_bkg_mk_mdc.pl') or (warn "Can't find stack_bkg_mk_mdc.pl" and $missing_tools = 1); 93 my $fpack = can_run('fpack') or (warn "Can't find fpack" and $missing_tools = 1); 94 93 95 94 96 if ($missing_tools) { … … 146 148 my $mask; 147 149 my $variance; 148 149 # We need to background restore HERE150 # and change the image file supplied to ppstamp151 150 152 151 my $fileArgs = " -file $params->{image}"; … … 224 223 225 224 # unless the stage is stack_summary we use ppstamp to make postage stamps (including -wholefile) 226 # otherwisewe make copies of the input files to the outputs225 # if stage is stack_summary we make copies of the input files to the outputs 227 226 my $use_ppstamp = ($stage ne 'stack_summary'); 228 227 … … 243 242 $exitStatus = $PS_EXIT_SYS_ERROR; 244 243 } 245 # XXX: if stage is stack deal with EXP and NUM images if selected 244 245 # if stage is stack deal with EXP and NUM images if selected by running ppstamp again 246 if (!$exitStatus and $stage eq 'stack' and ($options & ($PSTAMP_SELECT_EXP | $PSTAMP_SELECT_NUM))) { 247 # XXX Here I am assuming that nothing relevant gets added to $argString 248 # Need to check 249 my $roiArgs = $params->{job_args}; 250 251 # XXX: define expnum and exptime input images in the params file so that we don't have to 252 # make assumptions about the file rules here 253 my $pathBase = $params->{stack_path_base}; 254 $pathBase = $params->{path_base} unless defined $pathBase; 255 unless (defined $pathBase) { 256 my_die("stack path base undefined found when creating exp or expnum image", $job_id, $PS_EXIT_PROG_ERROR); 257 } 258 $pathBase .= ".unconv"; 259 my $tmpBase = "$outputBase.TMP"; 260 # nocompress because exp image gets corrupted if we do 261 my $command = "$ppstamp $tmpBase $roiArgs -nocompress -stage stack"; 262 # XXX: use file rules 263 # Image is the EXP (exptime) image 264 $command .= " -file $pathBase.exp.fits"; 265 # treat number image as mask 266 $command .= " -mask $pathBase.num.fits" if ($options & $PSTAMP_SELECT_NUM); 267 268 $command .= " -forheader $calibfile" if $calibfile; 269 270 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 271 run(command => $command, verbose => $verbose); 272 273 if (WIFEXITED($error_code)) { 274 $exitStatus = WEXITSTATUS($error_code); 275 } else { 276 print STDERR "ppstamp failed error_code: $error_code\n"; 277 $exitStatus = $PS_EXIT_SYS_ERROR; 278 } 279 280 # command to compress fits files to stdout using gzip 281 my $fpack_gzip = "$fpack -g -S"; 282 $fpack_gzip .= " -D" unless $save_temps; 283 284 if (!$exitStatus and ($options & $PSTAMP_SELECT_NUM)) { 285 # rename the num image if selected since it is not a mask 286 # Change .exp.mk to .num 287 my $tmpName = "$tmpBase.mk.fits"; 288 my $numName = "$outputBase.num.fits"; 289 # optionally fpack it while we're here unless user wants uncompressed images 290 unless ($options & $PSTAMP_SELECT_UNCOMPRESSED) { 291 my $command = "$fpack_gzip $tmpName > $numName"; 292 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 293 run(command => $command, verbose => $verbose); 294 295 if (WIFEXITED($error_code)) { 296 $exitStatus = WEXITSTATUS($error_code); 297 } else { 298 print STDERR "ppstamp failed error_code: $error_code\n"; 299 print STDERR "@$stderr_buf\n"; 300 $exitStatus = $PS_EXIT_SYS_ERROR; 301 } 302 } elsif (!$exitStatus) { 303 rename $tmpName, $numName 304 or my_die ("failed to rename $tmpName to $numName", $job_id, $PS_EXIT_UNKNOWN_ERROR); 305 } 306 307 } 308 # fpack the exp image if not -nocompress 309 unless ($exitStatus or ($options & $PSTAMP_SELECT_UNCOMPRESSED)) { 310 my $command = "$fpack_gzip $tmpBase.fits > $outputBase.exp.fits"; 311 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 312 run(command => $command, verbose => $verbose); 313 314 if (WIFEXITED($error_code)) { 315 $exitStatus = WEXITSTATUS($error_code); 316 } else { 317 print STDERR "ppstamp failed error_code: $error_code\n"; 318 print STDERR "@$stderr_buf\n"; 319 $exitStatus = $PS_EXIT_SYS_ERROR; 320 } 321 } elsif (!$exitStatus) { 322 rename "$tmpBase.fits", "$outputBase.exp.fits" 323 or my_die ("failed to rename $tmpBase.fits to $outputBase.exp.fits", $job_id, $PS_EXIT_UNKNOWN_ERROR); 324 } 325 } 246 326 } else { 247 327 $exitStatus = justCopyFiles($outputBase, \$options, $params);
Note:
See TracChangeset
for help on using the changeset viewer.
