Index: trunk/Ohana/src/libdvo/include/dvo.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvo.h	(revision 36084)
+++ trunk/Ohana/src/libdvo/include/dvo.h	(revision 36490)
@@ -308,4 +308,6 @@
 # define BOUNDARY_TREE_NAME_LENGTH 128
 
+// BoundaryTree is a structure to describe the 3pi RINGS skycell boundaries in terms of lines of constant (RA,DEC)
+// the structure is flexible for a variety of RINGS-like tessellations, but is not appropriate for the LOCAL style tess
 typedef struct {
   int FixedGridDEC;	      // is the DEC sequence linear?
@@ -342,13 +344,36 @@
 } BoundaryTree;
 
-// XXX DROP? // a reduced-subset structure for relastro
-// XXX DROP? typedef struct {
-// XXX DROP?   double         R;
-// XXX DROP?   double         D;
-// XXX DROP?   unsigned short Nmeasure;
-// XXX DROP?   int            measureOffset;
-// XXX DROP?   uint32_t       flags;
-// XXX DROP?   int            catID;
-// XXX DROP? } AverageTinyAstro;
+typedef enum { TESS_NONE, TESS_LOCAL, TESS_RINGS } TessType;
+
+// TessellationTable is a structure to describe the parameters of a set of "tessellations"
+// (these are not strictly tessellations but projection sets as only the non-local
+// versions can cover the full sky).  For LOCAL projection cells, the structure describes
+// the boundaries of a SINGLE projection cell with Nx * Ny skycells and includes some
+// basic parameters (not used by the fullsky, eg RINGS, tessellations)
+typedef struct {
+  double Rmin; // this tessellation is valid only for RA >= Rmin
+  double Rmax; // this tessellation is valid only for RA <  Rmax
+  double Dmin; // this tessellation is valid only for DEC >= Dmin
+  double Dmax; // this tessellation is valid only for DEC <  Dmax
+
+  double Xo;
+  double Yo;
+  double Ro;
+  double Do;
+  double dPix;
+  int dX;
+  int dY;
+
+  int NX_SUB;
+  int NY_SUB;
+
+  char *basename;
+  int Nbasename;
+  int projectIDoff;
+  int skycellIDoff;
+
+  TessType type; // 
+  BoundaryTree *tree;
+} TessellationTable;
 
 // a reduced-subset structure for relphot
@@ -387,4 +412,61 @@
 } MeasureTiny;
 
+
+/** STRUCT DEFINITION **/
+typedef struct {
+  float            dR;                   // RA offset (arcsec)
+  float            dD;                   // DEC offset (arcsec)
+  float            M;                    // catalog mag (mag)
+  float            Mcal;                 // image cal mag (mag)
+  float            Map;                  // aperture mag (mag)
+  float            Mkron;                // kron magnitude (mag)
+  float            dMkron;               // kron magnitude error (mag)
+  float            dM;                   // mag error (mag)
+  float            dMcal;                // systematic calibration error (mag)
+  float            dt;                   // exposure time (2.5*log(exptime))
+  float            FluxPSF;              // flux from psf fit (counts/sec?)
+  float            dFluxPSF;             // error on psf flux (counts/sec?)
+  float            FluxKron;             // flux from kron ap (counts/sec?)
+  float            dFluxKron;            // error on kron flux (counts/sec?)
+  float            airmass;              // (airmass - 1) (airmass)
+  float            az;                   // telescope azimuth
+  float            Xccd;                 // X coord on chip (raw value) (pixels)
+  float            Yccd;                 // Y coord on chip (raw value) (pixels)
+  float            Sky;                  // local estimate of sky flux (counts/sec)
+  float            dSky;                 // local estimate of sky flux (counts/sec)
+  int              t;                    // time in seconds (UNIX)
+  unsigned int     averef;               // reference to average entry      
+  unsigned int     detID;                // detection ID
+  unsigned int     imageID;              // reference to DVO image ID
+  unsigned int     objID;                // unique ID for object in table
+  unsigned int     catID;                // unique ID for table in which object was first realized
+  uint64_t         extID;                // external ID (eg PSPS detID)
+  float            psfQF;                // psf coverage/quality factor
+  float            psfQFperf;            // psf coverage / quality factor (all mask bits)
+  float            psfChisq;             // psf fit chisq
+  int              psfNdof;              // psf degrees of freedom
+  int              psfNpix;              // psf number of pixels
+  float            crNsigma;             // Nsigma deviation towards CR
+  float            extNsigma;            // Nsigma deviation towards EXT
+  short            FWx;                  // object fwhm major axis (1/100 of pixels)
+  short            FWy;                  // object fwhm minor axis (1/100 of pixels )
+  short            theta;                // angle wrt ccd X dir ((0xffff/360) deg)
+  short            Mxx;                  // second moments in pixel coords (1/100 of pixels)
+  short            Mxy;                  // second moments in pixel coords (1/100 of pixels)
+  short            Myy;                  // second moments in pixel coords (1/100 of pixels)
+  unsigned short   t_msec;               // time fraction of second (milliseconds)
+  unsigned short   photcode;             // photcode
+  short            dXccd;                // X coord error on chip (1/100 of pixels)
+  short            dYccd;                // Y coord error on chip (1/100 of pixels)
+  short            dRsys;                // systematic error from astrom (1/100 of pixels)
+  short            posangle;             // position angle sky to chip ((0xffff/360) deg)
+  float            pltscale;             // plate scale (arcsec/pixel)
+  unsigned int     dbFlags;              // flags supplied by analysis in database
+  unsigned int     photFlags;            // flags supplied by photometry program
+} Measure_PS1_V4alt;
+
+Measure_PS1_V4alt *gfits_table_get_Measure_PS1_V4alt (FTable *table, off_t *Ndata, char *swapped);
+Measure *Measure_PS1_V4alt_ToInternal (Measure_PS1_V4alt *in, off_t Nvalues);
+
 /* a catalog contains this data */
 typedef struct Catalog {
@@ -717,8 +799,17 @@
 int free_tiny_values (Catalog *catalog);
 
+BoundaryTree *BoundaryTreeLoad(char *filename);
+BoundaryTree *BoundaryTreeRead(Header *headerPHU, Header *headerZone, FILE *f);
+
+int BoundaryTreeSave(char *filename, BoundaryTree *tree);
+int BoundaryTreeWrite(FILE *f, BoundaryTree *tree);
+
 int BoundaryTreeCellCoords (BoundaryTree *tree, int *zone, int *band, double ra, double dec);
-int BoundaryTreeSave(char *filename, BoundaryTree *tree);
-BoundaryTree *BoundaryTreeLoad(char *filename);
 int BoundaryTreeProjection (double *x, double *y, double r, double d, BoundaryTree *tree, int zone, int band);
+
+TessellationTable *TessellationTableLoad(char *filename, int *Ntess);
+int TessellationTableSave(char *filename, TessellationTable *tess, int Ntess);
+int TessellationPrimaryCellIDs (TessellationTable *tess, int Ntess, int *tessID, int *projID, int *skycellID, double ra, double dec);
+void TessellationTableInit (TessellationTable *tess, int Ntess);
 
 void dvo_average_init (Average *average);
