Changeset 12798
- Timestamp:
- Apr 10, 2007, 3:55:05 PM (19 years ago)
- File:
-
- 1 edited
-
trunk/ippScripts/scripts/warp_overlap.pl (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ippScripts/scripts/warp_overlap.pl
r12780 r12798 89 89 90 90 unless ($no_op) { 91 ## dvoImageOverlaps -D CATDIR tessalation (astrom.cmf) 92 # dvoImageOverlaps uses the astrometry output file, 93 ## Calculates the overlaps between imfiles and skycells 91 ## Calculate the overlaps between imfiles and skycells 92 93 # XXX where does the catdir come from (recipe file for pswarp?) 94 # the tess_id is the catdir used to define the tessalation 95 $tess_id = $catdir; 96 # we have two options for the astrometry file: 97 # - saved by chiptool, in which case there may be a different one for each imfile 98 # - saved by camtool, in which case there may only be a single astrom file 99 my $psastroFile; 100 my $camAstrom = 1; 101 if ($camAstrom) { 102 my $imfile = $imfiles->[0]; 103 my $camRoot = $ipprc->convert_filename_absolute( $imfile->{cam_path_base} ); 104 $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $camRoot); # MEF psastro output 105 106 # run the dvoImageOverlaps program to get the overlaps with this image 107 my $command = "dvoImageOverlaps -D CATDIR $tess_id $psastroFile"; 108 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 109 run(command => $command, verbose => 1); 110 unless ($success) { 111 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 112 &my_die("Unable to perform dvoImageOverlaps: $error_code", $warp_id, $error_code); 113 } 114 my @matchlist = split ('\n', $stdout_buf); 115 116 # dvoImageOverlaps -D CATDIR tessalation (megacam) :: returns: 117 # 729534pa.cmf[ccd00.hdr] : skycell.051.fits 118 # PSASTRO.OUTPUT[CMF.HEAD] : SKYCELL 119 # [CMF.HEAD] is optionally used for MEF files (SIMPLE or MOSAIC) 120 121 # 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\]"; 129 my @skycells = &select_skycells ($entry, @matchlist); 130 foreach $skycell (@skycells) { 131 my %overlap = (); 132 $overlap{skycell_id} = $skycell; 133 $overlap{tess_id} = $catdir; 134 $overlap{cam_id} = $imfile->{cam_id}; 135 $overlap{class_id} = $imfile->{class_id}; 136 $overlap{fault} = $imfile->{fault}; 137 push @overlaps \$overlap; 138 } 139 } 140 } else { 141 my @overlaps = (); 142 foreach $imfile (@$imfiles) { 143 my $class_id = $imfile->{class_id}; 144 my $chipRoot = $ipprc->convert_filename_absolute( $imfile->{chip_path_base} ); 145 my $psastroFile = $ipprc->filename("PSASTRO.OUTPUT", $chipRoot, $class_id); # SPLIT psastro output 146 147 # run the dvoImageOverlaps program to get the overlaps with this image 148 my $command = "dvoImageOverlaps -D CATDIR $tess_id $psastroFile"; 149 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 150 run(command => $command, verbose => 1); 151 unless ($success) { 152 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 153 &my_die("Unable to perform dvoImageOverlaps: $error_code", $warp_id, $error_code); 154 } 155 my @matchlist = split ('\n', $stdout_buf); 156 157 # dvoImageOverlaps -D CATDIR tessalation (megacam) :: returns: 158 # 729534pa.ccd00.cmf : skycell.051.fits 159 # 729534pa.ccd00.cmf : skycell.052.fits 160 # PSASTRO.OUTPUT : SKYCELL 161 162 # now match the imfiles to this list 163 my @skycells = &select_skycells ($psastroFile, @matchlist); 164 # XXX should I check and warn if int(@skycells) != int(@matchlist) ? 165 foreach $skycell (@skycells) { 166 my %overlap = (); 167 $overlap{skycell_id} = $skycell; 168 $overlap{tess_id} = $catdir; 169 $overlap{cam_id} = $imfile->{cam_id}; 170 $overlap{class_id} = $imfile->{class_id}; 171 $overlap{fault} = $imfile->{fault}; 172 push @overlaps \$overlap; 173 } 174 } 175 } 94 176 } else { 95 # Add in the skycell and tesselation for each imfile 177 # create an overlap with an entry for each skycell:imfile match 178 my @overlaps = (); 96 179 foreach my $imfile (@$imfiles) { 97 $imfile->{skycell_id} = 'default'; 98 $imfile->{tess_id} = 'default'; 99 $imfile->{fault} = 0; 180 my %overlap = (); 181 $overlap{skycell_id} = 'default'; 182 $overlap{tess_id} = 'default'; 183 $overlap{cam_id} = $imfile->{cam_id}; 184 $overlap{class_id} = $imfile->{class_id}; 185 $overlap{fault} = $imfile->{fault}; 186 push @overlaps \$overlap; 100 187 } 101 188 } … … 115 202 open my $overlapFile, "> $overlapName" or die "Unable to open mdc file $overlapName"; 116 203 print $overlapFile "warpSkyCellMap MULTI\n\n"; 117 foreach my $ imfile (@$imfiles) {118 print $overlapFile "warpSkyCellMap \tMETADATA\n";119 print $overlapFile " \twarp_id\t\tS32\t" . $warp_id . "\n";120 print $overlapFile " \tskycell_id\tSTR\t" . $imfile->{skycell_id} . "\n";121 print $overlapFile " \ttess_id\t\tSTR\t" . $imfile->{tess_id} . "\n";122 print $overlapFile " \tcam_id\t\tS32\t" . int($imfile->{cam_id}) . "\n";123 print $overlapFile " \tclass_id\tSTR\t" . $imfile->{class_id} . "\n";124 print $overlapFile " \tfault\t\tS16\t" . $imfile->{fault} . "\n";204 foreach my $overlap (@overlaps) { 205 print $overlapFile "warpSkyCellMap METADATA\n"; 206 print $overlapFile " warp_id S32 $warp_id\n"; 207 print $overlapFile " skycell_id STR $overlap->{skycell_id}\n"; 208 print $overlapFile " tess_id STR $overlap->{tess_id}\n"; 209 print $overlapFile " cam_id S32 $overlap->{cam_id}\n"; 210 print $overlapFile " class_id STR $overlap->{class_id}\n"; 211 print $overlapFile " fault S16 $overlap->{fault}\n"; 125 212 print $overlapFile "END\n\n"; 126 213 } … … 143 230 } 144 231 145 146 147 232 sub my_die 148 233 { … … 157 242 } 158 243 244 sub select_skycells 245 { 246 my $entry = shift; 247 my @list = @_; 248 249 my @skycells = (); 250 251 foreach my $line (@list) { 252 if ($line =~ m|$entry|) { 253 ($skycell) = $line =~ m|$entry\s+:\s+(\S+)|; 254 push @skycells, $skycell; 255 } 256 } 257 return @skycells; 258 } 259 159 260 END { 160 261 my $status = $?;
Note:
See TracChangeset
for help on using the changeset viewer.
