Changeset 13275 for trunk/ippScripts/scripts/warp_overlap.pl
- Timestamp:
- May 4, 2007, 4:52:03 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/warp_overlap.pl (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/warp_overlap.pl
r13176 r13275 17 17 use PS::IPP::Metadata::Stats; 18 18 use 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 ); 19 use File::Temp qw( tempfile ); 20 21 use 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 ); 30 31 my $ipprc = PS::IPP::Config->new(); # IPP configuration 31 32 use File::Spec; … … 82 83 } 83 84 84 # Make sure everything is from the same exposure, and get the exposure tag85 my $exp_tag; # Exposure tag86 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 directory95 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 105 85 # Determine the imfile/skycell overlaps 106 86 my @overlaps = (); … … 111 91 my $tessellations = $ipprc->tessellations(); # Hash of defined tessellations 112 92 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 113 99 my $tess_dir = $ipprc->convert_filename_absolute( $$tessellations{$tess_id} ); # Catdir for DVO 114 100 print STDERR "tessellation: $tess_id, $tess_dir\n"; 115 101 116 102 my $imfile = $imfiles->[0]; 117 my $camRoot = $i pprc->convert_filename_absolute( $imfile->{cam_path_base} );103 my $camRoot = $imfile->{cam_path_base}; 118 104 my $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $camRoot); # MEF psastro output 119 105 … … 123 109 124 110 # 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); 126 112 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 127 113 run(command => $command, verbose => 1); … … 145 131 if ($fileLevel eq "chip") { 146 132 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} ); 148 134 my $extname = $ipprc->extname_rule("CMF.HEAD", $class_id); # MEF psastro output 149 135 … … 176 162 # Extract the skycells to images, used as warp templates. 177 163 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 } 187 175 } 188 176 } … … 202 190 203 191 # 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"; 192 my ($overlapFile, $overlapName) = tempfile( 'overlaps.wrp' . $warp_id . '.mdc.XXXX', UNLINK => 1 ); 206 193 print $overlapFile "warpSkyCellMap MULTI\n\n"; 207 194 foreach my $overlap (@overlaps) { … … 229 216 exit($error_code); 230 217 } 231 232 unlink $overlapName;233 218 } 234 219
Note:
See TracChangeset
for help on using the changeset viewer.
