Index: trunk/ippTools/src/pxtables.c
===================================================================
--- trunk/ippTools/src/pxtables.c	(revision 11736)
+++ trunk/ippTools/src/pxtables.c	(revision 11763)
@@ -79,8 +79,7 @@
     CREATE_TABLE(detResidExpCreateTable);
     CREATE_TABLE(detRunSummaryCreateTable);
-    CREATE_TABLE(skyCellCreateTable);
-    CREATE_TABLE(skyCellMapCreateTable);
     CREATE_TABLE(p4RunCreateTable);
     CREATE_TABLE(p4InputExpCreateTable);
+    CREATE_TABLE(p4SkyCellMapCreateTable);
     CREATE_TABLE(p4ScfileCreateTable);
     CREATE_TABLE(p4InputScfileCreateTable);
@@ -154,4 +153,5 @@
     DROP_TABLE(p4RunDropTable);
     DROP_TABLE(p4InputExpDropTable);
+    DROP_TABLE(p4SkyCellMapDropTable);
     DROP_TABLE(p4ScfileDropTable);
     DROP_TABLE(p4InputScfileDropTable);
Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 11736)
+++ trunk/ippTools/src/warptool.c	(revision 11763)
@@ -34,7 +34,14 @@
 static bool updaterunMode(pxConfig *config);
 static bool addinputexpMode(pxConfig *config);
-static bool toscfileMode(pxConfig *config);
-static bool addscfileMode(pxConfig *config);
-static bool scfileMode(pxConfig *config);
+static bool expMode(pxConfig *config);
+static bool imfileMode(pxConfig *config);
+static bool tooverlapMode(pxConfig *config);
+static bool addoverlapMode(pxConfig *config);
+static bool scmapMode(pxConfig *config);
+static bool towarpedMode(pxConfig *config);
+static bool addwarpedMode(pxConfig *config);
+static bool warpedMode(pxConfig *config);
+
+#if 0
 static bool tostackedimfileMode(pxConfig *config);
 //static bool addstackedimfileMode(pxConfig *config);
@@ -43,4 +50,5 @@
 //static bool adddiffimfileMode(pxConfig *config);
 static bool diffimfileMode(pxConfig *config);
+#endif 
 
 static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state);
@@ -64,5 +72,14 @@
         MODECASE(P4TOOL_MODE_UPDATERUN,         updaterunMode);
         MODECASE(P4TOOL_MODE_ADDINPUTEXP,       addinputexpMode);
-        MODECASE(P4TOOL_MODE_TOSCFILE,          toscfileMode);
+        MODECASE(P4TOOL_MODE_EXP,               expMode);
+        MODECASE(P4TOOL_MODE_IMFILE,            imfileMode);
+        MODECASE(P4TOOL_MODE_TOOVERLAP,         tooverlapMode);
+        MODECASE(P4TOOL_MODE_ADDOVERLAP,        addoverlapMode);
+        MODECASE(P4TOOL_MODE_SCMAP,             scmapMode);
+        MODECASE(P4TOOL_MODE_TOWARPED,          towarpedMode);
+        MODECASE(P4TOOL_MODE_ADDWARPED,         addwarpedMode);
+        MODECASE(P4TOOL_MODE_WARPED,            warpedMode);
+
+#if 0
         MODECASE(P4TOOL_MODE_ADDSCFILE,         addscfileMode);
         MODECASE(P4TOOL_MODE_SCFILE,            scfileMode);
@@ -73,4 +90,5 @@
 //        MODECASE(P4TOOL_MODE_ADDDIFFIMFILE,     adddiffimfileMode);
         MODECASE(P4TOOL_MODE_DIFFIMFILE,        diffimfileMode);
+#endif
         default:
             psAbort("invalid option (this should not happen)");
@@ -255,4 +273,6 @@
 
     // XXX need to validate the p4_id here
+    // XXX instead of validiting it here we should just use forgein key
+    // constrants
     if (!p4InputExpInsert(config->dbh, 
             (psS32)atoi(p4_id),
@@ -268,5 +288,20 @@
 }
 
-static bool toscfileMode(pxConfig *config)
+
+static bool expMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, NULL);
+    return true;
+}
+
+
+static bool imfileMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, NULL);
+    return true;
+}
+
+
+static bool tooverlapMode(pxConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
@@ -274,12 +309,13 @@
     psString query = psStringCopy(
         " SELECT DISTINCT"
-        "   p4InputImfile.p4_id,"
+        "   p4InputExp.p4_id,"
         "   p2ProcessedImfile.*,"
         "   p4Run.workdir"
         " FROM p4Run"
-        " JOIN p4InputImfile"
+        " JOIN p4InputExp"
         "   USING(p4_id)"
-        " LEFT JOIN p4WarpedImfile"
-        "   USING(p4_id, exp_tag, p3_version, class_id)"
+        " LEFT JOIN p4Scfile"
+        "   ON p4Run.p4_id = p4Scfile.p4_id"
+        "   AND exp_tag, p3_version, class_id)"
         " JOIN p3ProcessedExp"
         "   ON p4InputImfile.exp_tag = p3ProcessedExp.exp_tag"
@@ -343,5 +379,27 @@
 }
 
-static bool addscfileMode(pxConfig *config)
+
+static bool addoverlapMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, NULL);
+    return true;
+}
+
+
+static bool scmapMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, NULL);
+    return true;
+}
+
+
+static bool towarpedMode(pxConfig *config)
+{
+    PS_ASSERT_PTR_NON_NULL(config, NULL);
+    return true;
+}
+
+
+static bool addwarpedMode(pxConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
@@ -437,5 +495,5 @@
 }
 
-static bool scfileMode(pxConfig *config)
+static bool warpedMode(pxConfig *config)
 {
     PS_ASSERT_PTR_NON_NULL(config, NULL);
@@ -497,4 +555,5 @@
 }
 
+#if 0
 static bool tostackedimfileMode(pxConfig *config)
 {
@@ -562,5 +621,4 @@
 }
 
-#if 0
 static bool addstackedimfileMode(pxConfig *config)
 {
@@ -625,5 +683,4 @@
     return true;
 }
-#endif
 
 static bool stackedimfileMode(pxConfig *config)
@@ -760,5 +817,4 @@
 }
 
-#if 0
 static bool adddiffimfileMode(pxConfig *config)
 {
@@ -842,5 +898,4 @@
     return true;
 }
-#endif
 
 static bool diffimfileMode(pxConfig *config)
@@ -903,4 +958,5 @@
     return true;
 }
+#endif
 
 static bool setp4RunState(pxConfig *config, const char *p4_id, const char *state)
Index: trunk/ippTools/src/warptool.h
===================================================================
--- trunk/ippTools/src/warptool.h	(revision 11736)
+++ trunk/ippTools/src/warptool.h	(revision 11763)
@@ -28,13 +28,12 @@
     P4TOOL_MODE_UPDATERUN,
     P4TOOL_MODE_ADDINPUTEXP,
-    P4TOOL_MODE_TOSCFILE,
-    P4TOOL_MODE_ADDSCFILE,
-    P4TOOL_MODE_SCFILE,
-    P4TOOL_MODE_TOSTACKEDIMFILE,
-    P4TOOL_MODE_ADDSTACKEDIMFILE,
-    P4TOOL_MODE_STACKEDIMFILE,
-    P4TOOL_MODE_TODIFFIMFILE,
-    P4TOOL_MODE_ADDDIFFIMFILE,
-    P4TOOL_MODE_DIFFIMFILE
+    P4TOOL_MODE_EXP,
+    P4TOOL_MODE_IMFILE,
+    P4TOOL_MODE_TOOVERLAP,
+    P4TOOL_MODE_ADDOVERLAP,
+    P4TOOL_MODE_SCMAP,
+    P4TOOL_MODE_TOWARPED,
+    P4TOOL_MODE_ADDWARPED,
+    P4TOOL_MODE_WARPED,
 } p4toolMode;
 
Index: trunk/ippTools/src/warptoolConfig.c
===================================================================
--- trunk/ippTools/src/warptoolConfig.c	(revision 11736)
+++ trunk/ippTools/src/warptoolConfig.c	(revision 11763)
@@ -80,46 +80,106 @@
     psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-magiced",  0,
             "has this exposure been magiced", false);
-   
-    // -toscfile
-    psMetadata *toscfileArgs = psMetadataAlloc();
-    psMetadataAddStr(toscfileArgs, PS_LIST_TAIL, "-p4_id", 0,
-            "search by p4 ID", NULL);
-    psMetadataAddBool(toscfileArgs, PS_LIST_TAIL, "-simple",  0,
-            "use the simple output format", false);
- 
-    // -addscfile
-    psMetadata *addscfileArgs = psMetadataAlloc();
-    psMetadataAddStr(addscfileArgs, PS_LIST_TAIL, "-p4_id", 0,
-            "define p4 ID (required)", NULL);
-    psMetadataAddStr(addscfileArgs, PS_LIST_TAIL, "-skycell_id",  0,
+
+    // -exp
+    psMetadata *expArgs = psMetadataAlloc();
+    psMetadataAddStr(expArgs, PS_LIST_TAIL, "-p4_id", 0,
+            "define p4 ID (required)", NULL);
+    psMetadataAddStr(expArgs, PS_LIST_TAIL, "-exp_tag", 0,
+            "define exposure tag (required)", NULL);
+    psMetadataAddS32(expArgs, PS_LIST_TAIL, "-p3_version", 0,
+            "define phase 3 version of exposure tag (required)", 0);
+    psMetadataAddU64(expArgs, PS_LIST_TAIL, "-limit",  0,
+            "limit result set to N items", 0);
+    psMetadataAddBool(expArgs, PS_LIST_TAIL, "-simple",  0,
+            "use the simple output format", false);
+
+    // -imfile
+    psMetadata *imfileArgs = psMetadataAlloc();
+    psMetadataAddStr(imfileArgs, PS_LIST_TAIL, "-p4_id", 0,
+            "define p4 ID (required)", NULL);
+    psMetadataAddStr(imfileArgs, PS_LIST_TAIL, "-exp_tag", 0,
+            "define exposure tag (required)", NULL);
+    psMetadataAddS32(imfileArgs, PS_LIST_TAIL, "-p3_version", 0,
+            "define phase 3 version of exposure tag (required)", 0);
+    psMetadataAddU64(imfileArgs, PS_LIST_TAIL, "-limit",  0,
+            "limit result set to N items", 0);
+    psMetadataAddBool(imfileArgs, PS_LIST_TAIL, "-simple",  0,
+            "use the simple output format", false);
+
+    // -tooverlap
+    psMetadata *tooverlapArgs = psMetadataAlloc();
+    psMetadataAddStr(tooverlapArgs, PS_LIST_TAIL, "-p4_id", 0,
+            "search by p4 ID", NULL);
+    psMetadataAddU64(tooverlapArgs, PS_LIST_TAIL, "-limit",  0,
+            "limit result set to N items", 0);
+    psMetadataAddBool(tooverlapArgs, PS_LIST_TAIL, "-simple",  0,
+            "use the simple output format", false);
+
+    // -addoverlap
+    psMetadata *addoverlapArgs = psMetadataAlloc();
+    psMetadataAddStr(addoverlapArgs, PS_LIST_TAIL, "-p4_id", 0,
+            "search by p4 ID", NULL);
+    psMetadataAddStr(addoverlapArgs, PS_LIST_TAIL, "-mapfile", 0,
+            "skycell <-> imfile mapping description", NULL);
+
+    // -scmap
+    psMetadata *scmapArgs = psMetadataAlloc();
+    psMetadataAddStr(scmapArgs, PS_LIST_TAIL, "-p4_id", 0,
+            "search by p4 ID", NULL);
+    psMetadataAddStr(scmapArgs, PS_LIST_TAIL, "-skycell_id", 0,
+            "searcy by skycell ID", NULL);
+    psMetadataAddStr(scmapArgs, PS_LIST_TAIL, "-tess_id", 0,
+            "searcy by tess ID", NULL);
+    psMetadataAddU64(scmapArgs, PS_LIST_TAIL, "-limit",  0,
+            "limit result set to N items", 0);
+    psMetadataAddBool(scmapArgs, PS_LIST_TAIL, "-simple",  0,
+            "use the simple output format", false);
+
+    // -towarped
+    psMetadata *towarpedArgs = psMetadataAlloc();
+    psMetadataAddStr(towarpedArgs, PS_LIST_TAIL, "-p4_id", 0,
+            "search by p4 ID", NULL);
+    psMetadataAddU64(towarpedArgs, PS_LIST_TAIL, "-limit",  0,
+            "limit result set to N items", 0);
+    psMetadataAddBool(towarpedArgs, PS_LIST_TAIL, "-simple",  0,
+            "use the simple output format", false);
+ 
+    // -addwarped
+    psMetadata *addwarpedArgs = psMetadataAlloc();
+    psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-p4_id", 0,
+            "define p4 ID (required)", NULL);
+    psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-skycell_id",  0,
             "define skycell ID (required)", NULL);
-    psMetadataAddStr(addscfileArgs, PS_LIST_TAIL, "-tess_id",  0,
+    psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-tess_id",  0,
             "define tessellation ID (required)", NULL);
-    psMetadataAddStr(addscfileArgs, PS_LIST_TAIL, "-exp_tag", 0,
-            "define exposure tag (required)", NULL);
-    psMetadataAddS32(addscfileArgs, PS_LIST_TAIL, "-p3_version", 0,
-            "define phase 3 version of exposure tag (required)", 0);
-    psMetadataAddStr(addscfileArgs, PS_LIST_TAIL, "-uri", 0,
+    psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-exp_tag", 0,
+            "define exposure tag (required)", NULL);
+    psMetadataAddS32(addwarpedArgs, PS_LIST_TAIL, "-p3_version", 0,
+            "define phase 3 version of exposure tag (required)", 0);
+    psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-uri", 0,
             "define URI of file (required)", 0);
-    psMetadataAddF64(addscfileArgs, PS_LIST_TAIL, "-bg",  0,
+    psMetadataAddF64(addwarpedArgs, PS_LIST_TAIL, "-bg",  0,
             "define exposue background", NAN);
-    psMetadataAddF64(addscfileArgs, PS_LIST_TAIL, "-bg_mean_stdev",  0,            "define exposue background mean stdev", NAN);
-
- 
-    // -scfile
-    psMetadata *scfileArgs = psMetadataAlloc();
-    psMetadataAddStr(scfileArgs, PS_LIST_TAIL, "-p4_id", 0,
-            "search by p4 ID", NULL);
-    psMetadataAddStr(scfileArgs, PS_LIST_TAIL, "-skycell_id",  0,
+    psMetadataAddF64(addwarpedArgs, PS_LIST_TAIL, "-bg_mean_stdev",  0,
+            "define exposue background mean stdev", NAN);
+ 
+    // -warped
+    psMetadata *warpedArgs = psMetadataAlloc();
+    psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-p4_id", 0,
+            "search by p4 ID", NULL);
+    psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-skycell_id",  0,
             "define skycell ID (required)", NULL);
-    psMetadataAddStr(scfileArgs, PS_LIST_TAIL, "-tess_id",  0,
+    psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-tess_id",  0,
             "define tessellation ID (required)", NULL);
-    psMetadataAddStr(scfileArgs, PS_LIST_TAIL, "-exp_tag", 0,
-            "define exposure tag (required)", NULL);
-    psMetadataAddS32(scfileArgs, PS_LIST_TAIL, "-p3_version", 0,
-            "define phase 3 version of exposure tag (required)", 0);
-    psMetadataAddBool(scfileArgs, PS_LIST_TAIL, "-simple",  0,
-            "use the simple output format", false);
-
+    psMetadataAddStr(warpedArgs, PS_LIST_TAIL, "-exp_tag", 0,
+            "define exposure tag (required)", NULL);
+    psMetadataAddS32(warpedArgs, PS_LIST_TAIL, "-p3_version", 0,
+            "define phase 3 version of exposure tag (required)", 0);
+    psMetadataAddU64(warpedArgs, PS_LIST_TAIL, "-limit",  0,
+            "limit result set to N items", 0);
+    psMetadataAddBool(warpedArgs, PS_LIST_TAIL, "-simple",  0,
+            "use the simple output format", false);
+
+#if 0
     // -tostackedimfile
     psMetadata *tostackedimfileArgs = psMetadataAlloc();
@@ -183,4 +243,5 @@
     psMetadataAddBool(diffimfileArgs, PS_LIST_TAIL, "-simple",  0,
             "use the simple output format", false);
+#endif 
 
     psFree(now);
@@ -209,7 +270,13 @@
     PXTOOL_MODE("-updaterun",       P4TOOL_MODE_UPDATERUN,      updaterunArgs);
     PXTOOL_MODE("-addinputexp",     P4TOOL_MODE_ADDINPUTEXP,    addinputexpArgs);
-    PXTOOL_MODE("-toscfile",        P4TOOL_MODE_TOSCFILE,       toscfileArgs);
-    PXTOOL_MODE("-addscfile",       P4TOOL_MODE_ADDSCFILE,      addscfileArgs);
-    PXTOOL_MODE("-scfile",          P4TOOL_MODE_SCFILE,         scfileArgs);
+    PXTOOL_MODE("-exp",             P4TOOL_MODE_EXP,            expArgs);
+    PXTOOL_MODE("-imfile",          P4TOOL_MODE_IMFILE,         imfileArgs);
+    PXTOOL_MODE("-tooverlap",       P4TOOL_MODE_TOOVERLAP,      tooverlapArgs);
+    PXTOOL_MODE("-addoverlap",      P4TOOL_MODE_ADDOVERLAP,     addoverlapArgs);
+    PXTOOL_MODE("-scmap",           P4TOOL_MODE_SCMAP,          scmapArgs);
+    PXTOOL_MODE("-towarped",        P4TOOL_MODE_TOWARPED,       towarpedArgs);
+    PXTOOL_MODE("-addwarped",       P4TOOL_MODE_ADDWARPED,      addwarpedArgs);
+    PXTOOL_MODE("-warped",          P4TOOL_MODE_WARPED,         warpedArgs);
+#if 0
     PXTOOL_MODE("-tostackedimfile", P4TOOL_MODE_TOSTACKEDIMFILE, tostackedimfileArgs);
     PXTOOL_MODE("-addstackedimfile", P4TOOL_MODE_ADDSTACKEDIMFILE, addstackedimfileArgs);
@@ -218,4 +285,5 @@
     PXTOOL_MODE("-adddiffimfile", P4TOOL_MODE_ADDDIFFIMFILE, adddiffimfileArgs);
     PXTOOL_MODE("-diffimfile",   P4TOOL_MODE_DIFFIMFILE, diffimfileArgs);
+#endif
 
     bool argErr = false;
