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.pl

    r26554 r27301  
    3232my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
    3333my $censorObjects = can_run('censorObjects') or (warn "Can't find censorObjects" and $missing_tools = 1);
     34my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1);
    3435my $ppStatsFromMetadata = can_run('ppStatsFromMetadata') or (warn "Can't find ppStatsFromMetadata" and $missing_tools = 1);
    3536if ($missing_tools) {
     
    3940
    4041# Parse the command-line arguments
    41 my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base);
     42my ($magic_ds_id, $camera, $streaks, $inv_streaks, $exp_id, $stage, $stage_id, $component, $uri, $path_base, $cam_path_base, $cam_reduction);
    4243my ($outroot, $recoveryroot);
    4344my ($replace, $release);
     
    5657           'path_base=s'    => \$path_base,  # path_base of the input
    5758           'cam_path_base=s'=> \$cam_path_base,  # path_base from camera stage (for chip and raw)
     59           'cam_reduction=s'=> \$cam_reduction,  # reduction class from camera stage (for chip and raw)
    5860           'outroot=s'      => \$outroot,     # "directory" for temporary images (may be nebulous)
    5961           'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels
     
    8486my $ipprc = PS::IPP::Config->new( $camera ) or my_die( "Unable to set up", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR ); # IPP configuration
    8587$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile;
     88my $recipe_psastro = $ipprc->reduction($cam_reduction, 'PSASTRO'); # Recipe to use
     89&my_die("Unrecognised PSASTRO recipe", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro;
    8690
    8791my ($skycell_args, $class_id, $skycell_id);
     
    97101} elsif ($stage ne "camera") {
    98102    &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    99 }   
     103}
    100104$inv_streaks = undef if defined($inv_streaks) and ($inv_streaks eq "NULL");
    101105
     
    114118    if ($stage eq 'camera') {
    115119        my $nebulousServer = metadataLookupStr( $ipprc->{_siteConfig}, 'NEB_SERVER' );
    116         &my_die("cannot find NEB_SERVER in site configuration", 
    117                                         $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) 
     120        &my_die("cannot find NEB_SERVER in site configuration",
     121                                        $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR)
    118122            if !$ nebulousServer;
    119123
     
    233237        $mask   = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id) if $release ;
    234238    } elsif ($stage eq "chip") {
     239
     240        # Check to see if we're using dynamic masks
     241        my $dynamicMasks;               # Use dynamic masks?
     242        {
     243            # Get the PSASTRO recipe
     244            my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -";
     245            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     246                run(command => $command, verbose => $verbose);
     247            unless ($success) {
     248                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     249                &my_die("Unable to perform ppConfigDump: $error_code", $magic_ds_id, $component,
     250                        $PS_EXIT_CONFIG_ERROR);
     251            }
     252            my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
     253                &my_die("Unable to parse metadata config doc", $magic_ds_id, $component,
     254                        $PS_EXIT_CONFIG_ERROR);
     255
     256            $dynamicMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK');
     257        }
     258
    235259        # we use the mask output from the camera stage for input and replace
    236260        # the output of the chip stage with that mask as well.
    237261        $image  = $ipprc->filename("PPIMAGE.CHIP", $path_base, $class_id);
    238         $mask   = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
    239         $ch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
    240262        $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id);
    241263        $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path_base);
    242         if (!$ipprc->file_exists($mask)) {
    243             carp("camera mask file $mask for $component not found. Continuing using mask from chip stage.");
    244             $mask = $ch_mask;
    245             $ch_mask = undef;
    246         }
     264
     265        if ($dynamicMasks) {
     266            $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
     267            $ch_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
     268        } else {
     269            $mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
     270        }
     271
    247272        # XXX: should we censor the sources as well? For now we're leaving them out of the distribution bundles
    248273        # because they confuse people
     
    262287
    263288        if ($inv_streaks) {
    264             # create a temporary file containing the contents of the 
     289            # create a temporary file containing the contents of the
    265290            # two streaks files
    266291            ($allstreaks_fh, $allstreaks_name) = tempfile ("/tmp/all.streaks.XXXX",
     
    357382        my $quality = $file->{quality};
    358383        if (!$quality) {
    359             my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $path_base, $class_id); 
     384            my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $path_base, $class_id);
    360385            if (! $ipprc->file_exists($mask)) {
    361386                # camera mask doesn't exist for this chip. Fall back to the chip mask
     
    379404                &my_die("Unable to perform censorObjects: $error_code", $magic_ds_id, $component, $error_code);
    380405            }
    381             my $output = $ipprc->filename("CENSOR.OUTPUT", $backup_path_base); 
     406            my $output = $ipprc->filename("CENSOR.OUTPUT", $backup_path_base);
    382407            &my_die("expected output file $output not found ", $magic_ds_id, $component, $PS_EXIT_DATA_ERROR)
    383408                unless $ipprc->file_exists($output);
     
    481506    }
    482507
    483     close $fout 
     508    close $fout
    484509        or my_die("failed to close combined streaks file", $magic_ds_id,
    485510                     $component, $PS_EXIT_UNKNOWN_ERROR);
Note: See TracChangeset for help on using the changeset viewer.