Changeset 35384 for trunk/PS-IPP-PStamp
- Timestamp:
- Apr 9, 2013, 2:08:27 PM (13 years ago)
- Location:
- trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp
- Files:
-
- 2 edited
-
Job.pm (modified) (25 diffs)
-
RequestFile.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r35315 r35384 15 15 our @EXPORT_OK = qw( 16 16 locate_images 17 new_locate_images 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 (!$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,172 my $results = lookup($ipprc, $rowList, $imagedb, $req_type, $stage, $id, $tess_id, $component, 170 173 $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); 174 175 return $results; 176 } 177 178 sub new_locate_images { 179 my $ipprc = shift; 180 my $imagedb = shift; 181 my $camera = shift; 182 my $row = shift; 183 my $verbose = shift; 184 185 my $req_type = $row->{REQ_TYPE}; 186 187 # we die in response to bad data in request files 188 # The caller is responsible for updating the database 189 # pstampparse.pl error checks now so this shouldn't happen 190 &my_die("Unknown req_type: $req_type", $PS_EXIT_PROG_ERROR) 191 if ($req_type ne "byid") and 192 ($req_type ne "byexp") and 193 ($req_type ne "bycoord") and 194 ($req_type ne "bydiff") and 195 ($req_type ne "byskycell"); 196 197 if (!$default_data_groups) { 198 $default_data_groups = load_data_groups($verbose); 199 } 200 201 my $stage = $row->{IMG_TYPE}; 202 my $id = $row->{ID}; 203 my $component = $row->{COMPONENT}; 204 my $tess_id = $row->{TESS_ID}; 205 206 my $filter = $row->{REQFILT}; 207 my $mjd_min = $row->{MJD_MIN}; 208 my $mjd_max = $row->{MJD_MAX}; 209 my $data_group = $row->{DATA_GROUP}; 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 234 235 if ($req_type eq "bycoord") { 236 my $x = $row->{CENTER_X}; 237 my $y = $row->{CENTER_Y}; 238 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); 239 return $results; 240 } 241 242 # for compatability with the lower level functions 243 my $rowList = [$row]; 244 245 if (($req_type eq "byid") and ($stage eq "diff")) { 246 # lookups of all of the information for diff images requires a two level lookup to 247 # get the exposure information. Switching the req_type allows us to keep that code 248 # in one place 249 $req_type = "bydiff"; 250 my $results = lookup_diff($ipprc, $rowList, $imagedb, $id, $component, 1, $option_mask, $stage, $verbose); 251 return $results; 252 } 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, $verbose); 171 306 172 307 return $results; … … 505 640 my $byid = shift; 506 641 my $option_mask = shift; 507 my $ img_type = shift;642 my $stage = shift; 508 643 my $verbose = shift; 509 644 … … 573 708 # we have a stack - stack diff (well it might be stack - warp....) 574 709 # 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";710 if (($stage ne "diff") and ($stage ne "stack")) { 711 print STDERR "lookup_diff: cannot lookup IMG_TYPE $stage bydiff from a stack stack diff run\n"; 577 712 setErrorCodes($rowList, $PSTAMP_INVALID_REQUEST); 578 713 # all images will be the same so we can stop … … 625 760 } 626 761 627 if ($ img_type eq "diff") {762 if ($stage eq "diff") { 628 763 my @imageList = ($image); 629 764 … … 656 791 sub lookup_bycoord { 657 792 my $ipprc = shift; 658 my $row List= shift;793 my $row = shift; 659 794 my $imagedb = shift; 660 my $ img_type= shift;795 my $stage = shift; 661 796 my $tess_id = shift; 662 797 my $component = shift; … … 673 808 my $verbose = shift; 674 809 810 my ($release_name, $survey) = get_release($row); 811 812 my $rowList = [$row]; 813 675 814 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 );815 if (($stage eq "raw") or ($stage eq "chip")) { 816 817 my $chips = lookup_by_cam_id_and_coords($ipprc, $imagedb, $stage, 818 $ra, $dec, $need_magic, $dateobs_begin, $dateobs_end, $filter, $data_group, $verbose, $release_name, $survey, $row->{FWHM_MIN}, $row->{FWHM_MAX}); 680 819 681 820 if (!$chips or scalar @$chips == 0) { … … 684 823 foreach my $chip (@$chips) { 685 824 next if $component and ($chip->{component} ne $component); 686 my $these_results = lookup($ipprc, $rowList, $imagedb, "byid", $ img_type, $chip->{id},825 my $these_results = lookup($ipprc, $rowList, $imagedb, "byid", $stage, $chip->{id}, 687 826 $tess_id, $chip->{component}, $need_magic, 688 827 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); … … 695 834 } else { 696 835 # 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");836 die "unexpected image type $stage" if ($stage ne "warp") 837 and ($stage ne "stack") and ($stage ne "diff"); 699 838 700 839 my $skycells = lookup_skycell_by_coords($ipprc, $tess_id, $component, $ra, $dec, $verbose); … … 704 843 } else { 705 844 foreach my $skycell (@$skycells) { 706 my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $ img_type, undef,845 my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $stage, undef, 707 846 $skycell->{tess_id}, $skycell->{component}, $need_magic, 708 847 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); … … 722 861 723 862 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;863 my $ipprc = shift; 864 my $imagedb = shift; 865 my $stage = shift; 866 my $ra = shift; 867 my $dec = shift; 868 my $need_magic = shift; 730 869 my $dateobs_begin = shift; 731 870 my $dateobs_end = shift; … … 733 872 my $data_group = shift; 734 873 my $verbose = shift; 735 736 my $camruns; 737 738 { 739 my $search_radius = 1.6; # XXX: this should be camera specific 740 874 my $release_name = shift; 875 my $survey = shift; 876 my $fwhm_min = shift; 877 my $fwhm_max = shift; 878 879 my $search_radius = 1.6; # XXX: this should be camera specific 880 881 my $command; 882 my $using_camtool = 0; 883 if ($release_name or $survey) { 884 my $command = "$releasetool -dbname $imagedb -listrelexp"; 885 if ($survey) { 886 $command .= " -survey_name $survey"; 887 } 888 if ($release_name) { 889 $command .= " -release_name $release_name"; 890 } else { 891 $command .= " -priority_order"; 892 } 893 if ($fwhm_min != 0) { 894 $command .= " -fwhm_min $fwhm_min"; 895 } 896 if ($fwhm_max != 0) { 897 $command .= " -fwhm_max $fwhm_max"; 898 } 899 } else { 900 $using_camtool = 1; 741 901 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 902 # NOTE: we are applying the data_group to the camera run. 747 903 # If we're looking for chip stage images there is no guarentee that … … 755 911 } 756 912 $command .= " -destreaked" if $need_magic; 757 758 # run the tool and parse the output 759 $camruns = runToolAndParse($command, $verbose); 760 } 761 if (!$camruns) { 913 } 914 $command .= " -ra $ra -decl $dec -radius $search_radius"; 915 $command .= " -dateobs_begin $dateobs_begin" if $dateobs_begin; 916 $command .= " -dateobs_end $dateobs_end" if $dateobs_end ; 917 $command .= " -filter $filter" if $filter; 918 919 # run the tool and parse the output 920 my $results = runToolAndParse($command, $verbose); 921 if (!$results) { 762 922 return undef; 763 923 } 764 924 my $components; 765 925 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 926 foreach my $result (@$results) { 927 my $cam_id = $result->{cam_id}; 928 my $exp_id = $result->{exp_id}; 929 930 # go on if we already have a result for this exposure 770 931 next if $exp_id eq $last_exp_id; 771 932 772 next if $camRun->{quality}; 773 next if $camRun->{fault}; 774 775 updateCamRunCache($camRun); 933 next if $result->{quality}; 934 935 if ($using_camtool) { 936 next if $result->{fault}; 937 updateCamRunCache($result); 938 } 776 939 777 940 $last_exp_id = $exp_id; 778 941 779 942 # XXX Use file rule 780 my $astrom = $ camRun->{path_base} . ".smf";943 my $astrom = $result->{path_base} . ".smf"; 781 944 my $astrom_resolved = $ipprc->file_resolve($astrom); 782 945 next if !$astrom_resolved; … … 832 995 } 833 996 834 print "cam_id $cam_id exp_id $ camRun->{exp_id} chip_id $camRun->{chip_id} $class_id\n";997 print "cam_id $cam_id exp_id $result->{exp_id} chip_id $result->{chip_id} $class_id\n"; 835 998 836 999 # build the hash to return … … 840 1003 # problem 841 1004 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},1005 exp_id => $result->{exp_id}, 1006 exp_name => $result->{exp_name}, 1007 chip_id => $result->{chip_id}, 1008 cam_id => $result->{cam_id}, 846 1009 class_id => $class_id, 847 1010 component => $class_id 848 1011 }; 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};1012 if ($stage eq "chip") { 1013 $comp->{id} = $result->{chip_id}; 1014 $comp->{state} = $result->{chip_state}; 1015 $comp->{magicked} = 0; 1016 } else { 1017 $comp->{id} = $result->{exp_id}; 855 1018 $comp->{state} = 'full'; 856 $comp->{magicked} = $ camRun->{raw_magicked};1019 $comp->{magicked} = $0; 857 1020 } 858 1021 push @$components, $comp; … … 1407 1570 $dvoImagesAtCoords = can_run('dvoImagesAtCoords') or (warn "Can't find dvoImagesAtCoords" 1408 1571 and $missing_tools = 1); 1572 $releasetool = can_run('releasetool') or (warn "Can't find releasetool" 1573 and $missing_tools = 1); 1409 1574 $whichimage = can_run('whichimage') or (warn "Can't find whichimage" and $missing_tools = 1); 1410 1575 $ppConfigDump = can_run('ppConfigDump') or (warn "Can't find ppConfigDump" and $missing_tools = 1); … … 1462 1627 } 1463 1628 1629 sub get_release { 1630 my $row = shift; 1631 1632 my $survey; 1633 my $release_name = $row->{IPP_RELEASE}; 1634 if (!isnull($release_name)) { 1635 # no release check for survey 1636 $survey = $row->{SURVEY_NAME}; 1637 } 1638 1639 return ($release_name, $survey); 1640 } 1641 1464 1642 sub my_die 1465 1643 { -
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/RequestFile.pm
r35364 r35384 52 52 $PSTAMP_NO_OVERLAP 53 53 $PSTAMP_NOT_AUTHORIZED 54 $PSTAMP_UNKNOWN_PROJECT 54 55 ); 55 56 our %EXPORT_TAGS = (standard => [@EXPORT_OK]); … … 101 102 our $PSTAMP_NO_OVERLAP = 28; 102 103 our $PSTAMP_NOT_AUTHORIZED = 29; 104 our $PSTAMP_UNKNOWN_PROJECT = 22; 103 105 104 106
Note:
See TracChangeset
for help on using the changeset viewer.
