Changeset 12863
- Timestamp:
- Apr 17, 2007, 1:55:48 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/warp_overlap.pl (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/warp_overlap.pl
r12800 r12863 26 26 $PS_EXIT_DATA_ERROR 27 27 $PS_EXIT_TIMEOUT_ERROR 28 _mdLookupStr 28 29 ); 29 30 my $ipprc = PS::IPP::Config->new(); # IPP configuration … … 49 50 ) unless defined $warp_id 50 51 and defined $camera; 52 53 $ipprc->define_camera($camera); 51 54 52 55 # Look for programs we need … … 88 91 } 89 92 93 # determine the imfile/skycell overlaps 94 my @overlaps = (); 95 90 96 unless ($no_op) { 91 97 ## Calculate the overlaps between imfiles and skycells 92 98 93 # XXX where does the catdir come from (recipe file for pswarp?)94 99 # the tess_id is the catdir used to define the tessalation 95 $tess_id = $catdir; 100 my $command = "ppConfigDump -camera $camera -dump-recipe PSWARP -"; 101 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 102 run(command => $command, verbose => 1); 103 unless ($success) { 104 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 105 &my_die("Unable to perform ppConfigDump: $error_code", $error_code); 106 } 107 my $parser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 108 my $recipe = $parser->parse( join '', @$stdout_buf); 109 my $tess_id = _mdLookupStr($recipe, 'DVO.TESSALATION'); 110 print STDERR "tessalation: $tess_id\n"; 111 96 112 # we have two options for the astrometry file: 97 113 # - saved by chiptool, in which case there may be a different one for each imfile 98 114 # - saved by camtool, in which case there may only be a single astrom file 99 115 my $psastroFile; 116 117 # XXX select this value from the recipe files (psastro? maybe not...?) 100 118 my $camAstrom = 1; 101 119 if ($camAstrom) { … … 103 121 my $camRoot = $ipprc->convert_filename_absolute( $imfile->{cam_path_base} ); 104 122 $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $camRoot); # MEF psastro output 123 124 my @dirlist = File::Spec->splitdir( $psastroFile ); 125 my $psastroRootFile = pop @dirlist; 126 print STDERR "psastroRootFile: $psastroRootFile\n"; 105 127 106 128 # run the dvoImageOverlaps program to get the overlaps with this image … … 112 134 &my_die("Unable to perform dvoImageOverlaps: $error_code", $warp_id, $error_code); 113 135 } 114 my @matchlist = split ('\n', $stdout_buf); 136 my @matchlist = split ('\n', (join "", @$stdout_buf)); 137 138 #my $Nmatch = @matchlist; 139 #print STDERR "Nmatch: $Nmatch\n"; 140 #foreach my $line (@matchlist) { 141 # print STDERR "line: $line\n"; 142 #} 115 143 116 144 # dvoImageOverlaps -D CATDIR tessalation (megacam) :: returns: … … 120 148 121 149 # now match the imfiles to this list 122 my @overlaps = (); 123 foreach $imfile (@$imfiles) { 124 my $class_id = $imfile->{class_id}; 125 my $chipRoot = $ipprc->convert_filename_absolute( $imfile->{chip_path_base} ); 126 my $extname = $ipprc->extname_rule("CMF.HEAD", $class_id); # MEF psastro output 127 128 my $entry = "$psastroFile\[$extname\]"; 150 my @unique_skycells = (); 151 my %found_skycells = (); 152 foreach my $imfile (@$imfiles) { 153 my $fileLevel = $imfile->{filelevel}; 154 my $entry = ""; 155 if ($fileLevel eq "chip") { 156 my $class_id = $imfile->{class_id}; 157 my $chipRoot = $ipprc->convert_filename_absolute( $imfile->{chip_path_base} ); 158 my $extname = $ipprc->extname_rule("CMF.HEAD", $class_id); # MEF psastro output 159 160 print STDERR "class: $class_id, chiproot: $chipRoot, extname: $extname\n"; 161 162 $entry = "$psastroRootFile\[$extname\]"; 163 } else { 164 $entry = "$psastroRootFile"; 165 } 129 166 my @skycells = &select_skycells ($entry, @matchlist); 130 foreach $skycell (@skycells) {167 foreach my $skycell (@skycells) { 131 168 my %overlap = (); 132 169 $overlap{skycell_id} = $skycell; 133 $overlap{tess_id} = $ catdir;170 $overlap{tess_id} = $tess_id; 134 171 $overlap{cam_id} = $imfile->{cam_id}; 135 172 $overlap{class_id} = $imfile->{class_id}; 136 173 $overlap{fault} = $imfile->{fault}; 137 push @overlaps \$overlap; 174 push @overlaps, \%overlap; 175 176 printf STDERR "overlap: %s : %s\n", $skycell, $imfile->{cam_id}; 177 178 # generate a unique list of the skycells 179 unless ($found_skycells{$skycell}) { 180 push @unique_skycells, $skycell; 181 $found_skycells{$skycell} = 1; 182 } 138 183 } 139 184 } 185 186 # extract the skycells to names of the form $camRoot.skycell... 187 # with calls to dvoImageExtract 188 my $skycellDir = "$camRoot/skycells"; 189 system "mkdir -p $skycellDir" unless -d $skycellDir; 190 191 foreach my $skycell (@unique_skycells) { 192 vsystem ("dvoImageExtract -D CATDIR $tess_id $skycell -o $skycellDir/$skycell"); 193 } 194 140 195 } else { 141 my @overlaps = (); 142 foreach $imfile (@$imfiles) { 196 foreach my $imfile (@$imfiles) { 143 197 my $class_id = $imfile->{class_id}; 144 198 my $chipRoot = $ipprc->convert_filename_absolute( $imfile->{chip_path_base} ); … … 163 217 my @skycells = &select_skycells ($psastroFile, @matchlist); 164 218 # XXX should I check and warn if int(@skycells) != int(@matchlist) ? 165 foreach $skycell (@skycells) {219 foreach my $skycell (@skycells) { 166 220 my %overlap = (); 167 221 $overlap{skycell_id} = $skycell; 168 $overlap{tess_id} = $ catdir;222 $overlap{tess_id} = $tess_id; 169 223 $overlap{cam_id} = $imfile->{cam_id}; 170 224 $overlap{class_id} = $imfile->{class_id}; 171 225 $overlap{fault} = $imfile->{fault}; 172 push @overlaps \$overlap; 226 push @overlaps, \%overlap; 227 228 print STDERR "overlap: $skycell -> $imfile->{cam_id}\n"; 173 229 } 174 230 } … … 176 232 } else { 177 233 # create an overlap with an entry for each skycell:imfile match 178 my @overlaps = ();179 234 foreach my $imfile (@$imfiles) { 180 235 my %overlap = (); … … 184 239 $overlap{class_id} = $imfile->{class_id}; 185 240 $overlap{fault} = $imfile->{fault}; 186 push @overlaps \$overlap;241 push @overlaps, \%overlap; 187 242 } 188 243 } … … 247 302 my @list = @_; 248 303 304 my $skycell; 249 305 my @skycells = (); 250 306 251 307 foreach my $line (@list) { 252 308 if ($line =~ m|$entry|) { 253 ($skycell) = $line =~ m|$entry\ s+:\s+(\S+)|;309 ($skycell) = $line =~ m|$entry\S*\s+:\s+(\S+)|; 254 310 push @skycells, $skycell; 255 311 } 256 312 } 257 return @skycells; 313 @skycells; 314 } 315 316 sub vsystem { 317 print STDERR "@_\n"; 318 my $status = system ("@_"); 319 $status; 258 320 } 259 321
Note:
See TracChangeset
for help on using the changeset viewer.
