Changeset 19161
- Timestamp:
- Aug 21, 2008, 5:31:31 PM (18 years ago)
- File:
-
- 1 edited
-
trunk/pstamp/lib/PStamp/Job.pm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/pstamp/lib/PStamp/Job.pm
r19001 r19161 51 51 my $results = lookup_bycoord($ipprc, $image_db, $x, $y, $mjd_min, $mjd_max, $filter, $verbose); 52 52 53 # If the type is raw we're done, otherwise we have more work to do54 if ($img_type eq "raw") {55 return $results;56 }57 53 $req_type = "byexp"; 58 54 $id = $results->{exp_name}; … … 90 86 my $want_astrom; 91 87 my $use_class_id; 88 89 # special class_id value "null" means all 90 if ($class_id eq "null") { 91 $class_id = undef; 92 } 92 93 93 94 if ($img_type eq "raw") { … … 112 113 $weight_name = "PSWARP.OUTPUT.WEIGHT"; 113 114 $base_name = "path_base"; # name of the field for the warptool output 114 $want_astrom = 1;115 $use_class_id = 1;116 115 } elsif ($img_type eq "diff") { 117 116 $command = "$difftool -diffskyfile -dbname $image_db"; … … 179 178 $out->{weight} = $ipprc->filename($weight_name, $base, $class_id) if $weight_name; 180 179 } 181 $out->{astrom} = find_astrometry($ipprc, $image) if $want_astrom;182 180 $out->{camera} = $camera; 181 $out->{astrom} = find_astrometry($ipprc, $image_db, $image, $verbose) if $want_astrom; 183 182 184 183 push @$output, $out; … … 255 254 } 256 255 256 # find the astrometry file for a given exposure 257 # return undef if no completed camRun exists 257 258 sub find_astrometry { 258 # 259 #XXX need to get this from the config as in warp_overlap.pl 260 # $astrom_name = "PSASTRO.OUTPUT.MEF"; 261 # $astrom_name = "PSASTRO.OUTPUT"; 262 # $out->{astrom} = $ipprc->filename($astrom_name, $base, $class_id) if $astrom_name; 263 return undef; 259 my $ipprc = shift; 260 my $image_db = shift; 261 my $image = shift; # hashref to output of the lookup tool 262 my $verbose = shift; 263 264 my $missing_tools; 265 my $camtool = can_run("camtool") or (warn "Can't find camtool" and $missing_tools = 1); 266 my $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); 267 if ($missing_tools) { 268 warn("Can't find required tools."); 269 exit ($PS_EXIT_CONFIG_ERROR); 270 } 271 272 my $command = "$camtool -dbname $image_db -processedexp -exp_id $image->{exp_id}"; 273 # run the tool and parse the output 274 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 275 run(command => $command, verbose => $verbose); 276 unless ($success) { 277 print STDERR @$stderr_buf; 278 return undef; 279 } 280 281 my $mdcParser = PS::IPP::Metadata::Config->new; # Parser for metadata config files 282 283 my $output = join "", @$stdout_buf; 284 if (!$output) { 285 print STDERR "no output returned from $command\n" if $verbose; 286 return undef; 287 } 288 my $camruns = parse_md_fast($mdcParser, $output); 289 if (!$camruns) { 290 return undef; 291 } 292 293 # If there are multiple cam runs for this exposure, take the last one 294 # assuming that it has the best astrometry 295 my $camdata = pop @$camruns; 296 if (!$camdata) { 297 # no cam runs for this exposure id therefore best astrometry is whatever is in the header 298 return undef; 299 } 300 my $camRoot = $camdata->{path_base}; 301 my $camera = $image->{camera}; 302 my $astromSource; 303 { 304 my $command = "$ppConfigDump -camera $camera -dump-recipe PSWARP -"; 305 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 306 run(command => $command, verbose => $verbose); 307 unless ($success) { 308 $error_code = (($error_code >> 8) or $PS_EXIT_PROG_ERROR); 309 die("Unable to perform ppConfigDump: $error_code"); 310 } 311 my $metadata = $mdcParser->parse(join "", @$stdout_buf) or 312 die("Unable to parse metadata config doc"); 313 $astromSource = metadataLookupStr($metadata, 'ASTROM.SOURCE'); 314 } 315 316 my $astromFile = $ipprc->filename($astromSource, $camRoot); 317 318 return $astromFile; 264 319 } 265 320
Note:
See TracChangeset
for help on using the changeset viewer.
