IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 30260


Ignore:
Timestamp:
Jan 12, 2011, 4:49:23 PM (15 years ago)
Author:
bills
Message:

when reverting delete recovery images

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippScripts/scripts/magic_destreak_revert.pl

    r29983 r30260  
    3939# Parse the command-line arguments
    4040my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction, $magicked, $run_state);
    41 my ($outroot, $recoveryroot, $replace, $release, $bytes, $md5sum);
     41my ($outroot, $recovery_path_base, $replace, $release, $bytes, $md5sum);
    4242my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
    4343
     
    5353           'cam_reduction=s'=> \$cam_reduction,  # reduction class of the associated camera run
    5454           'outroot=s'      => \$outroot,     # "directory" for temporary images (may be nebulous)
    55            'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels
     55           'recovery_path_base=s' => \$recovery_path_base,# "directory" for saving the images of excised pixels
    5656           'replace=s'      => \$replace,    # replace the input images with the results.
    5757           'bothways=s'     => \$bothways,   # run has inverse files (bothways diff)
     
    130130
    131131# default value is "NULL" do not use it
    132 if (defined($recoveryroot) and ($recoveryroot eq "NULL")) {
    133     $recoveryroot = undef;
     132if (defined($recovery_path_base) and ($recovery_path_base eq "NULL")) {
     133    $recovery_path_base = undef;
    134134}
    135135
     
    149149}
    150150
    151 my $recovery_path_base;
    152 if ($recoveryroot) {
    153     # note: trailing / is necessary
    154     $recovery_path_base = "$recoveryroot/$basename/";
    155 }
    156 
    157151
    158152my ($image, $mask, $ch_mask, $weight, $sources, $astrom);
    159153my ($bimage, $bmask, $bch_mask, $bweight, $bsources, $bastrom);
     154my ($rimage, $rmask, $rch_mask, $rweight);
    160155
    161156if ($stage eq "raw") {
     
    214209    $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $class_id);
    215210    $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);
    216217} elsif ($stage eq "camera") {
    217218    $astrom =  $ipprc->filename("PSASTRO.OUTPUT", $path_base);
     
    226227    $bweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $backup_path_base);
    227228    $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);
    228232} elsif ($stage eq "diff") {
    229233    my $name = "PPSUB.OUTPUT";
     
    236240    $bweight = $ipprc->filename("$name.VARIANCE", $backup_path_base);
    237241    $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    }
    238247}
    239248
    240249revert_files($replace, $image, $mask, $weight, $sources, $astrom, $bimage, $bmask, $bweight, $bsources, $bastrom);
     250if ($recovery_path_base) {
     251    delete_recovery_files($rimage, $rmask, $rweight, $rch_mask);
     252}
    241253
    242254if ($stage eq "diff" and $bothways) {
     
    251263    $bsources = $ipprc->filename("$name.SOURCES", $backup_path_base);
    252264    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    }
    253271}
    254272
     
    426444
    427445
    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);
     446sub 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    }
    433455}
    434456
Note: See TracChangeset for help on using the changeset viewer.