Changeset 30260 for trunk/ippScripts/scripts/magic_destreak_revert.pl
- Timestamp:
- Jan 12, 2011, 4:49:23 PM (15 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/magic_destreak_revert.pl (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/magic_destreak_revert.pl
r29983 r30260 39 39 # Parse the command-line arguments 40 40 my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction, $magicked, $run_state); 41 my ($outroot, $recovery root, $replace, $release, $bytes, $md5sum);41 my ($outroot, $recovery_path_base, $replace, $release, $bytes, $md5sum); 42 42 my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile); 43 43 … … 53 53 'cam_reduction=s'=> \$cam_reduction, # reduction class of the associated camera run 54 54 'outroot=s' => \$outroot, # "directory" for temporary images (may be nebulous) 55 'recovery root=s' => \$recoveryroot,# "directory" for saving the images of excised pixels55 'recovery_path_base=s' => \$recovery_path_base,# "directory" for saving the images of excised pixels 56 56 'replace=s' => \$replace, # replace the input images with the results. 57 57 'bothways=s' => \$bothways, # run has inverse files (bothways diff) … … 130 130 131 131 # default value is "NULL" do not use it 132 if (defined($recovery root) and ($recoveryrooteq "NULL")) {133 $recovery root= undef;132 if (defined($recovery_path_base) and ($recovery_path_base eq "NULL")) { 133 $recovery_path_base = undef; 134 134 } 135 135 … … 149 149 } 150 150 151 my $recovery_path_base;152 if ($recoveryroot) {153 # note: trailing / is necessary154 $recovery_path_base = "$recoveryroot/$basename/";155 }156 157 151 158 152 my ($image, $mask, $ch_mask, $weight, $sources, $astrom); 159 153 my ($bimage, $bmask, $bch_mask, $bweight, $bsources, $bastrom); 154 my ($rimage, $rmask, $rch_mask, $rweight); 160 155 161 156 if ($stage eq "raw") { … … 214 209 $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $class_id); 215 210 $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $class_id); 211 212 $rimage = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $class_id); 213 # This is somewhat kludgey but it works whether the mask is camera mask or chip mask 214 $rmask = dirname($recovery_path_base) . "/REC_" . basename($mask); 215 $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $class_id); 216 $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $class_id); 216 217 } elsif ($stage eq "camera") { 217 218 $astrom = $ipprc->filename("PSASTRO.OUTPUT", $path_base); … … 226 227 $bweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $backup_path_base); 227 228 $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base); 229 $rimage = $ipprc->filename("PSWARP.OUTPUT", $recovery_path_base); 230 $rmask = $ipprc->filename("PSWARP.OUTPUT.MASK", $recovery_path_base); 231 $rweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $recovery_path_base); 228 232 } elsif ($stage eq "diff") { 229 233 my $name = "PPSUB.OUTPUT"; … … 236 240 $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base); 237 241 $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 242 if ($recovery_path_base) { 243 $rimage = $ipprc->filename($name, $recovery_path_base); 244 $rmask = $ipprc->filename("$name.MASK", $recovery_path_base); 245 $rweight = $ipprc->filename("$name.VARIANCE", $recovery_path_base); 246 } 238 247 } 239 248 240 249 revert_files($replace, $image, $mask, $weight, $sources, $astrom, $bimage, $bmask, $bweight, $bsources, $bastrom); 250 if ($recovery_path_base) { 251 delete_recovery_files($rimage, $rmask, $rweight, $rch_mask); 252 } 241 253 242 254 if ($stage eq "diff" and $bothways) { … … 251 263 $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base); 252 264 revert_files($replace, $image, $mask, $weight, $sources, undef, $bimage, $bmask, $bweight, $bsources, undef); 265 if ($recovery_path_base) { 266 $rimage = $ipprc->filename($name, $recovery_path_base); 267 $rmask = $ipprc->filename("$name.MASK", $recovery_path_base); 268 $rweight = $ipprc->filename("$name.VARIANCE", $recovery_path_base); 269 delete_recovery_files($rimage, $rmask, $rweight); 270 } 253 271 } 254 272 … … 426 444 427 445 428 sub file_check 429 { 430 my $file = shift; # Name of file 431 &my_die("Unable to find output file: $file", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR) unless 432 $ipprc->file_exists($file); 446 sub delete_recovery_files 447 { 448 foreach my $file (@_) { 449 if ($ipprc->file_exists($file)) { 450 if (!$ipprc->file_delete($file)) { 451 &my_die("failed to delete recovery file $file", $magic_ds_id, $component, $PS_EXIT_UNKNOWN_ERROR); 452 } 453 } 454 } 433 455 } 434 456
Note:
See TracChangeset
for help on using the changeset viewer.
