Changeset 25107
- Timestamp:
- Aug 18, 2009, 11:55:23 AM (17 years ago)
- Location:
- trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp
- Files:
-
- 2 edited
-
Job.pm (modified) (7 diffs)
-
RequestFile.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r24968 r25107 36 36 my $id = shift; # required unless req_type eq bycoord 37 37 my $component= shift; # class_id or skycell_id 38 my $inverse = shift; 38 39 my $x = shift; 39 40 my $y = shift; … … 43 44 my $verbose = shift; 44 45 46 45 47 # we die in response to bad data in request files 46 48 die "Unknown req_type: $req_type" if ($req_type ne "byid") and ($req_type ne "byexp") 47 49 and ($req_type ne "bycoord") and ($req_type ne "bydiff"); 50 48 51 if (($req_type eq "byid") and ($img_type eq "diff")) { 49 52 # lookups of all of the information for diff images requires a two level lookup to … … 51 54 # in one place 52 55 $req_type = "bydiff"; 53 } 56 my $results = lookup_diff($ipprc, $image_db, $id, $component, 1, $inverse, $img_type, $verbose); 57 return $results; 58 } 59 54 60 if ($req_type eq "bydiff") { 55 my $results = lookup_ bydiff($ipprc, $image_db, $id, $img_type, $verbose);61 my $results = lookup_diff($ipprc, $image_db, $id, $component, 0, $inverse, $img_type, $verbose); 56 62 if (!$results) { 57 63 return undef; 58 64 } 59 65 if (($img_type eq "warp") or ($img_type eq "diff")) { 60 # lookup_bydiff has done all of the work 61 return [$results]; 62 } elsif (($img_type eq "raw") or ($img_type eq "chip")) { 66 # lookup_diff has done all of the work 67 return $results; 68 } 69 70 my $image = $results->[0]; 71 if (($img_type eq "raw") or ($img_type eq "chip")) { 63 72 $req_type = "byexp"; 64 $id = $ results->{exp_name};73 $id = $image->{exp_name}; 65 74 return undef if !$id; 66 75 # fall through and lookup byexp 67 # } elsif ($img_type eq "warp") {68 # $req_type = "byid";69 # $id = $results->{warp_id};70 # $component = $results->{skycell_id};71 # return undef if !$id;72 # # fall through and lookup by warp_id73 76 } elsif ($img_type eq "stack") { 74 77 $req_type = "byid"; 75 $id = $ results->{stack_id};78 $id = $image->{stack_id}; 76 79 return undef if !$id; 77 80 # fall though and lookup by stack id … … 254 257 return $output; 255 258 } 256 sub lookup_ bydiff {259 sub lookup_diff { 257 260 my $ipprc = shift; 258 261 my $image_db = shift; 259 262 my $id = shift; 263 my $skycell_id = shift; 264 my $byid = shift; 265 my $inverse = shift; 260 266 my $img_type = shift; 261 267 my $verbose = shift; … … 268 274 } 269 275 270 my $command = "$difftool -diffskyfile -diff_image_id $id -dbname $image_db"; 276 my $command = "$difftool -diffskyfile -dbname $image_db"; 277 278 if ($byid) { 279 $command .= " -diff_id $id"; 280 } else { 281 $command .= " -diff_skyfile_id $id"; 282 } 283 $command .= " -skycell_id $skycell_id" if $skycell_id; 271 284 272 285 # run the tool and parse the output … … 289 302 290 303 my $n = @$images; 291 if ( $n > 1) {304 if (!$byid && ($n > 1)) { 292 305 die ("difftool returned an unexpected number of diffskyfiles: $n"); 293 306 } elsif ($n == 0) { … … 295 308 } 296 309 297 my $image = $images->[0]; 298 299 my $skycell_id = $image->{skycell_id}; 300 301 if ($image->{fault}) { 302 print STDERR "selected difference image $id $image->{diff_id} $skycell_id has fault: $image->{fault}\n"; 303 return undef; 304 } 305 306 # The standard way to do a diff is warp - stack 307 # so we interpret the requested image in that way 308 309 my $stack_id = $image->{stack2}; 310 # XXX difftool currently returns max long long for null 311 # this line is ready if we switch the code to return zero for null 312 if ($stack_id and ($stack_id != 9223372036854775807)) { 313 $image->{stack_id} = $stack_id; 314 } 315 316 my $warp_id = $image->{warp1}; 317 # XXX difftool currently returns max long long for null 318 # this line is ready if we switch the code to return zero for null 319 if ($warp_id and ($warp_id != 9223372036854775807)) { 320 $image->{warp_id} = $warp_id; 321 322 ## now use the warp and go get the exposure information 323 $command = "warptool -warped -warp_id $warp_id -skycell_id $skycell_id -dbname $image_db -limit 1"; 324 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 325 run(command => $command, verbose => $verbose); 326 unless ($success) { 327 # not sure if we should die here 328 print STDERR @$stderr_buf; 329 return undef; 330 } 331 332 my $buf = join "", @$stdout_buf; 333 if (!$buf) { 334 return undef; 335 } 336 337 my $mdcParser = PS::IPP::Metadata::Config->new; 338 my $warps = parse_md_fast($mdcParser, $buf) 339 or die ("Unable to parse metadata config doc"); 340 my $warp = $warps->[0]; 341 342 if ($img_type eq "warp") { 343 $image = $warp; 310 my @results; 311 foreach my $image (@$images) { 312 my $skycell_id = $image->{skycell_id}; 313 314 if ($image->{fault}) { 315 print STDERR "selected difference image $id $image->{diff_id} $skycell_id has fault: $image->{fault}\n"; 316 next; 317 } 318 319 # The standard way to do a diff is warp - stack 320 # so we interpret the requested image in that way 321 322 my $stack_id = $image->{stack2}; 323 # XXX difftool currently returns max long long for null 324 # this line is ready if we switch the code to return zero for null 325 if ($stack_id and ($stack_id != 9223372036854775807)) { 326 $image->{stack_id} = $stack_id; 327 } 328 329 my $warp_id; 330 if ($inverse and !$image->{bothways}) { 331 print STDERR "inverse image requested for diffRun that is not bothways ignoring\n"; 332 $inverse = 0; 333 } 334 if ($inverse) { 335 $warp_id = $image->{warp2}; 344 336 } else { 345 $image->{exp_id} = $warp->{exp_id}; 346 $image->{exp_name} = $warp->{exp_name}; 347 $image->{camera} = $warp->{camera}; 348 } 349 } 350 351 if (($img_type eq "diff") or ($img_type eq "warp")) { 352 # the $image is going to be returned directly in this case so we need to duplicate 353 # some of processing that lookup does for other img_types 354 $image->{image} = $image->{uri}; 355 if ($image->{camera}) { 356 $ipprc->define_camera($image->{camera}); 357 if ($img_type eq "diff") { 358 $image->{mask} = $ipprc->filename("PPSUB.OUTPUT.MASK", $image->{path_base}); 359 $image->{weight} = $ipprc->filename("PPSUB.OUTPUT.VARIANCE", $image->{path_base}); 337 $warp_id = $image->{warp1}; 338 } 339 # XXX difftool currently returns max long long for null 340 # this line is ready if we switch the code to return zero for null 341 if ($warp_id and ($warp_id != 9223372036854775807)) { 342 $image->{warp_id} = $warp_id; 343 344 ## now use the warp and go get the exposure information 345 $command = "warptool -warped -warp_id $warp_id -skycell_id $skycell_id -dbname $image_db -limit 1"; 346 my ( $success, $error_code, $full_buf, $stdout_buf, $stderr_buf ) = 347 run(command => $command, verbose => $verbose); 348 unless ($success) { 349 # XXX: I'm not sure if we should die here 350 print STDERR @$stderr_buf; 351 return undef; 352 } 353 354 my $buf = join "", @$stdout_buf; 355 if (!$buf) { 356 next; 357 } 358 359 my $mdcParser = PS::IPP::Metadata::Config->new; 360 my $warps = parse_md_fast($mdcParser, $buf) 361 or die ("Unable to parse metadata config doc"); 362 my $warp = $warps->[0]; 363 364 if ($img_type eq "warp") { 365 $image = $warp; 360 366 } else { 361 $image->{mask} = $ipprc->filename("PSWARP.OUTPUT.MASK", $image->{path_base}); 362 $image->{weight} = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $image->{path_base}); 367 $image->{exp_id} = $warp->{exp_id}; 368 $image->{exp_name} = $warp->{exp_name}; 369 $image->{camera} = $warp->{camera}; 363 370 } 364 371 } else { 365 # XXX this will only happen if the minuend is not a warp 366 print STDERR "WARNING: cannot resolve camera so cannot get weight and mask images\n"; 367 } 368 } 369 370 return $image; 372 print STDERR "unexpected result warp_id not defined\n"; 373 next; 374 } 375 376 if (($img_type eq "diff") or ($img_type eq "warp")) { 377 # the $image is going to be returned directly in this case so we need to duplicate 378 # some of processing that lookup does for other img_types 379 if ($image->{camera}) { 380 $ipprc->define_camera($image->{camera}); 381 if ($img_type eq "diff") { 382 my $filerule_base = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT"; 383 $image->{image} = $ipprc->filename($filerule_base, $image->{path_base}); 384 $image->{mask} = $ipprc->filename($filerule_base . ".MASK", $image->{path_base}); 385 $image->{weight} = $ipprc->filename($filerule_base . ".VARIANCE", $image->{path_base}); 386 } else { 387 $image->{image} = $ipprc->filename("PSWARP.OUTPUT", $image->{path_base}); 388 $image->{mask} = $ipprc->filename("PSWARP.OUTPUT.MASK", $image->{path_base}); 389 $image->{weight} = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $image->{path_base}); 390 } 391 } else { 392 # XXX this will only happen if the minuend is not a warp 393 print STDERR "WARNING: cannot resolve camera so cannot get weight and mask images\n"; 394 next; 395 } 396 } 397 push @results, $image; 398 } 399 return \@results; 371 400 } 372 401 -
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm
r25077 r25107 22 22 $PSTAMP_SELECT_MASK 23 23 $PSTAMP_SELECT_WEIGHT 24 $PSTAMP_SELECT_INVERSE 24 25 $PSTAMP_SUCCESS 25 26 $PSTAMP_SYSTEM_ERROR … … 46 47 our $PSTAMP_SELECT_WEIGHT = 4; 47 48 49 our $PSTAMP_SELECT_INVERSE = 1024; 50 48 51 # job and result codes 49 52 # NOTE: these must match the values in pstamp/src/pstamp.h … … 51 54 our $PSTAMP_SYSTEM_ERROR = 10; 52 55 our $PSTAMP_NOT_IMPLEMENTED = 11; 53 our $PSTAMP_UNKNOWN_ERROR = 12;56 our $PSTAMP_UNKNOWN_ERROR = 12; 54 57 55 58 our $PSTAMP_DUP_REQUEST = 20;
Note:
See TracChangeset
for help on using the changeset viewer.
