IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 26, 2009, 1:59:32 PM (17 years ago)
Author:
beaumont
Message:

merged with trunk

Location:
branches/cnb_branches/cnb_branch_20090301
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/cnb_branches/cnb_branch_20090301

  • branches/cnb_branches/cnb_branch_20090301/ippTools/src

    • Property svn:ignore
      •  

        old new  
        3333pstamptool
        3434disttool
         35receivetool
  • branches/cnb_branches/cnb_branch_20090301/ippTools/src/camtool.c

    r23594 r24244  
    109109    psMetadata *where = psMetadataAlloc();
    110110    pxcamGetSearchArgs (config, where);
    111     PXOPT_COPY_STR(config->args, where, "-label",     "chipRun.label",    "==");
    112     PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "==");
    113 
    114     if (!psListLength(where->list)
    115         && !psMetadataLookupBool(NULL, config->args, "-all")) {
     111    pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "==");
     112    PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "==");
     113
     114    if (!psListLength(where->list) &&
     115        !psMetadataLookupBool(NULL, config->args, "-all")) {
    116116        psFree(where);
    117117        psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
     
    137137    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
    138138    if (where && psListLength(where->list)) {
    139         psString whereClause = psDBGenerateWhereSQL(where, NULL);
    140         psStringAppend(&query, "%s", whereClause);
     139        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     140        psStringAppend(&query, " AND %s", whereClause);
    141141        psFree(whereClause);
    142142    }
     
    175175    // old values in place (i.e., passing the values through).
    176176
    177     // loop over our list of chipRun rows
     177    // if end_stage is warp (or NULL), check for valid tess_id
    178178    for (long i = 0; i < psArrayLength(output); i++) {
    179179        psMetadata *md = output->data[i];
    180180
    181         chipRunRow *row = chipRunObjectFromMetadata(md);
     181        bool status;
     182        char *end_stage = psMetadataLookupStr(&status, md, "end_stage");
     183        if (end_stage && strcasecmp(end_stage, "warp")) continue;
     184
     185        char *raw_tess_id   = psMetadataLookupStr(&status, md, "tess_id");
     186        if (raw_tess_id || tess_id) continue;
     187
     188        char *label  = psMetadataLookupStr(&status, md, "label");
     189        psS64 exp_id = psMetadataLookupS64(&status, md, "exp_id");
     190
     191        if (!status) {
     192            psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id);
     193            psFree(output);
     194            return false;
     195        }
     196    }
     197
     198    // loop over our list of camRun rows
     199    for (long i = 0; i < psArrayLength(output); i++) {
     200        psMetadata *md = output->data[i];
     201
     202        camRunRow *row = camRunObjectFromMetadata(md);
    182203        if (!row) {
    183             psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into chipRun");
     204            psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into camRun");
    184205            psFree(output);
    185206            return false;
     
    247268
    248269    if (state) {
    249         // set chipRun.state to state
     270        // set camRun.state to state
    250271        if (!pxcamRunSetStateByQuery(config, where, state)) {
    251272            psFree(where);
     
    255276
    256277    if (label) {
    257         // set chipRun.label to label
     278        // set camRun.label to label
    258279        if (!pxcamRunSetLabelByQuery(config, where, label)) {
    259280            psFree(where);
     
    275296    pxcamGetSearchArgs (config, where);
    276297    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id", "==");
    277     PXOPT_COPY_STR(config->args, where, "-label",    "camRun.label", "==");
     298    pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "==");
    278299    PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "==");
    279300
     
    289310    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
    290311    if (psListLength(where->list)) {
    291         psString whereClause = psDBGenerateWhereSQL(where, NULL);
    292         psStringAppend(&query, "%s", whereClause);
     312        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     313        psStringAppend(&query, " AND %s", whereClause);
    293314        psFree(whereClause);
    294315    }
     
    339360    pxcamGetSearchArgs (config, where);
    340361    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id",                "==");
    341     PXOPT_COPY_STR(config->args, where, "-label",     "camRun.label",                 "==");
     362    pxAddLabelSearchArgs (config, where, "-label",    "camRun.label",                 "==");
    342363    PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction",             "==");
    343     PXOPT_COPY_S64(config->args, where, "-chip_id",   "chipRun.chip_id",              "==");
    344     PXOPT_COPY_STR(config->args, where, "-class_id",  "chipProcessedImfile.class_id", "==");
    345 
    346     // XXX is this used? PXOPT_COPY_STR(config->args, where, "-class",    "class",         "==");
     364    PXOPT_COPY_S64(config->args, where, "-chip_id",   "camRun.chip_id",              "==");
     365    PXOPT_COPY_STR(config->args, where, "-class_id",  "camProcessedExp.class_id", "==");
    347366
    348367    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     
    356375    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
    357376    if (psListLength(where->list)) {
    358         psString whereClause = psDBGenerateWhereSQL(where, NULL);
    359         psStringAppend(&query, "%s", whereClause);
     377        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
     378        psStringAppend(&query, " AND %s", whereClause);
    360379        psFree(whereClause);
    361380    }
     
    381400
    382401    // negate simple so the default is true
    383     if (!ippdbPrintMetadatas(stdout, output, "chipProcessedImfile", !simple)) {
     402    if (!ippdbPrintMetadatas(stdout, output, "camProcessedExp", !simple)) {
    384403        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    385404        psFree(output);
     
    470489
    471490    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false);
    472     PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
     491    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
     492    PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false);
    473493
    474494    // generate restrictions
    475495    psMetadata *where = psMetadataAlloc();
    476     PXOPT_COPY_S64(config->args, where, "-cam_id",   "cam_id",   "==");
     496    PXOPT_COPY_S64(config->args, where, "-cam_id",   "camRun.cam_id",   "==");
    477497
    478498    psString query = pxDataGet("camtool_find_pendingexp.sql");
     
    484504    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
    485505    if (psListLength(where->list)) {
    486         psString whereClaus = psDBGenerateWhereSQL(where, NULL);
    487         psStringAppend(&query, "%s", whereClaus);
     506        psString whereClaus = psDBGenerateWhereConditionSQL(where, NULL);
     507        psStringAppend(&query, " AND %s", whereClaus);
    488508        psFree(whereClaus);
    489509    }
     
    535555        zpt_lq,
    536556        zpt_uq,
    537         fwhm_major,
    538         fwhm_major_lq,
    539         fwhm_major_uq,
    540         fwhm_minor,
    541         fwhm_minor_lq,
    542         fwhm_minor_uq,
    543 
    544         iq_fwhm_major,
    545         iq_fwhm_major_err,
    546         iq_fwhm_minor,
    547         iq_fwhm_minor_err,
     557        fwhm_major,
     558        fwhm_major_lq,
     559        fwhm_major_uq,
     560        fwhm_minor,
     561        fwhm_minor_lq,
     562        fwhm_minor_uq,
     563
     564        iq_fwhm_major,
     565        iq_fwhm_major_err,
     566        iq_fwhm_minor,
     567        iq_fwhm_minor_err,
    548568
    549569        iq_m2,
     
    578598        n_astrom,
    579599        path_base,
    580         code
     600        fault,
     601        quality
    581602        );
    582603
     
    601622
    602623    // NULL for end_stage means go as far as possible
    603     // EAM : skip here if code != 0
     624    // EAM : skip here if fault != 0
    604625    // Also, we can run fake even if tess_id is not defined
    605     if (code || (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "cam"))) {
     626    if (fault || (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "cam"))) {
    606627        psFree(row);
    607628        psFree(pendingRow);
     
    656677    pxcamGetSearchArgs (config, where);
    657678    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id",    "==");
    658     PXOPT_COPY_STR(config->args, where, "-label",     "camRun.label",     "==");
     679    pxAddLabelSearchArgs (config, where, "-label",    "camRun.label",     "==");
    659680    PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction", "==");
     681
     682    if (!psListLength(where->list) &&
     683        !psMetadataLookupBool(NULL, config->args, "-all")) {
     684        psFree(where);
     685        psError(PXTOOLS_ERR_DATA, false, "search parameters (or -all) are required");
     686        return false;
     687    }
    660688
    661689    psString query = pxDataGet("camtool_find_processedexp.sql");
     
    669697        psStringAppend(&query, " WHERE %s", whereClause);
    670698        psFree(whereClause);
     699    }
     700
     701    // we either add AND (condition) or WHERE (condition):
     702    if (where->list && faulted) {
     703        // list only faulted rows
     704        psStringAppend(&query, " %s", " AND camProcessedExp.fault != 0");
     705    }
     706    if (where->list && !faulted) {
     707        // don't list faulted rows
     708        psStringAppend(&query, " %s", " AND camProcessedExp.fault = 0");
     709    }
     710    if (!where->list && faulted) {
     711        // list only faulted rows
     712        psStringAppend(&query, " %s", " WHERE camProcessedExp.fault != 0");
     713    }
     714    if (!where->list && !faulted) {
     715        // don't list faulted rows
     716        psStringAppend(&query, " %s", " WHERE camProcessedExp.fault = 0");
    671717    }
    672718    psFree(where);
    673 
    674     if (faulted) {
    675         // list only faulted rows
    676         psStringAppend(&query, " %s", "AND camProcessedExp.fault != 0");
    677     } else {
    678         // don't list faulted rows
    679         psStringAppend(&query, " %s", "AND camProcessedExp.fault = 0");
    680     }
    681719
    682720    // order by cam_id so that the postage stamp parser can easliy find the 'latest' astrometry
     
    730768    PXOPT_COPY_STR(config->args, where, "-label",     "camRun.label",          "==");
    731769    PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction",      "==");
    732     PXOPT_COPY_S16(config->args, where, "-code",      "camProcessedExp.fault", "==");
     770    PXOPT_COPY_S16(config->args, where, "-fault", "camProcessedExp.fault", "==");
    733771
    734772    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
     
    818856    PS_ASSERT_PTR_NON_NULL(config, false);
    819857
    820     PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
     858    PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);
    821859
    822860    psMetadata *where = psMetadataAlloc();
     
    826864    PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
    827865
    828     if (!pxSetFaultCode(config->dbh, "camProcessedExp", where, code)) {
     866    if (!pxSetFaultCode(config->dbh, "camProcessedExp", where, fault)) {
    829867        psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
    830868        psFree (where);
     
    915953
    916954    psMetadata *where = psMetadataAlloc();
    917     PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     955    pxAddLabelSearchArgs (config, where, "-label", "camRun.label", "==");
    918956
    919957    psString query = pxDataGet("camtool_pendingcleanuprun.sql");
     
    9801018        PXOPT_COPY_S64(config->args, where, "-cam_id", "cam_id", "==");
    9811019    }
    982     PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
     1020    pxAddLabelSearchArgs (config, where, "-label", "label", "==");
    9831021
    9841022    psString query = pxDataGet("camtool_pendingcleanupexp.sql");
     
    10991137    char sqlFilename[80];
    11001138  } ExportTable;
    1101  
     1139
    11021140  int numExportTables = 2;
    11031141
     
    11071145  PXOPT_LOOKUP_STR(outfile, config->args, "-outfile", true,  false);
    11081146  PXOPT_LOOKUP_U64(limit,   config->args, "-limit",   false, false);
     1147  PXOPT_LOOKUP_BOOL(clean, config->args, "-clean", false);
    11091148
    11101149  FILE *f = fopen (outfile, "w");
     
    11551194    }
    11561195    if (!psArrayLength(output)) {
    1157       psTrace("regtool", PS_LOG_INFO, "no rows found");
     1196      psError(PS_ERR_UNKNOWN, true, "no rows found");
    11581197      psFree(output);
    1159       return true;
     1198      return false;
     1199    }
     1200
     1201    if (clean) {
     1202        if (!strcmp(tables[i].tableName, "camRun")) {
     1203            if (!pxSetStateCleaned("camRun", "state", output)) {
     1204                psFree(output);
     1205                psError(PS_ERR_UNKNOWN, false, "pxSetStateClean failed for table %s",  tables[i].tableName);
     1206                return false;
     1207            }
     1208        }
    11601209    }
    11611210
     
    11791228
    11801229  PS_ASSERT_PTR_NON_NULL(config, NULL);
    1181  
     1230
    11821231  PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
    11831232
     
    11901239  psAssert (item, "entry not in input?");
    11911240  psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
    1192  
     1241
    11931242  psMetadataItem *entry = psListGet (item->data.list, 0);
    11941243  assert (entry);
     
    11991248  // fprintf (stdout, "---- cam run ----\n");
    12001249  // psMetadataPrint (stderr, entry->data.md, 1);
    1201  
    1202   item = psMetadataLookup (input, "camProcessedImfile");
     1250
     1251  item = psMetadataLookup (input, "camProcessedExp");
    12031252  psAssert (item, "entry not in input?");
    12041253  psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
Note: See TracChangeset for help on using the changeset viewer.