Changeset 35398 for trunk/PS-IPP-PStamp
- Timestamp:
- Apr 12, 2013, 11:03:47 AM (13 years ago)
- File:
-
- 1 edited
-
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r35384 r35398 15 15 our @EXPORT_OK = qw( 16 16 locate_images 17 new_locate_images17 locate_images_for_row 18 18 resolve_project 19 19 getCamRunByCamID … … 79 79 ($req_type ne "byskycell"); 80 80 81 if (!$d efault_data_groups) {81 if (!$data_group and !$default_data_groups) { 82 82 $default_data_groups = load_data_groups($verbose); 83 83 } … … 171 171 172 172 my $results = lookup($ipprc, $rowList, $imagedb, $req_type, $stage, $id, $tess_id, $component, 173 $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); 173 $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, 174 undef, undef, undef, $verbose); 174 175 175 176 return $results; 176 177 } 177 178 178 sub new_locate_images{179 sub locate_images_for_row { 179 180 my $ipprc = shift; 180 181 my $imagedb = shift; … … 195 196 ($req_type ne "byskycell"); 196 197 197 if (!$default_data_groups) {198 $default_data_groups = load_data_groups($verbose);199 }200 201 198 my $stage = $row->{IMG_TYPE}; 202 199 my $id = $row->{ID}; … … 208 205 my $mjd_max = $row->{MJD_MAX}; 209 206 my $data_group = $row->{DATA_GROUP}; 207 if (isnull($data_group) and !$default_data_groups) { 208 $default_data_groups = load_data_groups($verbose); 209 } 210 210 211 211 my $rownum = $row->{ROWNUM}; … … 230 230 $filter = undef; 231 231 } 232 233 234 232 235 233 if ($req_type eq "bycoord") { … … 240 238 } 241 239 242 # for compatability with the lower level functions 240 # for compatability with the lower level functions that haven't been converted to take a single row 243 241 my $rowList = [$row]; 244 242 … … 251 249 return $results; 252 250 } 251 252 my ($release_name, $survey) = get_release_info($row); 253 253 254 254 if ($req_type eq "bydiff") { … … 303 303 304 304 my $results = lookup($ipprc, $rowList, $imagedb, $req_type, $stage, $id, $tess_id, $component, 305 0, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); 305 0, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, 306 undef, $release_name, $survey, 307 $verbose); 306 308 307 309 return $results; … … 328 330 my $mjd_min = shift; 329 331 my $mjd_max = shift; 332 my $selectedAstrom = shift; 333 my $release_name = shift; 334 my $survey = shift; 330 335 my $verbose = shift; 331 336 … … 352 357 my $magic_arg = $need_magic ? " -destreaked" : ""; 353 358 359 my $row = $rowList->[0]; 360 354 361 # all rows have the same center type 355 my $skycenter = ! ($rowList->[0]->{COORD_MASK} & $PSTAMP_CENTER_IN_PIXELS); 362 my $skycenter = ! ($row->{COORD_MASK} & $PSTAMP_CENTER_IN_PIXELS); 363 364 my $use_releasetool = 0; 365 my $release_args; 366 if (($req_type eq 'byexp' and $stage ne 'raw') or ($req_type eq 'byskycell' and $stage ne 'diff')) { 367 unless (isnull($release_name) and isnull($survey)) { 368 $use_releasetool = 1; 369 $release_args = " -release_name $release_name" if $release_name; 370 $release_args .= " -surveyName $survey" if $survey; 371 } 372 } 356 373 357 374 my $component_args; … … 384 401 # use chiptool -processsedimfile. Otherwise use chiptool -listrun and then 385 402 # choose the chips containing the center pixel by calling selectComponets() below 386 if ($component or $use_imfile_id or !$skycenter) { 387 $command = "$chiptool -processedimfile -pstamp_order -dbname $imagedb"; 388 if ($component and $component ne 'all') { 389 $class_id = $component; 390 $component_args = " -class_id $class_id"; 391 } 392 } else { 393 $command = "$chiptool -listrun -pstamp_order -dbname $imagedb"; 403 if ($use_releasetool) { 404 $command = "$releasetool -dbname $imagedb -priority_order -listrelexp $release_args"; 394 405 $choose_components = 1; 395 } 396 $id_opt = $use_imfile_id ? "-chip_imfile_id" : "-chip_id"; 406 } else { 407 $command = "$chiptool -pstamp_order -dbname $imagedb"; 408 if ($component or $use_imfile_id or !$skycenter) { 409 $command .= " -processedimfile"; 410 if ($component and $component ne 'all') { 411 $class_id = $component; 412 $component_args = " -class_id $class_id"; 413 } 414 } else { 415 $command .= " -listrun"; 416 $choose_components = 1; 417 } 418 $id_opt = $use_imfile_id ? "-chip_imfile_id" : "-chip_id"; 419 } 397 420 # XXX: perhaps we should stop resolving images to this level here and do it at job run time. 398 421 # With the mdc file it has all of the information that it needs. … … 408 431 $want_astrom = 1; 409 432 $set_class_id = 1; 410 } elsif ($stage eq "warp") { 411 if ($component or $use_imfile_id or !$skycenter) { 412 $command = "$warptool -warped -pstamp_order -dbname $imagedb"; 413 if ($component and $component ne 'all') { 414 $skycell_id = $component; 415 $component_args = " -skycell_id $skycell_id"; 416 } 417 } else { 418 $command = "$warptool -listrun -pstamp_order -dbname $imagedb"; 433 } elsif ($stage eq 'warp') { 434 if ($use_releasetool) { 435 $command = "$releasetool -dbname $imagedb -priority_order -listrelexp $release_args"; 419 436 $choose_components = 1; 420 } 421 $id_opt = $use_imfile_id ? "-warp_skyfile_id" : "-warp_id"; 437 } else { 438 $command = "$warptool -pstamp_order -dbname $imagedb"; 439 if ($component or $use_imfile_id or !$skycenter) { 440 $command .= " -warped"; 441 if ($component and $component ne 'all') { 442 $skycell_id = $component; 443 $component_args = " -skycell_id $skycell_id"; 444 } 445 } else { 446 $command = " -listrun"; 447 $choose_components = 1; 448 } 449 $id_opt = $use_imfile_id ? "-warp_skyfile_id" : "-warp_id"; 450 } 422 451 $image_name = "PSWARP.OUTPUT"; 423 452 $mask_name = "PSWARP.OUTPUT.MASK"; … … 427 456 $base_name = "path_base"; # name of the field for the warptool output 428 457 } elsif ($stage eq "diff") { 458 # XXX: is this path ever used for diff images anymore? 429 459 if ($component or $use_imfile_id or !$skycenter) { 430 460 $command = "$difftool -diffskyfile -pstamp_order -dbname $imagedb"; … … 447 477 } elsif ($stage eq "stack") { 448 478 $skycell_id = $component; 449 $command = "$stacktool -sumskyfile -dbname $imagedb"; 450 # only consider stacks in full state. 451 $command .= " -state full"; 452 $id_opt = "-stack_id"; 479 if ($use_releasetool) { 480 $command = "$releasetool -listrelstack -dbname $imagedb $release_args"; 481 $base_name = 'stack_path_base'; 482 } else { 483 $command = "$stacktool -sumskyfile -dbname $imagedb"; 484 # only consider stacks in full state. 485 $command .= " -state full"; 486 $id_opt = "-stack_id"; 487 $base_name = 'path_base'; 488 } 453 489 $component_args = " -skycell_id $skycell_id" if $skycell_id and $skycell_id ne 'all'; 454 490 … … 464 500 # this is wrong but gets the right answer. Need to figure out how to find the 465 501 # rule properly 466 #$cmf_name = "PSPHOT.OUTPUT"; # this puts .fpa. in the name467 502 $cmf_name = "PSWARP.OUTPUT.SOURCES"; 503 # $cmf_name = "PSPHOT.OUTPUT"; # this puts .fpa. in the name 468 504 $psf_name = "PPSTACK.TARGET.PSF"; 469 $base_name = "path_base";470 505 } else { 471 die "Unknown IMG_TYP esupplied: $stage";506 die "Unknown IMG_TYPE supplied: $stage"; 472 507 } 473 508 … … 512 547 if (!isnull($data_group)) { 513 548 $command .= " -data_group $data_group"; 514 } elsif ($req_type eq 'byskycell') { 549 } elsif (!$use_releasetool and $req_type eq 'byskycell') { 550 # XXX: Why am I using default data_groups only for byskycell requests? 515 551 $command .= $default_data_groups; 516 552 } … … 527 563 $images = filterRuns($stage, $need_magic, $images, $inverse, $verbose); 528 564 } 565 529 566 if ($choose_components) { 530 567 # the list of "images" is actually a list of "Runs" 531 568 # match the coords in the rows to the components in the runs 532 569 # returns an actual list of images 533 $images = selectComponents($ipprc, $imagedb, $req_type, $stage, $rowList, $images, $verbose); 570 if ($skycenter) { 571 $images = selectComponents($ipprc, $imagedb, $req_type, $stage, $rowList, $images, $verbose); 572 } else { 573 $images = selectComponentsByName($ipprc, $imagedb, $req_type, $stage, $component, $rowList, $images, $verbose); 574 } 534 575 } else { 535 # put index for each of the rows into all of the the images576 # put index for each of the rows into all of the the selected images 536 577 setRowRefs($rowList, $images); 537 578 } … … 597 638 # dquery wants these set 598 639 $out->{magicked} = 0; 599 $out->{data_state} = $out->{state}; 640 if ($use_releasetool) { 641 if ($image->{skycal_path_base}) { 642 $out->{astrom} = $image->{skycal_path_base} . ".cmf"; 643 } 644 $out->{data_state} = $out->{state} = $out->{stack_state}; 645 } else { 646 $out->{data_state} = $out->{state}; 647 } 600 648 } 601 649 $out->{stage_id} = $stage_id; … … 605 653 my $mask_base; 606 654 if ($want_astrom) { 607 if (! defined $out->{astrom}) { 655 if ($selectedAstrom) { 656 $out->{astrom} = $selectedAstrom; 657 $out->{cam_path_base} = basename($selectedAstrom); 658 } elsif (! defined $out->{astrom}) { 608 659 if (! find_astrometry($ipprc, $imagedb, $out, $verbose)) { 609 660 print STDERR "failed to find astrometry for $stage $stage_id\n"; … … 806 857 my $mjd_min = shift; 807 858 my $mjd_max = shift; 859 my $astrom = shift; 808 860 my $verbose = shift; 809 861 810 my ($release_name, $survey) = get_release ($row);862 my ($release_name, $survey) = get_release_info($row); 811 863 812 864 my $rowList = [$row]; … … 825 877 my $these_results = lookup($ipprc, $rowList, $imagedb, "byid", $stage, $chip->{id}, 826 878 $tess_id, $chip->{component}, $need_magic, 827 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); 879 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, 880 $chip->{astrom}, undef, undef, 881 $verbose); 828 882 829 883 next if !$these_results; … … 845 899 my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $stage, undef, 846 900 $skycell->{tess_id}, $skycell->{component}, $need_magic, 847 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); 901 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, 902 undef, $release_name, $survey, 903 $verbose); 848 904 849 905 next if !$these_results; … … 882 938 my $using_camtool = 0; 883 939 if ($release_name or $survey) { 884 my$command = "$releasetool -dbname $imagedb -listrelexp";885 if ( $survey) {940 $command = "$releasetool -dbname $imagedb -listrelexp"; 941 if (!isnull($survey)) { 886 942 $command .= " -survey_name $survey"; 887 943 } 888 if ( $release_name) {944 if (!isnull($release_name)) { 889 945 $command .= " -release_name $release_name"; 890 946 } else { … … 935 991 if ($using_camtool) { 936 992 next if $result->{fault}; 937 updateCamRunCache($result); 938 } 993 } else { 994 $result->{path_base} = $result->{cam_path_base}; 995 } 996 updateCamRunCache($result); 939 997 940 998 $last_exp_id = $exp_id; … … 1008 1066 cam_id => $result->{cam_id}, 1009 1067 class_id => $class_id, 1010 component => $class_id 1068 component => $class_id, 1069 astrom => $astrom 1011 1070 }; 1012 1071 if ($stage eq "chip") { … … 1444 1503 } 1445 1504 1505 sub selectComponentsByName { 1506 my $ipprc = shift; 1507 my $imagedb = shift; 1508 my $req_type = shift; 1509 my $stage = shift; 1510 my $component = shift; 1511 my $rowList = shift; 1512 my $runList = shift; 1513 my $verbose = shift; 1514 my $results = []; 1515 1516 $component = "" if $component and lc($component) eq 'all'; 1517 1518 # all runs match all rows so they can share a common row_index 1519 # XXX: I'm not sure we ever actually get here with more than one 1520 # row 1521 my $numRows = scalar @$rowList; 1522 my $row_index = []; 1523 for (my $i=0; $i < $numRows; $i++) { 1524 push @$row_index, $i; 1525 } 1526 1527 if (($req_type eq "byid") or ($req_type eq "byexp")) { 1528 my ($last_tess_id, $tess_dir_abs, $astrom_file) = ("", "", ""); 1529 foreach my $run (@$runList) { 1530 # now find the images for this run 1531 #foreach my $c (keys %components) { 1532 my $command; 1533 my $stage_id; 1534 if ($stage eq 'raw') { 1535 $stage_id = $run->{exp_id}; 1536 $command = "$regtool -processedimfile -exp_id $stage_id"; 1537 $command .= " -class_id $component" if $component; 1538 } elsif ($stage eq 'chip') { 1539 $stage_id = $run->{chip_id}; 1540 $command = "$chiptool -processedimfile -chip_id $stage_id"; 1541 $command .= " -class_id $component" if $component; 1542 } elsif ($stage eq 'warp') { 1543 $stage_id = $run->{warp_id}; 1544 $command = "$warptool -warped -warp_id $stage_id"; 1545 $command .= " -skycell_id $component" if $component; 1546 } 1547 $command .= " -dbname $imagedb"; 1548 my $images = runToolAndParse($command, $verbose); 1549 if (!defined $images) { 1550 print "No $component found for $stage ${stage}_id $stage_id\n"; 1551 next; 1552 } 1553 foreach my $image (@$images) { 1554 $image->{row_index} = $row_index; 1555 if (($stage eq "raw") or ($stage eq 'chip')) { 1556 $image->{cam_id} = $run->{cam_id}; 1557 $image->{cam_path_base} = $run->{cam_path_base}; 1558 } 1559 push @$results, $image; 1560 } 1561 } 1562 } else { 1563 &my_die ("selectComponentsByName not supported for REQ_TYPE: $req_type\n", $PS_EXIT_PROG_ERROR); 1564 } 1565 return $results; 1566 } 1567 1446 1568 sub filterRuns { 1447 1569 my $stage = shift; … … 1627 1749 } 1628 1750 1629 sub get_release {1751 sub get_release_info { 1630 1752 my $row = shift; 1631 1753 1632 1754 my $survey; 1633 1755 my $release_name = $row->{IPP_RELEASE}; 1634 if (!isnull($release_name)) { 1756 if (isnull($release_name)) { 1757 $release_name = ""; 1635 1758 # no release check for survey 1636 1759 $survey = $row->{SURVEY_NAME}; 1760 } else { 1761 $survey = ""; 1637 1762 } 1638 1763
Note:
See TracChangeset
for help on using the changeset viewer.
