IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 29, 2010, 3:55:49 PM (16 years ago)
Author:
eugene
Message:

update merges from trunk

Location:
branches/eam_branches/20100225
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/20100225

  • branches/eam_branches/20100225/ippScripts/scripts/magic_destreak_cleanup.pl

    r26555 r27517  
    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.");
     
    8687my $dbh = DBI->connect($dsn, $dbuser, $dbpassword) or die "Cannot connect to mysql server\n";
    8788
    88 my $q1 = "SELECT magicDSRun.*, camera, camProcessedExp.path_base AS cam_path_base, magicRun.inverse"
    89          . " 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)"
    9091         . " WHERE magic_ds_id = $magic_ds_id";
    9192my $q2 = "SELECT * from magicDSFile where magic_ds_id = $magic_ds_id";
    92 
    93 # my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    9493
    9594my $stmt1 = $dbh->prepare($q1);
     
    103102my $stage_id = $run->{stage_id};
    104103my $cam_path_base = $run->{cam_path_base};
     104my $cam_reduction = $run->{cam_reduction};
     105$cam_reduction = 'DEFAULT' if !$cam_reduction or ($cam_reduction eq 'NULL');
    105106my $inverse = $run->{inverse};
    106107
     
    108109&my_die("unexpected run state found: $state", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $state ne "goto_cleaned";
    109110&my_die("clean not allowed for raw stage, use goto_restore", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) if $stage eq "raw";
     111
     112my $recipe_psastro = $ipprc->reduction($cam_reduction, 'PSASTRO'); # Recipe to use
     113&my_die("Unrecognised PSASTRO recipe", $magic_ds_id, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro;
    110114
    111115
     
    124128
    125129        if ($stage eq "chip") {
    126             # we use the mask output from the camera stage for input and replace
    127             # the output of the chip stage with that mask as well.
    128             my $cammask   = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component);
     130            # Check to see if we're using dynamic masks
     131            my $dynamicMasks;               # Use dynamic masks?
     132            {
     133                # Get the PSASTRO recipe
     134                my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -";
     135                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     136                    run(command => $command, verbose => $verbose);
     137                unless ($success) {
     138                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     139                    &my_die("Unable to perform ppConfigDump: $error_code", $magic_ds_id, $component,
     140                            $PS_EXIT_CONFIG_ERROR);
     141                }
     142                my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
     143                my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
     144                    &my_die("Unable to parse metadata config doc", $magic_ds_id, $component,
     145                            $PS_EXIT_CONFIG_ERROR);
     146
     147                $dynamicMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK');
     148            }
    129149
    130150            if ($backup_path_base) {
    131151                $bimage  = $ipprc->filename("PPIMAGE.CHIP", $backup_path_base, $component);
    132                 $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component);
     152
     153                if ($dynamicMasks) {
     154                    my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component);
     155                    # This is kludgey but correct
     156                    $bmask = dirname($backup_path_base) . "/SR_" . basename($mask);
     157                    $bch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component);
     158                } else {
     159                    $bmask = $ipprc->filename("PPIMAGE.CHIP.MASK", $backup_path_base, $component);
     160                }
    133161                $bweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $backup_path_base, $component);
    134                 # This is kludgey but correct
    135                
    136                 my $prefix;
    137                 if ($backup_path_base =~ /\.SR/) {
    138                     $prefix = "";
     162            }
     163            if ($recovery_path_base) {
     164                $rimage  = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $component);
     165
     166                if ($dynamicMasks) {
     167                    my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $component);
     168                    # This is kludgey but correct
     169                    $rmask = dirname($recovery_path_base) . "/" . basename($mask);
     170                    $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component);
    139171                } else {
    140                     $prefix = "SR_";
    141                 }
    142 
    143                 $bmask   = dirname($backup_path_base) . "/" . $prefix . basename($cammask);
    144             }
    145             if ($recovery_path_base) {
    146                 $rimage  = $ipprc->filename("PPIMAGE.CHIP", $recovery_path_base, $component);
    147                 $rch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component);
     172                    $rmask = $ipprc->filename("PPIMAGE.CHIP.MASK", $recovery_path_base, $component);
     173                }
    148174                $rweight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $recovery_path_base, $component);
    149                 # This is kludgey but correct
    150                 $rmask   = dirname($recovery_path_base) . "/" . basename($cammask);
    151175            }
    152176        } elsif ($stage eq "camera") {
     
    160184                $bweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $backup_path_base);
    161185                $bsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $backup_path_base);
    162             } 
     186            }
    163187            if ($recovery_path_base) {
    164188                $rimage  = $ipprc->filename("PSWARP.OUTPUT", $recovery_path_base);
     
    166190                $rweight = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $recovery_path_base);
    167191                $rsources = $ipprc->filename("PSWARP.OUTPUT.SOURCES", $recovery_path_base);
    168             } 
     192            }
    169193        } elsif ($stage eq "diff") {
    170194            my $name = "PPSUB.OUTPUT";
     
    226250                if (!$no_update) {
    227251                    print STDERR "deleting $file\n" if $verbose;
    228                     $ipprc->file_delete($file) or my_die("Failed to delete $file", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR);
     252                    $ipprc->file_delete($file, 1) or my_die("Failed to delete $file", $magic_ds_id, $PS_EXIT_UNKNOWN_ERROR);
    229253                    } else {
    230254                    print STDERR "skipping delete $file\n";
Note: See TracChangeset for help on using the changeset viewer.