IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 4, 2007, 4:52:03 PM (19 years ago)
Author:
Paul Price
Message:

Major upgrade to allow use of Nebulous

File:
1 edited

Legend:

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

    r13112 r13275  
    1818use PS::IPP::Metadata::List qw( parse_md_list );
    1919
    20 use PS::IPP::Config qw(
    21     $PS_EXIT_SUCCESS
    22     $PS_EXIT_UNKNOWN_ERROR
    23     $PS_EXIT_SYS_ERROR
    24     $PS_EXIT_CONFIG_ERROR
    25     $PS_EXIT_PROG_ERROR
    26     $PS_EXIT_DATA_ERROR
    27     $PS_EXIT_TIMEOUT_ERROR
    28     );
     20use PS::IPP::Config qw($PS_EXIT_SUCCESS
     21                       $PS_EXIT_UNKNOWN_ERROR
     22                       $PS_EXIT_SYS_ERROR
     23                       $PS_EXIT_CONFIG_ERROR
     24                       $PS_EXIT_PROG_ERROR
     25                       $PS_EXIT_DATA_ERROR
     26                       $PS_EXIT_TIMEOUT_ERROR
     27                       caturi
     28                       );
    2929my $ipprc = PS::IPP::Config->new(); # IPP configuration
    3030use File::Spec;
     31use File::Temp qw( tempfile );
    3132
    3233use Getopt::Long qw( GetOptions :config auto_help auto_version gnu_getopt );
     
    8485}
    8586
    86 # Set output directory
    87 if (defined $workdir) {
    88     $workdir = $ipprc->convert_filename_absolute( $workdir );
    89     $workdir = File::Spec->catdir( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
    90 } else {
    91     my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} );
    92     my ($vol, $dir, $file) = File::Spec->splitpath( $example );
    93     $workdir = $dir;
    94 }
    95 system "mkdir -p $workdir" unless -d $workdir;
    96 
    97 my $outputFile = "$tess_id.$skycell_id.wrp$warp_id"; # Root name
    98 my $outputRoot = File::Spec->catfile( $workdir, $outputFile );
     87$workdir = caturi( $workdir, "tess_" . $tess_id, "sky_" . $skycell_id ) if defined $workdir;
     88my $outputRoot = $ipprc->file_prepare( "$tess_id.$skycell_id.wrp$warp_id", $workdir, $$imfiles[0]->{uri} );
    9989my $outputImage = $ipprc->filename("PSWARP.OUTPUT", $outputRoot, $skycell_id );
    10090my $outputBin1 = $ipprc->filename("PSWARP.BIN1", $outputRoot, $skycell_id );
    10191my $outputBin2 = $ipprc->filename("PSWARP.BIN2", $outputRoot, $skycell_id );
    10292my $outputStats = $outputRoot . '.stats';
    103 my $skyFile = File::Spec->catfile( $workdir, $skycell_id ); # Target sky cell file
    104 my $listName = $outputRoot . '.list';
     93my $skyFile = caturi( $workdir, $skycell_id ); # Target sky cell file
    10594
    10695# Get list of filenames
    107 open my $listFile, "> $listName" or &my_die("Unable to open $listName", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR);
     96my ($listFile, $listName) = tempfile( "$tess_id.$skycell_id.wrp$warp_id.list.XXXX", UNLINK => 1);
    10897foreach my $imfile (@$imfiles) {
    109     my $uri = $ipprc->convert_filename_absolute( $imfile->{uri} );
    110 
    111     print $listFile "$uri\n";
     98    print $listFile ( $imfile->{uri} . "\n");
    11299}
    113100close $listFile;
     
    123110        &my_die("Unable to perform pswarp: $error_code", $warp_id, $skycell_id, $error_code);
    124111    }
    125     &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputImage;
    126     &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputStats;
    127 #    &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin1;
    128 #    &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $outputBin2;
     112    &my_die("Couldn't find expected output file: $outputImage", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputImage);
     113    &my_die("Couldn't find expected output file: $outputStats", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputStats);
     114#    &my_die("Couldn't find expected output file: $outputBin1", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin1);
     115#    &my_die("Couldn't find expected output file: $outputBin2", $warp_id, $skycell_id, $tess_id, $PS_EXIT_SYS_ERROR) unless -f $ipprc->file_resolve($outputBin2);
    129116
    130117    # Get the statistics on the warped image
    131118    my $statsFile;              # File handle
    132     open $statsFile, "$outputStats" or die "Can't open statistics file $outputStats: $!\n";
     119    open $statsFile, $ipprc->file_resolve($outputStats) or die "Can't open statistics file $outputStats: $!\n";
    133120    my @contents = <$statsFile>; # Contents of file
    134121    close $statsFile;
     
    138125}
    139126
    140 # Take off the absolute path, to stuff into the database
    141 $outputImage = $ipprc->convert_filename_relative( $outputImage );
    142 $outputRoot = $ipprc->convert_filename_relative( $outputRoot );
    143 
     127# Add the processed file to the database
    144128my $bg = ($stats->bg_mean() or 'NAN');
    145129my $bg_stdev = ($stats->bg_stdev() or 'NAN');
    146 
    147 # Add the processed file to the database
    148130unless ($no_update) {
    149131    my $command = "$warptool -addwarped -warp_id $warp_id -skycell_id $skycell_id -tess_id $tess_id" .
     
    159141        exit($error_code);
    160142    }
    161 
    162     unlink $outputStats;
    163143}
    164144
Note: See TracChangeset for help on using the changeset viewer.