Changeset 38077
- Timestamp:
- Apr 1, 2015, 12:39:27 PM (11 years ago)
- File:
-
- 1 edited
-
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm
r36645 r38077 83 83 ($req_type ne "byskycell"); 84 84 85 if (0) { 85 86 if (!$data_group and !$default_data_groups) { 86 87 $default_data_groups = load_data_groups($verbose); 87 88 } 89 } 88 90 89 91 my $dateobs_begin; … … 211 213 my $mjd_max = $row->{MJD_MAX}; 212 214 my $data_group = $row->{DATA_GROUP}; 215 216 # default_data_groups is a concept far past it's sell by date 217 if (0) { 213 218 if (isnull($data_group) and !$default_data_groups) { 214 219 $default_data_groups = load_data_groups($verbose); 215 220 } 221 } 216 222 217 223 my $rownum = $row->{ROWNUM}; … … 273 279 my ($release_name, $survey, $default_tess_id) = get_release_info($row); 274 280 if (!$tess_id and $default_tess_id) { 275 $tess_id = $default_tess_id; 281 # Don't want to set default tess_id in this context 282 # byid: no the tess_id is defined by the run 283 # byexp warp: This is the one case where it might make sense to use a default to avoid double lookup. 284 # this could be avoided if we did a two level lookup in that case. Find the warpRun first then use the 285 # run's tess id to find the specific skycell(s). 286 # bydiff: no tess_id defined by the diff 287 # byskycell requires tess_id so this does not apply 288 # note: currently get_release_info only sets default_tess_id for byskycell and bycoord requests 289 if (ref($default_tess_id) eq 'ARRAY') { 290 $tess_id = $default_tess_id->[0]; 291 } else { 292 $tess_id = $default_tess_id; 293 } 276 294 } 277 295 … … 393 411 my $release_args; 394 412 if (($req_type eq 'byexp' and $stage ne 'raw') or ($req_type eq 'byskycell' and $stage ne 'diff')) { 395 if ($release_name or $survey) { 413 # XXX: Think hard before committing the change to use releasetool for byexp requests regardless. 414 # XXX: using releasetool by default for byexp requests will break for nightly data when 415 # the release table survey task breaks. 416 # (MOPS one off requests for last night's data) 417 # we could fall back and do the old style lookup in that case. 418 # Need to fix the duplicate camRun problem. 419 my $force_releasetool_for_byexp = 0; 420 if ($release_name or $survey or ($force_releasetool_for_byexp and ($req_type eq 'byexp'))) { 396 421 $use_releasetool = 1; 397 422 if ($release_name) { … … 599 624 $command .= " -data_group $data_group"; 600 625 } elsif (!$use_releasetool and $req_type eq 'byskycell') { 601 # XXX: Why am I using default data_groups only for byskycell requests? 626 # Default data_groups are used by bycoord in the camera run lookup and 627 # here for byskycell. 602 628 $command .= $default_data_groups; 603 629 } … … 773 799 my ($release_name, $survey, $default_tess_id) = get_release_info($row); 774 800 if (!$tess_id and $default_tess_id) { 775 $tess_id = $default_tess_id; 801 if (ref($default_tess_id) eq 'ARRAY') { 802 # XXX: handle the case where default_tess_id is an array 803 # For now just take the first entry (RINGS.V3) 804 $tess_id = $default_tess_id->[0]; 805 } else { 806 $tess_id = $default_tess_id; 807 } 776 808 } 777 809 … … 1061 1093 1062 1094 1095 my @tess_ids; 1063 1096 my ($release_name, $survey, $default_tess_id) = get_release_info($row); 1064 if (!$tess_id and $default_tess_id) { 1065 $tess_id = $default_tess_id; 1097 if ($tess_id) { 1098 push @tess_ids, $tess_id; 1099 } elsif ($default_tess_id) { 1100 if (ref($default_tess_id) eq 'ARRAY') { 1101 @tess_ids = @$default_tess_id; 1102 } else { 1103 push @tess_ids, $default_tess_id; 1104 } 1066 1105 } 1067 1106 1068 1107 my $rowList = [$row]; 1069 1108 1070 my $results = ();1109 my $results = []; 1071 1110 if (($stage eq "raw") or ($stage eq "chip")) { 1072 1111 … … 1081 1120 next if $component and ($chip->{component} ne $component); 1082 1121 my $these_results = lookup($ipprc, $rowList, $imagedb, "byid", $stage, $chip->{id}, 1083 $tess_id, $chip->{component}, $need_magic, 1122 # lookup doesn't need tess_id in this context 1123 # $tess_id, 1124 undef, 1125 $chip->{component}, $need_magic, 1084 1126 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, 1085 1127 $fwhm_min, $fwhm_max, … … 1097 1139 and ($stage ne "stack") and ($stage ne "diff"); 1098 1140 1099 my $skycells = lookup_skycell_by_coords($ipprc, $tess_id, $component, $ra, $dec, $verbose); 1100 1101 if (!$skycells or scalar @$skycells == 0) { 1141 foreach my $tess_id (@tess_ids) { 1142 my $skycells = lookup_skycell_by_coords($ipprc, $tess_id, $component, $ra, $dec, $verbose); 1143 1144 if ($skycells and scalar @$skycells != 0) { 1145 # XXX: We are not applying the fwhm cuts unless we use releasetool 1146 foreach my $skycell (@$skycells) { 1147 my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $stage, undef, 1148 $skycell->{tess_id}, $skycell->{component}, $need_magic, 1149 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max, 1150 $fwhm_min, $fwhm_max, 1151 undef, 0, $release_name, $survey, 1152 $verbose); 1153 1154 next if !$these_results; 1155 push @$results, @$these_results; 1156 } 1157 } 1158 } 1159 if (scalar @$results == 0) { 1102 1160 setErrorCodes($rowList, $PSTAMP_NO_IMAGE_MATCH); 1103 } else {1104 # XXX: We are not applying the fwhm cuts unless we use releasetool1105 foreach my $skycell (@$skycells) {1106 my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $stage, undef,1107 $skycell->{tess_id}, $skycell->{component}, $need_magic,1108 $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max,1109 $fwhm_min, $fwhm_max,1110 undef, 0, $release_name, $survey,1111 $verbose);1112 1113 next if !$these_results;1114 push @$results, @$these_results;1115 }1116 1161 } 1117 1162 } … … 1976 2021 } 1977 2022 2023 # get user supplied release paramters and the asssociated default_tess_id. 2024 # If release parameters are not supplied set defaults. 1978 2025 sub get_release_info { 1979 2026 my $row = shift; … … 1985 2032 # no release check for survey 1986 2033 $survey = isnull($row->{SURVEY_NAME}) ? "" : $row->{SURVEY_NAME}; 1987 } else { 1988 # if release is given leave survey empty 1989 $survey = ""; 1990 } 1991 1992 my $tess_id; 1993 if ($release_name) { 1994 # hack to optimize bycoord and byskycell lookups for well known releases 1995 # XXX: todo query database and return a list for the survey or release 1996 if ($release_name eq '3PI.PV1') { 1997 $tess_id = 'RINGS.V3'; 1998 } 1999 } 2000 2001 return ($release_name, $survey, $tess_id); 2034 } 2035 2036 # XXX: From here down this function is currently very PS1 specific and depends on 2037 # conventions being used for release names. 2038 # The comments following the lines marked 'XXX to improve' give suggestions on 2039 # how these hacks can be cleaned up. 2040 2041 my $tess_id = $row->{TESS_ID}; 2042 if (!$release_name and !$survey) { 2043 # no release or survey. If user does not supply 2044 # a data group use a default survey 2045 my $req_type = $row->{REQ_TYPE}; 2046 if ($req_type eq "bycoord" or $req_type eq 'byskycell') { 2047 # USING 3PI for bycoord and byskycell requests 2048 # XXX to improve 2049 # get default survey from project 2050 my $data_group = $row->{DATA_GROUP}; 2051 if (isnull($data_group) and isnull($tess_id)) { 2052 print "No release information supplied for this row. Defaulting to 3PI survey\n"; 2053 $survey = '3PI'; 2054 } 2055 } 2056 } 2057 2058 # if survey was not supplied, guess it from the release_name. This is used below 2059 # to choose the default_tess_id 2060 if (!$survey) { 2061 if ($release_name) { 2062 # XXX: to improve 2063 # get survey from ippRelease(release_name) in database. Would need to cache 2064 # such results 2065 if ($release_name =~ "^3PI") { 2066 $survey = '3PI'; 2067 } elsif ($release_name =~ "^MD") { 2068 $survey = substr($release_name, 0, 4); 2069 } elsif ($release_name =~ "^SSS") { 2070 $survey = 'SSS'; 2071 } elsif ($release_name =~ "^SAS") { 2072 $survey = 'SAS'; 2073 } else { 2074 # we don't know 2075 print "Can't guess survey for $release_name\n"; 2076 } 2077 } elsif (!isnull($tess_id)) { 2078 # finally if it is a MD tessellation use the MD field as the survey 2079 # (This will also work for M31 and STS when that data is released. 2080 if ($tess_id =~ "^MD") { 2081 $survey = substr($tess_id, 0, 4); 2082 } 2083 } 2084 } 2085 2086 # choose default tess_id based on the survey 2087 2088 # Note: Setting a default_tess_id effectively disables lookup bycoord requests 2089 # for previous tessellations unless the user supplies the tess_id (which is 2090 # applied by the caller to this function). 2091 # bills has decided that this is desirable behaviour since most everything has 2092 # been processed on a V3 tess. 2093 my $default_tess_id; 2094 if ($survey) { 2095 # XXX: to improve 2096 # Put default tess_id in survey table. 2097 # note users will need to supply tessellation to get at 3pi skycells 2098 # in the cnp tessellation. Hmm. Maybe we need to be clever and look 2099 # at declination or perhaps allow default_tess_id to be an array. 2100 if ($survey eq '3PI') { 2101 $default_tess_id = ['RINGS.V3', 'CNP.V3']; 2102 } elsif ($survey eq 'SSS' or $survey eq 'SAS') { 2103 $default_tess_id = 'RINGS.V3'; 2104 } elsif ($survey =~ 'MD') { 2105 $default_tess_id = $survey . '.V3'; 2106 } 2107 } 2108 2109 # leave the returned survey blank if release_name was supplied 2110 # XXX: Why? Answer: this is how this function always behaved and I'm not sure if the 2111 # callers depend on that behavior. 2112 $survey = "" if $release_name; 2113 2114 return ($release_name, $survey, $default_tess_id); 2002 2115 } 2003 2116 … … 2007 2120 if (!isnull($run_type)) { 2008 2121 $run_type = lc($run_type); 2122 # XXX: these diff_mode values should be defined somewhere else. 2009 2123 if ($run_type eq 'warp_warp') { 2010 2124 $diff_mode = 1;
Note:
See TracChangeset
for help on using the changeset viewer.
