IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 21, 2006, 11:02:26 AM (20 years ago)
Author:
jhoblitt
Message:

implement -select

File:
1 edited

Legend:

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

    r7602 r7611  
    1212static bool runsMode(pxConfig *config);
    1313static bool selectrunsMode(pxConfig *config);
     14static bool selectMode(pxConfig *config);
    1415static bool inputMode(pxConfig *config);
    1516static bool rawMode(pxConfig *config);
     
    5253        MODECASE(DETTOOL_MODE_RUNS, runsMode);
    5354        MODECASE(DETTOOL_MODE_SELECTRUNS, selectrunsMode);
     55        MODECASE(DETTOOL_MODE_SELECT, selectMode);
    5456        MODECASE(DETTOOL_MODE_INPUT, inputMode);
    5557        MODECASE(DETTOOL_MODE_RAW, rawMode);
     
    279281    PS_ASSERT_PTR_NON_NULL(config, 0);
    280282
     283    // detselect -camera megacam -type flat -time 2005/1/1
    281284    // -inst & -dete_type are required
    282285    bool status = false;
     
    327330    psFree(result);
    328331
     332    // FLAT CHIP flat.0000 DONE
    329333    fprintf(stdout, "FLAT CHIP %d DONE\n", det_id);
    330334
     
    332336}
    333337
     338static bool selectMode(pxConfig *config)
     339{
     340    PS_ASSERT_PTR_NON_NULL(config, 0);
     341
     342    // detselect -select -detID flat.0000 -classID ccd00
     343    // -detID & -classID are required
     344    bool status = false;
     345    psString det_id = psMetadataLookupStr(&status, config->args, "-detID");
     346    if (!status) {
     347        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -detID");
     348        return false;
     349    }
     350    if (!det_id) {
     351        psError(PS_ERR_UNKNOWN, true, "-detID is required");
     352        return false;
     353    }
     354    psString class_id = psMetadataLookupStr(&status, config->args, "-classID");
     355    if (!status) {
     356        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -classID");
     357        return false;
     358    }
     359    if (!class_id) {
     360        psError(PS_ERR_UNKNOWN, true, "-classID is required");
     361        return false;
     362    }
     363
     364    char *query = "SELECT uri FROM detNormalizedImfile"
     365        " WHERE iteration = (SELECT iteration FROM detMasterFrame"
     366        " WHERE det_id = '%s' ORDER BY iteration DESC LIMIT 1)";
     367
     368    if (!p_psDBRunQuery(config->dbh, query, det_id)) {
     369        psError(PS_ERR_UNKNOWN, false, "database error");
     370        return false;
     371    }
     372
     373    psArray *result = p_psDBFetchResult(config->dbh);
     374    if (!result) {
     375    }
     376
     377    // sanity check the result
     378    if (psArrayLength(result) != 1) {
     379    }
     380
     381    // just a view... doesn't need to be free'd
     382    psMetadata *run = result->data[0];
     383
     384    psString uri = psMetadataLookupStr(&status, run, "uri");
     385    if (!status) {
     386        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for uri");
     387        psFree(result);
     388        return false;
     389    }
     390    psFree(result);
     391
     392    // flat.0000 ccd00 flat.split/flat.00.fits DONE
     393
     394    fprintf(stdout, "%s %s %s DONE\n", det_id, class_id, uri);
     395
     396    return true;
     397}
    334398static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration)
    335399{
Note: See TracChangeset for help on using the changeset viewer.