IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 25, 2009, 1:50:29 PM (17 years ago)
Author:
bills
Message:

put streak removed files in the same 'directory' as the inputs for compatability with
nebulous;

File:
1 edited

Legend:

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

    r24378 r24553  
    1616use IPC::Cmd 0.36 qw( can_run run );
    1717use File::Temp qw( tempfile );
    18 use File::Basename qw( basename );
     18use File::Basename qw( basename dirname );
    1919use PS::IPP::Metadata::Config;
    2020use PS::IPP::Metadata::List qw( parse_md_list );
     
    3737my ($magic_ds_id, $camera, $streaks, $stage, $stage_id, $component, $uri, $path_base, $inverse, $cam_path_base);
    3838my ($outroot, $recoveryroot);
    39 my ($replace, $remove, $release);
     39my ($replace, $release);
    4040my ($dbname, $save_temps, $verbose, $no_update, $no_op, $logfile);
    4141
     
    5454           'recoveryroot=s' => \$recoveryroot,# "directory" for saving the images of excised pixels
    5555           'replace=s'      => \$replace,    # replace the input images with the results.
    56            'remove=s'       => \$remove,     # remove the original images when done YIKES!
    5756           'release'        => \$release,    # NAN masked pixels for release
    5857           'save-temps'     => \$save_temps, # Save temporary files?
     
    9695my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files
    9796
     97my $dirname = dirname($path_base);
    9898my $basename = basename($path_base);
    99 
    100 #
    101 # parse the replace and remove arguments check for errors and set up
     99my $nebulousInput = inNebulous($dirname);
     100
     101# parse replace arguments check for errors and set up
    102102# the appropriate paths
    103103if (defined($replace) and ($replace eq "T")) {
     
    117117}
    118118
    119 if (defined($remove) and ($remove eq "T")) {
    120     $remove = 1;
    121 } else {
    122     $remove = 0;
    123 }
    124 
    125 if ($remove and !$replace) {
    126     &my_die("cannot remove without replace", $magic_ds_id, $component, $PS_EXIT_CONFIG_ERROR);
    127 }
    128 
    129119# create the output directories if it is not a nebulous path and it doesn't exist
    130 if (index($outroot, "neb://") != 0) {
     120if (!inNebulous($outroot)) {
    131121    if (! -e $outroot ) {
    132122        my $code = system "mkdir -p $outroot";
     
    134124                $code >> 8) if $code;
    135125    }
     126#} elsif ($replace) {
     127    # if input is in nebulous and we've been asked to replace the input with the destreaked
     128    # version the output must be in nebulous as well
     129    # XXX Is this necessary? if ($replace) the outputs are going to the nebulous "directory" of the
     130    # input anyways. Why require that other files (log) be in nebulous
    136131}
    137132
    138133my $backup_path_base;
    139 if (! $remove) {
    140     $backup_path_base = "$outroot/$basename";
     134my $tmproot;
     135if ($replace) {
     136    # in replace mode, we place the output files in the same "directory" as the inputs
     137    # Nebulous requires this for the two inputs to nebSwap which we use
     138    # We prepend the path with SR_ This causes the filenames for instances of the swapped files to
     139    # have SR in them.
     140    $tmproot = $dirname . "/SR_";
     141    $backup_path_base = $tmproot . "$basename";
     142} else {
     143    # note: trailing / is necessary
     144    $tmproot = "$outroot/";
     145    $backup_path_base = $tmproot . $basename;
    141146}
    142147
    143148my $recovery_path_base;
    144149if ($recoveryroot) {
    145     if (index($recoveryroot, "neb://") != 0) {
     150    if (!inNebulous($recoveryroot)) {
    146151        if (! -e $recoveryroot ) {
    147152            my $code = system "mkdir -p $recoveryroot";
     
    150155        }
    151156    }
    152     $recovery_path_base = "$recoveryroot/$basename";
     157    # note: trailing / is necessary
     158    $recovery_path_base = "$recoveryroot/$basename/";
    153159}
    154160
     
    209215
    210216{
    211     my $command = "$streaksremove -stage $stage -tmproot $outroot -streaks $streaks -image $image";
     217    my $command = "$streaksremove -stage $stage -tmproot $tmproot -streaks $streaks -image $image";
    212218
    213219    $command .= " -class_id $class_id" if defined $class_id;
     
    219225    $command .= " -skycelllist $skycell_list" if defined $skycell_list;
    220226    $command .= " -replace" if $replace;
    221     $command .= " -remove" if $remove;
    222227    $command .= " -release" if $release;
    223228    $command .= " -dbname $dbname" if defined $dbname;
     
    272277}
    273278
     279sub inNebulous
     280{
     281    my $path = shift;
     282
     283    my $scheme = file_scheme($path);
     284
     285    return $scheme and ($scheme eq "neb");
     286}
     287
     288
    274289sub my_die
    275290{
Note: See TracChangeset for help on using the changeset viewer.