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

    r27015 r27517  
    3030my $magicdstool   = can_run('magicdstool') or (warn "Can't find magicdstool" and $missing_tools = 1);
    3131my $isdestreaked = can_run('isdestreaked') or (warn "Can't find isdestreaked" 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, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base);
     39my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $bothways, $cam_path_base, $cam_reduction);
    3940my ($outroot, $recoveryroot, $replace, $release, $bytes, $md5sum);
    4041my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
     
    4849           'path_base=s'    => \$path_base,  # path_base of the input
    4950           'cam_path_base=s'=> \$cam_path_base,  # path_base of the associated camera run
     51           'cam_reduction=s'=> \$cam_reduction,  # reduction class of the associated camera run
    5052           'outroot=s'      => \$outroot,     # "directory" for temporary images (may be nebulous)
    5153           'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels
     
    7981$ipprc->redirect_output($logfile) or my_die( "Unable to redirect output", $magic_ds_id, $component, $PS_EXIT_SYS_ERROR ) if $logfile;
    8082
     83$cam_reduction = 'DEFAULT' if !defined $cam_reduction or ($cam_reduction eq "NULL");
     84my $recipe_psastro = $ipprc->reduction($cam_reduction, 'PSASTRO'); # Recipe to use
     85&my_die("Unrecognised PSASTRO recipe", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) unless defined $recipe_psastro;
     86
    8187my $nebulousServer = metadataLookupStr( $ipprc->{_siteConfig}, 'NEB_SERVER' );
    8288&my_die("cannot find NEB_SERVER in site configuration", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) if !$nebulousServer;
     
    112118}
    113119
    114 &my_die("replace not allowed for non-nebulous files", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR) 
     120&my_die("replace not allowed for non-nebulous files", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR)
    115121    if ($replace eq "T") and !$nebulousInput;
    116122
     
    156162    $bimage = $backup_path_base . ".fits";
    157163} elsif ($stage eq "chip") {
     164    # Check to see if we're using dynamic masks
     165    my $dynamicMasks;               # Use dynamic masks?
     166    {
     167        # Get the PSASTRO recipe
     168        my $command = "$ppConfigDump -camera $camera -recipe PSASTRO $recipe_psastro -dump-recipe PSASTRO -";
     169        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     170            run(command => $command, verbose => $verbose);
     171        unless ($success) {
     172            $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     173            &my_die("Unable to perform ppConfigDump: $error_code", $magic_ds_id, $component,
     174                    $PS_EXIT_CONFIG_ERROR);
     175        }
     176        my $recipeData = $mdcParser->parse(join "", @$stdout_buf) or
     177            &my_die("Unable to parse metadata config doc", $magic_ds_id, $component,
     178                    $PS_EXIT_CONFIG_ERROR);
     179
     180        $dynamicMasks = metadataLookupBool($recipeData, 'REFSTAR_MASK');
     181    }
     182
    158183    # we use the mask output from the camera stage for input and replace
    159184    # the output of the chip stage with that mask as well.
    160185    $image  = $ipprc->filename("PPIMAGE.CHIP", $path_base, $class_id);
    161     $mask   = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
    162     $ch_mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
    163186    $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id);
     187
     188    if ($dynamicMasks) {
     189        $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $cam_path_base, $class_id);
     190        $ch_mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
     191    } else {
     192        $mask = $ipprc->filename("PPIMAGE.CHIP.MASK", $path_base, $class_id);
     193    }
    164194
    165195    $bimage  = $ipprc->filename("PPIMAGE.CHIP", $backup_path_base, $class_id);
     
    253283    if ($mask) {
    254284        if (!revert_file($mask, $bmask)) {
    255             if ($stage eq 'chip') {
    256                 # don't fail if the mask file (from the camera stage) fails to revert.
    257                 # It probably doesn't exist
    258                 # XXX: Handle this properly
    259                 print STDERR "failure to revert mask file, ignored\n";
    260             } else {
    261                 &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    262             }
     285            &my_die("failed to restore mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    263286        }
    264287    }
     
    268291            &my_die("failed to restore chip mask file", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    269292        }
    270     } 
     293    }
    271294
    272295
     
    306329    my $original = shift;
    307330    my $backup   = shift;
     331    my $force = 1; # force deletion of backup files in nebulous
    308332
    309333    my $o_path = $ipprc->file_resolve($original);
     
    352376        }
    353377
    354         if ($b_path and -e $b_path) {
     378        if ($b_path) {
    355379            print "ready to delete backup\n" if $verbose;
    356             if (! $ipprc->file_delete($backup)) {
     380            if (! $ipprc->file_delete($backup, $force)) {
    357381                print "failed to delete $backup\n";
    358382                return 0;
     
    363387        print "original uri: $original is not a destreaked file no need to swap backup_result: $backup_result\n";
    364388        # delete the 'backup' (destreaked target) file if it exists
    365         if ($b_path and -e $b_path) {
    366             if (! $ipprc->file_delete($backup)) {
     389        if ($b_path) {
     390            if (! $ipprc->file_delete($backup, $force)) {
    367391                print "failed to delete $backup\n";
    368392                return 0;
Note: See TracChangeset for help on using the changeset viewer.