Changeset 36010 for trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
- Timestamp:
- Aug 22, 2013, 4:12:08 PM (13 years ago)
- File:
-
- 1 edited
-
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r35996 r36010 244 244 if (isnull($filter)) { 245 245 $filter = undef; 246 } 247 248 if ($stage eq 'stack_summary') { 249 # stack_summary jobs are so different from others that we lookup in a unique function 250 return lookup_stack_summary($ipprc, $row, $imagedb, $tess_id, $component, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose); 246 251 } 247 252 … … 736 741 } 737 742 743 sub lookup_stack_summary { 744 my ($ipprc, $row, $imagedb, $tess_id, $component, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, $verbose) = @_; 745 746 $row->{error_code} = $PSTAMP_NO_IMAGE_MATCH; 747 748 my $req_type = $row->{REQ_TYPE}; 749 my $results; 750 if ($req_type eq 'byid') { 751 my $sass_id = $row->{ID}; 752 my $command = "$stacktool -dbname $imagedb -summary -sass_id $sass_id"; 753 $results = runToolAndParse($command, $verbose); 754 } else { 755 my $skycells; 756 if ($req_type eq 'bycoord') { 757 my $ra = $row->{CENTER_X}; 758 my $dec = $row->{CENTER_Y}; 759 $skycells = lookup_skycell_by_coords($ipprc, $tess_id, $component, $ra, $dec, $verbose); 760 } elsif ($req_type eq 'byskycell') { 761 if (!defined $tess_id or !defined $component) { 762 print STDERR "Error: TESS_ID and COMPONENT are required for REQ_TYPE byskycell\n"; 763 $row->{error_code} = $PSTAMP_INVALID_REQUEST; 764 } 765 my $skycell = { 766 tess_id => $tess_id, 767 component => $component 768 }; 769 push @$skycells, $skycell 770 } else { 771 print STDERR "Error: $req_type is not a valid REQ_TYPE for IMG_TYPE stack_summary\n"; 772 $row->{error_code} = $PSTAMP_INVALID_REQUEST; 773 return undef; 774 } 775 776 if ($skycells) { 777 foreach my $skycell (@$skycells) { 778 my $tess_id = $skycell->{tess_id}; 779 my $skycell_id = $skycell->{component}; 780 781 my $projection_cell = skycell_id_to_projection_cell($skycell_id); 782 783 print "$tess_id $skycell_id $projection_cell\n"; 784 my $command = "$stacktool -dbname $imagedb -summary -tess_id $tess_id -projection_cell $projection_cell"; 785 786 $command .= " -filter $filter" if $filter; 787 $command .= " -data_group $data_group" if $data_group; 788 789 my $these_results = runToolAndParse($command, $verbose); 790 push @$results, @$these_results if $these_results; 791 } 792 } 793 # XXX: Lookup stackSummaries that match 794 } 795 if ($results) { 796 foreach my $summary (@$results) { 797 my $path_base = $summary->{path_base}; 798 my $projection_cell = $summary->{projection_cell}; 799 800 # we need to flesh out the hashes returned with values that the parser expects 801 $summary->{component} = $projection_cell; 802 $summary->{stage_id} = $summary->{sass_id}; 803 # $summary->{image} = "$path_base.$projection_cell.image.b1.fits"; 804 $summary->{image} = "$path_base.$projection_cell"; 805 $summary->{state} = 'full'; 806 $summary->{data_state} = 'full'; 807 $summary->{fault} = 0; 808 $summary->{imagedb} = $imagedb; 809 $summary->{row_index} = []; 810 push @{$summary->{row_index}}, 0; 811 # XXX: is there anything else? 812 # TODO: create a function to validate the components returned 813 # and make sure that any required elements are there 814 } 815 } 816 817 return $results; 818 } 738 819 sub lookup_diff { 739 820 my $ipprc = shift; … … 1878 1959 return $diff_mode; 1879 1960 } 1961 1962 sub setErrorCodesForRows { 1963 my $rowList = shift; 1964 my $error_code = shift; 1965 1966 foreach my $row (@$rowList) { 1967 $row->{error_code} = $error_code; 1968 } 1969 1970 } 1971 1972 # not particularly elegant 1973 sub skycell_id_to_projection_cell { 1974 my $skycell_id = shift; 1975 my @strs = split '\.', $skycell_id; 1976 1977 my $num = scalar @strs; 1978 my $projection_cell = $strs[0]; 1979 for (my $i=1; $i < $num - 1; $i++) { 1980 $projection_cell .= ".$strs[$i]"; 1981 } 1982 1983 return $projection_cell; 1984 } 1880 1985 1881 1986
Note:
See TracChangeset
for help on using the changeset viewer.
