Changeset 24726 for trunk/ippScripts/scripts/magic_destreak.pl
- Timestamp:
- Jul 8, 2009, 6:19:50 PM (17 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/magic_destreak.pl (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/magic_destreak.pl
r24702 r24726 21 21 22 22 use PS::IPP::Config 1.01 qw( :standard ); 23 use Nebulous::Client; 23 24 24 25 use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt ); … … 30 31 my $streaksremove = can_run('streaksremove') or (warn "Can't find streaksremove" and $missing_tools = 1); 31 32 my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1); 32 # XXX: replace with real name for tool 33 my $censordetections = ""; 34 # my $censordetections = can_run('censordetections') or (warn "Can't find censordetections" and $missing_tools = 1); 33 my $censorObjects = can_run('censorObjects') or (warn "Can't find censorObjects" and $missing_tools = 1); 35 34 if ($missing_tools) { 36 35 warn("Can't find required tools."); … … 54 53 'path_base=s' => \$path_base, # path_base of the input 55 54 'inverse' => \$inverse, # Inverse subtraction? 56 'cam_path_base=s'=> \$cam_path_base, # path_base of the associated camera run55 'cam_path_base=s'=> \$cam_path_base, # path_base from camera stage (for chip and raw) 57 56 'outroot=s' => \$outroot, # "directory" for temporary images (may be nebulous) 58 57 'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels … … 102 101 my $basename = basename($path_base); 103 102 my $nebulousInput = inNebulous($dirname); 103 my $nebulousOutput = inNebulous($outroot); 104 104 105 105 # parse replace arguments check for errors and set up 106 106 # the appropriate paths 107 my $nebulous; 107 108 if (defined($replace) and ($replace eq "T")) { 109 # for camera stage we need a handle to the nebulous server 110 if ($stage eq 'camera') { 111 my $nebulousServer = metadataLookupStr( $ipprc->{_siteConfig}, 'NEB_SERVER' ); 112 &my_die("cannot find NEB_SERVER in site configuration", 113 $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) 114 if !$ nebulousServer; 115 116 $nebulous = eval { Nebulous::Client->new( proxy => $nebulousServer ); }; 117 if ($@ or not defined $nebulous) { 118 &my_die ("Unable to create a Nebulous::Client object with proxy $nebulousServer", 119 $magic_ds_id, $component , $PS_EXIT_UNKNOWN_ERROR); 120 } 121 } 108 122 $replace = 1; 109 123 } else { … … 111 125 } 112 126 127 113 128 # default value is "NULL" do not use 114 129 if (defined($recoveryroot) and ($recoveryroot eq "NULL")) { … … 122 137 123 138 # create the output directories if it is not a nebulous path and it doesn't exist 124 if (! inNebulous($outroot)) {139 if (! $nebulousOutput) { 125 140 if (! -e $outroot ) { 126 141 my $code = system "mkdir -p $outroot"; … … 128 143 $code >> 8) if $code; 129 144 } 130 #} elsif ($replace) {131 # if input is in nebulous and we've been asked to replace the input with the destreaked132 # version the output must be in nebulous as well133 # XXX Is this necessary? if ($replace) the outputs are going to the nebulous "directory" of the134 # input anyways. Why require that other files (log) be in nebulous135 145 } 136 146 … … 208 218 $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id); 209 219 $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path_base); 220 if (!$ipprc->file_exists($mask)) { 221 carp("camera mask file $mask for $component not found. Continuing using mask from chip stage."); 222 $mask = $ch_mask; 223 $ch_mask = undef; 224 } 225 # XXX: should we censor the sources as well? For now we're leaving them out of the distribution bundles 226 # because they confuse people 227 # XXX: make sure that this is the right file rule 228 # $sources = $ipprc->filename("PSPHOT.OUT.CMF.SPL", $path_base); 229 210 230 } elsif ($stage eq "warp") { 211 231 $image = $ipprc->filename("PSWARP.OUTPUT", $path_base); … … 247 267 } 248 268 } else { 269 # camera stage. The only work to do is to censor the detections file 270 249 271 my $tempOutRoot = "/tmp/destreak"; 250 272 my ($maskListFile, $maskListName) = tempfile( "$tempOutRoot.mask.list.XXXX", UNLINK => !$save_temps); … … 272 294 if (!$quality) { 273 295 my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $path_base, $class_id); 296 if (! $ipprc->file_exists($mask)) { 297 # camera mask doesn't exist for this chip. Fall back to the chip mask 298 $mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $file->{path_base}, $class_id); 299 } 274 300 print $maskListFile "$mask\n"; 275 301 } … … 279 305 my $astrom = $ipprc->filename("PSASTRO.OUTPUT", $path_base); 280 306 { 281 my $output = $tmproot . basename($astrom); 282 my $command = "$censordetections -stage $stage -output $output"; 283 $command .= " -astrom $astrom"; 284 $command .= " -masklist $maskListName"; 285 $command .= " -replace" if $replace; 307 my $command = "$censorObjects -file $astrom -masklist $maskListName $backup_path_base"; 308 # $command .= " -replace" if $replace; 286 309 $command .= " -dbname $dbname" if defined $dbname; 287 310 unless (defined $no_op) { … … 290 313 unless ($success) { 291 314 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 292 &my_die("Unable to perform streaksremove: $error_code", $magic_ds_id, $component, $error_code); 315 &my_die("Unable to perform censorObjects: $error_code", $magic_ds_id, $component, $error_code); 316 } 317 my $output = $ipprc->filename("CENSOR.OUTPUT", $backup_path_base); 318 &my_die("expected output file $output not found ", $magic_ds_id, $component, $PS_EXIT_DATA_ERROR) 319 unless $ipprc->file_exists($output); 320 321 if ($replace) { 322 $nebulous->swap($astrom, $output) or 323 &my_die("nebulous swap failed $astrom $output", $magic_ds_id, $component, $PS_EXIT_UNKNOWN_ERROR); 293 324 } 294 325 } else {
Note:
See TracChangeset
for help on using the changeset viewer.
