Index: branches/pap/ippTools/src/faketool.c
===================================================================
--- branches/pap/ippTools/src/faketool.c	(revision 23948)
+++ branches/pap/ippTools/src/faketool.c	(revision 25027)
@@ -134,8 +134,8 @@
     PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">=");
     PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<");
-    PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">=");
-    PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<");
-    PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">=");
-    PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<");
+    PXOPT_COPY_RADEC(config->args, where, "-ra_min", "ra", ">=");
+    PXOPT_COPY_RADEC(config->args, where, "-ra_max", "ra", "<");
+    PXOPT_COPY_RADEC(config->args, where, "-decl_min", "decl", ">=");
+    PXOPT_COPY_RADEC(config->args, where, "-decl_max", "decl", "<");
     PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">=");
     PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<");
@@ -157,6 +157,6 @@
     PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<");
     PXOPT_COPY_STR(config->args, where, "-object", "object", "==");
-    PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">=");
-    PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<");
+    PXOPT_COPY_F32(config->args, where, "-sun_angle_min", "sun_angle", ">=");
+    PXOPT_COPY_F32(config->args, where, "-sun_angle_max", "sun_angle", "<");
     PXOPT_COPY_STR(config->args, where, "-comment", "comment", "LIKE");
 
@@ -235,8 +235,8 @@
         bool status;
         char *end_stage = psMetadataLookupStr(&status, md, "end_stage");
-	if (end_stage && strcasecmp(end_stage, "warp")) continue;
+        if (end_stage && strcasecmp(end_stage, "warp")) continue;
 
         char *raw_tess_id   = psMetadataLookupStr(&status, md, "tess_id");
-	if (raw_tess_id || tess_id) continue;
+        if (raw_tess_id || tess_id) continue;
 
         char *label  = psMetadataLookupStr(&status, md, "label");
@@ -244,5 +244,5 @@
 
         if (!status) {
-	    psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id);
+            psError(PS_ERR_UNKNOWN, false, "cannot queue analysis to WARP without a defined tess id: label: %s, exp_id %" PRId64, label, exp_id);
             psFree(output);
             return false;
@@ -302,8 +302,8 @@
     PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">=");
     PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<");
-    PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">=");
-    PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<");
-    PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">=");
-    PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<");
+    PXOPT_COPY_RADEC(config->args, where, "-ra_min", "ra", ">=");
+    PXOPT_COPY_RADEC(config->args, where, "-ra_max", "ra", "<");
+    PXOPT_COPY_RADEC(config->args, where, "-decl_min", "decl", ">=");
+    PXOPT_COPY_RADEC(config->args, where, "-decl_max", "decl", "<");
     PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">=");
     PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<");
@@ -325,6 +325,6 @@
     PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<");
     PXOPT_COPY_STR(config->args, where, "-object", "object", "==");
-    PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">=");
-    PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<");
+    PXOPT_COPY_F32(config->args, where, "-sun_angle_min", "sun_angle", ">=");
+    PXOPT_COPY_F32(config->args, where, "-sun_angle_max", "sun_angle", "<");
     PXOPT_COPY_STR(config->args, where, "-label", "fakeRun.label", "==");
 
@@ -455,6 +455,6 @@
 
     if (where && psListLength(where->list)) {
-        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
-        psStringAppend(&query, " WHERE %s", whereClause);
+        psString whereClause = psDBGenerateWhereConditionSQL(where, "fakeRun");
+        psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
     }
@@ -563,5 +563,5 @@
 
     psMetadata *where = psMetadataAlloc();
-    PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_id", "==");
+    PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
     PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "==");
     PXOPT_COPY_STR(config->args, where, "-class_id", "rawImfile.class_id", "==");
@@ -632,6 +632,6 @@
 
     psMetadata *where = psMetadataAlloc();
+    pxAddLabelSearchArgs (config, where, "-label", "fakeRun.label", "==");
     PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
-    PXOPT_COPY_STR(config->args, where, "-label", "fakeRun.label", "==");
     PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
     PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
@@ -646,8 +646,8 @@
     PXOPT_COPY_F64(config->args, where, "-airmass_min", "airmass", ">=");
     PXOPT_COPY_F64(config->args, where, "-airmass_max", "airmass", "<");
-    PXOPT_COPY_F64(config->args, where, "-ra_min", "ra", ">=");
-    PXOPT_COPY_F64(config->args, where, "-ra_max", "ra", "<");
-    PXOPT_COPY_F64(config->args, where, "-decl_min", "decl", ">=");
-    PXOPT_COPY_F64(config->args, where, "-decl_max", "decl", "<");
+    PXOPT_COPY_RADEC(config->args, where, "-ra_min", "ra", ">=");
+    PXOPT_COPY_RADEC(config->args, where, "-ra_max", "ra", "<");
+    PXOPT_COPY_RADEC(config->args, where, "-decl_min", "decl", ">=");
+    PXOPT_COPY_RADEC(config->args, where, "-decl_max", "decl", "<");
     PXOPT_COPY_F32(config->args, where, "-exp_time_min", "exp_time", ">=");
     PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<");
@@ -669,6 +669,6 @@
     PXOPT_COPY_F64(config->args, where, "-posang_max", "posang", "<");
     PXOPT_COPY_STR(config->args, where, "-object", "object", "==");
-    PXOPT_COPY_F32(config->args, where, "-solang_min", "solang", ">=");
-    PXOPT_COPY_F32(config->args, where, "-solang_max", "solang", "<");
+    PXOPT_COPY_F32(config->args, where, "-sun_angle_min", "sun_angle", ">=");
+    PXOPT_COPY_F32(config->args, where, "-sun_angle_max", "sun_angle", "<");
 
     if (!psListLength(where->list)
@@ -895,5 +895,5 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxAddLabelSearchArgs (config, where, "-label", "label", "==");
+    pxAddLabelSearchArgs (config, where, "-label", "fakeRun.label", "==");
 
     psString query = pxDataGet("faketool_pendingcleanuprun.sql");
@@ -1157,10 +1157,11 @@
         // pxwarpQueueByFakeID() can only be run after fakeRun.state has been set to stop
         if (!pxwarpQueueByFakeID(config,
-                    fakeRun->fake_id,
-                    fakeRun->workdir,
-                    fakeRun->label,
-                    fakeRun->dvodb,
-                    fakeRun->tess_id,
-                    fakeRun->end_stage
+                                 fakeRun->fake_id,
+                                 fakeRun->workdir,
+                                 fakeRun->label,
+                                 fakeRun->dvodb,
+                                 fakeRun->tess_id,
+                                 fakeRun->reduction,
+                                 fakeRun->end_stage
         )) {
             psError(PS_ERR_UNKNOWN, false, "failed to queue warpRun");
