Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 23459)
+++ trunk/ippTools/src/warptool.c	(revision 23613)
@@ -30,5 +30,4 @@
 #include "pxtools.h"
 #include "warptool.h"
-#include "pxwarp.h"
 
 static psS64 definerunMode(pxConfig *config);
@@ -191,5 +190,44 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxwarpGetSearchArgs (config, where);
+    PXOPT_COPY_S64(config->args, where, "-fake_id",            "fakeRun.fake_id",       "==");
+    PXOPT_COPY_S64(config->args, where, "-cam_id",             "camRun.cam_id",         "==");
+    PXOPT_COPY_S64(config->args, where, "-chip_id",            "chipRun.chip_id",       "==");
+    PXOPT_COPY_S64(config->args, where, "-exp_id",             "rawExp.exp_id",         "==");
+    PXOPT_COPY_STR(config->args, where, "-exp_name",           "rawExp.exp_name",       "==");
+    PXOPT_COPY_STR(config->args, where, "-inst",               "rawExp.camera",         "==");
+    PXOPT_COPY_STR(config->args, where, "-telescope",          "rawExp.telescope",      "==");
+    PXOPT_COPY_TIME(config->args, where, "-dateobs_begin",     "rawExp.dateobs",        ">=");
+    PXOPT_COPY_TIME(config->args, where, "-dateobs_end",       "rawExp.dateobs",        "<=");
+    PXOPT_COPY_STR(config->args, where, "-exp_tag",            "rawExp.exp_tag",        "==");
+    PXOPT_COPY_STR(config->args, where, "-exp_type",           "rawExp.exp_type",       "==");
+    PXOPT_COPY_STR(config->args, where, "-filelevel",          "rawExp.filelevel",      "==");
+    PXOPT_COPY_STR(config->args, where, "-filter",             "rawExp.filter",         "==");
+    PXOPT_COPY_F64(config->args, where, "-airmass_min",        "rawExp.airmass",        ">=");
+    PXOPT_COPY_F64(config->args, where, "-airmass_max",        "rawExp.airmass",        "<");
+    PXOPT_COPY_F64(config->args, where, "-ra_min",             "rawExp.ra",             ">=");
+    PXOPT_COPY_F64(config->args, where, "-ra_max",             "rawExp.ra",             "<");
+    PXOPT_COPY_F64(config->args, where, "-decl_min",           "rawExp.decl",           ">=");
+    PXOPT_COPY_F64(config->args, where, "-decl_max",           "rawExp.decl",           "<");
+    PXOPT_COPY_F32(config->args, where, "-exp_time_min",       "rawExp.exp_time",       ">=");
+    PXOPT_COPY_F32(config->args, where, "-exp_time_max",       "rawExp.exp_time",       "<");
+    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "rawExp.sat_pixel_frac", ">=");
+    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "rawExp.sat_pixel_frac", "<");
+    PXOPT_COPY_F64(config->args, where, "-bg_min",             "rawExp.bg",             ">=");
+    PXOPT_COPY_F64(config->args, where, "-bg_max",             "rawExp.bg",             "<");
+    PXOPT_COPY_F64(config->args, where, "-bg_stdev_min",       "rawExp.bg_stdev",       ">=");
+    PXOPT_COPY_F64(config->args, where, "-bg_stdev_max",       "rawExp.bg_stdev",       "<");
+    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min",  "rawExp.bg_mean_stdev",  ">=");
+    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max",  "rawExp.bg_mean_stdev",  "<");
+    PXOPT_COPY_F64(config->args, where, "-alt_min",            "rawExp.alt",            ">=");
+    PXOPT_COPY_F64(config->args, where, "-alt_max",            "rawExp.alt",            "<");
+    PXOPT_COPY_F64(config->args, where, "-az_min",             "rawExp.az",             ">=");
+    PXOPT_COPY_F64(config->args, where, "-az_max",             "rawExp.az",             "<");
+    PXOPT_COPY_F32(config->args, where, "-ccd_temp_min",       "rawExp.ccd_temp",       ">=");
+    PXOPT_COPY_F32(config->args, where, "-ccd_temp_max",       "rawExp.ccd_temp",       "<");
+    PXOPT_COPY_F64(config->args, where, "-posang_min",         "rawExp.posang",         ">=");
+    PXOPT_COPY_F64(config->args, where, "-posang_max",         "rawExp.posang",         "<");
+    PXOPT_COPY_STR(config->args, where, "-object",             "rawExp.object",         "==");
+    PXOPT_COPY_F32(config->args, where, "-solang_min",         "rawExp.solang",         ">=");
+    PXOPT_COPY_F32(config->args, where, "-solang_max",         "rawExp.solang",         "<");
     PXOPT_COPY_STR(config->args, where, "-reduction", "fakeRun.reduction", "==");
     PXOPT_COPY_STR(config->args, where, "-label",     "fakeRun.label",     "==");
@@ -227,7 +265,7 @@
 
     // use psDBGenerateWhereSQL because the SQL yields an intermediate table
-    if (where && psListLength(where->list)) {
-        psString whereClause = psDBGenerateWhereSQL(where, NULL);
-        psStringAppend(&query, "%s", whereClause);
+    if (psListLength(where->list)) {
+        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
+        psStringAppend(&query, "AND %s", whereClause);
         psFree(whereClause);
     }
@@ -299,9 +337,8 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxwarpGetSearchArgs (config, where);
     PXOPT_COPY_S64(config->args, where, "-warp_id",   "warpRun.warp_id",   "==");
     PXOPT_COPY_STR(config->args, where, "-reduction", "warpRun.reduction", "==");
-    PXOPT_COPY_STR(config->args, where, "-label",     "warpRun.label", 	   "==");
-    PXOPT_COPY_STR(config->args, where, "-state",     "warpRun.state", 	   "==");
+    PXOPT_COPY_STR(config->args, where, "-label",     "warpRun.label",     "==");
+    PXOPT_COPY_STR(config->args, where, "-state",     "warpRun.state",     "==");
 
     if (!psListLength(where->list)
@@ -1070,5 +1107,4 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxwarpGetSearchArgs (config, where);
     PXOPT_COPY_S64(config->args, where, "-warp_id",    "warpSkyfile.warp_id", "==");
     PXOPT_COPY_STR(config->args, where, "-skycell_id", "warpSkyfile.skycell_id", "==");
@@ -1627,9 +1663,9 @@
 
   int numImportTables = 3;
-  
+
   char tables[3] [80] = {"warpImfile", "warpSkyfile", "warpSkyCellMap"};
 
   PS_ASSERT_PTR_NON_NULL(config, NULL);
-  
+
   PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
 
@@ -1642,5 +1678,5 @@
   psAssert (item, "entry not in input?");
   psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
-  
+
   psMetadataItem *entry = psListGet (item->data.list, 0);
   assert (entry);
@@ -1656,7 +1692,7 @@
     psAssert (item, "entry not in input?");
     psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
-    
+
     switch (i) {
-      case 0:  
+      case 0:
         for (int i = 0; i < item->data.list->n; i++) {
           entry = psListGet (item->data.list, i);
@@ -1670,6 +1706,6 @@
         }
         break;
-        
-      case 1:  
+
+      case 1:
         for (int i = 0; i < item->data.list->n; i++) {
           entry = psListGet (item->data.list, i);
@@ -1683,6 +1719,6 @@
         }
         break;
-        
-      case 2:  
+
+      case 2:
         for (int i = 0; i < item->data.list->n; i++) {
           entry = psListGet (item->data.list, i);
