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

    r26554 r27517  
    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
     
    8587$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile;
    8688
     89$cam_reduction = 'DEFAULT' if !$cam_reduction or ($cam_reduction eq 'NULL');
     90
     91my $recipe_psastro = $ipprc->reduction($cam_reduction, 'PSASTRO'); # Recipe to use
     92&my_die("Unrecognised PSASTRO recipe", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro;
     93
    8794my ($skycell_args, $class_id, $skycell_id);
    8895
     
    97104} elsif ($stage ne "camera") {
    98105    &my_die("Invalid value for stage: $stage", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    99 }   
     106}
    100107$inv_streaks = undef if defined($inv_streaks) and ($inv_streaks eq "NULL");
    101108
     
    114121    if ($stage eq 'camera') {
    115122        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) 
     123        &my_die("cannot find NEB_SERVER in site configuration",
     124                                        $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR)
    118125            if !$ nebulousServer;
    119126
     
    233240        $mask   = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id) if $release ;
    234241    } elsif ($stage eq "chip") {
     242
     243        # Check to see if we're using dynamic masks
     244        my $dynamicMasks;               # Use dynamic masks?
     245        {
     246            # Get the PSASTRO recipe
     247            my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -";
     248            my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     249                run(command => $command, verbose => $verbose);
     250            unless ($success) {
     251                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     252                &my_die("Unable to perform ppConfigDump: $error_code", $magic_ds_id, $component,
     253                        $PS_EXIT_CONFIG_ERROR);
     254            }
     255            my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
     256                &my_die("Unable to parse metadata config doc", $magic_ds_id, $component,
     257                        $PS_EXIT_CONFIG_ERROR);
     258
     259            $dynamicMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK');
     260        }
     261
    235262        # we use the mask output from the camera stage for input and replace
    236263        # the output of the chip stage with that mask as well.
    237264        $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);
    240265        $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id);
    241266        $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         }
     267
     268        if ($dynamicMasks) {
     269            $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
     270            $ch_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
     271        } else {
     272            $mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
     273        }
     274
    247275        # XXX: should we censor the sources as well? For now we're leaving them out of the distribution bundles
    248276        # because they confuse people
     
    262290
    263291        if ($inv_streaks) {
    264             # create a temporary file containing the contents of the 
     292            # create a temporary file containing the contents of the
    265293            # two streaks files
    266294            ($allstreaks_fh, $allstreaks_name) = tempfile ("/tmp/all.streaks.XXXX",
     
    357385        my $quality = $file->{quality};
    358386        if (!$quality) {
    359             my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $path_base, $class_id); 
     387            my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $path_base, $class_id);
    360388            if (! $ipprc->file_exists($mask)) {
    361389                # camera mask doesn't exist for this chip. Fall back to the chip mask
     
    379407                &my_die("Unable to perform censorObjects: $error_code", $magic_ds_id, $component, $error_code);
    380408            }
    381             my $output = $ipprc->filename("CENSOR.OUTPUT", $backup_path_base); 
     409            my $output = $ipprc->filename("CENSOR.OUTPUT", $backup_path_base);
    382410            &my_die("expected output file $output not found ", $magic_ds_id, $component, $PS_EXIT_DATA_ERROR)
    383411                unless $ipprc->file_exists($output);
     
    481509    }
    482510
    483     close $fout 
     511    close $fout
    484512        or my_die("failed to close combined streaks file", $magic_ds_id,
    485513                     $component, $PS_EXIT_UNKNOWN_ERROR);
Note: See TracChangeset for help on using the changeset viewer.