Index: trunk/ippTools/src/stacktool.c
===================================================================
--- trunk/ippTools/src/stacktool.c	(revision 16931)
+++ trunk/ippTools/src/stacktool.c	(revision 16940)
@@ -99,26 +99,30 @@
     PXOPT_LOOKUP_STR(workdir, config->args, "-workdir", true, false);
 
-    psMetadata *where = psMetadataAlloc();
-    // map -inst -> camera
-    PXOPT_COPY_STR(config->args, where, "-select_inst", "camera", "==");
-    PXOPT_COPY_STR(config->args, where, "-select_telescope", "telescope", "==");
-    PXOPT_COPY_STR(config->args, where, "-select_filter", "filter", "==");
-    PXOPT_COPY_STR(config->args, where, "-select_uri", "uri", "==");
-    PXOPT_COPY_TIME(config->args, where, "-select_dateobs_begin", "dateobs", ">=");
-    PXOPT_COPY_TIME(config->args, where, "-select_dateobs_end", "dateobs", "<");
-    PXOPT_COPY_F32(config->args, where, "-select_airmass_min", "airmass", ">=");
-    PXOPT_COPY_F32(config->args, where, "-select_airmass_max", "airmass", "<=");
-    PXOPT_COPY_F32(config->args, where, "-select_sat_pixel_frac_max", "sat_pixel_frac", "<=");
-    PXOPT_COPY_F32(config->args, where, "-select_exp_time_min", "exp_time", ">=");
-    PXOPT_COPY_F32(config->args, where, "-select_exp_time_max", "exp_time", "<=");
-    PXOPT_COPY_F32(config->args, where, "-select_ccd_temp_min", "ccd_temp", ">=");
-    PXOPT_COPY_F32(config->args, where, "-select_ccd_temp_max", "ccd_temp", "<=");
-    PXOPT_COPY_F32(config->args, where, "-select_posang_min", "posang", ">=");
-    PXOPT_COPY_F32(config->args, where, "-select_posang_max", "posang", "<=");
-    PXOPT_COPY_F32(config->args, where, "-select_solang_min", "solang", ">=");
-    PXOPT_COPY_F32(config->args, where, "-select_solang_max", "solang", "<=");
-
-    if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
-        psFree(where);
+    psMetadata *whereRE = psMetadataAlloc(); // rawExp where
+    psMetadata *whereWSF = psMetadataAlloc(); // warpSkyfile where
+    // map -inst -> camera, etc
+    PXOPT_COPY_STR(config->args, whereRE, "-select_inst", "camera", "==");
+    PXOPT_COPY_STR(config->args, whereRE, "-select_telescope", "telescope", "==");
+    PXOPT_COPY_STR(config->args, whereRE, "-select_filter", "filter", "==");
+    PXOPT_COPY_STR(config->args, whereRE, "-select_uri", "uri", "==");
+    PXOPT_COPY_TIME(config->args, whereRE, "-select_dateobs_begin", "dateobs", ">=");
+    PXOPT_COPY_TIME(config->args, whereRE, "-select_dateobs_end", "dateobs", "<");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_airmass_min", "airmass", ">=");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_airmass_max", "airmass", "<=");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_sat_pixel_frac_max", "sat_pixel_frac", "<=");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_exp_time_min", "exp_time", ">=");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_exp_time_max", "exp_time", "<=");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_ccd_temp_min", "ccd_temp", ">=");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_ccd_temp_max", "ccd_temp", "<=");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_posang_min", "posang", ">=");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_posang_max", "posang", "<=");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_solang_min", "solang", ">=");
+    PXOPT_COPY_F32(config->args, whereRE, "-select_solang_max", "solang", "<=");
+    PXOPT_COPY_STR(config->args, whereWSF, "-select_skycell_id", "skycell_id", "==");
+
+    if (!psListLength(whereRE->list) && !psListLength(whereWSF->list) &&
+        !psMetadataLookupBool(NULL, config->args, "-all")) {
+        psFree(whereRE);
+        psFree(whereWSF);
         psError(PXTOOLS_ERR_DATA, false, "search parameters are required");
         return false;
@@ -128,5 +132,6 @@
     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
     PXOPT_LOOKUP_TIME(registered, config->args, "-registered", false, false);
-    PXOPT_COPY_STR(config->args, where, "-select_exp_type", "exp_type", "==");
+    PXOPT_COPY_STR(config->args, whereRE, "-select_exp_type", "exp_type", "==");
+    PXOPT_COPY_F32(config->args, whereWSF, "-select_good_frac_min", "good_frac", ">=");
 
     psString query = pxDataGet("stacktool_find_complete_warps.sql");
@@ -136,9 +141,17 @@
     }
 
-    if (where) {
-        psString whereClause = psDBGenerateWhereConditionSQL(where, "rawExp");
+    if (whereRE) {
+        psString whereClause = psDBGenerateWhereConditionSQL(whereRE, "rawExp");
         psStringAppend(&query, " AND %s", whereClause);
         psFree(whereClause);
     }
+    psFree(whereRE);
+
+    if (whereWSF) {
+        psString whereClause = psDBGenerateWhereConditionSQL(whereWSF, "warpSkyfile");
+        psStringAppend(&query, " AND %s", whereClause);
+        psFree(whereClause);
+    }
+    psFree(whereWSF);
 
     if (!p_psDBRunQuery(config->dbh, query)) {
Index: trunk/ippTools/src/stacktoolConfig.c
===================================================================
--- trunk/ippTools/src/stacktoolConfig.c	(revision 16931)
+++ trunk/ippTools/src/stacktoolConfig.c	(revision 16940)
@@ -51,4 +51,8 @@
     psMetadataAddTime(queueArgs, PS_LIST_TAIL, "-registered",  0,
             "time detrend run was registered", now);
+    psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-select_skycell_id",  0,
+            "search for skycell_id", NULL);
+    psMetadataAddF32(queueArgs, PS_LIST_TAIL, "-select_good_frac_min",  0,
+            "define min good_frac", 0.0);
     psMetadataAddStr(queueArgs, PS_LIST_TAIL, "-select_exp_type",  0,
             "search for exp_type", "object");
