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

    r13176 r13275  
    1717use PS::IPP::Metadata::Stats;
    1818use PS::IPP::Metadata::List qw( parse_md_list );
    19 
    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     metadataLookupStr
    29     );
     19use File::Temp qw( tempfile );
     20
     21use PS::IPP::Config qw($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                       metadataLookupStr
     29                       caturi
     30                       );
    3031my $ipprc = PS::IPP::Config->new(); # IPP configuration
    3132use File::Spec;
     
    8283}
    8384
    84 # Make sure everything is from the same exposure, and get the exposure tag
    85 my $exp_tag;                    # Exposure tag
    86 foreach my $imfile ( @$imfiles ) {
    87     unless (defined $exp_tag) {
    88         $exp_tag = $imfile->{exp_tag};
    89     } elsif ($exp_tag ne $imfile->{exp_tag}) {
    90         &my_die("Multiple exposures in the same warp.", $warp_id, $PS_EXIT_SYS_ERROR);
    91     }
    92 }
    93 
    94 # Set output directory
    95 if (defined $workdir) {
    96     $workdir = $ipprc->convert_filename_absolute( $workdir );
    97 } else {
    98     my $example = $ipprc->convert_filename_absolute( $$imfiles[0]->{uri} );
    99     my ($vol, $dir, $file) = File::Spec->splitpath( $example );
    100     $workdir = $dir;
    101 }
    102 system "mkdir -p $workdir" unless -d $workdir;
    103 
    104 
    10585# Determine the imfile/skycell overlaps
    10686my @overlaps = ();
     
    11191    my $tessellations = $ipprc->tessellations(); # Hash of defined tessellations
    11292    foreach my $tess_id ( keys %$tessellations ) {
     93        ### Because DVO doesn't use psModules, it doesn't understand Nebulous --- check
     94        my $uri = URI->new( $$tessellations{$tess_id} );
     95        if (defined $uri->scheme() and $uri->scheme() eq 'neb') {
     96            &my_die("Tessellation $tess_id refers to a Nebulous path: $$tessellations{$tess_id}", $warp_id, $PS_EXIT_CONFIG_ERROR);
     97        }                   
     98       
    11399        my $tess_dir = $ipprc->convert_filename_absolute( $$tessellations{$tess_id} ); # Catdir for DVO
    114100        print STDERR "tessellation: $tess_id, $tess_dir\n";
    115101
    116102        my $imfile = $imfiles->[0];
    117         my $camRoot = $ipprc->convert_filename_absolute( $imfile->{cam_path_base} );
     103        my $camRoot = $imfile->{cam_path_base};
    118104        my $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $camRoot); # MEF psastro output
    119105       
     
    123109       
    124110        # run the dvoImageOverlaps program to get the overlaps with this image
    125         my $command = "$dvoImageOverlaps -D CATDIR $tess_dir $psastroFile";
     111        my $command = "$dvoImageOverlaps -D CATDIR $tess_dir " . $ipprc->file_resolve($psastroFile);
    126112        my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    127113            run(command => $command, verbose => 1);
     
    145131            if ($fileLevel eq "chip") {
    146132                my $class_id = $imfile->{class_id};
    147                 my $chipRoot = $ipprc->convert_filename_absolute( $imfile->{chip_path_base} );
     133                my $chipRoot = $ipprc->file_resolve( $imfile->{chip_path_base} );
    148134                my $extname = $ipprc->extname_rule("CMF.HEAD", $class_id); # MEF psastro output
    149135               
     
    176162        # Extract the skycells to images, used as warp templates.
    177163        foreach my $skycell_id (@unique_skycells) {
    178             my $skyDir = File::Spec->catdir($workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
    179             system "mkdir -p $skyDir" unless -d $skyDir;
    180             my $skyFile = File::Spec->catfile( $skyDir , $skycell_id );
    181             my $command = "$dvoImageExtract -D CATDIR $tess_dir $skycell_id -o $skyFile";
    182             my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
    183                 run(command => $command, verbose => 1);
    184             unless ($success) {
    185                 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
    186                 &my_die("Unable to perform dvoImageExtract: $error_code", $warp_id, $error_code);
     164            my $skyDir = caturi($workdir, "tess_" . $tess_id, "sky_" . $skycell_id );
     165            my $skyFile = $ipprc->file_prepare( $skycell_id, $skyDir );
     166            unless ($ipprc->file_exists( $skyFile )) {
     167                my $skyFileResolved = $ipprc->file_create( $skyFile ); # Resolved filename, for Nebulous
     168                my $command = "$dvoImageExtract -D CATDIR $tess_dir $skycell_id -o $skyFileResolved";
     169                my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) =
     170                    run(command => $command, verbose => 1);
     171                unless ($success) {
     172                    $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR);
     173                    &my_die("Unable to perform dvoImageExtract: $error_code", $warp_id, $error_code);
     174                }
    187175            }
    188176        }
     
    202190
    203191# Generate a MDC file with the overlaps
    204 my $overlapName = File::Spec->catfile( $workdir, 'overlaps.wrp' . $warp_id . '.mdc' );
    205 open my $overlapFile, "> $overlapName" or die "Unable to open mdc file $overlapName";
     192my ($overlapFile, $overlapName) = tempfile( 'overlaps.wrp' . $warp_id . '.mdc.XXXX', UNLINK => 1 );
    206193print $overlapFile "warpSkyCellMap MULTI\n\n";
    207194foreach my $overlap (@overlaps) {
     
    229216        exit($error_code);
    230217    }
    231 
    232     unlink $overlapName;
    233218}
    234219
Note: See TracChangeset for help on using the changeset viewer.