Index: /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/include/dvomerge.h
===================================================================
--- /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/include/dvomerge.h	(revision 28862)
+++ /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/include/dvomerge.h	(revision 28863)
@@ -59,4 +59,5 @@
 
 int        SkyTablePopulatedRange PROTO((off_t *ns, off_t *ne, SkyTable *sky, off_t Nstart));
+int        SkyListPopulatedRange  PROTO((off_t *ns, off_t *ne, SkyList *sky, off_t Nstart));
 
 SkyList   *SkyTablePopulatedList  PROTO((SkyTable *sky));
Index: /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/SkyTablePopulatedRange.c
===================================================================
--- /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/SkyTablePopulatedRange.c	(revision 28862)
+++ /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/SkyTablePopulatedRange.c	(revision 28863)
@@ -12,4 +12,27 @@
     Ns = sky[0].regions[Nstart].childS;
     Ne = sky[0].regions[Nstart].childE;
+    if (Ns == 0) {
+      fprintf (stderr, "no populated tables at an appropriate depth\n");
+      exit (1);
+    }
+    Nstart = Ns;
+  }
+
+  *ns = Ns;
+  *ne = Ne;
+  return (TRUE);
+}
+
+int SkyListPopulatedRange (off_t *ns, off_t *ne, SkyList *sky, off_t Nstart) {
+
+  off_t Ns, Ne;
+
+  // given the starting sky region, find the populated range at or below this region
+
+  Ns = Nstart;
+  Ne = Nstart + 1;
+  while (!sky[0].regions[Nstart][0].table) {
+    Ns = sky[0].regions[Nstart][0].childS;
+    Ne = sky[0].regions[Nstart][0].childE;
     if (Ns == 0) {
       fprintf (stderr, "no populated tables at an appropriate depth\n");
Index: /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/args.c	(revision 28862)
+++ /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/args.c	(revision 28863)
@@ -10,4 +10,22 @@
   if ((N = get_argument (*argc, argv, "-v"))) {
     VERBOSE = TRUE;
+    remove_argument (N, argc, argv);
+  }
+
+  /*** provide additional data ***/ 
+  /* restrict to a portion of the sky? */
+  UserPatch.Rmin = 0;
+  UserPatch.Rmax= 360;
+  UserPatch.Dmin = -90;
+  UserPatch.Dmax = +90;
+  if ((N = get_argument (*argc, argv, "-region"))) {
+    remove_argument (N, argc, argv);
+    UserPatch.Rmin = atof (argv[N]);
+    remove_argument (N, argc, argv);
+    UserPatch.Rmax = atof (argv[N]);
+    remove_argument (N, argc, argv);
+    UserPatch.Dmin = atof (argv[N]);
+    remove_argument (N, argc, argv);
+    UserPatch.Dmax = atof (argv[N]);
     remove_argument (N, argc, argv);
   }
Index: /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/dvomergeUpdate.c
===================================================================
--- /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/dvomergeUpdate.c	(revision 28862)
+++ /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/dvomergeUpdate.c	(revision 28863)
@@ -6,5 +6,5 @@
   off_t i, j, Ns, Ne;
   SkyTable *outsky, *insky;
-  SkyList *outlist;
+  SkyList *outlist, *inlist;
   Catalog incatalog, outcatalog;
   char filename[256], *input, *output;
@@ -46,4 +46,7 @@
   SkyTableSetFilenames (insky, input, "cpt");
 
+  // XXX apply this...generate the subset matching the user-selected region
+  inlist = SkyListByPatch (insky, -1, &UserPatch);
+
   // generate an output table populated at the desired depth
   outsky = SkyTableLoadOptimal (output, NULL, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
@@ -55,14 +58,14 @@
   // loop over the populatable output tables; check for data in input in the corresponding regions
 
-  SkyTablePopulatedRange (&Ns, &Ne, insky, 0);
-  depth = insky[0].regions[Ns].depth;
+  SkyListPopulatedRange (&Ns, &Ne, inlist, 0);
+  depth = inlist[0].regions[Ns][0].depth;
   
   // loop over the populated input regions
   for (i = 0; i < outsky[0].Nregions; i++) {
-    if (!insky[0].regions[i].table) continue;
-    if (VERBOSE) fprintf (stderr, "input: %s\n", insky[0].regions[i].name);
+    if (!inlist[0].regions[i][0].table) continue;
+    if (VERBOSE) fprintf (stderr, "input: %s\n", inlist[0].regions[i][0].name);
 
     // load / create output catalog (if catalog does not exist, it will be created)
-    LoadCatalog (&incatalog, &insky[0].regions[i], insky[0].filename[i], "r");
+    LoadCatalog (&incatalog, &inlist[0].regions[i][0], inlist[0].filename[i], "r");
     // skip empty input catalogs
     if (!incatalog.Naves_disk) {
@@ -78,5 +81,5 @@
     // compare to a slightly reduced footprint
     float dPos = 2.0/3600.0;
-    outlist = SkyListByBounds (outsky, depth, insky[0].regions[i].Rmin + dPos, insky[0].regions[i].Rmax - dPos, insky[0].regions[i].Dmin + dPos, insky[0].regions[i].Dmax - dPos);
+    outlist = SkyListByBounds (outsky, depth, inlist[0].regions[i][0].Rmin + dPos, inlist[0].regions[i][0].Rmax - dPos, inlist[0].regions[i][0].Dmin + dPos, inlist[0].regions[i][0].Dmax - dPos);
     for (j = 0; j < outlist[0].Nregions; j++) {
       if (VERBOSE) fprintf (stderr, "output : %s\n", outlist[0].regions[j][0].name);
@@ -93,5 +96,5 @@
       dvo_catalog_free (&outcatalog);
 
-      fprintf (stderr, "merged %s into %s\n", insky[0].regions[i].name, outlist[0].regions[j][0].name);
+      fprintf (stderr, "merged %s into %s\n", inlist[0].regions[i][0].name, outlist[0].regions[j][0].name);
     }
     SkyListFree (outlist);
Index: /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/help.c
===================================================================
--- /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/help.c	(revision 28862)
+++ /branches/eam_branches/ipp-20100621/Ohana/src/dvomerge/src/help.c	(revision 28863)
@@ -4,4 +4,5 @@
   fprintf (stderr, "USAGE: dvomerge (input1) and (input2) to (output)\n");
   fprintf (stderr, "   OR: dvomerge (input) into (output)\n");
+  fprintf (stderr, "   [-region Rmin Rmax Dmin Dmax]\n");
   exit (2);
 }
