Changeset 37262
- Timestamp:
- Aug 15, 2014, 3:51:40 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tags/ipp-pv3-20140717/pstamp/scripts/pstamp_job_run.pl
r36812 r37262 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 ($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 my $pathBase = "$params->{stack_path_base}.unconv"; 251 my $tmpBase = "$outputBase.TMP"; 252 # nocompress because exp image gets corrupted if we do 253 my $command = "$ppstamp $tmpBase $roiArgs -nocompress -stage stack"; 254 # XXX: use file rules 255 # Image is the EXP (exptime) image 256 $command .= " -file $pathBase.exp.fits"; 257 # treat number image as mask 258 $command .= " -mask $pathBase.num.fits" if ($options & $PSTAMP_SELECT_NUM); 259 260 $command .= " -forheader $calibfile" if $calibfile; 261 262 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 263 run(command => $command, verbose => $verbose); 264 265 if (WIFEXITED($error_code)) { 266 $exitStatus = WEXITSTATUS($error_code); 267 } else { 268 print STDERR "ppstamp failed error_code: $error_code\n"; 269 $exitStatus = $PS_EXIT_SYS_ERROR; 270 } 271 272 # command to compress fits files to stdout using gzip 273 my $fpack_gzip = "$fpack -g -S"; 274 $fpack_gzip .= " -D" unless $save_temps; 275 276 if (!$exitStatus and ($options & $PSTAMP_SELECT_NUM)) { 277 # rename the num image if selected since it is not a mask 278 # Change .exp.mk to .num 279 my $tmpName = "$tmpBase.mk.fits"; 280 my $numName = "$outputBase.num.fits"; 281 # optionally fpack it while we're here unless user wants uncompressed images 282 unless ($options & $PSTAMP_SELECT_UNCOMPRESSED) { 283 my $command = "$fpack_gzip $tmpName > $numName"; 284 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 285 run(command => $command, verbose => $verbose); 286 287 if (WIFEXITED($error_code)) { 288 $exitStatus = WEXITSTATUS($error_code); 289 } else { 290 print STDERR "ppstamp failed error_code: $error_code\n"; 291 print STDERR "@$stderr_buf\n"; 292 $exitStatus = $PS_EXIT_SYS_ERROR; 293 } 294 } elsif (!$exitStatus) { 295 rename $tmpName, $numName 296 or my_die ("failed to rename $tmpName to $numName", $job_id, $PS_EXIT_UNKNOWN_ERROR); 297 } 298 299 } 300 # fpack the exp image if not -nocompress 301 unless ($exitStatus or ($options & $PSTAMP_SELECT_UNCOMPRESSED)) { 302 my $command = "$fpack_gzip $tmpBase.fits > $outputBase.exp.fits"; 303 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 304 run(command => $command, verbose => $verbose); 305 306 if (WIFEXITED($error_code)) { 307 $exitStatus = WEXITSTATUS($error_code); 308 } else { 309 print STDERR "ppstamp failed error_code: $error_code\n"; 310 print STDERR "@$stderr_buf\n"; 311 $exitStatus = $PS_EXIT_SYS_ERROR; 312 } 313 } elsif (!$exitStatus) { 314 rename "$tmpBase.fits", "$outputBase.exp.fits" 315 or my_die ("failed to rename $tmpBase.fits to $outputBase.exp.fits", $job_id, $PS_EXIT_UNKNOWN_ERROR); 316 } 317 } 246 318 } else { 247 319 $exitStatus = justCopyFiles($outputBase, \$options, $params);
Note:
See TracChangeset
for help on using the changeset viewer.
