IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38163


Ignore:
Timestamp:
Apr 21, 2015, 10:22:57 AM (11 years ago)
Author:
bills
Message:

From the trunk. Enhanced a comment

Location:
tags/ipp-20141024/PS-IPP-PStamp
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tags/ipp-20141024/PS-IPP-PStamp

  • tags/ipp-20141024/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r36645 r38163  
    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        # we use releasetool for lookups if we get here and have a survey or release specfied and
     414        # the survey is not 'bypass'
     415        # That is a hook to allow sophisticated users to bypass the release mechanisms. Useful for
     416        # MOPS which is interested primarily in nightly data and wants to get their data immediately
     417        # without regard to timeleness of the relexp tables.
     418        # This also alows us to defer loading release tables for gpc2
     419        if ($release_name or ($survey and $survey ne 'bypass')) { 
    396420            $use_releasetool = 1;
    397421            if ($release_name) {
     
    554578        # $cmf_name    = "PSPHOT.OUTPUT";    # this puts .fpa. in the name
    555579        $psf_name    = "PPSTACK.TARGET.PSF";
     580        # XXX TODO should we filter stacks so that only one per skycell/filter combintation is returned for
     581        # most requests. Currently unless a release is provided all that match are returned.
     582        # Actually maybe that is the right answer. User's simply need to specify a release value
     583        # if that is all that they want.
    556584    } else {
     585        # this should have been caught before we get here.
    557586        die "Unknown IMG_TYPE supplied: $stage";
    558587    }
     
    590619        $command .= " -dateobs_end $dateobs_end" if $dateobs_end;
    591620    } elsif ($req_type ne "byid") {
     621        # stacks
    592622        $command .= " -mjd_obs_begin $mjd_min" if $mjd_min;
    593623        $command .= " -mjd_obs_end $mjd_max" if $mjd_max;
     
    599629        $command .= " -data_group $data_group";
    600630    } elsif (!$use_releasetool and $req_type eq 'byskycell') {
    601         # XXX: Why am I using default data_groups only for byskycell requests?
     631        # Default data_groups are used by bycoord in the camera run lookup and
     632        # here for byskycell.
    602633        $command .= $default_data_groups;
    603634    }
     
    773804        my ($release_name, $survey, $default_tess_id) = get_release_info($row);
    774805        if (!$tess_id and $default_tess_id) {
    775             $tess_id = $default_tess_id;
     806            if (ref($default_tess_id) eq 'ARRAY') {
     807                # XXX: handle the case where default_tess_id is an array
     808                # For now just take the first entry (RINGS.V3)
     809                $tess_id = $default_tess_id->[0];
     810            } else {
     811                $tess_id = $default_tess_id;
     812            }
    776813        }
    777814
     
    10611098   
    10621099
     1100    my @tess_ids;
    10631101    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;
     1102    if ($tess_id) {
     1103        push @tess_ids, $tess_id;
     1104    } elsif ($default_tess_id) {
     1105        if (ref($default_tess_id) eq 'ARRAY') {
     1106            @tess_ids = @$default_tess_id;
     1107        } else {
     1108            push @tess_ids, $default_tess_id;
     1109        }
    10661110    }
    10671111
    10681112    my $rowList = [$row];
    10691113
    1070     my $results = ();
     1114    my $results = [];
    10711115    if (($stage eq "raw") or ($stage eq "chip")) {
    10721116
     
    10811125                next if $component and ($chip->{component} ne $component);
    10821126                my $these_results = lookup($ipprc, $rowList, $imagedb, "byid", $stage, $chip->{id},
    1083                     $tess_id, $chip->{component}, $need_magic,
     1127                    # lookup doesn't need tess_id in this context
     1128                    # $tess_id,
     1129                    undef,
     1130                    $chip->{component}, $need_magic,
    10841131                    $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max,
    10851132                    $fwhm_min, $fwhm_max,
     
    10971144                                              and ($stage ne "stack") and ($stage ne "diff");
    10981145
    1099         my $skycells = lookup_skycell_by_coords($ipprc, $tess_id, $component, $ra, $dec, $verbose);
    1100 
    1101         if (!$skycells or scalar @$skycells == 0) {
     1146        foreach my $tess_id (@tess_ids) {
     1147            my $skycells = lookup_skycell_by_coords($ipprc, $tess_id, $component, $ra, $dec, $verbose);
     1148
     1149            if ($skycells and scalar @$skycells != 0) {
     1150                # XXX: We are not applying the fwhm cuts unless we use releasetool
     1151                foreach my $skycell (@$skycells) {
     1152                    my $these_results = lookup($ipprc, $rowList, $imagedb, "byskycell", $stage, undef,
     1153                        $skycell->{tess_id}, $skycell->{component}, $need_magic,
     1154                        $dateobs_begin, $dateobs_end, $filter, $data_group, $option_mask, $mjd_min, $mjd_max,
     1155                        $fwhm_min, $fwhm_max,
     1156                        undef, 0, $release_name, $survey,
     1157                        $verbose);
     1158
     1159                    next if !$these_results;
     1160                    push @$results, @$these_results;
     1161                }
     1162            }
     1163        }
     1164        if (scalar @$results == 0) {
    11021165            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             }
    11161166        }
    11171167    }
     
    19762026}
    19772027
     2028# get user supplied release paramters and the asssociated default_tess_id.
     2029# If release parameters are not supplied set defaults.
    19782030sub get_release_info {
    19792031    my $row = shift;
     
    19852037        # no release check for survey
    19862038        $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);
     2039    }
     2040
     2041    # XXX: From here down this function is currently very PS1 specific and depends on
     2042    # conventions being used for release names.
     2043    # The comments following the lines  marked 'XXX to improve' give suggestions on
     2044    # how these hacks can be cleaned up.
     2045
     2046    my $tess_id = $row->{TESS_ID};
     2047    if (!$release_name and !$survey) {
     2048        # no release or survey. If user does not supply
     2049        # a data group use a default survey
     2050        my $req_type = $row->{REQ_TYPE};
     2051        if ($req_type eq "bycoord" or $req_type eq 'byskycell') {
     2052            # USING 3PI for bycoord and byskycell requests
     2053            # XXX to improve
     2054            # get default survey from project
     2055            my $data_group = $row->{DATA_GROUP};
     2056            if (isnull($data_group) and isnull($tess_id)) {
     2057                print "No release information supplied for this row. Defaulting to 3PI survey\n";
     2058                $survey = '3PI';
     2059            }
     2060        }
     2061    }
     2062
     2063    # if survey was not supplied, guess it from the release_name. This is used below
     2064    # to choose the default_tess_id
     2065    if (!$survey) {
     2066        if ($release_name) {
     2067            # XXX: to improve
     2068            # get survey from ippRelease(release_name) in database. Would need to cache
     2069            # such results
     2070            if ($release_name =~ "^3PI") {
     2071                $survey = '3PI';
     2072            } elsif ($release_name =~ "^MD") {
     2073                $survey = substr($release_name, 0, 4);
     2074            } elsif ($release_name =~ "^SSS") {
     2075                $survey = 'SSS';
     2076            } elsif ($release_name =~ "^SAS") {
     2077                $survey = 'SAS';
     2078            } else {
     2079                # we don't know
     2080                print "Can't guess survey for $release_name\n";
     2081            }
     2082        } elsif (!isnull($tess_id)) {
     2083            # finally if it is a MD tessellation use the MD field as the survey
     2084            # (This will also work for M31 and STS when that data is released.
     2085            if ($tess_id =~ "^MD") {
     2086                $survey = substr($tess_id, 0, 4);
     2087            }
     2088        }
     2089    }
     2090
     2091    # choose default tess_id based on the survey
     2092
     2093    # Note: Setting a default_tess_id effectively disables lookup bycoord requests
     2094    # for previous tessellations unless the user supplies the tess_id (which is
     2095    # applied by the caller to this function).
     2096    # bills has decided that this is desirable behaviour since most everything has
     2097    # been processed on a V3 tess.
     2098    my $default_tess_id;
     2099    if ($survey) {
     2100        # XXX: to improve
     2101        # Put default tess_id in survey table.
     2102        # note users will need to supply tessellation to get at 3pi skycells
     2103        # in the cnp tessellation. Hmm. Maybe we need to be clever and look
     2104        # at declination or perhaps allow default_tess_id to be an array.
     2105        if ($survey eq '3PI') {
     2106            $default_tess_id = ['RINGS.V3', 'CNP.V3'];
     2107        } elsif ($survey eq 'SSS' or $survey eq 'SAS') {
     2108            $default_tess_id = 'RINGS.V3';
     2109        } elsif ($survey =~ 'MD') {
     2110            $default_tess_id = $survey . '.V3';
     2111        }
     2112    }
     2113           
     2114    # leave the returned survey blank if release_name was supplied
     2115    # XXX: Why? Answer: this is how this function always behaved and I'm not sure if the
     2116    # callers depend on that behavior.
     2117    $survey = "" if $release_name;
     2118
     2119    return ($release_name, $survey, $default_tess_id);
    20022120}
    20032121
     
    20072125    if (!isnull($run_type)) {
    20082126        $run_type = lc($run_type);
     2127        # XXX: these diff_mode values should be defined somewhere else.
    20092128        if ($run_type eq 'warp_warp') {
    20102129            $diff_mode = 1;
Note: See TracChangeset for help on using the changeset viewer.