IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 8, 2009, 6:19:50 PM (17 years ago)
Author:
bills
Message:

updates to magic destreak processing

File:
1 edited

Legend:

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

    r24702 r24726  
    2121
    2222use PS::IPP::Config 1.01 qw( :standard );
     23use Nebulous::Client;
    2324
    2425use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    3031my $streaksremove = can_run('streaksremove') or (warn "Can't find streaksremove" and $missing_tools = 1);
    3132my $camtool = can_run('camtool') or (warn "Can't find camtool" and $missing_tools = 1);
    32 # XXX: replace with real name for tool
    33 my $censordetections = "";
    34 # my $censordetections = can_run('censordetections') or (warn "Can't find censordetections" and $missing_tools = 1);
     33my $censorObjects = can_run('censorObjects') or (warn "Can't find censorObjects" and $missing_tools = 1);
    3534if ($missing_tools) {
    3635    warn("Can't find required tools.");
     
    5453           'path_base=s'    => \$path_base,  # path_base of the input
    5554           'inverse'        => \$inverse,    # Inverse subtraction?
    56            'cam_path_base=s'=> \$cam_path_base,  # path_base of the associated camera run
     55           'cam_path_base=s'=> \$cam_path_base,  # path_base from camera stage (for chip and raw)
    5756           'outroot=s'      => \$outroot,     # "directory" for temporary images (may be nebulous)
    5857           'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels
     
    102101my $basename = basename($path_base);
    103102my $nebulousInput = inNebulous($dirname);
     103my $nebulousOutput = inNebulous($outroot);
    104104
    105105# parse replace arguments check for errors and set up
    106106# the appropriate paths
     107my $nebulous;
    107108if (defined($replace) and ($replace eq "T")) {
     109    # for camera stage we need a handle to the nebulous server
     110    if ($stage eq 'camera') {
     111        my $nebulousServer = metadataLookupStr( $ipprc->{_siteConfig}, 'NEB_SERVER' );
     112        &my_die("cannot find NEB_SERVER in site configuration",
     113                                        $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR)
     114            if !$ nebulousServer;
     115
     116        $nebulous = eval { Nebulous::Client->new( proxy => $nebulousServer ); };
     117        if ($@ or not defined $nebulous) {
     118            &my_die ("Unable to create a Nebulous::Client object with proxy $nebulousServer",
     119                                    $magic_ds_id, $component , $PS_EXIT_UNKNOWN_ERROR);
     120        }
     121    }
    108122    $replace = 1;
    109123} else {
     
    111125}
    112126
     127
    113128# default value is "NULL" do not use
    114129if (defined($recoveryroot) and ($recoveryroot eq "NULL")) {
     
    122137
    123138# create the output directories if it is not a nebulous path and it doesn't exist
    124 if (!inNebulous($outroot)) {
     139if (! $nebulousOutput) {
    125140    if (! -e $outroot ) {
    126141        my $code = system "mkdir -p $outroot";
     
    128143                $code >> 8) if $code;
    129144    }
    130 #} elsif ($replace) {
    131     # if input is in nebulous and we've been asked to replace the input with the destreaked
    132     # version the output must be in nebulous as well
    133     # XXX Is this necessary? if ($replace) the outputs are going to the nebulous "directory" of the
    134     # input anyways. Why require that other files (log) be in nebulous
    135145}
    136146
     
    208218        $weight = $ipprc->filename("PPIMAGE.CHIP.VARIANCE", $path_base, $class_id);
    209219        $astrom = $ipprc->filename("PSASTRO.OUTPUT", $cam_path_base);
     220        if (!$ipprc->file_exists($mask)) {
     221            carp("camera mask file $mask for $component not found. Continuing using mask from chip stage.");
     222            $mask = $ch_mask;
     223            $ch_mask = undef;
     224        }
     225        # XXX: should we censor the sources as well? For now we're leaving them out of the distribution bundles
     226        # because they confuse people
     227        # XXX: make sure that this is the right file rule
     228        # $sources = $ipprc->filename("PSPHOT.OUT.CMF.SPL",  $path_base);
     229
    210230    } elsif ($stage eq "warp") {
    211231        $image  = $ipprc->filename("PSWARP.OUTPUT", $path_base);
     
    247267    }
    248268} else {
     269    # camera stage. The only work to do is to censor the detections file
     270
    249271    my $tempOutRoot = "/tmp/destreak";
    250272    my ($maskListFile,   $maskListName)   = tempfile( "$tempOutRoot.mask.list.XXXX",   UNLINK => !$save_temps);
     
    272294        if (!$quality) {
    273295            my $mask = $ipprc->filename("PSASTRO.OUTPUT.MASK", $path_base, $class_id);
     296            if (! $ipprc->file_exists($mask)) {
     297                # camera mask doesn't exist for this chip. Fall back to the chip mask
     298                $mask= $ipprc->filename("PPIMAGE.CHIP.MASK", $file->{path_base}, $class_id);
     299            }
    274300            print $maskListFile "$mask\n";
    275301        }
     
    279305    my $astrom = $ipprc->filename("PSASTRO.OUTPUT", $path_base);
    280306    {
    281         my $output = $tmproot . basename($astrom);
    282         my $command = "$censordetections -stage $stage -output $output";
    283         $command .= " -astrom $astrom";
    284         $command .= " -masklist $maskListName";
    285         $command .= " -replace" if $replace;
     307        my $command = "$censorObjects -file $astrom -masklist $maskListName $backup_path_base";
     308        # $command .= " -replace" if $replace;
    286309        $command .= " -dbname $dbname" if defined $dbname;
    287310        unless (defined $no_op) {
     
    290313            unless ($success) {
    291314                $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    292                 &my_die("Unable to perform streaksremove: $error_code", $magic_ds_id, $component, $error_code);
     315                &my_die("Unable to perform censorObjects: $error_code", $magic_ds_id, $component, $error_code);
     316            }
     317            my $output = $ipprc->filename("CENSOR.OUTPUT", $backup_path_base);
     318            &my_die("expected output file $output not found ", $magic_ds_id, $component, $PS_EXIT_DATA_ERROR)
     319                unless $ipprc->file_exists($output);
     320
     321            if ($replace) {
     322                $nebulous->swap($astrom, $output) or
     323                    &my_die("nebulous swap failed $astrom $output", $magic_ds_id, $component, $PS_EXIT_UNKNOWN_ERROR);
    293324            }
    294325        } else {
Note: See TracChangeset for help on using the changeset viewer.