IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 32424


Ignore:
Timestamp:
Sep 21, 2011, 11:56:51 AM (15 years ago)
Author:
watersc1
Message:

updated LAP code

Location:
tags/ipp-20110622/ippTools
Files:
8 edited
1 copied

Legend:

Unmodified
Added
Removed
  • tags/ipp-20110622/ippTools/share/Makefile.am

    r32284 r32424  
    424424        laptool_pendingexp.sql \
    425425        laptool_pendingrun.sql \
     426        laptool_WSdiff_check.sql \
    426427        laptool_stacks.sql
    427428
  • tags/ipp-20110622/ippTools/share/laptool_definerun.sql

    r31604 r32424  
    1 SELECT DISTINCT want.exp_id, have.chip_id, false as private, true as active, false as pairwise
     1SELECT DISTINCT
     2  want.exp_id,
     3  have.chip_id,
     4  COALESCE(have.private,false) as private,
     5  true as active,
     6  false as pairwise
    27  FROM
    38  (SELECT exp_id FROM rawExp
     
    813  ) AS want
    914  LEFT JOIN
    10   (SELECT exp_id,MAX(chip_id) AS chip_id, chipRun.state
     15  (SELECT
     16     exp_id,
     17     MAX(chip_id) AS chip_id,
     18     chipRun.state,
     19     lapExp.private
    1120     FROM lapExp JOIN chipRun USING(exp_id,chip_id)
    12      where private IS FALSE
    13      AND chip_id IS NOT NULL
     21     JOIN lapRun USING(lap_id)
     22     where chip_id IS NOT NULL
    1423     AND
    15          (
     24-- This is the restriction to only draw from the current lapSequence
     25     @CHIPWHERE@
     26--       (
    1627          -- (active = TRUE) OR
    17           (chipRun.state = 'full') OR
    18           (chipRun.state = 'new')
     28          -- (chipRun.state = 'full') OR
     29          -- (chipRun.state = 'new')
    1930          -- when we can do updates, put that here.
    20           )
     31--        )
    2132     GROUP BY exp_id
    2233) AS have USING(exp_id)
  • tags/ipp-20110622/ippTools/share/laptool_pendingexp.sql

    r31435 r32424  
    33       lapRun.dist_group, lapRun.registered, lapRun.fault, lapRun.quick_sass_id, lapRun.final_sass_id,
    44       exp_id, chip_id, pair_id, private, pairwise, active, lapExp.data_state,
    5        dateobs, object, comment
     5       dateobs, object, comment,
     6       chipRun.state AS chip_state
    67  FROM lapRun JOIN lapExp USING(lap_id)
    78  JOIN rawExp USING(exp_id,filter)
     9  LEFT JOIN chipRun USING(exp_id,chip_id)
    810WHERE active IS TRUE AND lapRun.fault = 0
    911-- lap_id restriction here.
  • tags/ipp-20110622/ippTools/src/laptool.c

    r31958 r32424  
    3030static bool updateexpMode(pxConfig *config);
    3131
     32static bool diffcheckMode(pxConfig *config);
     33
    3234static bool inactiveexpMode(pxConfig *config);
    3335
     
    6264    MODECASE(LAPTOOL_MODE_UPDATEEXP,     updateexpMode);
    6365
     66    MODECASE(LAPTOOL_MODE_DIFFCHECK,     diffcheckMode);
     67   
    6468    MODECASE(LAPTOOL_MODE_INACTIVEEXP,   inactiveexpMode);
    6569  default:
     
    276280  PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "==");
    277281
     282  psMetadata *chipWhere = psMetadataAlloc();
     283  PXOPT_COPY_S64(config->args, chipWhere, "-seq_id", "lapRun.seq_id", "==");
     284 
    278285  // This seems unnecessarily clunky.
    279286  if (!all_obsmode) {
     
    296303  }
    297304
     305  psString chipWhereClause = psDBGenerateWhereConditionSQL(chipWhere,NULL);
    298306  if (whereClause) {
    299307    psStringSubstitute(&query,whereClause,"@WHERE@");
    300308  }
     309  if (chipWhereClause) {
     310    psStringSubstitute(&query,chipWhereClause,"@CHIPWHERE@");
     311  }
    301312  psFree(where);
     313  psFree(chipWhere);
    302314
    303315  // Fetch exposures
     
    755767}
    756768
    757 
    758    
     769static bool diffcheckMode(pxConfig *config)
     770{
     771  PS_ASSERT_PTR_NON_NULL(config, false);
     772  PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     773 
     774  psMetadata *where = psMetadataAlloc();
     775  PXOPT_COPY_S64(config->args, where, "-lap_id", "lapRun.lap_id", "==");
     776  PXOPT_COPY_S64(config->args, where, "-exp_id",  "exp_id", "==");
     777  PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     778  PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
     779  PXOPT_COPY_S64(config->args, where, "-seq_id",  "seq_id", "==");
     780  PXOPT_COPY_STR(config->args, where, "-skycell_id", "skycell_id", "==");
     781
     782  psString query = pxDataGet("laptool_WSdiff_check.sql");
     783  if (!query) {
     784    psError(PXTOOLS_ERR_SYS, false, "failed to retrieve SQL statement");
     785    return(false);
     786  }
     787 
     788  if (psListLength(where->list)) {
     789    psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     790    psStringPrepend(&whereClause, "\n AND ");
     791    psStringSubstitute(&query,whereClause,"@WHERE@");
     792    psFree(whereClause);
     793  }
     794
     795  if (!p_psDBRunQuery(config->dbh, query)) {
     796    psError(PS_ERR_UNKNOWN, false, "database error");
     797    psFree(query);
     798    return false;
     799  }
     800  psFree(query);
     801
     802  psArray *output = p_psDBFetchResult(config->dbh);
     803  if (!output) {
     804    psErrorCode err = psErrorCodeLast();
     805    switch (err) {
     806    case PS_ERR_DB_CLIENT:
     807      psError(PXTOOLS_ERR_SYS, false, "database error");
     808    case PS_ERR_DB_SERVER:
     809      psError(PXTOOLS_ERR_PROG, false, "database error");
     810    default:
     811      psError(PXTOOLS_ERR_PROG, false, "unknown error %d",err);
     812    }
     813
     814    return false;
     815  }
     816  if (!psArrayLength(output)) {
     817    psTrace("laptool", PS_LOG_INFO, "no rows found");
     818    psFree(output);
     819    return true;
     820  }
     821
     822  if (psArrayLength(output)) {
     823    if (!ippdbPrintMetadatas(stdout, output, "lapRunWarpStackSkycells", !simple)) {
     824      psError(PS_ERR_UNKNOWN, false, "failed to print array");
     825      psFree(output);
     826      return false;
     827    }
     828  }
     829
     830  psFree(output);
     831  return(true);
     832}   
    759833
    760834static bool inactiveexpMode(pxConfig *config)
  • tags/ipp-20110622/ippTools/src/laptool.h

    r31435 r32424  
    1919  LAPTOOL_MODE_STACKS,
    2020  LAPTOOL_MODE_UPDATEEXP,
     21  LAPTOOL_MODE_DIFFCHECK,
    2122  LAPTOOL_MODE_INACTIVEEXP
    2223} laptoolMode;
  • tags/ipp-20110622/ippTools/src/laptoolConfig.c

    r31528 r32424  
    132132  ADD_OPT(Bool,updateexpArgs, "-inactive",                    "set this exposure to active", 0);
    133133
     134  // -diffcheck
     135  psMetadata *diffcheckArgs = psMetadataAlloc();
     136  ADD_OPT(S64, diffcheckArgs, "-lap_id",                      "search by lap run ID", 0);
     137  ADD_OPT(S64, diffcheckArgs, "-exp_id",                      "search by exposure ID", 0);
     138  ADD_OPT(S64, diffcheckArgs, "-chip_id",                     "search by chip ID", 0);
     139  ADD_OPT(S64, diffcheckArgs, "-warp_id",                     "search by warp ID", 0);
     140  ADD_OPT(S64, diffcheckArgs, "-seq_id",                      "search by lap sequence ID", 0);
     141  ADD_OPT(Str, diffcheckArgs, "-skycell_id",                  "search by skycell ID", 0);
     142  ADD_OPT(Bool, diffcheckArgs, "-simple",                     "use simple output format", 0);
     143 
    134144  // -inactiveexp
    135145  psMetadata *inactiveexpArgs = psMetadataAlloc();
     
    152162  PXOPT_ADD_MODE("-stacks",                  "", LAPTOOL_MODE_STACKS,           stacksArgs);
    153163  PXOPT_ADD_MODE("-updateexp",               "", LAPTOOL_MODE_UPDATEEXP,        updateexpArgs);
     164  PXOPT_ADD_MODE("-diffcheck",               "", LAPTOOL_MODE_DIFFCHECK,        diffcheckArgs);
    154165  PXOPT_ADD_MODE("-inactiveexp",             "", LAPTOOL_MODE_INACTIVEEXP,      inactiveexpArgs);
    155166 
  • tags/ipp-20110622/ippTools/src/warptool.c

    • Property svn:mergeinfo deleted
    r32273 r32424  
    24332433    PXOPT_COPY_S64(config->args, where, "-exp_id",     "rawExp.exp_id", "==");
    24342434    PXOPT_COPY_STR(config->args, where, "-exp_name",   "rawExp.exp_name", "==");
     2435    PXOPT_COPY_S64(config->args, where, "-chip_id",    "chipRun.chip_id", "==");
     2436    PXOPT_COPY_S64(config->args, where, "-cam_id",     "camRun.cam_id", "==");
    24352437    PXOPT_COPY_S64(config->args, where, "-fake_id",    "fakeRun.fake_id", "==");
    24362438    PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "rawExp.dateobs",  ">=");
  • tags/ipp-20110622/ippTools/src/warptoolConfig.c

    • Property svn:mergeinfo deleted
    r31956 r32424  
    269269    psMetadataAddStr(listrunArgs, PS_LIST_TAIL, "-tess_id",  0,          "search by tessellation ID", NULL);
    270270    psMetadataAddStr(listrunArgs, PS_LIST_TAIL, "-state",  0,            "search by state", NULL);
    271     psMetadataAddS64(listrunArgs, PS_LIST_TAIL, "-exp_id", 0,            "search by exposure tag", 0);
    272     psMetadataAddStr(listrunArgs, PS_LIST_TAIL, "-exp_name", 0,          "search by exposure tag", 0);
    273     psMetadataAddS64(listrunArgs, PS_LIST_TAIL, "-fake_id", 0,           "search by phase 3 version of exposure tag", 0);
     271    psMetadataAddS64(listrunArgs, PS_LIST_TAIL, "-exp_id", 0,            "search by exposure id", 0);
     272    psMetadataAddStr(listrunArgs, PS_LIST_TAIL, "-exp_name", 0,          "search by exposure tag", NULL);
     273    psMetadataAddS64(listrunArgs, PS_LIST_TAIL, "-chip_id", 0,           "search by chip id", 0);
     274    psMetadataAddS64(listrunArgs, PS_LIST_TAIL, "-cam_id",  0,           "search by cam id", 0);
     275    psMetadataAddS64(listrunArgs, PS_LIST_TAIL, "-fake_id", 0,           "search by phase 3 version of exposure tag (fake_id)", 0);
    274276    psMetadataAddTime(listrunArgs, PS_LIST_TAIL, "-dateobs_begin", 0,    "search for exposures by time (>=)", NULL);
    275277    psMetadataAddTime(listrunArgs, PS_LIST_TAIL, "-dateobs_end", 0,      "search for exposures by time (<=)", NULL);
Note: See TracChangeset for help on using the changeset viewer.