IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 16, 2010, 12:39:45 PM (16 years ago)
Author:
Paul Price
Message:

Make destreaking care about whether we used dynamic masking (so that we need to care about the camera mask or only use the chip mask). This we get from the (current) recipe, which is not ideal, but better than simply looking whether the file exists (it may not be available over NFS or Nebulous). Though I have discussed these fixes with Bill, I have not yet tested the code.

File:
1 edited

Legend:

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

    r27256 r27301  
    3030my $missing_tools;
    3131my $magicdstool   = can_run('magicdstool') or (warn "Can't find magicdstool" and $missing_tools = 1);
     32my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    3233if ($missing_tools) {
    3334    warn("Can't find required tools.");
     
    3637
    3738# Parse the command-line arguments
    38 my ($magic_ds_id, $camera, $force);
     39my ($magic_ds_id, $camera);
    3940my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
    4041
     
    4243           'magic_ds_id=s'  => \$magic_ds_id,# Magic destreak run identifier
    4344           'camera=s'       => \$camera,     # camera for evaluating file rules
    44            'force'          => \$force,      # force deletion
    4545           'save-temps'     => \$save_temps, # Save temporary files?
    4646           'dbname=s'       => \$dbname,     # Database name
     
    8787my $dbh = DBI->connect($dsn, $dbuser, $dbpassword) or die "Cannot connect to mysql server\n";
    8888
    89 my $q1 = "SELECT magicDSRun.*, camera, camProcessedExp.path_base AS cam_path_base, magicRun.inverse"
    90          . " FROM magicDSRun JOIN magicRun USING(magic_id) JOIN rawExp USING(exp_id) LEFT JOIN camProcessedExp USING(cam_id)"
     89my $q1 = "SELECT magicDSRun.*, camera, camProcessedExp.path_base AS cam_path_base, camRun.reduction AS cam_reduction, magicRun.inverse"
     90         . " FROM magicDSRun JOIN magicRun USING(magic_id) JOIN rawExp USING(exp_id) LEFT JOIN camProcessedExp USING(cam_id) LEFT JOIN camRun USING(cam_id)"
    9191         . " WHERE magic_ds_id = $magic_ds_id";
    9292my $q2 = "SELECT * from magicDSFile where magic_ds_id = $magic_ds_id";
    93 
    94 # my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    9593
    9694my $stmt1 = $dbh->prepare($q1);
     
    104102my $stage_id = $run->{stage_id};
    105103my $cam_path_base = $run->{cam_path_base};
     104my $cam_reduction = $run->{cam_reduction};
    106105my $inverse = $run->{inverse};
    107 my $replace = $run->{re_place};
    108106
    109107
    110108&my_die("unexpected run state found: $state", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $state ne "goto_cleaned";
    111 &my_die("clean not allowed for raw stage, use goto_restore", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if ($stage eq "raw"); # XXX: add this once we implement and $replace;
     109&my_die("clean not allowed for raw stage, use goto_restore", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $stage eq "raw";
     110
     111my $recipe_psastro = $ipprc->reduction($cam_reduction, 'PSASTRO'); # Recipe to use
     112&my_die("Unrecognised PSASTRO recipe", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro;
    112113
    113114
     
    126127
    127128        if ($stage eq "chip") {
    128             # we use the mask output from the camera stage for input and replace
    129             # the output of the chip stage with that mask as well.
    130             my $cammask   = $cam_path_base ? $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component) : undef;
     129            # Check to see if we're using dynamic masks
     130            my $dynamicMasks;               # Use dynamic masks?
     131            {
     132                # Get the PSASTRO recipe
     133                my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -";
     134                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     135                    run(command => $command, verbose => $verbose);
     136                unless ($success) {
     137                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     138                    &my_die("Unable to perform ppConfigDump: $error_code", $magic_ds_id, $component,
     139                            $PS_EXIT_CONFIG_ERROR);
     140                }
     141                my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     142                my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
     143                    &my_die("Unable to parse metadata config doc", $magic_ds_id, $component,
     144                            $PS_EXIT_CONFIG_ERROR);
     145
     146                $dynamicMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK');
     147            }
    131148
    132149            if ($backup_path_base) {
    133150                $bimage  = $ipprc->filename("PPIMAGE.CHIP", $backup_path_base, $component);
    134                 $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component);
     151
     152                if ($dynamicMasks) {
     153                    my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component);
     154                    # This is kludgey but correct
     155                    $bmask = dirname($backup_path_base) . "/SR_" . basename($mask);
     156                    $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component);
     157                } else {
     158                    $bmask = $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component);
     159                }
    135160                $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $component);
    136                 # This is kludgey but correct
    137                
    138                 my $prefix;
    139                 if ($backup_path_base =~ /\.SR/) {
    140                     $prefix = "";
     161            }
     162            if ($recovery_path_base) {
     163                $rimage  = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $component);
     164
     165                if ($dynamicMasks) {
     166                    my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component);
     167                    # This is kludgey but correct
     168                    $rmask = dirname($recovery_path_base) . "/" . basename($mask);
     169                    $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component);
    141170                } else {
    142                     $prefix = "SR_";
    143                 }
    144 
    145                 $bmask   = dirname($backup_path_base) . "/" . $prefix . basename($cammask) if $cammask;
    146             }
    147             if ($recovery_path_base) {
    148                 $rimage  = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $component);
    149                 $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component);
     171                    $rmask = $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component);
     172                }
    150173                $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $component);
    151                 # This is kludgey but correct
    152                 $rmask   = dirname($recovery_path_base) . "/" . basename($cammask) if $cammask;;
    153174            }
    154175        } elsif ($stage eq "camera") {
     
    162183                $bweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $backup_path_base);
    163184                $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base);
    164             } 
     185            }
    165186            if ($recovery_path_base) {
    166187                $rimage  = $ipprc->filename("PSWARP.OUTPUT", $recovery_path_base);
     
    168189                $rweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $recovery_path_base);
    169190                $rsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $recovery_path_base);
    170             } 
     191            }
    171192        } elsif ($stage eq "diff") {
    172193            my $name = "PPSUB.OUTPUT";
     
    228249                if (!$no_update) {
    229250                    print STDERR "deleting $file\n" if $verbose;
    230                     $ipprc->file_delete($file, $force) or my_die("Failed to delete $file", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR);
    231                 } else {
     251                    $ipprc->file_delete($file, 1) or my_die("Failed to delete $file", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR);
     252                    } else {
    232253                    print STDERR "skipping delete $file\n";
    233254                }
Note: See TracChangeset for help on using the changeset viewer.