IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 24, 2008, 3:02:43 PM (18 years ago)
Author:
eugene
Message:

add workdir, det_type, various argument fixes

File:
1 edited

Legend:

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

    r19621 r20377  
    2626    PXOPT_LOOKUP_S64(ref_det_id, config->args, "-det_id", true, false); // required
    2727    PXOPT_LOOKUP_S32(ref_iter, config->args, "-iteration", true, false); // required
     28    PXOPT_LOOKUP_STR(det_type, config->args, "-det_type", true, false); // required
    2829    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); // optional
     30
     31    // optional modifications
     32    PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", false, false);
     33    PXOPT_LOOKUP_STR(reduction, config->args, "-reduction", false, false);
     34    PXOPT_LOOKUP_STR(label, config->args, "-label", false, false);
    2935
    3036    // build the needed where
     
    3238    psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", ref_det_id);
    3339    psMetadataAddS32(where, PS_LIST_TAIL, "iteration", 0, "==", ref_iter);
     40
     41    // select the detRun that matches
    3442    psArray *runs = detRunSelectRowObjects(config->dbh, where, 1);
    3543    psFree (where);
     
    4654        return false;
    4755    }
     56
     57    char *use_workdir   = (workdir)   ? workdir   : detRun->workdir;
     58    char *use_reduction = (reduction) ? reduction : detRun->reduction;
     59    char *use_label     = (label)     ? label     : detRun->label;
    4860
    4961    detRunInsert(config->dbh,
    5062         0,             // det_id
    5163         0,             // iteration
    52          detRun->det_type,
     64         det_type,
    5365         "correction",  // mode
    5466         "run",         // state
    5567         detRun->filelevel,
    56          detRun->workdir,
     68         use_workdir,
    5769         detRun->camera,
    5870         detRun->telescope,
    5971         detRun->exp_type,
    60          detRun->reduction,
     72         use_reduction,
    6173         detRun->filter,
    6274         detRun->airmass_min,
     
    7587         detRun->solang_min,
    7688         detRun->solang_max,
    77          detRun->label,
     89         use_label,
    7890         detRun->det_id, // ref_det_id
    7991         detRun->iteration // ref_iter
    8092    );
    81 
    8293    psFree(runs);
    8394
     
    91102
    92103    psMetadata *where_new = psMetadataAlloc();
    93     psMetadataAddS64(where, PS_LIST_TAIL, "det_id", 0, "==", new_det_id);
     104    psMetadataAddS64(where_new, PS_LIST_TAIL, "det_id", 0, "==", new_det_id);
    94105    psArray *detRuns = psDBSelectRows(config->dbh, "detRun", where_new, 0);
    95106    psFree(where_new);
     
    116127}
    117128
    118 bool tocorrectexpMode(pxConfig *config)
    119 {
    120     PS_ASSERT_PTR_NON_NULL(config, false);
     129bool tocorrectimfileMode(pxConfig *config)
     130{
     131    PS_ASSERT_PTR_NON_NULL(config, false);
     132
     133    psMetadata *where = psMetadataAlloc();
     134    PXOPT_COPY_S64(config->args, where, "-det_id", "det_id", "==");
     135    PXOPT_COPY_STR(config->args, where, "-det_type", "det_type", "==");
    121136
    122137    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    123138    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    124139
    125     psString query = pxDataGet("dettool_tocorrectexp.sql");
     140    psString query = pxDataGet("dettool_tocorrectimfile.sql");
    126141    if (!query) {
    127142        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    128143        return false;
    129144    }
     145
     146    if (psListLength(where->list)) {
     147        // NOTE the SQL uses an intermediate table 'det1' for this query
     148        psString whereClause = psDBGenerateWhereConditionSQL(where, "det1");
     149        psStringAppend(&query, " AND %s", whereClause);
     150        psFree(whereClause);
     151    }
     152    psFree (where);
    130153
    131154    // treat limit == 0 as "no limit"
     
    155178
    156179    // negative simple so the default is true
    157     if (!ippdbPrintMetadatas(stdout, output, "detRun", !simple)) {
     180    if (!ippdbPrintMetadatas(stdout, output, "detPendingCorrectImfile", !simple)) {
    158181        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    159182        psFree(output);
     
    166189}
    167190
    168 bool tocorrectimfileMode(pxConfig *config)
    169 {
    170     PS_ASSERT_PTR_NON_NULL(config, false);
    171 
    172     psMetadata *where = psMetadataAlloc();
    173     PXOPT_COPY_STR(config->args, where, "-det_type", "det_type", "==");
     191bool tocorrectexpMode(pxConfig *config)
     192{
     193    PS_ASSERT_PTR_NON_NULL(config, false);
    174194
    175195    PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
    176196    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
    177197
    178     psString query = pxDataGet("dettool_tocorrectimfile.sql");
     198    psString query = pxDataGet("dettool_tocorrectexp.sql");
    179199    if (!query) {
    180200        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
    181201        return false;
    182202    }
    183 
    184     if (psListLength(where->list)) {
    185         // NOTE the SQL uses an intermediate table 'det1' for this query
    186         psString whereClause = psDBGenerateWhereConditionSQL(where, "det1");
    187         psStringAppend(&query, " AND %s", whereClause);
    188         psFree(whereClause);
    189     }
    190     psFree (where);
    191203
    192204    // treat limit == 0 as "no limit"
     
    216228
    217229    // negative simple so the default is true
    218     if (!ippdbPrintMetadatas(stdout, output, "detPendingCorrectImfile", !simple)) {
     230    if (!ippdbPrintMetadatas(stdout, output, "detRun", !simple)) {
    219231        psError(PS_ERR_UNKNOWN, false, "failed to print array");
    220232        psFree(output);
Note: See TracChangeset for help on using the changeset viewer.