Index: trunk/ippTools/src/dettool.c
===================================================================
--- trunk/ippTools/src/dettool.c	(revision 10741)
+++ trunk/ippTools/src/dettool.c	(revision 11047)
@@ -77,5 +77,5 @@
 //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 detInputExpRow *rawDetrenTodetInputExpRow(rawExpRow *rawExp, psS32 det_id, psS32 iteration);
 static psArray *searchRawImfiles(pxConfig *config, psMetadata *where);
 static psS32 incrementIteration(pxConfig *config, const char *det_id);
@@ -161,8 +161,8 @@
      psString query = psStringCopy(
         "SELECT"
-        "   rawDetrendExp.*"
-        " FROM rawDetrendExp"
+        "   rawExp.*"
+        " FROM rawExp"
         " LEFT JOIN detInputExp"
-        "   ON rawDetrendExp.exp_tag = detInputExp.exp_tag"
+        "   ON rawExp.exp_tag = detInputExp.exp_tag"
         " WHERE"
         "    detInputExp.exp_tag IS NULL"
@@ -170,5 +170,5 @@
 
     if (config->where) {
-        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawDetrendExp");
+        psString whereClause = psDBGenerateWhereConditionSQL(config->where, "rawExp");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
@@ -189,5 +189,5 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
+        psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found");
         psFree(output);
         return true;
@@ -205,5 +205,5 @@
 
     // negative simple so the default is true
-    if (!ippdbPrintMetadatas(stdout, output, "rawDetrendExp", !simple)) {
+    if (!ippdbPrintMetadatas(stdout, output, "rawExp", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print array");
         psFree(output);
@@ -390,15 +390,15 @@
 
     // check that the specified exp_tags actually exist
-    psArray *detrendExps = rawDetrendExpSelectRowObjects(config->dbh, where, 0);
+    psArray *detrendExps = rawExpSelectRowObjects(config->dbh, where, 0);
     psFree(where);
     if (!detrendExps) {
-        psError(PS_ERR_UNKNOWN, false, "no rawDetrendExp rows found");
-        return false;
-    }
-
-    // we should have one rawDetrendExp row per exp_tag specified
+        psError(PS_ERR_UNKNOWN, false, "no rawExp rows found");
+        return false;
+    }
+
+    // we should have one rawExp row per exp_tag specified
     if (psListLength(item->data.list) != psArrayLength(detrendExps)) {
         psAbort(config->argv[0],
-    "an -exp_tag matched more then one rawDetrendExp (this should not happen");
+    "an -exp_tag matched more then one rawExp (this should not happen");
 
     }
@@ -433,5 +433,5 @@
     long det_id = psDBLastInsertID(config->dbh);
 
-    // create new detInputExp row(s) from the rawDetrendExp row(s)
+    // create new detInputExp row(s) from the rawExp row(s)
     psArray *inputExps = psArrayAllocEmpty(psArrayLength(detrendExps));
     for (long i = 0; i < psArrayLength(detrendExps); i++) {
@@ -803,8 +803,8 @@
     }
 
-    // search for rawDetrendExps with the specified options
-    psArray *detrendExps = rawDetrendExpSelectRowObjects(config->dbh, where, 0);
+    // search for rawExps with the specified options
+    psArray *detrendExps = rawExpSelectRowObjects(config->dbh, where, 0);
     psFree(where);
-    // make sure that we found at least one rawDetrendExp
+    // make sure that we found at least one rawExp
     if (!detrendExps) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -815,5 +815,5 @@
     }
     if (!psArrayLength(detrendExps)) {
-        psError(PS_ERR_UNKNOWN, true, "no rawDetrendExp rows found");
+        psError(PS_ERR_UNKNOWN, true, "no rawExp rows found");
         psFree(detrendExps);
         psFree(registered);
@@ -825,5 +825,5 @@
     if (pretend) {
         // negative simple so the default is true
-        if (!rawDetrendExpPrintObjects(stdout, detrendExps, !simple)) {
+        if (!rawExpPrintObjects(stdout, detrendExps, !simple)) {
             psError(PS_ERR_UNKNOWN, false, "failed to print array");
             psFree(detrendExps);
@@ -874,5 +874,5 @@
     long det_id = psDBLastInsertID(config->dbh);
 
-    // create new detInputExp row(s) from the rawDetrendExp row(s)
+    // create new detInputExp row(s) from the rawExp row(s)
     psArray *inputExps = psArrayAllocEmpty(psArrayLength(detrendExps));
     for (long i = 0; i < psArrayLength(detrendExps); i++) {
@@ -1208,5 +1208,5 @@
         "       detResidExp.accept"
         "   FROM detResidExp"
-        "   JOIN rawDetrendExp"
+        "   JOIN rawExp"
         "       USING(exp_tag)"
         "   WHERE det_id = %d"
@@ -1214,5 +1214,5 @@
 
     if (time_filter->list->n) {
-        psString whereClause = psDBGenerateWhereConditionSQL(time_filter, "rawDetrendExp");
+        psString whereClause = psDBGenerateWhereConditionSQL(time_filter, "rawExp");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
@@ -1325,5 +1325,5 @@
 }
 
-static detInputExpRow *rawDetrenTodetInputExpRow(rawDetrendExpRow *rawExp, psS32 det_id, psS32 iteration)
+static detInputExpRow *rawDetrenTodetInputExpRow(rawExpRow *rawExp, psS32 det_id, psS32 iteration)
 {
     PS_ASSERT_PTR_NON_NULL(rawExp, NULL);
@@ -1342,5 +1342,5 @@
 
     // select detInputExp.*
-    // select rawDetrendExp.*
+    // select rawExp.*
     // by:
     // exp_tag
@@ -1349,5 +1349,5 @@
         "SELECT DISTINCT *"
         " FROM detInputExp"
-        " JOIN rawDetrendExp"
+        " JOIN rawExp"
         " USING(exp_tag)"
         );
@@ -1373,5 +1373,5 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
+        psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found");
         psFree(output);
         return true;
@@ -1409,9 +1409,9 @@
             "   detRun.det_type,"
             "   rawImfile.*,"
-            "   rawDetrendExp.camera"
+            "   rawExp.camera"
             " FROM rawImfile"
             " JOIN detInputExp"
             "   USING(exp_tag) "
-            " JOIN rawDetrendExp"
+            " JOIN rawExp"
             "   USING(exp_tag) "
             " JOIN detRun"
@@ -1494,10 +1494,10 @@
             "   detRun.det_type,"
             "   rawImfile.*,"
-            "   rawDetrendExp.camera"
+            "   rawExp.camera"
             " FROM detRun"
             " JOIN detInputExp"
             "    USING(det_id, iteration)"
-            " JOIN rawDetrendExp"
-            "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
+            " JOIN rawExp"
+            "    ON detInputExp.exp_tag = rawExp.exp_tag"
             " JOIN rawImfile"
             "    ON detInputExp.exp_tag = rawImfile.exp_tag"
@@ -1582,5 +1582,5 @@
         detInputExpSelectRowObjects(config->dbh, where, 0);
     if (!detInputExp) {
-        psError(PS_ERR_UNKNOWN, false, "no rawDetrendExp rows found");
+        psError(PS_ERR_UNKNOWN, false, "no rawExp rows found");
         return NULL;
     }
@@ -1789,14 +1789,14 @@
         "    detRun.det_type,"
         "    detProcessedImfile.exp_tag,"
-        "    rawDetrendExp.camera,"
+        "    rawExp.camera,"
         "    detProcessedImfile.class_id,"
-        "    rawDetrendExp.imfiles"
+        "    rawExp.imfiles"
         " FROM detRun"
         " JOIN detInputExp"
         "   USING(det_id, iteration)"
-        " JOIN rawDetrendExp"
-        "   ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
+        " JOIN rawExp"
+        "   ON detInputExp.exp_tag = rawExp.exp_tag"
         " JOIN rawImfile"
-        "   ON rawDetrendExp.exp_tag = rawImfile.exp_tag"
+        "   ON rawExp.exp_tag = rawImfile.exp_tag"
         " LEFT JOIN detProcessedImfile"
         "   ON detRun.det_id = detProcessedImfile.det_id"
@@ -1813,8 +1813,8 @@
         "   AND detInputExp.include = 1"
         " GROUP BY"
-        "    rawDetrendExp.exp_tag,"
+        "    rawExp.exp_tag,"
         "    detRun.det_id"
         " HAVING"
-        "    COUNT(detProcessedImfile.class_id) = rawDetrendExp.imfiles"
+        "    COUNT(detProcessedImfile.class_id) = rawExp.imfiles"
         " ) AS detProcessedExp"
         );
@@ -1850,5 +1850,5 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
+        psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found");
         psFree(output);
         return true;
@@ -1960,6 +1960,6 @@
         "    ON detRun.det_id = detInputExp.det_id"
         "    AND detRun.iteration = detInputExp.iteration"
-        " JOIN rawDetrendExp"
-        "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
+        " JOIN rawExp"
+        "    ON detInputExp.exp_tag = rawExp.exp_tag"
         " JOIN detProcessedImfile"
         "    ON detInputExp.det_id = detProcessedImfile.det_id"
@@ -2001,5 +2001,5 @@
     if (!psArrayLength(output)) {
         // XXX check psError here
-        psError(PS_ERR_UNKNOWN, false, "no pending rawDetrendExp rows found");
+        psError(PS_ERR_UNKNOWN, false, "no pending rawExp rows found");
         return true;
     }
@@ -2114,11 +2114,11 @@
         "    detRun.det_type,"
         "    detProcessedImfile.class_id,"
-        "    rawDetrendExp.camera"
+        "    rawExp.camera"
         " FROM detRun"
         " JOIN detInputExp"
         "    ON detRun.det_id = detInputExp.det_id"
         "    AND detRun.iteration = detInputExp.iteration"
-        " JOIN rawDetrendExp"
-        "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
+        " JOIN rawExp"
+        "    ON detInputExp.exp_tag = rawExp.exp_tag"
         " JOIN rawImfile"
         "    ON detInputExp.exp_tag = rawImfile.exp_tag"
@@ -2271,5 +2271,5 @@
 
     // negative simple so the default is true
-    if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) {
+    if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print array");
         psFree(output);
@@ -2471,5 +2471,5 @@
 
     // negative simple so the default is true
-    if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) {
+    if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print array");
         psFree(output);
@@ -2517,6 +2517,6 @@
         "   detRun.det_type,"
         "   detRun.iteration,"
-        "   rawDetrendExp.camera,"
-        "   rawDetrendExp.imfiles,"
+        "   rawExp.camera,"
+        "   rawExp.imfiles,"
         "   detStackedImfile.class_id"
         " FROM detRun"
@@ -2524,6 +2524,6 @@
         "   ON detRun.det_id = detInputExp.det_id"
         "   AND detRun.iteration = detInputExp.iteration"
-        " JOIN rawDetrendExp"
-        "   ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
+        " JOIN rawExp"
+        "   ON detInputExp.exp_tag = rawExp.exp_tag"
         " JOIN detStackedImfile"
         "   ON detInputExp.det_id = detStackedImfile.det_id"
@@ -2540,8 +2540,8 @@
         "   AND detNormalizedStatImfile.class_id IS NULL"
         " GROUP BY"
-        "   rawDetrendExp.exp_tag,"
+        "   rawExp.exp_tag,"
         "   detRun.iteration,"
         "   detRun.det_id"
-        " HAVING MAX(rawDetrendExp.imfiles) = COUNT(detStackedImfile.class_id)"
+        " HAVING MAX(rawExp.imfiles) = COUNT(detStackedImfile.class_id)"
         ") as tonormalizedstat"
         );
@@ -2734,5 +2734,5 @@
         "SELECT DISTINCT"
         "   detRun.det_type,"
-        "   rawDetrendExp.camera,"
+        "   rawExp.camera,"
         "   detStackedImfile.uri,"
         "   detNormalizedStatImfile.*"
@@ -2742,6 +2742,6 @@
         " JOIN detInputExp"
         "   USING(det_id, iteration)"
-        " JOIN rawDetrendExp"
-        "   ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
+        " JOIN rawExp"
+        "   ON detInputExp.exp_tag = rawExp.exp_tag"
         " JOIN detNormalizedStatImfile"
         "   ON detStackedImfile.det_id = detNormalizedStatImfile.det_id"
@@ -2805,5 +2805,5 @@
 
     // negative simple so the default is true
-    if (!ippdbPrintMetadatas(stdout, output, "rawDetrendImfile", !simple)) {
+    if (!ippdbPrintMetadatas(stdout, output, "rawImfile", !simple)) {
         psError(PS_ERR_UNKNOWN, false, "failed to print array");
         psFree(output);
@@ -3064,14 +3064,14 @@
         "    detRun.iteration,"
         "    detRun.det_type,"
-        "    rawDetrendExp.camera,"
-        "    rawDetrendExp.telescope,"
-        "    rawDetrendExp.exp_type,"
-        "    rawDetrendExp.imfiles"
+        "    rawExp.camera,"
+        "    rawExp.telescope,"
+        "    rawExp.exp_type,"
+        "    rawExp.imfiles"
         " FROM detRun"
         " JOIN detInputExp"
         "    ON detRun.det_id = detInputExp.det_id"
         "    AND detRun.iteration = detInputExp.iteration"
-        " JOIN rawDetrendExp"
-        "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
+        " JOIN rawExp"
+        "    ON detInputExp.exp_tag = rawExp.exp_tag"
         " JOIN detNormalizedImfile"
         "    ON detInputExp.det_id = detNormalizedImfile.det_id"
@@ -3227,14 +3227,14 @@
         "    detRun.iteration,"
         "    detRun.det_type,"
-        "    rawDetrendExp.camera,"
-        "    rawDetrendExp.telescope,"
-        "    rawDetrendExp.exp_type,"
-        "    rawDetrendExp.imfiles"
+        "    rawExp.camera,"
+        "    rawExp.telescope,"
+        "    rawExp.exp_type,"
+        "    rawExp.imfiles"
         " FROM detRun"
         " JOIN detInputExp"
         "    ON detRun.det_id = detInputExp.det_id"
         "    AND detRun.iteration = detInputExp.iteration"
-        " JOIN rawDetrendExp"
-        "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
+        " JOIN rawExp"
+        "    ON detInputExp.exp_tag = rawExp.exp_tag"
         " JOIN detNormalizedImfile"
         "    ON detInputExp.det_id = detNormalizedImfile.det_id"
@@ -3462,10 +3462,10 @@
         "   detProcessedImfile.uri,\n"
         "   detNormalizedImfile.uri AS det_uri,\n"
-        "   rawDetrendExp.camera\n"
+        "   rawExp.camera\n"
         " FROM detRun\n"
         " JOIN detInputExp\n"
         "   USING(det_id, iteration)\n"
-        " JOIN rawDetrendExp\n"
-        "   ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
+        " JOIN rawExp\n"
+        "   ON detInputExp.exp_tag = rawExp.exp_tag\n"
         " JOIN detProcessedImfile\n"
         "   ON detRun.det_id = detProcessedImfile.det_id\n"
@@ -3497,10 +3497,10 @@
         "   rawImfile.uri,\n"
         "   'NULL' AS det_uri,\n"
-        "   rawDetrendExp.camera\n"
+        "   rawExp.camera\n"
         " FROM detRun\n"
         " JOIN detInputExp\n"
         "    USING(det_id, iteration)\n"
-        " JOIN rawDetrendExp\n"
-        "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
+        " JOIN rawExp\n"
+        "    ON detInputExp.exp_tag = rawExp.exp_tag\n"
         " JOIN rawImfile\n"
         "    ON detInputExp.exp_tag = rawImfile.exp_tag\n"
@@ -3689,6 +3689,6 @@
         " JOIN detInputExp\n"
         "    USING(det_id, iteration)\n"
-        " JOIN rawDetrendExp\n"
-        "    ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
+        " JOIN rawExp\n"
+        "    ON detInputExp.exp_tag = rawExp.exp_tag\n"
         " JOIN rawImfile\n"
         "    ON detInputExp.exp_tag = rawImfile.exp_tag\n"
@@ -4047,12 +4047,12 @@
         "       detInputExp.exp_tag,\n"
         "       detInputExp.include,\n"
-        "       rawDetrendExp.imfiles,\n"
-        "       rawDetrendExp.camera,\n"
+        "       rawExp.imfiles,\n"
+        "       rawExp.camera,\n"
         "       detResidImfile.class_id\n"
         "   FROM detRun\n"
         "   JOIN detInputExp\n"
         "       USING(det_id, iteration)\n"
-        "   JOIN rawDetrendExp\n"
-        "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
+        "   JOIN rawExp\n"
+        "       ON detInputExp.exp_tag = rawExp.exp_tag\n"
         "   JOIN detResidImfile\n"
         "       ON detRun.det_id = detResidImfile.det_id\n"
@@ -4073,5 +4073,5 @@
         "       detRun.det_id\n"
         "   HAVING\n"
-        "       rawDetrendExp.imfiles = COUNT(detResidImfile.class_id)\n"
+        "       rawExp.imfiles = COUNT(detResidImfile.class_id)\n"
         " ) AS toresidexp\n"
         );
@@ -4171,10 +4171,10 @@
         "       detInputExp.exp_tag,"
         "       detInputExp.include,"
-        "       rawDetrendExp.imfiles"
+        "       rawExp.imfiles"
         "   FROM detRun"
         "   JOIN detInputExp"
         "       USING(det_id, iteration)"
-        "   JOIN rawDetrendExp"
-        "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag"
+        "   JOIN rawExp"
+        "       ON detInputExp.exp_tag = rawExp.exp_tag"
         "   JOIN detResidImfile"
         "       ON detRun.det_id = detResidImfile.det_id"
@@ -4195,5 +4195,5 @@
         "       detRun.det_id"
         "   HAVING"
-        "       rawDetrendExp.imfiles = COUNT(detResidImfile.class_id)"
+        "       rawExp.imfiles = COUNT(detResidImfile.class_id)"
         " ) AS toresidexp"
         );
@@ -4528,10 +4528,10 @@
         "       detRun.mode,\n"
         "       detInputExp.exp_tag,\n"
-        "       rawDetrendExp.camera\n"
+        "       rawExp.camera\n"
         "   FROM detRun\n"
         "   JOIN detInputExp\n"
         "       USING(det_id, iteration)\n"
-        "   JOIN rawDetrendExp\n"
-        "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
+        "   JOIN rawExp\n"
+        "       ON detInputExp.exp_tag = rawExp.exp_tag\n"
         "   LEFT JOIN detResidExp\n"
         "       ON detRun.det_id = detResidExp.det_id\n"
@@ -4802,6 +4802,6 @@
         "       ON detRun.det_id = detInputExp.det_id\n"
         "       AND detRun.iteration = detInputExp.iteration\n"
-        "   LEFT JOIN rawDetrendExp\n"
-        "       ON detInputExp.exp_tag = rawDetrendExp.exp_tag\n"
+        "   LEFT JOIN rawExp\n"
+        "       ON detInputExp.exp_tag = rawExp.exp_tag\n"
         "   LEFT JOIN detResidExp\n"
         "       ON detRun.det_id = detResidExp.det_id\n"
@@ -5305,5 +5305,5 @@
     psFree(where);
     if (!detrendExps) {
-        psError(PS_ERR_UNKNOWN, false, "no rawDetrendExp rows found");
+        psError(PS_ERR_UNKNOWN, false, "no rawExp rows found");
         psFree(where);
         return false;
