- Timestamp:
- Aug 11, 2009, 3:54:00 PM (17 years ago)
- Location:
- branches/czw_branch/cleanup
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
ippScripts/scripts/magic_destreak.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup
- Property svn:mergeinfo changed
/trunk merged: 24940-24950,24953-24971,24973-24977,24986-24989,24993-25017,25019,25021,25023-25024,25026,25029-25031,25036-25049
- Property svn:mergeinfo changed
-
branches/czw_branch/cleanup/ippScripts/scripts/magic_destreak.pl
r24951 r25051 38 38 39 39 # Parse the command-line arguments 40 my ($magic_ds_id, $camera, $streaks, $ stage, $stage_id, $component, $uri, $path_base, $inverse, $cam_path_base);40 my ($magic_ds_id, $camera, $streaks, $inv_streaks, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base); 41 41 my ($outroot, $recoveryroot); 42 42 my ($replace, $release); … … 47 47 'camera=s' => \$camera, # camera for evaluating file rules 48 48 'streaks=s' => \$streaks, # file containing the list of streaks 49 'inv_streaks=s' => \$inv_streaks,# file containing the list of streaks from the inverse diff 49 50 'stage=s' => \$stage, # raw, chip, warp, or diff 50 51 'stage_id=s' => \$stage_id, # exp_id, chip_id, warp_id, or diff_id … … 52 53 'uri=s' => \$uri, # uri of the input image 53 54 'path_base=s' => \$path_base, # path_base of the input 54 'inverse' => \$inverse, # Inverse subtraction?55 55 'cam_path_base=s'=> \$cam_path_base, # path_base from camera stage (for chip and raw) 56 56 'outroot=s' => \$outroot, # "directory" for temporary images (may be nebulous) … … 94 94 } elsif ($stage ne "camera") { 95 95 &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 96 } 96 } 97 $inv_streaks = undef if defined($inv_streaks) and ($inv_streaks eq "NULL"); 97 98 98 99 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files … … 205 206 206 207 my ($image, $mask, $ch_mask, $weight, $astrom, $sources); 208 209 # if we're destreaking a bothways diff need to combine the 210 # two streaks files 211 my ($allstreaks_fh, $allstreaks_name); 207 212 208 213 if ($stage eq "raw") { … … 234 239 $sources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $path_base); 235 240 } elsif ($stage eq "diff") { 236 my $name = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT"; # Base name for images 237 $image = $ipprc->filename($name, $path_base); 238 $mask = $ipprc->filename("$name.MASK", $path_base); 239 $weight = $ipprc->filename("$name.VARIANCE", $path_base); 241 $image = $ipprc->filename("PPSUB.OUTPUT", $path_base); 242 $mask = $ipprc->filename("PPSUB.OUTPUT.MASK", $path_base); 243 $weight = $ipprc->filename("PPSUB.OUTPUT.VARIANCE", $path_base); 240 244 $sources = $ipprc->filename("PPSUB.OUTPUT.SOURCES", $path_base); 245 246 if ($inv_streaks) { 247 # create a temporary file containing the contents of the 248 # two streaks files 249 ($allstreaks_fh, $allstreaks_name) = tempfile ("/tmp/all.streaks.XXXX", 250 UNLINK => !$save_temps); 251 252 combine_streaks($allstreaks_fh, $streaks, $inv_streaks); 253 254 # apply the combined streaks to both the forward and inverse diffs 255 $streaks = $allstreaks_name; 256 } 241 257 } 242 258 … … 266 282 } 267 283 } 284 if (($stage eq "diff") and $inv_streaks) { 285 $image = $ipprc->filename("PPSUB.INVERSE", $path_base); 286 $mask = $ipprc->filename("PPSUB.INVERSE.MASK", $path_base); 287 $weight = $ipprc->filename("PPSUB.INVERSE.VARIANCE", $path_base); 288 $sources = $ipprc->filename("PPSUB.INVERSE.SOURCES", $path_base); 289 290 my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks -image $image"; 291 292 $command .= " -recovery $recoveryroot" if defined $recoveryroot; 293 $command .= " -mask $mask" if defined $mask; 294 $command .= " -weight $weight" if defined $weight; 295 $command .= " -sources $sources" if defined $sources; 296 $command .= " -replace" if $replace; 297 $command .= " -release" if $release; 298 $command .= " -dbname $dbname" if defined $dbname; 299 unless (defined $no_op) { 300 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 301 run(command => $command, verbose => $verbose); 302 unless ($success) { 303 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 304 &my_die("Unable to perform streaksremove: $error_code", $magic_ds_id, $component, $error_code); 305 } 306 } else { 307 print "skipping command $command\n"; 308 } 309 } 268 310 } else { 269 311 # camera stage. The only work to do is to censor the detections file … … 376 418 } 377 419 420 sub combine_streaks 421 { 422 my $fout = shift; 423 my $fn1 = shift; 424 my $fn2 = shift; 425 426 my ($n1, @streaks1) = read_streaks_file($fn1); 427 my_die("failed to read streaks from $fn1", $magic_ds_id, $component, 428 $PS_EXIT_UNKNOWN_ERROR) if $n1 < 0; 429 430 my ($n2, @streaks2) = read_streaks_file($fn2); 431 my_die("failed to read streaks from $fn2", $magic_ds_id, $component, 432 $PS_EXIT_UNKNOWN_ERROR) if $n2 < 0; 433 434 print $fout $n1 + $n2 . "\n"; 435 436 foreach my $line (@streaks1, @streaks2) { 437 print $fout $line; 438 } 439 440 close $fout 441 or my_die("failed to close combined streaks file", $magic_ds_id, 442 $component, $PS_EXIT_UNKNOWN_ERROR); 443 } 444 445 sub read_streaks_file 446 { 447 my $filename = shift; 448 my $fh; 449 open $fh, "<$filename" or my_die("failed to open $filename", 450 $magic_ds_id, $component, $PS_EXIT_UNKNOWN_ERROR); 451 452 # first line is the number of streaks 453 my $line = <$fh>; 454 chomp $line; 455 my $nstreaks = $line; 456 457 my @streaks; 458 459 foreach $line (<$fh>) { 460 push @streaks, $line; 461 } 462 463 close $fh; 464 465 return ($nstreaks, @streaks); 466 } 467 378 468 379 469 sub my_die
Note:
See TracChangeset
for help on using the changeset viewer.
