- Timestamp:
- Apr 19, 2013, 3:42:02 PM (13 years ago)
- Location:
- branches/eam_branches/ipp-20130307
- Files:
-
- 2 edited
-
. (modified) (1 prop)
-
PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm (modified) (37 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-20130307
- Property svn:mergeinfo changed
/trunk merged: 35353-35354,35356-35368,35380,35383-35384,35388-35392,35394-35400,35409-35411
- Property svn:mergeinfo changed
-
branches/eam_branches/ipp-20130307/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r35350 r35413 15 15 our @EXPORT_OK = qw( 16 16 locate_images 17 locate_images_for_row 17 18 resolve_project 18 19 getCamRunByCamID … … 46 47 my $last_project = ""; 47 48 48 my ($regtool, $chiptool, $camtool, $warptool, $stacktool, $difftool );49 my ($regtool, $chiptool, $camtool, $warptool, $stacktool, $difftool, $releasetool); 49 50 my ($pstamptool, $dvoImagesAtCoords, $whichimage, $ppConfigDump); 50 51 … … 56 57 my $rowList = shift; # required 57 58 my $req_type = shift; # required 58 my $ img_type = shift; # required59 my $stage = shift; # required 59 60 my $id = shift; # required unless req_type eq bycoord or byskycell 60 61 my $tess_id = shift; … … 78 79 ($req_type ne "byskycell"); 79 80 80 $default_data_groups = load_data_groups($verbose); 81 if (!$data_group and !$default_data_groups) { 82 $default_data_groups = load_data_groups($verbose); 83 } 81 84 82 85 my $dateobs_begin; … … 104 107 my $x = $row->{CENTER_X}; 105 108 my $y = $row->{CENTER_Y}; 106 my $results = lookup_bycoord($ipprc, $row List, $imagedb, $img_type, $tess_id, $component, $need_magic, $x, $y, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose);109 my $results = lookup_bycoord($ipprc, $row, $imagedb, $stage, $tess_id, $component, $need_magic, $x, $y, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); 107 110 return $results; 108 111 } 109 112 110 if (($req_type eq "byid") and ($ img_type eq "diff")) {113 if (($req_type eq "byid") and ($stage eq "diff")) { 111 114 # lookups of all of the information for diff images requires a two level lookup to 112 115 # get the exposure information. Switching the req_type allows us to keep that code 113 116 # in one place 114 117 $req_type = "bydiff"; 115 my $results = lookup_diff($ipprc, $rowList, $imagedb, $id, $component, 1, $option_mask, $ img_type, $verbose);118 my $results = lookup_diff($ipprc, $rowList, $imagedb, $id, $component, 1, $option_mask, $stage, $verbose); 116 119 return $results; 117 120 } … … 120 123 # for bydiff reuqests we go look up the diffRun to obtain exp_id, chip_id, warp_id, stack_id, or 121 124 # the image from the diffRun 122 my $results = lookup_diff($ipprc, $rowList, $imagedb, $id, $component, 0, $option_mask, $ img_type, $verbose);125 my $results = lookup_diff($ipprc, $rowList, $imagedb, $id, $component, 0, $option_mask, $stage, $verbose); 123 126 if (!$results) { 124 127 return undef; 125 128 } 126 if ($ img_type eq "diff") {129 if ($stage eq "diff") { 127 130 # lookup_diff has done all of the work 128 131 return $results; … … 130 133 131 134 my $image = $results->[0]; 132 if ($ img_type eq "raw") {135 if ($stage eq "raw") { 133 136 $req_type = "byid"; 134 137 $id = $image->{exp_id}; 135 138 return undef if !$id; 136 139 # fall through and lookup byid 137 } elsif ($ img_type eq "chip") {140 } elsif ($stage eq "chip") { 138 141 $req_type = "byid"; 139 142 $id = $image->{chip_id}; 140 143 return undef if !$id; 141 144 # fall through and lookup byid 142 } elsif ($ img_type eq "warp") {145 } elsif ($stage eq "warp") { 143 146 $req_type = "byid"; 144 147 $id = $image->{warp_id}; … … 146 149 return undef if !$id; 147 150 # fall through and lookup by warp_id 148 } elsif ($ img_type eq "stack") {151 } elsif ($stage eq "stack") { 149 152 $req_type = "byid"; 150 153 $id = $image->{stack_id}; … … 153 156 } else { 154 157 # This is checked this elsewhere? 155 print STDERR "Error: $ img_type is an unknown image type\n";158 print STDERR "Error: $stage is an unknown image type\n"; 156 159 return undef; 157 160 } 158 161 } elsif ($req_type eq "byskycell") { 159 if (($ img_type eq "raw") or ($img_type eq "chip")) {162 if (($stage eq "raw") or ($stage eq "chip")) { 160 163 print STDERR "REQ_TYPE byskycell not supported for IMG_TYPE raw or chip\n"; 161 164 return undef; … … 167 170 } 168 171 169 my $results = lookup($ipprc, $rowList, $imagedb, $req_type, $img_type, $id, $tess_id, $component, 170 $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); 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, 174 undef, undef, undef, $verbose); 175 176 return $results; 177 } 178 179 sub locate_images_for_row { 180 my $ipprc = shift; 181 my $imagedb = shift; 182 my $camera = shift; 183 my $row = shift; 184 my $verbose = shift; 185 186 my $req_type = $row->{REQ_TYPE}; 187 188 # we die in response to bad data in request files 189 # The caller is responsible for updating the database 190 # pstampparse.pl error checks now so this shouldn't happen 191 &my_die("Unknown req_type: $req_type", $PS_EXIT_PROG_ERROR) 192 if ($req_type ne "byid") and 193 ($req_type ne "byexp") and 194 ($req_type ne "bycoord") and 195 ($req_type ne "bydiff") and 196 ($req_type ne "byskycell"); 197 198 my $stage = $row->{IMG_TYPE}; 199 my $id = $row->{ID}; 200 my $component = $row->{COMPONENT}; 201 my $tess_id = $row->{TESS_ID}; 202 203 my $filter = $row->{REQFILT}; 204 my $mjd_min = $row->{MJD_MIN}; 205 my $mjd_max = $row->{MJD_MAX}; 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 211 my $rownum = $row->{ROWNUM}; 212 my $job_type = $row->{JOB_TYPE}; 213 my $option_mask= $row->{OPTION_MASK}; 214 215 my $dateobs_begin; 216 my $dateobs_end; 217 if (!iszero($mjd_min)) { 218 $dateobs_begin = mjd_to_dateobs($mjd_min); 219 } 220 if (!iszero($mjd_max)) { 221 $dateobs_end = mjd_to_dateobs($mjd_max); 222 } 223 if (isnull($tess_id)) { 224 $tess_id = undef; 225 } 226 if (isnull($data_group)) { 227 $data_group = undef; 228 } 229 if (isnull($filter)) { 230 $filter = undef; 231 } 232 233 if ($req_type eq "bycoord") { 234 my $x = $row->{CENTER_X}; 235 my $y = $row->{CENTER_Y}; 236 my $results = lookup_bycoord($ipprc, $row, $imagedb, $stage, $tess_id, $component, 0, $x, $y, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); 237 return $results; 238 } 239 240 # for compatability with the lower level functions that haven't been converted to take a single row 241 my $rowList = [$row]; 242 243 if (($req_type eq "byid") and ($stage eq "diff")) { 244 # lookups of all of the information for diff images requires a two level lookup to 245 # get the exposure information. Switching the req_type allows us to keep that code 246 # in one place 247 $req_type = "bydiff"; 248 my $results = lookup_diff($ipprc, $rowList, $imagedb, $id, $component, 1, $option_mask, $stage, $verbose); 249 return $results; 250 } 251 252 my ($release_name, $survey) = get_release_info($row); 253 254 if ($req_type eq "bydiff") { 255 # for bydiff reuqests we go look up the diffRun to obtain exp_id, chip_id, warp_id, stack_id, or 256 # the image from the diffRun 257 my $results = lookup_diff($ipprc, $rowList, $imagedb, $id, $component, 0, $option_mask, $stage, $verbose); 258 if (!$results) { 259 return undef; 260 } 261 if ($stage eq "diff") { 262 # lookup_diff has done all of the work 263 return $results; 264 } 265 266 my $image = $results->[0]; 267 if ($stage eq "raw") { 268 $req_type = "byid"; 269 $id = $image->{exp_id}; 270 return undef if !$id; 271 # fall through and lookup byid 272 } elsif ($stage eq "chip") { 273 $req_type = "byid"; 274 $id = $image->{chip_id}; 275 return undef if !$id; 276 # fall through and lookup byid 277 } elsif ($stage eq "warp") { 278 $req_type = "byid"; 279 $id = $image->{warp_id}; 280 $component = $image->{skycell_id}; 281 return undef if !$id; 282 # fall through and lookup by warp_id 283 } elsif ($stage eq "stack") { 284 $req_type = "byid"; 285 $id = $image->{stack_id}; 286 return undef if !$id; 287 # fall though and lookup by stack_id 288 } else { 289 # This is checked this elsewhere? 290 print STDERR "Error: $stage is an unknown image type\n"; 291 return undef; 292 } 293 } elsif ($req_type eq "byskycell") { 294 if (($stage eq "raw") or ($stage eq "chip")) { 295 print STDERR "REQ_TYPE byskycell not supported for IMG_TYPE raw or chip\n"; 296 return undef; 297 } 298 if (!$tess_id or !$component) { 299 print STDERR "component and tess_id are required for REQ_TYPE byskycell\n"; 300 return undef; 301 } 302 } 303 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, 306 undef, $release_name, $survey, 307 $verbose); 171 308 172 309 return $results; … … 193 330 my $mjd_min = shift; 194 331 my $mjd_max = shift; 332 my $selectedAstrom = shift; 333 my $release_name = shift; 334 my $survey = shift; 195 335 my $verbose = shift; 196 336 … … 217 357 my $magic_arg = $need_magic ? " -destreaked" : ""; 218 358 359 my $row = $rowList->[0]; 360 219 361 # all rows have the same center type 220 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 } 221 373 222 374 my $component_args; … … 249 401 # use chiptool -processsedimfile. Otherwise use chiptool -listrun and then 250 402 # choose the chips containing the center pixel by calling selectComponets() below 251 if ($component or $use_imfile_id or !$skycenter) { 252 $command = "$chiptool -processedimfile -pstamp_order -dbname $imagedb"; 253 if ($component and $component ne 'all') { 254 $class_id = $component; 255 $component_args = " -class_id $class_id"; 256 } 257 } else { 258 $command = "$chiptool -listrun -pstamp_order -dbname $imagedb"; 403 if ($use_releasetool) { 404 $command = "$releasetool -dbname $imagedb -priority_order -listrelexp $release_args"; 259 405 $choose_components = 1; 260 } 261 $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 } 262 420 # XXX: perhaps we should stop resolving images to this level here and do it at job run time. 263 421 # With the mdc file it has all of the information that it needs. … … 273 431 $want_astrom = 1; 274 432 $set_class_id = 1; 275 } elsif ($stage eq "warp") { 276 if ($component or $use_imfile_id or !$skycenter) { 277 $command = "$warptool -warped -pstamp_order -dbname $imagedb"; 278 if ($component and $component ne 'all') { 279 $skycell_id = $component; 280 $component_args = " -skycell_id $skycell_id"; 281 } 282 } else { 283 $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"; 284 436 $choose_components = 1; 285 } 286 $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 } 287 451 $image_name = "PSWARP.OUTPUT"; 288 452 $mask_name = "PSWARP.OUTPUT.MASK"; … … 292 456 $base_name = "path_base"; # name of the field for the warptool output 293 457 } elsif ($stage eq "diff") { 458 # XXX: is this path ever used for diff images anymore? 294 459 if ($component or $use_imfile_id or !$skycenter) { 295 460 $command = "$difftool -diffskyfile -pstamp_order -dbname $imagedb"; … … 312 477 } elsif ($stage eq "stack") { 313 478 $skycell_id = $component; 314 $command = "$stacktool -sumskyfile -dbname $imagedb"; 315 # only consider stacks in full state. 316 $command .= " -state full"; 317 $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 } 318 489 $component_args = " -skycell_id $skycell_id" if $skycell_id and $skycell_id ne 'all'; 319 490 … … 329 500 # this is wrong but gets the right answer. Need to figure out how to find the 330 501 # rule properly 331 #$cmf_name = "PSPHOT.OUTPUT"; # this puts .fpa. in the name332 502 $cmf_name = "PSWARP.OUTPUT.SOURCES"; 503 # $cmf_name = "PSPHOT.OUTPUT"; # this puts .fpa. in the name 333 504 $psf_name = "PPSTACK.TARGET.PSF"; 334 $base_name = "path_base";335 505 } else { 336 die "Unknown IMG_TYP esupplied: $stage";506 die "Unknown IMG_TYPE supplied: $stage"; 337 507 } 338 508 … … 377 547 if (!isnull($data_group)) { 378 548 $command .= " -data_group $data_group"; 379 } 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? 380 551 $command .= $default_data_groups; 381 552 } … … 392 563 $images = filterRuns($stage, $need_magic, $images, $inverse, $verbose); 393 564 } 565 394 566 if ($choose_components) { 395 567 # the list of "images" is actually a list of "Runs" 396 568 # match the coords in the rows to the components in the runs 397 569 # returns an actual list of images 398 $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 } 399 575 } else { 400 # 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 401 577 setRowRefs($rowList, $images); 402 578 } … … 462 638 # dquery wants these set 463 639 $out->{magicked} = 0; 464 $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 } 465 648 } 466 649 $out->{stage_id} = $stage_id; … … 470 653 my $mask_base; 471 654 if ($want_astrom) { 472 if (! defined $out->{astrom}) { 655 if ($selectedAstrom) { 656 $out->{astrom} = $selectedAstrom; 657 $out->{cam_path_base} = basename($selectedAstrom); 658 } elsif (! defined $out->{astrom}) { 473 659 if (! find_astrometry($ipprc, $imagedb, $out, $verbose)) { 474 660 print STDERR "failed to find astrometry for $stage $stage_id\n"; … … 505 691 my $byid = shift; 506 692 my $option_mask = shift; 507 my $ img_type = shift;693 my $stage = shift; 508 694 my $verbose = shift; 509 695 … … 573 759 # we have a stack - stack diff (well it might be stack - warp....) 574 760 # but at any rate we only handle image type diff and stack 575 if (($ img_type ne "diff") and ($img_type ne "stack")) {576 print STDERR "lookup_diff: cannot lookup IMG_TYPE $ img_type bydiff from a stack stack diff run\n";761 if (($stage ne "diff") and ($stage ne "stack")) { 762 print STDERR "lookup_diff: cannot lookup IMG_TYPE $stage bydiff from a stack stack diff run\n"; 577 763 setErrorCodes($rowList, $PSTAMP_INVALID_REQUEST); 578 764 # all images will be the same so we can stop … … 625 811 } 626 812 627 if ($ img_type eq "diff") {813 if ($stage eq "diff") { 628 814 my @imageList = ($image); 629 815 … … 656 842 sub lookup_bycoord { 657 843 my $ipprc = shift; 658 my $row List= shift;844 my $row = shift; 659 845 my $imagedb = shift; 660 my $ img_type= shift;846 my $stage = shift; 661 847 my $tess_id = shift; 662 848 my $component = shift; … … 671 857 my $mjd_min = shift; 672 858 my $mjd_max = shift; 859 my $astrom = shift; 673 860 my $verbose = shift; 674 861 862 my ($release_name, $survey) = get_release_info($row); 863 864 my $rowList = [$row]; 865 675 866 my $results = (); 676 if (($ img_type eq "raw") or ($img_type eq "chip")) {677 678 my $chips = lookup_by_cam_id_and_coords($ipprc, $imagedb, $ img_type,679 $ra, $dec, $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $verbose );867 if (($stage eq "raw") or ($stage eq "chip")) { 868 869 my $chips = lookup_by_cam_id_and_coords($ipprc, $imagedb, $stage, 870 $ra, $dec, $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $verbose, $release_name, $survey, $row->{FWHM_MIN}, $row->{FWHM_MAX}); 680 871 681 872 if (!$chips or scalar @$chips == 0) { … … 684 875 foreach my $chip (@$chips) { 685 876 next if $component and ($chip->{component} ne $component); 686 my $these_results = lookup($ipprc, $rowList, $imagedb, "byid", $ img_type, $chip->{id},877 my $these_results = lookup($ipprc, $rowList, $imagedb, "byid", $stage, $chip->{id}, 687 878 $tess_id, $chip->{component}, $need_magic, 688 $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); 689 882 690 883 next if !$these_results; … … 695 888 } else { 696 889 # this should have been checked elsewhere 697 die "unexpected image type $ img_type" if ($img_type ne "warp")698 and ($ img_type ne "stack") and ($img_type ne "diff");890 die "unexpected image type $stage" if ($stage ne "warp") 891 and ($stage ne "stack") and ($stage ne "diff"); 699 892 700 893 my $skycells = lookup_skycell_by_coords($ipprc, $tess_id, $component, $ra, $dec, $verbose); … … 704 897 } else { 705 898 foreach my $skycell (@$skycells) { 706 my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $ img_type, undef,899 my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $stage, undef, 707 900 $skycell->{tess_id}, $skycell->{component}, $need_magic, 708 $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); 709 904 710 905 next if !$these_results; … … 722 917 723 918 sub lookup_by_cam_id_and_coords { 724 my $ipprc = shift;725 my $imagedb = shift;726 my $ img_type= shift;727 my $ra = shift;728 my $dec = shift;729 my $need_magic = shift;919 my $ipprc = shift; 920 my $imagedb = shift; 921 my $stage = shift; 922 my $ra = shift; 923 my $dec = shift; 924 my $need_magic = shift; 730 925 my $dateobs_begin = shift; 731 926 my $dateobs_end = shift; … … 733 928 my $data_group = shift; 734 929 my $verbose = shift; 735 736 my $camruns; 737 738 { 739 my $search_radius = 1.6; # XXX: this should be camera specific 740 930 my $release_name = shift; 931 my $survey = shift; 932 my $fwhm_min = shift; 933 my $fwhm_max = shift; 934 935 my $search_radius = 1.6; # XXX: this should be camera specific 936 937 my $command; 938 my $using_camtool = 0; 939 if ($release_name or $survey) { 940 $command = "$releasetool -dbname $imagedb -listrelexp"; 941 if (!isnull($survey)) { 942 $command .= " -survey_name $survey"; 943 } 944 if (!isnull($release_name)) { 945 $command .= " -release_name $release_name"; 946 } else { 947 $command .= " -priority_order"; 948 } 949 if ($fwhm_min != 0) { 950 $command .= " -fwhm_min $fwhm_min"; 951 } 952 if ($fwhm_max != 0) { 953 $command .= " -fwhm_max $fwhm_max"; 954 } 955 } else { 956 $using_camtool = 1; 741 957 my $command = "$camtool -dbname $imagedb -processedexp -pstamp_order"; 742 $command .= " -ra $ra -decl $dec -radius $search_radius";743 $command .= " -dateobs_begin $dateobs_begin" if $dateobs_begin;744 $command .= " -dateobs_end $dateobs_end" if $dateobs_end ;745 $command .= " -filter $filter" if $filter;746 958 # NOTE: we are applying the data_group to the camera run. 747 959 # If we're looking for chip stage images there is no guarentee that … … 755 967 } 756 968 $command .= " -destreaked" if $need_magic; 757 758 # run the tool and parse the output 759 $camruns = runToolAndParse($command, $verbose); 760 } 761 if (!$camruns) { 969 } 970 $command .= " -ra $ra -decl $dec -radius $search_radius"; 971 $command .= " -dateobs_begin $dateobs_begin" if $dateobs_begin; 972 $command .= " -dateobs_end $dateobs_end" if $dateobs_end ; 973 $command .= " -filter $filter" if $filter; 974 975 # run the tool and parse the output 976 my $results = runToolAndParse($command, $verbose); 977 if (!$results) { 762 978 return undef; 763 979 } 764 980 my $components; 765 981 my $last_exp_id = 0; 766 foreach my $camRun (@$camruns) { 767 my $cam_id = $camRun->{cam_id}; 768 my $exp_id = $camRun->{exp_id}; 769 982 foreach my $result (@$results) { 983 my $cam_id = $result->{cam_id}; 984 my $exp_id = $result->{exp_id}; 985 986 # go on if we already have a result for this exposure 770 987 next if $exp_id eq $last_exp_id; 771 988 772 next if $camRun->{quality}; 773 next if $camRun->{fault}; 774 775 updateCamRunCache($camRun); 989 next if $result->{quality}; 990 991 if ($using_camtool) { 992 next if $result->{fault}; 993 } else { 994 $result->{path_base} = $result->{cam_path_base}; 995 } 996 updateCamRunCache($result); 776 997 777 998 $last_exp_id = $exp_id; 778 999 779 1000 # XXX Use file rule 780 my $astrom = $ camRun->{path_base} . ".smf";1001 my $astrom = $result->{path_base} . ".smf"; 781 1002 my $astrom_resolved = $ipprc->file_resolve($astrom); 782 1003 next if !$astrom_resolved; … … 832 1053 } 833 1054 834 print "cam_id $cam_id exp_id $ camRun->{exp_id} chip_id $camRun->{chip_id} $class_id\n";1055 print "cam_id $cam_id exp_id $result->{exp_id} chip_id $result->{chip_id} $class_id\n"; 835 1056 836 1057 # build the hash to return … … 840 1061 # problem 841 1062 my $comp = { 842 exp_id => $ camRun->{exp_id},843 exp_name => $ camRun->{exp_name},844 chip_id => $ camRun->{chip_id},845 cam_id => $ camRun->{cam_id},1063 exp_id => $result->{exp_id}, 1064 exp_name => $result->{exp_name}, 1065 chip_id => $result->{chip_id}, 1066 cam_id => $result->{cam_id}, 846 1067 class_id => $class_id, 847 component => $class_id 1068 component => $class_id, 1069 astrom => $astrom 848 1070 }; 849 if ($ img_type eq "chip") {850 $comp->{id} = $ camRun->{chip_id};851 $comp->{state} = $ camRun->{chip_state};852 $comp->{magicked} = $camRun->{chip_magicked};853 } else { 854 $comp->{id} = $ camRun->{exp_id};1071 if ($stage eq "chip") { 1072 $comp->{id} = $result->{chip_id}; 1073 $comp->{state} = $result->{chip_state}; 1074 $comp->{magicked} = 0; 1075 } else { 1076 $comp->{id} = $result->{exp_id}; 855 1077 $comp->{state} = 'full'; 856 $comp->{magicked} = $ camRun->{raw_magicked};1078 $comp->{magicked} = $0; 857 1079 } 858 1080 push @$components, $comp; … … 1281 1503 } 1282 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 1283 1568 sub filterRuns { 1284 1569 my $stage = shift; … … 1407 1692 $dvoImagesAtCoords = can_run('dvoImagesAtCoords') or (warn "Can't find dvoImagesAtCoords" 1408 1693 and $missing_tools = 1); 1694 $releasetool = can_run('releasetool') or (warn "Can't find releasetool" 1695 and $missing_tools = 1); 1409 1696 $whichimage = can_run('whichimage') or (warn "Can't find whichimage" and $missing_tools = 1); 1410 1697 $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); … … 1462 1749 } 1463 1750 1751 sub get_release_info { 1752 my $row = shift; 1753 1754 my $survey; 1755 my $release_name = $row->{IPP_RELEASE}; 1756 if (isnull($release_name)) { 1757 $release_name = ""; 1758 # no release check for survey 1759 $survey = $row->{SURVEY_NAME}; 1760 } else { 1761 $survey = ""; 1762 } 1763 1764 return ($release_name, $survey); 1765 } 1766 1464 1767 sub my_die 1465 1768 {
Note:
See TracChangeset
for help on using the changeset viewer.
