IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 1, 2015, 12:39:27 PM (11 years ago)
Author:
bills
Message:

Remove the "past its sell by date" default_data_groups concept. The list quickly beomes
stale. Users who want the best results need to use SURVEY/IPP_RELEASE to be sure
to get properly selected data.
Change to using releasetool for lookups in more instances by guessing/defaulting the
SURVEY when it isn't supplied based on tess_id and data_group. If no guess is found
we default to 3PI for bycoord and byskycell requests.
"byexp" requests still fall back to not using releasetool if survey is not supplied
because the release tables sometimes become stale if duplicate camRuns get queued
for an exposure. We need MOPS' directly submitted requests to succeed. This can
be changed once camera run queuing is hardened to fail if a duplicate is attempted to
be queued.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r36645 r38077  
    8383           ($req_type ne "byskycell");
    8484
     85if (0) {
    8586    if (!$data_group and !$default_data_groups) {
    8687        $default_data_groups = load_data_groups($verbose);
    8788    }
     89}
    8890
    8991    my $dateobs_begin;
     
    211213    my $mjd_max   = $row->{MJD_MAX};
    212214    my $data_group = $row->{DATA_GROUP};
     215
     216    # default_data_groups is a concept far past it's sell by date
     217if (0) {
    213218    if (isnull($data_group) and !$default_data_groups) {
    214219        $default_data_groups = load_data_groups($verbose);
    215220    }
     221}
    216222
    217223    my $rownum     = $row->{ROWNUM};
     
    273279    my ($release_name, $survey, $default_tess_id) = get_release_info($row);
    274280    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        }
    276294    }
    277295
     
    393411    my $release_args;
    394412    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'))) {
    396421            $use_releasetool = 1;
    397422            if ($release_name) {
     
    599624        $command .= " -data_group $data_group";
    600625    } 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.
    602628        $command .= $default_data_groups;
    603629    }
     
    773799        my ($release_name, $survey, $default_tess_id) = get_release_info($row);
    774800        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            }
    776808        }
    777809
     
    10611093   
    10621094
     1095    my @tess_ids;
    10631096    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        }
    10661105    }
    10671106
    10681107    my $rowList = [$row];
    10691108
    1070     my $results = ();
     1109    my $results = [];
    10711110    if (($stage eq "raw") or ($stage eq "chip")) {
    10721111
     
    10811120                next if $component and ($chip->{component} ne $component);
    10821121                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,
    10841126                    $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max,
    10851127                    $fwhm_min, $fwhm_max,
     
    10971139                                              and ($stage ne "stack") and ($stage ne "diff");
    10981140
    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) {
    11021160            setErrorCodes($rowList, $PSTAMP_NO_IMAGE_MATCH);
    1103         } else {
    1104             # XXX: We are not applying the fwhm cuts unless we use releasetool
    1105             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             }
    11161161        }
    11171162    }
     
    19762021}
    19772022
     2023# get user supplied release paramters and the asssociated default_tess_id.
     2024# If release parameters are not supplied set defaults.
    19782025sub get_release_info {
    19792026    my $row = shift;
     
    19852032        # no release check for survey
    19862033        $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);
    20022115}
    20032116
     
    20072120    if (!isnull($run_type)) {
    20082121        $run_type = lc($run_type);
     2122        # XXX: these diff_mode values should be defined somewhere else.
    20092123        if ($run_type eq 'warp_warp') {
    20102124            $diff_mode = 1;
Note: See TracChangeset for help on using the changeset viewer.