IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 21, 2006, 4:43:27 PM (20 years ago)
Author:
jhoblitt
Message:

implement -residdetrun

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippTools/src/dettool.c

    r8460 r8462  
    32203220    PS_ASSERT_PTR_NON_NULL(config, false);
    32213221
     3222    /* which returns a list of detrend runs (with detrend id, iteration and
     3223     * detrend type) which have completed all residexps.
     3224     */
     3225 
     3226    // select detRun.position
     3227    // select detRun.iteration
     3228    // select detRun.det_type
     3229    // by:
     3230    // find the current iteration bassed on det_id
     3231    // find all exp_ids in the current det_id/iteration from detInputExp
     3232    // find all exp_ids in the current det_id/iteration from detResidExp
     3233    // compare the counts of exp_ids
     3234
     3235    psString query = psStringCopy(
     3236        "SELECT DISTINCT"
     3237        "   det_id,"
     3238        "   iteration,"
     3239        "   det_type"
     3240        " FROM"
     3241        "   (SELECT DISTINCT"
     3242        "       detRun.position AS det_id,"
     3243        "       detRun.iteration,"
     3244        "       detRun.det_type,"
     3245        "       detInputExp.exp_id"
     3246        "   FROM detRun"
     3247        "       LEFT JOIN detInputExp"
     3248        "       ON detRun.position = detInputExp.det_id"
     3249        "       AND detRun.iteration = detInputExp.iteration"
     3250        "   LEFT JOIN rawDetrendExp"
     3251        "       ON detInputExp.exp_id = rawDetrendExp.exp_id"
     3252        "   LEFT JOIN detResidExp"
     3253        "       ON detRun.position = detResidExp.det_id"
     3254        "       AND detRun.iteration = detResidExp.iteration"
     3255        "       AND detInputExp.exp_id = detResidExp.exp_id"
     3256        "   GROUP BY"
     3257        "       detRun.position,"
     3258        "       detRun.iteration"
     3259        "   HAVING"
     3260        "       COUNT(detResidExp.exp_id) = COUNT(detInputExp.exp_id)"
     3261        " ) AS residdetrun"
     3262        );
     3263
     3264    // XXX does it make sens to accept any search params?
     3265#if 0
     3266    if (config->where) {
     3267        psString whereClause = psDBGenerateWhereConditionSQL(config->where);
     3268        psStringAppend(&query, " AND %s", whereClause);
     3269        psFree(whereClause);
     3270    }
     3271#endif
     3272
     3273    if (!p_psDBRunQuery(config->dbh, query)) {
     3274        psError(PS_ERR_UNKNOWN, false, "database error");
     3275        psFree(query);
     3276        return false;
     3277    }
     3278    psFree(query);
     3279
     3280    psArray *output = p_psDBFetchResult(config->dbh);
     3281    if (!output) {
     3282        // XXX check psError here
     3283        psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
     3284        return false;
     3285    }
     3286
     3287    bool simple = false;
     3288    {
     3289        bool status = false;
     3290        simple = psMetadataLookupBool(&status, config->args, "-simple");
     3291        if (!status) {
     3292            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
     3293            return false;
     3294        }
     3295    }
     3296
     3297    // negative simple so the default is true
     3298    if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) {
     3299        psError(PS_ERR_UNKNOWN, false, "failed to print array");
     3300        psFree(output);
     3301        return false;
     3302    }
     3303
     3304    psFree(output);
     3305
    32223306    return true;
    32233307}
Note: See TracChangeset for help on using the changeset viewer.