Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 23383)
+++ trunk/ippTools/src/warptool.c	(revision 23418)
@@ -191,46 +191,7 @@
 
     psMetadata *where = psMetadataAlloc();
-    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", "newExp.exp_id", "==");
-    PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
-    PXOPT_COPY_STR(config->args, where, "-inst", "camera", "==");
-    PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "==");
-    PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">=");
-    PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<=");
-    PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "==");
-    PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "==");
-    PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "==");
-    PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "==");
-    PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
-    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_F32(config->args, where, "-exp_time_min", "exp_time", ">=");
-    PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<");
-    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">=");
-    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<");
-    PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">=");
-    PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<");
-    PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">=");
-    PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<");
-    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">=");
-    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<");
-    PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">=");
-    PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<");
-    PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">=");
-    PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<");
-    PXOPT_COPY_F32(config->args, where, "-ccd_temp_min", "ccd_temp", ">=");
-    PXOPT_COPY_F32(config->args, where, "-ccd_temp_max", "ccd_temp", "<");
-    PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">=");
-    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_STR(config->args, where, "-label", "label", "==");
+    pxwarpGetSearchArgs (config, where);
+    PXOPT_COPY_STR(config->args, where, "-reduction", "fakeRun.reduction", "==");
+    PXOPT_COPY_STR(config->args, where, "-label",     "fakeRun.label",     "==");
 
     if (!psListLength(where->list) &&
@@ -338,45 +299,9 @@
 
     psMetadata *where = psMetadataAlloc();
-    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
-    PXOPT_COPY_S64(config->args, where, "-fake_id", "fake_id", "==");
-    PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
-    PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
-    PXOPT_COPY_STR(config->args, where, "-exp_name", "exp_name", "==");
-    PXOPT_COPY_STR(config->args, where, "-inst", "camera", "==");
-    PXOPT_COPY_STR(config->args, where, "-telescope", "telescope", "==");
-    PXOPT_COPY_TIME(config->args, where, "-dateobs_begin", "dateobs", ">=");
-    PXOPT_COPY_TIME(config->args, where, "-dateobs_end", "dateobs", "<=");
-    PXOPT_COPY_STR(config->args, where, "-exp_tag", "exp_tag", "==");
-    PXOPT_COPY_STR(config->args, where, "-exp_type", "exp_type", "==");
-    PXOPT_COPY_STR(config->args, where, "-filelevel", "filelevel", "==");
-    PXOPT_COPY_STR(config->args, where, "-reduction", "reduction", "==");
-    PXOPT_COPY_STR(config->args, where, "-filter", "filter", "==");
-    PXOPT_COPY_F32(config->args, where, "-airmass_min", "airmass", ">=");
-    PXOPT_COPY_F32(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_F32(config->args, where, "-exp_time_min", "exp_time", ">=");
-    PXOPT_COPY_F32(config->args, where, "-exp_time_max", "exp_time", "<");
-    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_min", "sat_pixel_frac", ">=");
-    PXOPT_COPY_F32(config->args, where, "-sat_pixel_frac_max", "sat_pixel_frac", "<");
-    PXOPT_COPY_F64(config->args, where, "-bg_min", "bt", ">=");
-    PXOPT_COPY_F64(config->args, where, "-bg_max", "bt", "<");
-    PXOPT_COPY_F64(config->args, where, "-bg_stdev_min", "bg_stdev", ">=");
-    PXOPT_COPY_F64(config->args, where, "-bg_stdev_max", "bg_stdev", "<");
-    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_min", "bg_mean_stdev", ">=");
-    PXOPT_COPY_F64(config->args, where, "-bg_mean_stdev_max", "bg_mean_stdev", "<");
-    PXOPT_COPY_F64(config->args, where, "-alt_min", "alt", ">=");
-    PXOPT_COPY_F64(config->args, where, "-alt_max", "alt", "<");
-    PXOPT_COPY_F64(config->args, where, "-az_min", "az", ">=");
-    PXOPT_COPY_F64(config->args, where, "-az_max", "az", "<");
-    PXOPT_COPY_F64(config->args, where, "-ccd_temp_min", "ccd_temp", ">=");
-    PXOPT_COPY_F64(config->args, where, "-ccd_temp_max", "ccd_temp", "<");
-    PXOPT_COPY_F64(config->args, where, "-posang_min", "posang", ">=");
-    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", "<");
+    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", 	   "==");
 
     if (!psListLength(where->list)
@@ -388,6 +313,6 @@
     }
 
-    PXOPT_LOOKUP_STR(state, config->args, "-state", false, false);
-    PXOPT_LOOKUP_STR(label, config->args, "-label", false, false);
+    PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
+    PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false);
 
     if ((!state) && (!label)) {
@@ -1183,51 +1108,11 @@
 
     psMetadata *where = psMetadataAlloc();
-    PXOPT_COPY_S64(config->args, where, "-warp_id", "warpSkyfile.warp_id", "==");
+    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", "==");
-    PXOPT_COPY_STR(config->args, where, "-tess_id", "warpSkyfile.tess_id", "==");
-    PXOPT_COPY_S64(config->args, where, "-fake_id", "fakeRun.fake_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, "-label", "warpRun.label", "==");
-    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, "-reduction", "rawExp.reduction", "==");
-    PXOPT_COPY_STR(config->args, where, "-filter", "rawExp.filter", "==");
-
-    PXOPT_COPY_F32(config->args, where, "-airmass_min", "rawExp.airmass", ">=");
-    PXOPT_COPY_F32(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_F64(config->args, where, "-ccd_temp_min", "rawExp.ccd_temp", ">=");
-    PXOPT_COPY_F64(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_S16(config->args, where, "-code", "warpSkyfile.fault", "==");
+    PXOPT_COPY_STR(config->args, where, "-tess_id",    "warpSkyfile.tess_id", "==");
+    PXOPT_COPY_STR(config->args, where, "-reduction",  "rawExp.reduction", "==");
+    PXOPT_COPY_STR(config->args, where, "-label",      "warpRun.label", "==");
+    PXOPT_COPY_S16(config->args, where, "-code",       "warpSkyfile.fault", "==");
 
     if (!psListLength(where->list)
@@ -1464,12 +1349,10 @@
     PS_ASSERT_PTR_NON_NULL(config, NULL);
 
-    PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", false, false);
+    PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false);
     PXOPT_LOOKUP_U64(limit, config->args, "-limit", false, false);
     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
 
     psMetadata *where = psMetadataAlloc();
-    if (warp_id) {
-        PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
-    }
+    PXOPT_COPY_S64(config->args, where, "-warp_id", "warp_id", "==");
     PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
 
@@ -1626,5 +1509,6 @@
 
     // note only updates if warpRun.state = run_state
-    if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id, run_state)) {
+    // XXX note that we have removed this constraint for now
+    if (!p_psDBRunQueryF(config->dbh, query, data_state, warp_id, skycell_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         // rollback
