Index: /trunk/ippTools/src/dettool.c
===================================================================
--- /trunk/ippTools/src/dettool.c	(revision 9370)
+++ /trunk/ippTools/src/dettool.c	(revision 9371)
@@ -18,6 +18,4 @@
 static bool rawMode(pxConfig *config);
 static bool toprocessMode(pxConfig *config);
-//static bool selectrunMode(pxConfig *config);
-//static bool selectMode(pxConfig *config);
 static bool addprocessedimfileMode(pxConfig *config);
 static bool toprocessedexpMode(pxConfig *config);
@@ -28,5 +26,4 @@
 static bool addstackedMode(pxConfig *config);
 static bool stackedMode(pxConfig *config);
-static bool stacframeMode(pxConfig *config); // needed?
 static bool tonormalizeMode(pxConfig *config);
 static bool addnormalizedstatMode(pxConfig *config);
@@ -38,7 +35,6 @@
 static bool toresidMode(pxConfig *config);
 static bool addresidimfileMode(pxConfig *config);
-static bool normalizedimfileMode(pxConfig *config); // needed?
+static bool normalizedimfileMode(pxConfig *config);
 static bool toresidexpMode(pxConfig *config);
-static bool normalizedframeMode(pxConfig *config);// neede?
 static bool residimfileMode(pxConfig *config);
 static bool addresidexpMode(pxConfig *config);
@@ -48,7 +44,4 @@
 static bool adddetrunsummaryMode(pxConfig *config);
 static bool updatedetrunMode(pxConfig *config);
-static bool declaremasterframeMode(pxConfig *config); // axe?
-static bool masterframeMode(pxConfig *config); // axe?
-static bool masterMode(pxConfig *config); // axe?
 static bool rerunMode(pxConfig *config);
 
@@ -59,6 +52,6 @@
 static detResidExpRow *mdToDetResidExp(pxConfig *config, psMetadata *row);
 static detRunSummaryRow *mdToDetRunSummary(pxConfig *config, psMetadata *row);
-static psArray *validDetInputClassIds(pxConfig *config, const char *det_id);
-static psArray *searchInputImfiles(pxConfig *config, const char *det_id);
+//static psArray *validDetInputClassIds(pxConfig *config, const char *det_id);
+//static psArray *searchInputImfiles(pxConfig *config, const char *det_id);
 static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration);
 static psArray *searchRawImfiles(pxConfig *config, psMetadata *where);
@@ -87,6 +80,4 @@
         MODECASE(DETTOOL_MODE_RAW,              rawMode);
         MODECASE(DETTOOL_MODE_TOPROCESS,        toprocessMode);
-//        MODECASE(DETTOOL_MODE_SELECTRUN, selectrunMode);
-//        MODECASE(DETTOOL_MODE_SELECT, selectMode);
         MODECASE(DETTOOL_MODE_ADDPROCESSEDIMFILE,addprocessedimfileMode);
         MODECASE(DETTOOL_MODE_TOPROCESSEDEXP,   toprocessedexpMode);
@@ -97,5 +88,4 @@
         MODECASE(DETTOOL_MODE_ADDSTACKED,       addstackedMode);
         MODECASE(DETTOOL_MODE_STACKED,          stackedMode);
-        MODECASE(DETTOOL_MODE_STACKEDFRAME,     stacframeMode); // needed?
         MODECASE(DETTOOL_MODE_TONORMALIZE,      tonormalizeMode);
         MODECASE(DETTOOL_MODE_ADDNORMALIZEDSTAT,addnormalizedstatMode);
@@ -109,5 +99,4 @@
         MODECASE(DETTOOL_MODE_ADDRESIDIMFILE,   addresidimfileMode);
         MODECASE(DETTOOL_MODE_TORESIDEXP,       toresidexpMode);
-        MODECASE(DETTOOL_MODE_NORMALIZEDFRAME,  normalizedframeMode); // needed?
         MODECASE(DETTOOL_MODE_RESIDIMFILE,      residimfileMode);
         MODECASE(DETTOOL_MODE_ADDRESIDEXP,      addresidexpMode);
@@ -117,7 +106,4 @@
         MODECASE(DETTOOL_MODE_ADDDETRUNSUMMARY, adddetrunsummaryMode);
         MODECASE(DETTOOL_MODE_UPDATEDETRUN,     updatedetrunMode);
-        MODECASE(DETTOOL_MODE_DECLAREMASTERFRAME, declaremasterframeMode);
-        MODECASE(DETTOOL_MODE_MASTERFRAME,      masterframeMode);
-        MODECASE(DETTOOL_MODE_MASTER,           masterMode);
         MODECASE(DETTOOL_MODE_RERUN,            rerunMode);
         default:
@@ -606,127 +592,4 @@
     return true;
 }
-
-#if 0
-static bool selectrunMode(pxConfig *config)
-{
-    PS_ASSERT_PTR_NON_NULL(config, 0);
-
-    // detselect -camera megacam -type flat -time 2005/1/1
-    // -inst & -dete_type are required
-    bool status = false;
-    psString camera = psMetadataLookupStr(&status, config->args, "-inst");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -inst");
-        return false;
-    }
-    if (!camera) {
-        psError(PS_ERR_UNKNOWN, true, "-inst is required");
-        return false;
-    }
-    psString det_type = psMetadataLookupStr(&status, config->args, "-det_type");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_type");
-        return false;
-    }
-    if (!det_type) {
-        psError(PS_ERR_UNKNOWN, true, "-det_type is required");
-        return false;
-    }
-
-    char *query = "SELECT detRun.position, det_type, camera FROM detRun JOIN detInputExp where camera = '%s' and det_type = '%s' LIMIT 1";
-
-    if (!p_psDBRunQuery(config->dbh, query, camera, det_type)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        return false;
-    }
-
-    psArray *result = p_psDBFetchResult(config->dbh);
-    if (!result) {
-    }
-
-    // sanity check the result
-    if (psArrayLength(result) != 1) {
-    }
-
-    // just a view... doesn't need to be free'd
-    psMetadata *run = result->data[0];
-
-    psS32 det_id = psMetadataLookupS32(&status, run, "position");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for position");
-        psFree(result);
-        return false;
-    }
-
-    psFree(result);
-
-    // FLAT CHIP flat.0000 DONE
-    fprintf(stdout, "FLAT CHIP %d DONE\n", det_id);
-
-    return true;
-}
-
-static bool selectMode(pxConfig *config)
-{
-    PS_ASSERT_PTR_NON_NULL(config, 0);
-
-    // detselect -select -detID flat.0000 -classID ccd00
-    // -detID & -classID are required
-    bool status = false;
-    psString det_id = psMetadataLookupStr(&status, config->args, "-detID");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -detID");
-        return false;
-    }
-    if (!det_id) {
-        psError(PS_ERR_UNKNOWN, true, "-detID is required");
-        return false;
-    }
-    psString class_id = psMetadataLookupStr(&status, config->args, "-classID");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -classID");
-        return false;
-    }
-    if (!class_id) {
-        psError(PS_ERR_UNKNOWN, true, "-classID is required");
-        return false;
-    }
-
-    char *query = "SELECT uri FROM detNormalizedImfile"
-        " WHERE iteration = (SELECT iteration FROM detMasterFrame"
-        " WHERE det_id = '%s' ORDER BY iteration DESC LIMIT 1)";
-
-    if (!p_psDBRunQuery(config->dbh, query, det_id)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        return false;
-    }
-
-    psArray *result = p_psDBFetchResult(config->dbh);
-    if (!result) {
-    }
-
-    // sanity check the result
-    if (psArrayLength(result) != 1) {
-    }
-
-    // just a view... doesn't need to be free'd
-    psMetadata *run = result->data[0];
-
-    psString uri = psMetadataLookupStr(&status, run, "uri");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for uri");
-        psFree(result);
-        return false;
-    }
-    psFree(result);
-
-    // flat.0000 ccd00 flat.split/flat.00.fits DONE
-
-    fprintf(stdout, "%s %s %s DONE\n", det_id, class_id, uri);
-
-    return true;
-}
-
-#endif
 
 static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration)
@@ -1599,260 +1462,4 @@
 }
 
-#if 0
-{
-    // find all matching detProcessedImfiles where query should be
-    // pre-generated the entry for iteration must be pruned from the default
-    // search as processed imfiles aren't 'iterated'
-    bool status = false;
-    psArray *processedImfiles =  NULL;
-
-    if (config->where) {
-        psMetadata *prunedWhere = psMetadataCopy(NULL, config->where);
-        psMetadataLookupS32(&status, prunedWhere, "iteration");
-        if (status) {
-            if (!psMetadataRemove(prunedWhere, 0, "iteration")) {
-                psError(PS_ERR_UNKNOWN, false, "failed to remove item iteration");
-                return false;
-            }
-        }
-        processedImfiles =
-            detProcessedImfileSelectRowObjects(config->dbh, prunedWhere, 0);
-        psFree(prunedWhere);
-    } else {
-        processedImfiles =
-            detProcessedImfileSelectRowObjects(config->dbh, NULL, 0);
-    }
-    if (!processedImfiles) {
-        psError(PS_ERR_UNKNOWN, false, "no detProcessedImfile rows found");
-        return false;
-    }
-
-    // remove detStackedImfiles unless -unmask
-    if (!psMetadataLookupBool(&status, config->args, "-unmask")) {
-        // detStackedImfiles doesn't have an exp_tag so we have to generate the
-        // where query ourselves
-        bool status = false;
-        psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false,
-                    "failed to lookup value for -det_id");
-            return false;
-        }
-        psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false,
-                    "failed to lookup value for -iteration");
-            return false;
-        }
-        psString class_id = psMetadataLookupStr(&status, config->args,
-            "-class_id");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false,
-                    "failed to lookup value for -class_id");
-            return false;
-        }
-        psMetadata *where = psMetadataAlloc();
-        if (det_id) {
-            if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==",
-                    (psS32)atoi(det_id))) {
-                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
-                psFree(where);
-                return false;
-            }
-        }
-        // iteration always has a value (and it may be 0 anyways)
-        if (!psMetadataAddS32(where, PS_LIST_TAIL, "iteration", 0, "==",
-                    iteration)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to add item iteration");
-            psFree(where);
-            return false;
-        }
-        if (class_id) {
-            if (!psMetadataAddStr(where, PS_LIST_TAIL, "class_id", 0, "==",
-                        class_id)) {
-                psError(PS_ERR_UNKNOWN, false, "failed to add item class_id");
-                psFree(where);
-                return false;
-            }
-        }
-
-        psArray *stackedImfiles = NULL;
-        if (where->list->n) {
-            stackedImfiles = detStackedImfileSelectRowObjects(
-                config->dbh, where, 0);
-        } else {
-            stackedImfiles = detStackedImfileSelectRowObjects(
-                config->dbh, NULL, 0);
-        }
-        psFree(where);
-        // XXX trace the not found case
-        if (stackedImfiles) {
-            for (long i = 0; i < psArrayLength(processedImfiles); i++) {
-                for (long j = 0; j < psArrayLength(stackedImfiles); j++) {
-                    if ((
-                    ((detProcessedImfileRow *)processedImfiles->data[i])->det_id
-                    ==
-                    ((detStackedImfileRow *)stackedImfiles->data[j])->det_id
-                    ) && (strcmp(
-                    ((detProcessedImfileRow *)processedImfiles->data[i])->class_id,
-                    ((detStackedImfileRow *)stackedImfiles->data[j])->class_id)
-                    == 0)) {
-                        // remove the rawImfiles from the list
-                        psArrayRemove(processedImfiles, processedImfiles->data[i]);
-                        i--;
-                        break;
-                    }
-                }
-            }
-            psFree(stackedImfiles);
-        }
-    }
-
-    // if -chip is specified only return results for complete 'chip' sets.
-    // I.e., when all of the same class_id for the input exposures have been
-    // processed.  This should be done after detStackedImfiles are masked so we
-    // don't have to do this check unless we have to.
-    if (psMetadataLookupBool(&status, config->args, "-chip")) {
-        // lookup det_id
-        bool status = false;
-        psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
-            return false;
-        }
-        // get a count of raw imfiles per class_id
-        psArray *rawImfiles = searchInputImfiles(config, det_id);
-        if (!rawImfiles) {
-            psError(PS_ERR_UNKNOWN, false, "no rawImfile row founds");
-            return false;
-        }
-
-        psHash *raw_counts = psHashAlloc(psArrayLength(rawImfiles));
-        for (long i = 0; i < psArrayLength(rawImfiles); i++) {
-            // check to see if the key already exists
-            psU32 *count = psHashLookup(
-                raw_counts,
-                ((rawImfileRow *)rawImfiles->data[i])->class_id
-            );
-            if (count) {
-                ++(*count);
-            } else {
-                psU32 *count = psAlloc(sizeof(psU32));
-                *count = 1;
-                psHashAdd(raw_counts,
-                    ((rawImfileRow *)rawImfiles->data[i])->class_id, count
-                );
-                psFree(count);
-            }
-        }
-
-        psFree(rawImfiles);
-
-#if 0
-        {
-            printf("raw counts:\n");
-            psList *keys  = psHashKeyList(raw_counts);
-            psListIterator *iter = psListIteratorAlloc(keys, 0, false);
-            char *key = NULL;
-            while ((key = psListGetAndIncrement(iter))) {
-                psU32 *count = psHashLookup(raw_counts, key);
-                printf("%s: %d\n", key, *count);
-            }
-            psFree(iter);
-            psFree(keys);
-        }
-#endif
-
-        // get a count of processed imfiles per class_id
-        psHash *processed_counts = psHashAlloc(psArrayLength(processedImfiles));
-        for (long i = 0; i < psArrayLength(processedImfiles); i++) {
-            // check to see if the key already exists
-            psU32 *count = psHashLookup(
-                processed_counts,
-                ((detProcessedImfileRow *)processedImfiles->data[i])->class_id
-            );
-            if (count) {
-                ++(*count);
-            } else {
-                psU32 *count = psAlloc(sizeof(psU32));
-                *count = 1;
-                psHashAdd(processed_counts,
-            ((detProcessedImfileRow *)processedImfiles->data[i])->class_id,
-                count
-                );
-                psFree(count);
-            }
-        }
-#if 0
-        {
-            printf("processed counts:\n");
-            psList *keys  = psHashKeyList(processed_counts);
-            psListIterator *iter = psListIteratorAlloc(keys, 0, false);
-            char *key = NULL;
-            while ((key = psListGetAndIncrement(iter))) {
-                psU32 *count = psHashLookup(processed_counts, key);
-                printf("%s: %d\n", key, *count);
-            }
-            psFree(iter);
-            psFree(keys);
-        }
-#endif
-
-        // compare the two class_id counts for any mismatched counts
-        psList *keys  = psHashKeyList(processed_counts);
-        psListIterator *iter = psListIteratorAlloc(keys, 0, false);
-        char *key = NULL;
-        while ((key = psListGetAndIncrement(iter))) {
-            psU32 *pcount = psHashLookup(processed_counts, key);
-            psU32 *rcount = psHashLookup(raw_counts, key);
-            if (*pcount != *rcount) {
-                psError(PS_ERR_UNKNOWN, false,
-                    "class_id %s count mismatch - processed: %u raw: %u ",
-                    key, *pcount, *rcount
-                );
-                // iterate through processedImfiles and remove *ALL* enteries
-                // with the mismatched class_id
-                for (long i = 0; i < psArrayLength(processedImfiles); i++) {
-                    if (((detProcessedImfileRow *)processedImfiles->data[i])->class_id) {
-                        psArrayRemove(processedImfiles, processedImfiles->data[i]);
-                        --i;
-                    }
-                }
-
-            }
-        }
-        psFree(iter);
-        psFree(keys);
-
-        psFree(raw_counts);
-        psFree(processed_counts);
-    }
-
-    bool simple = false;
-    {
-        bool status = false;
-        simple = psMetadataLookupBool(&status, config->args, "-simple");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
-            return false;
-        }
-    }
-
-    // print imfile list
-    if (processedImfiles->n) {
-        // negative simple so the default is true
-        if (!detProcessedImfilePrintObjects(stdout, processedImfiles, !simple)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to print array");
-            psFree(processedImfiles);
-            return false;
-        }
-    }
-
-    psFree(processedImfiles);
-
-    return true;
-}
-#endif
-
 static bool addstackedMode(pxConfig *config)
 {
@@ -2052,95 +1659,4 @@
 
     psFree(output);
-
-    return true;
-}
-
-static bool stacframeMode(pxConfig *config)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-
-    // XXX det_id is requried as a simplification
-    bool status = false;
-    psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
-        return false;
-    }
-    if (!det_id) {
-        psError(PS_ERR_UNKNOWN, true, "-det_id is required");
-        return false;
-    }
-
-    // find all detStackedImfile for det_id
-    psArray *stackedImfiles =
-        detStackedImfileSelectRowObjects(config->dbh, config->where, 0);
-    if (!stackedImfiles) {
-        psError(PS_ERR_UNKNOWN, false, "no detStackedImfile rows found");
-        return NULL;
-    }
-
-    // find all class_ids for the det_id's associated detInputExps
-    psArray *valid_class_ids = validDetInputClassIds(config, det_id);
-    if (!valid_class_ids) {
-        psError(PS_ERR_UNKNOWN, false, "no detInputExp imfile class_ids found");
-        return false;
-    }
-
-    // check class_ids for validity
-    for (long i = 0; i < psArrayLength(stackedImfiles); i++) {
-        bool valid = false;
-        for (long j = 0; j < psArrayLength(valid_class_ids); j++) {
-            if (strcmp(((detStackedImfileRow *)stackedImfiles->data[i])->class_id,
-                   (char *)valid_class_ids->data[j]) == 0) {
-                valid = true;
-                if (!psArrayRemove(valid_class_ids, valid_class_ids->data[j])) {
-                    psError(PS_ERR_UNKNOWN, false, "psArrayRemove() failed");
-                    psFree(stackedImfiles);
-                    psFree(valid_class_ids);
-                    return false;
-                }
-                j--; // must update loop index
-            }
-        }
-        if (!valid) {
-            psError(PS_ERR_UNKNOWN, true,
-                "class_id %s does not corespond to a detInputExp",
-                ((detStackedImfileRow *)stackedImfiles->data[i])->class_id);
-            psFree(stackedImfiles);
-            psFree(valid_class_ids);
-            return false;
-        }
-    }
-
-    // check for residual (unmatched) input imfile class_ids
-    if (psArrayLength(valid_class_ids)) {
-        psError(PS_ERR_UNKNOWN, true, "det_id frame is missing %ld class_ids",
-            psArrayLength(valid_class_ids));
-        psFree(valid_class_ids);
-        psFree(stackedImfiles);
-        return false;
-    }
-    psFree(valid_class_ids);
-
-    bool simple = false;
-    {
-        bool status = false;
-        simple = psMetadataLookupBool(&status, config->args, "-simple");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
-            return false;
-        }
-    }
-
-    // negative simple so the default is true
-    if (stackedImfiles->n) {
-        if (!detStackedImfilePrintObjects(stdout, stackedImfiles, !simple)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to print array");
-            psFree(stackedImfiles);
-            return false;
-        }
-    }
-
-    psFree(stackedImfiles);
 
     return true;
@@ -2442,4 +1958,7 @@
 }
 
+#if 0
+// XXX this function was left in commented as this method may be useful in the
+// future
 static psArray *validDetInputClassIds(pxConfig *config, const char *det_id)
 {
@@ -2528,4 +2047,5 @@
     return rawImfiles;
 }
+#endif
 
 static bool addnormalizedimfileMode(pxConfig *config)
@@ -3182,88 +2702,4 @@
 
     psFree(output);
-
-    return true;
-}
-
-
-static bool normalizedframeMode(pxConfig *config)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-
-    // XXX det_id is requried as a simplification
-    bool status = false;
-    psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
-        return false;
-    }
-    if (!det_id) {
-        psError(PS_ERR_UNKNOWN, true, "-det_id is required");
-        return false;
-    }
-
-    // find all detNormalizedIImfile for det_id
-    psArray *masterImfiles =
-        detNormalizedImfileSelectRowObjects(config->dbh, config->where, 0);
-    if (!masterImfiles) {
-        psError(PS_ERR_UNKNOWN, false, "no detNormalizedImfile rows found");
-        return false;
-    }
-
-    // find all input class_ids
-    psArray *valid_class_ids = validDetInputClassIds(config, det_id);
-    if (!valid_class_ids) {
-        psError(PS_ERR_UNKNOWN, false, "no detInputExp imfile class_ids found");
-        return false;
-    }
-
-    // check class_ids for validity
-    for (long i = 0; i < psArrayLength(masterImfiles); i++) {
-        bool valid = false;
-        for (long j = 0; j < psArrayLength(valid_class_ids); j++) {
-            if (strcmp(((detNormalizedImfileRow *)masterImfiles->data[i])->class_id,
-                   (char *)valid_class_ids->data[j]) == 0) {
-                valid = true;
-                if (!psArrayRemove(valid_class_ids, valid_class_ids->data[j])) {
-                    psError(PS_ERR_UNKNOWN, false, "psArrayRemove() failed");
-                    psFree(masterImfiles);
-                    psFree(valid_class_ids);
-                    return false;
-                }
-                j--; // must update loop index
-            }
-        }
-        if (!valid) {
-            psError(PS_ERR_UNKNOWN, true,
-        "class_id %s does not corespond to a detInputExp",
-            ((detNormalizedImfileRow *)masterImfiles->data[i])->class_id);
-            psFree(masterImfiles);
-            psFree(valid_class_ids);
-            return false;
-        }
-    }
-
-    // if we nade it this far we must have a complete frame
-
-    bool simple = false;
-    {
-        bool status = false;
-        simple = psMetadataLookupBool(&status, config->args, "-simple");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
-            return false;
-        }
-    }
-
-    // negative simple so the default is true
-    if (masterImfiles->n) {
-        if (!detNormalizedImfilePrintObjects(stdout, masterImfiles, !simple)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to print array");
-            psFree(masterImfiles);
-            return false;
-        }
-    }
-
-    psFree(masterImfiles);
 
     return true;
@@ -4719,125 +4155,4 @@
 }
 
-static bool declaremasterframeMode(pxConfig *config)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-
-    // det_id & iteration are required
-    bool status = false;
-    psString det_id = psMetadataLookupStr(&status, config->args, "-det_id");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -det_id");
-        return false;
-    }
-    if (!det_id) {
-        psError(PS_ERR_UNKNOWN, true, "-det_id is required");
-        return false;
-    }
-
-    // iteration has a default value
-    psS32 iteration = psMetadataLookupS32(&status, config->args, "-iteration");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -iteration");
-        return false;
-    }
-    // comment is optional
-    psString comment = psMetadataLookupStr(&status, config->args, "-comment");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -comment");
-        return false;
-    }
-
-    // create a new detMasterFrame row and insert it
-    detMasterFrameRow *masterFrame = detMasterFrameRowAlloc(
-                (psS32)atol(det_id),
-                iteration,
-                comment // may be NULL
-            );
-
-    if (!detMasterFrameInsertObject(config->dbh, masterFrame)) {
-        psError(PS_ERR_UNKNOWN, false, "database error");
-        psFree(masterFrame);
-        return false;
-    }
-
-    psFree(masterFrame);
-
-    return true;
-}
-
-static bool masterframeMode(pxConfig *config)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-
-    // no options are required... use the default where statement
-    psArray *masterFrames= detMasterFrameSelectRowObjects(config->dbh,
-            config->where, 0);
-    if (!masterFrames) {
-        psError(PS_ERR_UNKNOWN, false, "no detMasterFrame rows found");
-        return false;
-    }
-
-    bool simple = false;
-    {
-        bool status = false;
-        simple = psMetadataLookupBool(&status, config->args, "-simple");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
-            return false;
-        }
-    }
-
-    // negative simple so the default is true
-    if (masterFrames->n) {
-        if (!detMasterFramePrintObjects(stdout, masterFrames, !simple)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to print array");
-            psFree(masterFrames);
-            return false;
-        }
-    }
-
-    psFree(masterFrames);
-
-    return true;
-}
-
-static bool masterMode(pxConfig *config)
-{
-    PS_ASSERT_PTR_NON_NULL(config, false);
-
-    // join detMasterFrame & detNormalizedImfile tables
-    // no options are required... use the default where statement
-    psArray *normalizedImfiles = detNormalizedImfileSelectRowObjects(
-            config->dbh, config->where, 0);
-    if (!normalizedImfiles) {
-        psError(PS_ERR_UNKNOWN, false, "no detNormalizedImfile rows found");
-        return false;
-    }
-
-    bool simple = false;
-    {
-        bool status = false;
-        simple = psMetadataLookupBool(&status, config->args, "-simple");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -simple");
-            return false;
-        }
-    }
-
-    // negative simple so the default is true
-    if (normalizedImfiles->n) {
-        if (!detNormalizedImfilePrintObjects(stdout, normalizedImfiles, !simple)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to print array");
-            psFree(normalizedImfiles);
-            return false;
-        }
-    }
-
-    psFree(normalizedImfiles);
-
-    return true;
-}
-
-
 static bool rerunMode(pxConfig *config)
 {
Index: /trunk/ippTools/src/dettool.h
===================================================================
--- /trunk/ippTools/src/dettool.h	(revision 9370)
+++ /trunk/ippTools/src/dettool.h	(revision 9371)
@@ -13,6 +13,4 @@
     DETTOOL_MODE_RAW,
     DETTOOL_MODE_TOPROCESS,
-//    DETTOOL_MODE_SELECTRUN,
-//    DETTOOL_MODE_SELECT,
     DETTOOL_MODE_ADDPROCESSEDIMFILE,
     DETTOOL_MODE_PROCESSEDIMFILE,
@@ -23,5 +21,4 @@
     DETTOOL_MODE_ADDSTACKED,
     DETTOOL_MODE_STACKED,
-    DETTOOL_MODE_STACKEDFRAME,
     DETTOOL_MODE_TONORMALIZE,
     DETTOOL_MODE_ADDNORMALIZEDSTAT,
@@ -35,5 +32,4 @@
     DETTOOL_MODE_ADDRESIDIMFILE,
     DETTOOL_MODE_TORESIDEXP,
-    DETTOOL_MODE_NORMALIZEDFRAME,
     DETTOOL_MODE_RESIDIMFILE,
     DETTOOL_MODE_ADDRESIDEXP,
@@ -43,7 +39,4 @@
     DETTOOL_MODE_ADDDETRUNSUMMARY,
     DETTOOL_MODE_UPDATEDETRUN,
-    DETTOOL_MODE_DECLAREMASTERFRAME,
-    DETTOOL_MODE_MASTERFRAME,
-    DETTOOL_MODE_MASTER,
     DETTOOL_MODE_RERUN
 } dettoolMode;
Index: /trunk/ippTools/src/dettoolConfig.c
===================================================================
--- /trunk/ippTools/src/dettoolConfig.c	(revision 9370)
+++ /trunk/ippTools/src/dettoolConfig.c	(revision 9371)
@@ -72,26 +72,4 @@
             "use the simple output format", false);
 
-#if 0
-    // XXX temporary
-    // -selectrun
-    // detselect -camera megacam -type flat -time 2005/1/1
-    psMetadata *selectrunArgs = psMetadataAlloc();
-    psMetadataAddStr(selectrunArgs, PS_LIST_TAIL, "-inst",  0,
-        "search for detrend run for this camera (required)", NULL);
-    psMetadataAddStr(selectrunArgs, PS_LIST_TAIL, "-det_type",  0,
-        "search for type of detrend run (required)", NULL);
-    psMetadataAddStr(selectrunArgs, PS_LIST_TAIL, "-time",  0,
-        "search for detrend run on this date (required)", NULL);
-
-    // XXX temporary
-    // -select
-    // detselect -select -detID flat.0000 -classID ccd00
-    psMetadata *selectArgs = psMetadataAlloc();
-    psMetadataAddStr(selectArgs, PS_LIST_TAIL, "-detID",  0,
-        "defined detrend ID (required)", NULL);
-    psMetadataAddStr(selectArgs, PS_LIST_TAIL, "-classID",  0,
-        "defined class ID (required)", NULL);
-#endif
-
     // -input
     psMetadata *inputArgs = psMetadataAlloc();
@@ -250,20 +228,4 @@
         "use the simple output format", false);
 
-#if 0
-    // -stackedframe
-    // XXX axe?
-    psMetadata *stacframeArgs = psMetadataAlloc();
-    psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-det_id",  0,
-        "search for detrend ID (required)", NULL);
-    psMetadataAddS32(stacframeArgs, PS_LIST_TAIL, "-iteration",  0,
-        "search for iteration number", 0);
-    psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-class_id",  0,
-        "search for class ID", NULL);
-    psMetadataAddStr(stacframeArgs, PS_LIST_TAIL, "-recip",  0,
-        "search for recipe", NULL);
-    psMetadataAddBool(stacframeArgs, PS_LIST_TAIL, "-simple",  0,
-        "use the simple output format", false);
-#endif
- 
     // -addnormalizedimfile
     psMetadata *addnormalizedimfileArgs = psMetadataAlloc();
@@ -354,20 +316,4 @@
     psMetadataAddBool(toresidexpArgs, PS_LIST_TAIL, "-simple",  0,
         "use the simple output format", false);
-
-#if 0
-    // -normalizedframe
-    // XXX axe?
-    psMetadata *normalizedframeArgs = psMetadataAlloc();
-    psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-det_id",  0,
-        "search for detrend ID (required)", NULL);
-    psMetadataAddS32(normalizedframeArgs, PS_LIST_TAIL, "-iteration",  0,
-        "search for iteration number", 0);
-    psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-class_id",  0,
-        "search for class ID", NULL);
-    psMetadataAddStr(normalizedframeArgs, PS_LIST_TAIL, "-recip",  0,
-        "search for recipe", NULL);
-    psMetadataAddBool(normalizedframeArgs, PS_LIST_TAIL, "-simple",  0,
-        "use the simple output format", false);
-#endif
 
     // -addresidimfile
@@ -501,34 +447,4 @@
         "stop this detrend run", false);
 
-#if 0
-    // -declaremasterframe
-    // XXX axe?
-    psMetadata *declaremasterframeArgs = psMetadataAlloc();
-    psMetadataAddStr(declaremasterframeArgs, PS_LIST_TAIL, "-det_id",  0,
-        "define detrend ID (required)", NULL);
-    psMetadataAddS32(declaremasterframeArgs, PS_LIST_TAIL, "-iteration",  0,
-        "define iteration number", 0);
-    psMetadataAddStr(declaremasterframeArgs, PS_LIST_TAIL, "-comment",  0,
-        "define master frame comment", NULL);
- 
-    // -masterframe
-    // XXX axe?
-    psMetadata *masterframeArgs = psMetadataAlloc();
-    psMetadataAddStr(masterframeArgs, PS_LIST_TAIL, "-det_id",  0,
-        "search for detrend master for detrend ID", NULL);
-    psMetadataAddBool(masterframeArgs, PS_LIST_TAIL, "-simple",  0,
-        "use the simple output format", false);
-
-    // -master
-    // XXX axe?
-    psMetadata *masterArgs = psMetadataAlloc();
-    psMetadataAddStr(masterArgs, PS_LIST_TAIL, "-det_id",  0,
-        "search for detrend master for detrend ID", NULL);
-    psMetadataAddS32(masterArgs, PS_LIST_TAIL, "-iteration",  0,
-        "search for detrend master for detrend ID", 0);
-    psMetadataAddBool(masterArgs, PS_LIST_TAIL, "-simple",  0,
-        "use the simple output format", false);
-#endif
- 
     // -rerun
     psMetadata *rerunArgs = psMetadataAlloc();
@@ -565,6 +481,4 @@
     PXTOOL_MODE("-toprocess",       DETTOOL_MODE_TOPROCESS,     toprocessArgs);
     PXTOOL_MODE("-runs",            DETTOOL_MODE_RUNS,          runsArgs);
-//    PXTOOL_MODE("-selectrun",       DETTOOL_MODE_SELECTRUN,     selectrunArgs);
-//    PXTOOL_MODE("-select",          DETTOOL_MODE_SELECT,        selectArgs);
     PXTOOL_MODE("-input",           DETTOOL_MODE_INPUT,         inputArgs);
     PXTOOL_MODE("-addprocessedimfile", DETTOOL_MODE_ADDPROCESSEDIMFILE,  addprocessedimfileArgs);
@@ -579,5 +493,4 @@
     PXTOOL_MODE("-tonormalizedstat",      DETTOOL_MODE_TONORMALIZEDSTAT,    tonormstatArgs);
     PXTOOL_MODE("-stacked",         DETTOOL_MODE_STACKED,       stacArgs);
-//    PXTOOL_MODE("-stackedframe",    DETTOOL_MODE_STACKEDFRAME,  stacframeArgs);
     PXTOOL_MODE("-addnormalizedimfile", DETTOOL_MODE_ADDNORMALIZEDIMFILE,addnormalizedimfileArgs);
     PXTOOL_MODE("-tonormalizedexp", DETTOOL_MODE_TONORMALIZEDEXP, tonormalizedexpArgs);
@@ -587,5 +500,4 @@
     PXTOOL_MODE("-normalizedimfile",DETTOOL_MODE_NORMALIZEDIMFILE, normalizedimfileArgs);
     PXTOOL_MODE("-toresidexp",      DETTOOL_MODE_TORESIDEXP,    toresidexpArgs);
-//    PXTOOL_MODE("-normalizedframe", DETTOOL_MODE_NORMALIZEDFRAME,normalizedframeArgs);
     PXTOOL_MODE("-addresidimfile",  DETTOOL_MODE_ADDRESIDIMFILE,  addresidimfileArgs);
     PXTOOL_MODE("-residimfile",     DETTOOL_MODE_RESIDIMFILE,    residimfileArgs);
@@ -596,7 +508,4 @@
     PXTOOL_MODE("-adddetrunsummary", DETTOOL_MODE_ADDDETRUNSUMMARY,adddetrunsummaryArgs);
     PXTOOL_MODE("-updatedetrun", DETTOOL_MODE_UPDATEDETRUN, updatedetrunArgs);
-//   PXTOOL_MODE("-declaremasterframe",DETTOOL_MODE_DECLAREMASTERFRAME,declaremasterframeArgs);
-//    PXTOOL_MODE("-masterframe",     DETTOOL_MODE_MASTERFRAME,  masterframeArgs);
-//    PXTOOL_MODE("-master",          DETTOOL_MODE_MASTER,        masterArgs);
     PXTOOL_MODE("-rerun",           DETTOOL_MODE_RERUN,         rerunArgs);
 
