IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38119 for tags/ipp-20150329


Ignore:
Timestamp:
Apr 13, 2015, 6:12:49 PM (11 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
tags/ipp-20150329
Files:
6 edited
1 copied

Legend:

Unmodified
Added
Removed
  • tags/ipp-20150329/PS-IPP-PStamp/lib/PS/IPP/PStamp/Job.pm

    r36645 r38119  
    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;
  • tags/ipp-20150329/dbconfig/changes.txt

    r37834 r38119  
    25262526--
    25272527
    2528 UPDATE dbversion set schema_version = '1.1.80, updated= CURRENT_TIMESTAMP();
     2528UPDATE dbversion set schema_version = '1.1.80', updated= CURRENT_TIMESTAMP();
    25292529ALTER TABLE remoteComponent ADD COLUMN jobs INT after stage_id;
    25302530ALTER TABLE remoteComponent ADD COLUMN state VARCHAR(64) NOT NULL after jobs;
  • tags/ipp-20150329/ppSkycell/src/ppSkycellLoop.c

    r36655 r38119  
    240240              maxCRPIX1 = wcs->crpix1;
    241241            }
    242             if (wcs->crpix2 < maxCRPIX2) {
     242            if (wcs->crpix2 > maxCRPIX2) {
    243243              maxCRPIX2 = wcs->crpix2;
    244244            }
  • tags/ipp-20150329/pstamp/scripts/pstamp_job_run.pl

    r38062 r38119  
    9292my $stack_bkg_mk_mdc = can_run('stack_bkg_mk_mdc.pl') or (warn "Can't find stack_bkg_mk_mdc.pl" and $missing_tools = 1);
    9393my $fpack = can_run('fpack') or (warn "Can't find fpack" and $missing_tools = 1);
    94 
     94my $staticskytool = can_run('staticskytool') or (warn "Can't find staticskytool" and $missing_tools = 1);
    9595
    9696if ($missing_tools) {
     
    177177                # be copied from the cmf file.
    178178                $argString .= " -recipe PSPHOT STACKPHOT"
     179            }
     180        } elsif ($stage eq 'stack') {
     181            # no astrom file for stack (skycal cmf) Go find a staticsky cmf and use that
     182            # otherwise silently ignore the request for sources since the stack smf is not useful.
     183            my $staticsky_cmf = findStaticskyCMF($params);
     184            if ($staticsky_cmf) {
     185                print "Using staticsky cmf file $staticsky_cmf for sources\n";
     186                $argString .= " -write_cmf";
     187                $fileArgs  .= " -sources $staticsky_cmf";
     188                # Set psphot recipe to STACKPHOT so that the extended source paramters will
     189                # be copied from the cmf file.
     190                $argString .= " -recipe PSPHOT STACKPHOT";
     191                push @file_list, $staticsky_cmf;
     192            } else {
     193                print "No skycal or staticsky cmf for $params->{stack_id} ignoring request for sources\n";
    179194            }
    180195        } elsif ($params->{cmf}) {
     
    864879    return 0;
    865880}
     881sub findStaticskyCMF {
     882    my $params = shift;
     883    my $stack_id = $params->{stack_id};
     884
     885    &my_die( "NO stack_id found in findStaticskyCMF\n",
     886            $job_id, $PS_EXIT_PROG_ERROR, 'run') if !$stack_id;
     887
     888    my $command = "$staticskytool -dbname $params->{imagedb} -result -stack_id $stack_id";
     889    my $results = runToolAndParse($command, $verbose);
     890
     891    if (!$results) {
     892        print "no staticsky results found for stack $stack_id\n";
     893        return undef;
     894    }
     895
     896    my $latest;
     897    my $latest_sky_id = 0;
     898    foreach my $result (@$results) {
     899        if ($result->{sky_id} > $latest_sky_id) {
     900            $latest = $result;
     901            $latest_sky_id = $result->{sky_id};
     902        }
     903    }
     904    if ($latest) {
     905        # XXXX Use proper file rule
     906        return $latest->{path_base} .  ".stk.$stack_id.cmf";
     907    }
     908    # Can't happen can it?
     909    return undef;
     910}
    866911
    867912sub my_die
  • tags/ipp-20150329/tools/checkexp

    r29253 r38119  
    5353        summitExp.fault AS summit_fault,
    5454        pzDownloadExp.state AS download_state, count(pzDownloadImfile.class_id) AS download_count,
    55         newExp.state AS newExp_state, newExp.exp_id
     55        newExp.state AS newExp_state, newExp.exp_id,
     56        rawExp.state as rawExp_state
    5657        FROM summitExp LEFT JOIN pzDownloadExp USING(exp_name)
    5758            LEFT JOIN pzDownloadImfile USING(exp_name)
     
    8889my $first_exp_id;
    8990my $first_exp_name;
     91my $last_registered_exp_id = "";
     92my $last_registered_exp_name = "";
    9093while (my $se_ref = $se_stmt->fetchrow_hashref()) {
    9194    push @summit_exps, $se_ref;
     
    98101    my $imfiles = $se_ref->{imfiles};
    99102    my $dateobs = $se_ref->{dateobs};
     103    my $raw_state = $se_ref->{rawExp_state};
    100104    if ($summit_fault) {
    101105        push @summit_faults, $se_ref;
     
    115119            $last_new_exp_id = $exp_id;
    116120            $last_new_exp_name = $exp_name;
     121        }
     122        if ($raw_state and $raw_state eq 'full') {
     123            $last_registered_exp_id = $exp_id;
     124            $last_registered_exp_name = $exp_name;
    117125        }
    118126    }
     
    180188
    181189print "first exposure:  $first_exp_name $first_exp_id\n";
     190print "last registered: $last_registered_exp_name $last_registered_exp_id\n"
     191            if $last_registered_exp_id ne $last_exp_id;
    182192print "last copied:     $last_new_exp_name $last_new_exp_id\n"
    183193            if $last_new_exp_id ne $last_exp_id;
  • tags/ipp-20150329/tools/mysql-dump/gpc1_install.sh

    r36421 r38119  
    1313#    - Moves the MD5 checksum to the distribution directory
    1414# 4) Import gpc1 into gpc1_0 or gpc1_1 (ensured by gpc1Import.py utility)
     15# NOTE step 4 is no longer done
    1516. /home/panstarrs/ipp/mysql-dump/functions.sh
    1617
     
    6061fi
    6162
    62 log INFO "Symlinking backup file [$TARGET/$BACKUP_FILE] to distribution [$DISTRIBUTION_TARGET]"
     63log INFO "Hard linking backup file [$TARGET/$BACKUP_FILE] to distribution [$DISTRIBUTION_TARGET]"
    6364/usr/bin/ln -f $TARGET/$BACKUP_FILE $DISTRIBUTION_TARGET
    6465/usr/bin/cp -f $TARGET/$MD5FILE $DISTRIBUTION_MD5
    6566
     67# We no longer ingest the backup into the database.
    6668# if it is between 0 and 4, ingest into gpc1_0 or gpc1_1
    6769#HOUR=`date +"%H"`
Note: See TracChangeset for help on using the changeset viewer.