Changeset 24726
- Timestamp:
- Jul 8, 2009, 6:19:50 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
-
ippScripts/Build.PL (modified) (1 diff)
-
ippScripts/scripts/magic_destreak.pl (modified) (12 diffs)
-
ippScripts/scripts/magic_destreak_revert.pl (modified) (11 diffs)
-
ippTasks/magic.pro (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/Build.PL
r24512 r24726 57 57 scripts/magic_process.pl 58 58 scripts/magic_destreak.pl 59 scripts/magic_destreak_revert.pl 59 60 scripts/ippdb.pl 60 61 scripts/ipp_cleanup.pl -
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 { -
trunk/ippScripts/scripts/magic_destreak_revert.pl
r24686 r24726 70 70 defined $outroot; 71 71 72 # XXX: for testing73 $no_update = 1;74 75 72 &my_die("bytes and md5sum are is required for raw stage stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if ($stage eq 'raw' and (!$bytes or !$md5sum)); 76 73 … … 87 84 if ($@ or not defined $nebulous) { 88 85 &my_die ("Unable to create a Nebulous::Client object with proxy $nebulousServer", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 89 return undef;90 86 } 91 87 … … 109 105 my $nebulousInput = inNebulous($dirname); 110 106 111 # parse replace arguments check for errors and set up112 # the appropriate paths113 # this program doesn't make sense if $replace is false114 &my_die("Invalid value for replace: $replace", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if $replace ne "T";115 116 107 if (defined($replace) and ($replace eq "T")) { 117 108 $replace = 1; … … 120 111 } 121 112 122 # default value is "NULL" do not use 113 &my_die("replace not allowed for non-nebulous files", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) 114 if ($replace eq "T") and !$nebulousInput; 115 116 117 # default value is "NULL" do not use it 123 118 if (defined($recoveryroot) and ($recoveryroot eq "NULL")) { 124 119 $recoveryroot = undef; … … 135 130 $backup_path_base = $tmproot . "$basename"; 136 131 } else { 137 # note: t railing /is necessary132 # note: the trailing / here is necessary 138 133 $tmproot = "$outroot/"; 139 134 $backup_path_base = $tmproot . $basename; … … 189 184 } 190 185 191 do_swap($image, $bimage) or186 revert_file($image, $bimage) or 192 187 &my_die("failed to restore image file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 188 189 # don't commit next the next couple of lines and see xxx below 190 # change to if 0 to revert chip runs without masks 191 if (0) { 192 193 193 if ($mask) { 194 my $swap_result = do_swap($mask, $bmask); 195 if (! $swap_result) { 196 # delete next 5 lines 197 if ($stage eq "chip") { 198 # XXX: this is a kludge to get around my test environment 199 # Don't commit 200 print STDERR "failed to resotre camera mask file, proceeding\n"; 194 if (!revert_file($mask, $bmask)) { 195 if ($stage eq 'chip') { 196 # XXX: don't fail if the mask file fails to revert. It probably doesn't exist 197 # Handle this properly 198 print STDERR "failure to revert mask file, ignored\n"; 201 199 } else { 202 &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 203 } # delete this line 204 } 205 } 200 &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 201 } 202 } 203 } 204 206 205 if ($ch_mask) { 207 do_swap($ch_mask, $bch_mask) or 208 &my_die("failed to restore chip mask", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 206 # Handle this properly 207 if (!revert_file($ch_mask, $bch_mask)) { 208 # print STDERR "failure to revert chip mask file, ignored\n"; 209 &my_die("failed to restore chip mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 210 } 209 211 } 212 213 # xxx don't commmit next line 214 } 215 210 216 if ($weight) { 211 do_swap($weight, $bweight) or217 revert_file($weight, $bweight) or 212 218 &my_die("failed to restore variance image", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR); 213 219 } 214 220 215 # now reverse the desreaked file 216 # Change magicdstool to set the magicked value to zero 217 # Actually we should probably do this first to insure that no data gets deleted 218 # Input result into database 219 if (0) { 220 # XXX: this is the wrong mode 221 my $command = "$magicdstool -adddestreakedfile"; 221 # now revert the row in the database 222 { 223 my $command = "$magicdstool -revertdestreakedfile"; 222 224 $command .= " -magic_ds_id $magic_ds_id"; 223 225 $command .= " -component $component"; 224 $command .= " -setmagicked" if $replace;225 $command .= " -backup_path_base $backup_path_base" if $backup_path_base;226 $command .= " -recovery_path_base $recovery_path_base" if $recovery_path_base;227 226 $command .= " -dbname $dbname" if defined $dbname; 228 227 … … 242 241 243 242 244 245 243 ### Pau. 246 244 … … 256 254 } 257 255 258 sub do_swap256 sub revert_file 259 257 { 260 258 my $original = shift; … … 297 295 if ($b_path and -e $b_path) { 298 296 print "ready to delete backup\n" if $verbose; 299 if (! $ nebulous->delete($backup)) {297 if (! $ipprc->file_delete($backup)) { 300 298 print "failed to delete $backup\n"; 301 299 return 0; … … 307 305 # delete the 'backup' (destreaked target) file if it exists 308 306 if ($b_path and -e $b_path) { 309 if (! $ nebulous->delete($backup)) {307 if (! $ipprc->file_delete($backup)) { 310 308 print "failed to delete $backup\n"; 311 309 return 0; … … 348 346 $exit_code = $PS_EXIT_PROG_ERROR unless defined $exit_code; 349 347 350 my $command = "$magicdstool -adddestreakedfile"; 351 $command .= " -magic_ds_id $magic_ds_id"; 352 $command .= " -component $component"; 353 $command .= " -fault $exit_code"; 354 $command .= " -dbname $dbname" if defined $dbname; 355 356 # Add the processed file to the database 357 unless ($no_update) { 358 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 359 run(command => $command, verbose => $verbose); 360 unless ($success) { 361 carp("failed to update database for $magic_ds_id $component"); 362 } 363 } else { 364 print "Skipping command: $command\n"; 365 } 348 # we wouldn't be here unless an entry already exists in the database 349 # my $command = "$magicdstool -adddestreakedfile"; 350 # $command .= " -magic_ds_id $magic_ds_id"; 351 # $command .= " -component $component"; 352 # $command .= " -fault $exit_code"; 353 # $command .= " -dbname $dbname" if defined $dbname; 354 355 # # Add the processed file to the database 356 # unless ($no_update) { 357 # my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 358 # run(command => $command, verbose => $verbose); 359 # unless ($success) { 360 # carp("failed to update database for $magic_ds_id $component"); 361 # } 362 # } else { 363 # print "Skipping command: $command\n"; 364 # } 366 365 367 366 carp($msg); -
trunk/ippTasks/magic.pro
r24711 r24726 463 463 sprintf logfile "%s/%s.mds.%s.%s.%s.log" $OUTROOT $EXP_ID $MAGIC_DS_ID $STAGE_ID $COMPONENT 464 464 465 host anyhost 465 substr $COMPONENT 0 3 COMP_HEAD 466 if ("$COMP_HEAD" == "sky") 467 set.host.for.skycell $COMPONENT 468 else 469 # assume component is a class_id, if not we will default to anyhost 470 set.host.for.camera $CAMERA $COMPONENT 471 end 466 472 467 473 # TODO: do not add recoveryroot or replace if they are null or zero
Note:
See TracChangeset
for help on using the changeset viewer.
