Index: /branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/BoundaryTreeIO.c
===================================================================
--- /branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/BoundaryTreeIO.c	(revision 37100)
+++ /branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/BoundaryTreeIO.c	(revision 37101)
@@ -1,3 +1,5 @@
 # include "addstar.h"
+
+/** this file is deprecated (functions moved to libdvo) ***/
 
 # define GET_COLUMN_NEW(OUT,NAME,TYPE)					\
Index: /branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/findskycell.c
===================================================================
--- /branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/findskycell.c	(revision 37100)
+++ /branches/eam_branches/ipp-20140717/Ohana/src/addstar/src/findskycell.c	(revision 37101)
@@ -27,7 +27,7 @@
 int apply_tree (char *treefile, char *datafile);
 
-float SCALE = 1.0;
-int NX_SUB = 1;
-int NY_SUB = 1;
+float SCALE  = 1.0;
+float NX_SUB = 1.0;
+float NY_SUB = 1.0;
 
 double R_MIN = 0.0;
@@ -217,6 +217,6 @@
   ALLOCATE (tree.Xo,   double *, tree.Nzone);
   ALLOCATE (tree.Yo,   double *, tree.Nzone);
-  ALLOCATE (tree.dX,      int *, tree.Nzone);
-  ALLOCATE (tree.dY,      int *, tree.Nzone);
+  ALLOCATE (tree.dX,    float *, tree.Nzone);
+  ALLOCATE (tree.dY,    float *, tree.Nzone);
   ALLOCATE (tree.cell,    int *, tree.Nzone);
   ALLOCATE (tree.name,  char **, tree.Nzone);
@@ -251,6 +251,6 @@
     ALLOCATE (tree.Xo[zone],   double, tree.NBAND[zone]);
     ALLOCATE (tree.Yo[zone],   double, tree.NBAND[zone]);
-    ALLOCATE (tree.dX[zone],      int, tree.NBAND[zone]);
-    ALLOCATE (tree.dY[zone],      int, tree.NBAND[zone]);
+    ALLOCATE (tree.dX[zone],    float, tree.NBAND[zone]);
+    ALLOCATE (tree.dY[zone],    float, tree.NBAND[zone]);
     ALLOCATE (tree.cell[zone], int,    tree.NBAND[zone]);
     ALLOCATE (tree.name[zone], char *, tree.NBAND[zone]);
@@ -260,6 +260,6 @@
       tree.Xo[zone][band] = NAN;
       tree.Yo[zone][band] = NAN;
-      tree.dX[zone][band] = -1;
-      tree.dY[zone][band] = -1;
+      tree.dX[zone][band] = NAN;
+      tree.dY[zone][band] = NAN;
       tree.cell[zone][band] = -1;
       ALLOCATE (tree.name[zone][band], char, BOUNDARY_TREE_NAME_LENGTH);
@@ -286,6 +286,6 @@
       REALLOCATE (tree.Xo[zone],   double, tree.NBAND[zone]);
       REALLOCATE (tree.Yo[zone],   double, tree.NBAND[zone]);
-      REALLOCATE (tree.dX[zone],      int, tree.NBAND[zone]);
-      REALLOCATE (tree.dY[zone],      int, tree.NBAND[zone]);
+      REALLOCATE (tree.dX[zone],    float, tree.NBAND[zone]);
+      REALLOCATE (tree.dY[zone],    float, tree.NBAND[zone]);
       REALLOCATE (tree.cell[zone],    int, tree.NBAND[zone]);
       REALLOCATE (tree.name[zone], char *, tree.NBAND[zone]);
@@ -295,6 +295,6 @@
 	tree.Xo[zone][band] = NAN;
 	tree.Yo[zone][band] = NAN;
-	tree.dX[zone][band] = -1;
-	tree.dY[zone][band] = -1;
+	tree.dX[zone][band] = NAN;
+	tree.dY[zone][band] = NAN;
 	tree.cell[zone][j] = -1;
 	ALLOCATE (tree.name[zone][j], char, BOUNDARY_TREE_NAME_LENGTH);
Index: /branches/eam_branches/ipp-20140717/Ohana/src/libdvo/include/dvo.h
===================================================================
--- /branches/eam_branches/ipp-20140717/Ohana/src/libdvo/include/dvo.h	(revision 37100)
+++ /branches/eam_branches/ipp-20140717/Ohana/src/libdvo/include/dvo.h	(revision 37101)
@@ -383,12 +383,12 @@
   char  ***name; // projection cell name
   
-  int NX_SUB;
-  int NY_SUB;
+  float NX_SUB;
+  float NY_SUB;
   double dPix;
 
   double **Xo;
   double **Yo;
-  int **dX;
-  int **dY;
+  float **dX;
+  float **dY;
 } BoundaryTree;
 
@@ -411,9 +411,9 @@
   double Do;
   double dPix;
-  int dX;
-  int dY;
-
-  int NX_SUB;
-  int NY_SUB;
+  float dX;
+  float dY;
+
+  float NX_SUB;
+  float NY_SUB;
 
   char *basename;
Index: /branches/eam_branches/ipp-20140717/Ohana/src/libdvo/src/BoundaryTree.c
===================================================================
--- /branches/eam_branches/ipp-20140717/Ohana/src/libdvo/src/BoundaryTree.c	(revision 37100)
+++ /branches/eam_branches/ipp-20140717/Ohana/src/libdvo/src/BoundaryTree.c	(revision 37101)
@@ -84,6 +84,6 @@
   gfits_scan (headerPHU, "DEC_ORI",  "%lf", 1, &tree->DEC_origin);
   gfits_scan (headerPHU, "DEC_OFF",  "%lf", 1, &tree->DEC_offset);
-  gfits_scan (headerPHU, "NX_SUB",   "%d",  1, &tree->NX_SUB);
-  gfits_scan (headerPHU, "NY_SUB",   "%d",  1, &tree->NY_SUB);
+  gfits_scan (headerPHU, "NX_SUB",   "%f",  1, &tree->NX_SUB);
+  gfits_scan (headerPHU, "NY_SUB",   "%f",  1, &tree->NY_SUB);
   gfits_scan (headerPHU, "PIXSCALE", "%lf", 1, &tree->dPix);
 
@@ -111,6 +111,6 @@
   ALLOCATE (tree->Xo,   double *, tree->Nzone);
   ALLOCATE (tree->Yo,   double *, tree->Nzone);
-  ALLOCATE (tree->dX,      int *, tree->Nzone);
-  ALLOCATE (tree->dY,      int *, tree->Nzone);
+  ALLOCATE (tree->dX,    float *, tree->Nzone);
+  ALLOCATE (tree->dY,    float *, tree->Nzone);
   ALLOCATE (tree->cell,    int *, tree->Nzone);
   ALLOCATE (tree->projID,  int *, tree->Nzone);
@@ -121,6 +121,6 @@
     ALLOCATE (tree->Xo[i],   double, tree->Nband[i]);
     ALLOCATE (tree->Yo[i],   double, tree->Nband[i]);
-    ALLOCATE (tree->dX[i],      int, tree->Nband[i]);
-    ALLOCATE (tree->dY[i],      int, tree->Nband[i]);
+    ALLOCATE (tree->dX[i],    float, tree->Nband[i]);
+    ALLOCATE (tree->dY[i],    float, tree->Nband[i]);
     ALLOCATE (tree->cell[i],    int, tree->Nband[i]);
     ALLOCATE (tree->projID[i],  int, tree->Nband[i]);
@@ -147,6 +147,6 @@
   GET_COLUMN_NEW(&headerCell, &ftableCell, Xo,    "X_CENT",      double);
   GET_COLUMN_NEW(&headerCell, &ftableCell, Yo,    "Y_CENT",      double);
-  GET_COLUMN_NEW(&headerCell, &ftableCell, dX,    "X_GRID",      int);
-  GET_COLUMN_NEW(&headerCell, &ftableCell, dY,    "Y_GRID",      int);
+  GET_COLUMN_NEW(&headerCell, &ftableCell, dX,    "X_GRID",      float);
+  GET_COLUMN_NEW(&headerCell, &ftableCell, dY,    "Y_GRID",      float);
   GET_COLUMN_NEW(&headerCell, &ftableCell, name,  "NAME",        char); // XXX how is this done?
   gfits_free_header (&headerCell);
@@ -214,6 +214,6 @@
   gfits_modify (&header, "DEC_OFF", "%lf", 1, tree->DEC_offset);
 
-  gfits_modify (&header, "NX_SUB", "%d", 1, tree->NX_SUB);
-  gfits_modify (&header, "NY_SUB", "%d", 1, tree->NY_SUB);
+  gfits_modify (&header, "NX_SUB", "%f", 1, tree->NX_SUB);
+  gfits_modify (&header, "NY_SUB", "%f", 1, tree->NY_SUB);
   gfits_modify (&header, "PIXSCALE", "%lf", 1, tree->dPix);
 
@@ -289,6 +289,6 @@
     gfits_define_bintable_column (&theader, "D", "X_CENT", "projection cell center pixel", "none", 1.0, 0.0);
     gfits_define_bintable_column (&theader, "D", "Y_CENT", "projection cell center pixel", "none", 1.0, 0.0);
-    gfits_define_bintable_column (&theader, "J", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0);
-    gfits_define_bintable_column (&theader, "J", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0);
+    gfits_define_bintable_column (&theader, "E", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0);
+    gfits_define_bintable_column (&theader, "E", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0);
     gfits_define_bintable_column (&theader, fmt, "NAME", "cell name", "none", 1.0, 0.0);
 
@@ -310,6 +310,6 @@
     double *Xo            ; ALLOCATE (Xo,    double, Ncell);
     double *Yo            ; ALLOCATE (Yo,    double, Ncell);
-    int    *dX            ; ALLOCATE (dX,    int,    Ncell);
-    int    *dY            ; ALLOCATE (dY,    int,    Ncell);
+    float  *dX            ; ALLOCATE (dX,    float,  Ncell);
+    float  *dY            ; ALLOCATE (dY,    float,  Ncell);
     char   *name          ; ALLOCATE (name,  char,   Ncell*BOUNDARY_TREE_NAME_LENGTH);
 
Index: /branches/eam_branches/ipp-20140717/Ohana/src/libdvo/src/TessellationTable.c
===================================================================
--- /branches/eam_branches/ipp-20140717/Ohana/src/libdvo/src/TessellationTable.c	(revision 37100)
+++ /branches/eam_branches/ipp-20140717/Ohana/src/libdvo/src/TessellationTable.c	(revision 37101)
@@ -28,9 +28,9 @@
     tess[i].dPix = NAN;
 
-    tess[i].dX = 0;
-    tess[i].dY = 0;
-
-    tess[i].NX_SUB = 0;
-    tess[i].NY_SUB = 0;
+    tess[i].dX = NAN;
+    tess[i].dY = NAN;
+
+    tess[i].NX_SUB = NAN;
+    tess[i].NY_SUB = NAN;
 
     tess[i].basename = NULL;
@@ -123,6 +123,6 @@
   GET_COLUMN_NEW(Xo,     "X_CENT", double);
   GET_COLUMN_NEW(Yo,     "Y_CENT", double);
-  GET_COLUMN_NEW(dX,     "X_GRID", int);
-  GET_COLUMN_NEW(dY,     "Y_GRID", int);
+  GET_COLUMN_NEW(dX,     "X_GRID", float);
+  GET_COLUMN_NEW(dY,     "Y_GRID", float);
   GET_COLUMN_NEW(Rmin,   "R_MIN",  double);
   GET_COLUMN_NEW(Rmax,   "R_MAX",  double);
@@ -130,6 +130,6 @@
   GET_COLUMN_NEW(Dmax,   "D_MAX",  double);
   GET_COLUMN_NEW(dPix,   "SCALE",  double);
-  GET_COLUMN_NEW(NX_SUB, "NX_SUB", int);
-  GET_COLUMN_NEW(NY_SUB, "NY_SUB", int);
+  GET_COLUMN_NEW(NX_SUB, "NX_SUB", float);
+  GET_COLUMN_NEW(NY_SUB, "NY_SUB", float);
   GET_COLUMN_NEW(TYPE,   "TYPE",   int);
 
@@ -280,6 +280,6 @@
     gfits_modify (&header, "DEC_OFF", "%lf", 1, rings->DEC_offset);
 
-    gfits_modify (&header, "NX_SUB", "%d", 1, rings->NX_SUB);
-    gfits_modify (&header, "NY_SUB", "%d", 1, rings->NY_SUB);
+    gfits_modify (&header, "NX_SUB", "%f", 1, rings->NX_SUB);
+    gfits_modify (&header, "NY_SUB", "%f", 1, rings->NY_SUB);
     gfits_modify (&header, "PIXSCALE", "%lf", 1, rings->dPix);
   }
@@ -300,6 +300,6 @@
   gfits_define_bintable_column (&theader, "D", "X_CENT", "projection cell center pixel", "none", 1.0, 0.0);
   gfits_define_bintable_column (&theader, "D", "Y_CENT", "projection cell center pixel", "none", 1.0, 0.0);
-  gfits_define_bintable_column (&theader, "J", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0);
-  gfits_define_bintable_column (&theader, "J", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "E", "X_GRID", "skycell grid spacing", "none", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "E", "Y_GRID", "skycell grid spacing", "none", 1.0, 0.0);
   gfits_define_bintable_column (&theader, "D", "R_MIN",  "RA limit (lower)", "none", 1.0, 0.0);
   gfits_define_bintable_column (&theader, "D", "R_MAX",  "RA limit (upper)", "none", 1.0, 0.0);
@@ -307,6 +307,6 @@
   gfits_define_bintable_column (&theader, "D", "D_MAX",  "DEC limit (upper)", "none", 1.0, 0.0);
   gfits_define_bintable_column (&theader, "D", "SCALE",  "pixel scale for projection cell", "none", 1.0, 0.0);
-  gfits_define_bintable_column (&theader, "J", "NX_SUB", "skycell subdivision in x", "none", 1.0, 0.0);
-  gfits_define_bintable_column (&theader, "J", "NY_SUB", "skycell subdivision in y", "none", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "E", "NX_SUB", "skycell subdivision in x", "none", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "E", "NY_SUB", "skycell subdivision in y", "none", 1.0, 0.0);
   gfits_define_bintable_column (&theader, "J", "TYPE",   "type of tessellation", "none", 1.0, 0.0);
 
@@ -330,6 +330,6 @@
   double *Xo            ; ALLOCATE (Xo    ,    double, Nout);
   double *Yo            ; ALLOCATE (Yo    ,    double, Nout);
-  int    *dX            ; ALLOCATE (dX    ,    int,    Nout);
-  int    *dY            ; ALLOCATE (dY    ,    int,    Nout);
+  float  *dX            ; ALLOCATE (dX    ,    float,  Nout);
+  float  *dY            ; ALLOCATE (dY    ,    float,  Nout);
   double *Rmin          ; ALLOCATE (Rmin  ,    double, Nout);
   double *Rmax          ; ALLOCATE (Rmax  ,    double, Nout);
@@ -337,6 +337,6 @@
   double *Dmax          ; ALLOCATE (Dmax  ,    double, Nout);
   double *dPix          ; ALLOCATE (dPix  ,    double, Nout);
-  int    *NX_SUB        ; ALLOCATE (NX_SUB,    int,    Nout);
-  int    *NY_SUB        ; ALLOCATE (NY_SUB,    int,    Nout);
+  float  *NX_SUB        ; ALLOCATE (NX_SUB,    float,  Nout);
+  float  *NY_SUB        ; ALLOCATE (NY_SUB,    float,  Nout);
   int    *TYPE          ; ALLOCATE (TYPE,      int,    Nout);
 
@@ -559,4 +559,8 @@
     int xi = x / tess[myTess].tree->dX[zone][band];
     int yi = y / tess[myTess].tree->dY[zone][band];
+
+    xi = MAX(MIN(xi, tess[myTess].NX_SUB - 1.0), 0);
+    yi = MAX(MIN(yi, tess[myTess].NY_SUB - 1.0), 0);
+
     int N = xi + tess[myTess].tree->NX_SUB * yi;
   
