Changeset 25151
- Timestamp:
- Aug 20, 2009, 11:50:15 AM (17 years ago)
- Location:
- branches/czw_branch/cleanup/PS-IPP-PStamp/lib/PS/IPP/PStamp
- Files:
-
- 2 edited
-
Job.pm (modified) (7 diffs)
-
RequestFile.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/czw_branch/cleanup/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r25051 r25151 34 34 my $req_type = shift; # required 35 35 my $img_type = shift; # required 36 my $id = shift; # required unless req_type eq bycoord 36 my $id = shift; # required unless req_type eq bycoord or byskycell 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 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")) { 65 if ($img_type eq "diff") { 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_id 76 } elsif ($img_type eq "warp") { 77 $req_type = "byid"; 78 $id = $image->{warp_id}; 79 return undef if !$id; 80 # fall through and lookup by warp_id 73 81 } elsif ($img_type eq "stack") { 74 82 $req_type = "byid"; 75 $id = $ results->{stack_id};83 $id = $image->{stack_id}; 76 84 return undef if !$id; 77 # fall though and lookup by stack id85 # fall though and lookup by stack_id 78 86 } else { 79 87 # shouldn't I check this elsewhere? … … 254 262 return $output; 255 263 } 256 sub lookup_ bydiff {264 sub lookup_diff { 257 265 my $ipprc = shift; 258 266 my $image_db = shift; 259 267 my $id = shift; 268 my $skycell_id = shift; 269 my $byid = shift; 270 my $inverse = shift; 260 271 my $img_type = shift; 261 272 my $verbose = shift; … … 268 279 } 269 280 270 my $command = "$difftool -diffskyfile -diff_image_id $id -dbname $image_db"; 281 my $command = "$difftool -diffskyfile -dbname $image_db"; 282 283 if ($byid) { 284 $command .= " -diff_id $id"; 285 } else { 286 $command .= " -diff_skyfile_id $id"; 287 } 288 $command .= " -skycell_id $skycell_id" if $skycell_id; 271 289 272 290 # run the tool and parse the output … … 289 307 290 308 my $n = @$images; 291 if ( $n > 1) {309 if (!$byid && ($n > 1)) { 292 310 die ("difftool returned an unexpected number of diffskyfiles: $n"); 293 311 } elsif ($n == 0) { … … 295 313 } 296 314 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; 315 my @results; 316 foreach my $image (@$images) { 317 my $skycell_id = $image->{skycell_id}; 318 319 if ($image->{fault}) { 320 print STDERR "selected difference image $id $image->{diff_id} $skycell_id has fault: $image->{fault}\n"; 321 next; 322 } 323 324 # The standard way to do a diff is warp - stack 325 # so we interpret the requested image in that way 326 327 my $stack_id = $image->{stack2}; 328 # XXX difftool currently returns max long long for null 329 # this line is ready if we switch the code to return zero for null 330 if ($stack_id and ($stack_id != 9223372036854775807)) { 331 $image->{stack_id} = $stack_id; 332 } 333 334 my ($warp_id, $exp_id, $exp_name); 335 if ($inverse and !$image->{bothways}) { 336 print STDERR "Inverse images requested for diffRun that is not bothways. Ignoring.\n"; 337 $inverse = 0; 338 } 339 if ($inverse) { 340 $warp_id = $image->{warp2}; 341 $exp_id = $image->{exp_id_2}; 342 $exp_name = $image->{exp_name_2}; 344 343 } 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}); 344 $warp_id = $image->{warp1}; 345 $exp_id = $image->{exp_id_1}; 346 $exp_name = $image->{exp_name_1}; 347 } 348 # XXX difftool currently returns max long long for null 349 # this line is ready if we switch the code to return zero for null 350 if ($warp_id and ($warp_id != 9223372036854775807)) { 351 $image->{warp_id} = $warp_id; 352 $image->{exp_id} = $exp_id; 353 $image->{exp_name} = $exp_name; 354 } else { 355 print STDERR "unexpected result warp_id not defined\n"; 356 next; 357 } 358 if ($img_type eq "diff") { 359 # the $image is going to be returned directly in this case so we need to duplicate 360 # some of processing that lookup does for other img_types 361 if ($image->{camera}) { 362 $ipprc->define_camera($image->{camera}); 363 my $filerule_base = $inverse ? "PPSUB.INVERSE" : "PPSUB.OUTPUT"; 364 $image->{image} = $ipprc->filename($filerule_base, $image->{path_base}); 365 $image->{mask} = $ipprc->filename($filerule_base . ".MASK", $image->{path_base}); 366 $image->{weight} = $ipprc->filename($filerule_base . ".VARIANCE", $image->{path_base}); 360 367 } else { 361 $image->{mask} = $ipprc->filename("PSWARP.OUTPUT.MASK", $image->{path_base}); 362 $image->{weight} = $ipprc->filename("PSWARP.OUTPUT.VARIANCE", $image->{path_base}); 368 # XXX this will only happen if the minuend is not a warp 369 print STDERR "WARNING: cannot resolve camera so cannot get weight and mask images\n"; 370 next; 363 371 } 364 } 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 } 373 push @results, $image; 374 } 375 return \@results; 371 376 } 372 377 -
branches/czw_branch/cleanup/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm
r24951 r25151 22 22 $PSTAMP_SELECT_MASK 23 23 $PSTAMP_SELECT_WEIGHT 24 $PSTAMP_SELECT_INVERSE 25 $PSTAMP_SUCCESS 26 $PSTAMP_SYSTEM_ERROR 27 $PSTAMP_NOT_IMPLEMENTED 28 $PSTAMP_UNKNOWN_ERROR 29 $PSTAMP_DUP_REQUEST 30 $PSTAMP_INVALID_REQUEST 31 $PSTAMP_UNKNOWN_PRODUCT 32 $PSTAMP_NO_IMAGE_MATCH 33 $PSTAMP_NOT_DESTREAKED 34 $PSTAMP_NOT_AVAILABLE 35 $PSTAMP_GONE 36 $PSTAMP_NO_JOBS_QUEUED 37 $PSTAMP_NO_OVERLAP 24 38 ); 25 39 our %EXPORT_TAGS = (standard => [@EXPORT_OK]); … … 33 47 our $PSTAMP_SELECT_MASK = 2; 34 48 our $PSTAMP_SELECT_WEIGHT = 4; 49 50 our $PSTAMP_SELECT_INVERSE = 1024; 51 52 # job and result codes 53 # NOTE: these must match the values in pstamp/src/pstamp.h 54 our $PSTAMP_SUCCESS = 0; 55 our $PSTAMP_SYSTEM_ERROR = 10; 56 our $PSTAMP_NOT_IMPLEMENTED = 11; 57 our $PSTAMP_UNKNOWN_ERROR = 12; 58 59 our $PSTAMP_DUP_REQUEST = 20; 60 our $PSTAMP_INVALID_REQUEST = 21; 61 our $PSTAMP_UNKNOWN_PRODUCT = 22; 62 our $PSTAMP_NO_IMAGE_MATCH = 23; 63 our $PSTAMP_NOT_DESTREAKED = 24; 64 our $PSTAMP_NOT_AVAILABLE = 25; 65 our $PSTAMP_GONE = 26; 66 our $PSTAMP_NO_JOBS_QUEUED = 27; 67 our $PSTAMP_NO_OVERLAP = 28; 35 68 36 69 use IPC::Cmd 0.36 qw( can_run run );
Note:
See TracChangeset
for help on using the changeset viewer.
