Index: trunk/Ohana/src/addstar/src/FilterStars.c
===================================================================
--- trunk/Ohana/src/addstar/src/FilterStars.c	(revision 38145)
+++ trunk/Ohana/src/addstar/src/FilterStars.c	(revision 38153)
@@ -105,4 +105,20 @@
       stars[N].measure.dFluxAp /= image[0].exptime;
     }
+    if (stars[N].lensing) {
+      if (!isnan(stars[N].lensing-> F_ApR5)) stars[N].lensing-> F_ApR5 /= image[0].exptime;
+      if (!isnan(stars[N].lensing->dF_ApR5)) stars[N].lensing->dF_ApR5 /= image[0].exptime;
+      if (!isnan(stars[N].lensing->sF_ApR5)) stars[N].lensing->sF_ApR5 /= image[0].exptime;
+      if (!isnan(stars[N].lensing->fF_ApR5)) stars[N].lensing->fF_ApR5 /= image[0].exptime;
+
+      if (!isnan(stars[N].lensing-> F_ApR6)) stars[N].lensing-> F_ApR6 /= image[0].exptime;
+      if (!isnan(stars[N].lensing->dF_ApR6)) stars[N].lensing->dF_ApR6 /= image[0].exptime;
+      if (!isnan(stars[N].lensing->sF_ApR6)) stars[N].lensing->sF_ApR6 /= image[0].exptime;
+      if (!isnan(stars[N].lensing->fF_ApR6)) stars[N].lensing->fF_ApR6 /= image[0].exptime;
+
+      if (!isnan(stars[N].lensing-> F_ApR7)) stars[N].lensing-> F_ApR7 /= image[0].exptime;
+      if (!isnan(stars[N].lensing->dF_ApR7)) stars[N].lensing->dF_ApR7 /= image[0].exptime;
+      if (!isnan(stars[N].lensing->sF_ApR7)) stars[N].lensing->sF_ApR7 /= image[0].exptime;
+      if (!isnan(stars[N].lensing->fF_ApR7)) stars[N].lensing->fF_ApR7 /= image[0].exptime;
+    }
     
     // the external ID is supplied, but do we trust it?
Index: trunk/Ohana/src/addstar/src/ReadXradFITS.c
===================================================================
--- trunk/Ohana/src/addstar/src/ReadXradFITS.c	(revision 38145)
+++ trunk/Ohana/src/addstar/src/ReadXradFITS.c	(revision 38153)
@@ -72,13 +72,23 @@
     }
 
-    stars[i].lensing-> F_ApR5 = AperFlux   [Nap*Ncol + 3];
-    stars[i].lensing->dF_ApR5 = AperFluxErr[Nap*Ncol + 3];
-    stars[i].lensing->sF_ApR5 = AperFluxStd[Nap*Ncol + 3];
-    stars[i].lensing->fF_ApR5 = AperFill   [Nap*Ncol + 3];
+    // XXX this is all hard-wired and should make use of the headers. 
+    // psphot cmfs have 5 radial apertures:
+    // array 0, 1, 2, 3, 4
+    // SDSS  3, 4, 5, 6, 7
 
-    stars[i].lensing-> F_ApR6 = AperFlux   [Nap*Ncol + 4];
-    stars[i].lensing->dF_ApR6 = AperFluxErr[Nap*Ncol + 4];
-    stars[i].lensing->sF_ApR6 = AperFluxStd[Nap*Ncol + 4];
-    stars[i].lensing->fF_ApR6 = AperFill   [Nap*Ncol + 4];
+    stars[i].lensing-> F_ApR5 = AperFlux   [Nap*Ncol + 2];
+    stars[i].lensing->dF_ApR5 = AperFluxErr[Nap*Ncol + 2];
+    stars[i].lensing->sF_ApR5 = AperFluxStd[Nap*Ncol + 2];
+    stars[i].lensing->fF_ApR5 = AperFill   [Nap*Ncol + 2];
+
+    stars[i].lensing-> F_ApR6 = AperFlux   [Nap*Ncol + 3];
+    stars[i].lensing->dF_ApR6 = AperFluxErr[Nap*Ncol + 3];
+    stars[i].lensing->sF_ApR6 = AperFluxStd[Nap*Ncol + 3];
+    stars[i].lensing->fF_ApR6 = AperFill   [Nap*Ncol + 3];
+
+    stars[i].lensing-> F_ApR7 = AperFlux   [Nap*Ncol + 4];
+    stars[i].lensing->dF_ApR7 = AperFluxErr[Nap*Ncol + 4];
+    stars[i].lensing->sF_ApR7 = AperFluxStd[Nap*Ncol + 4];
+    stars[i].lensing->fF_ApR7 = AperFill   [Nap*Ncol + 4];
     Nap ++;
   }
Index: trunk/Ohana/src/addstar/src/resort_catalog.c
===================================================================
--- trunk/Ohana/src/addstar/src/resort_catalog.c	(revision 38145)
+++ trunk/Ohana/src/addstar/src/resort_catalog.c	(revision 38153)
@@ -40,4 +40,8 @@
   resort_catalog_lensing (catalog);
   resort_catalog_starpar (catalog);
+
+  // XXX somehow need to set the value of lensing->measure offset here 
+
+
 }
 
Index: trunk/Ohana/src/dvolens/Makefile
===================================================================
--- trunk/Ohana/src/dvolens/Makefile	(revision 38145)
+++ trunk/Ohana/src/dvolens/Makefile	(revision 38153)
@@ -29,4 +29,5 @@
 $(SRC)/help.$(ARCH).o		 \
 $(SRC)/initialize.$(ARCH).o	 \
+$(SRC)/myIndex.$(ARCH).o	 \
 $(SRC)/update_objects.$(ARCH).o	 \
 $(SRC)/update_objects_catalog.$(ARCH).o	 \
@@ -44,4 +45,5 @@
 $(SRC)/help.$(ARCH).o		 \
 $(SRC)/initialize.$(ARCH).o	 \
+$(SRC)/myIndex.$(ARCH).o	 \
 $(SRC)/update_objects.$(ARCH).o	 \
 $(SRC)/update_objects_catalog.$(ARCH).o	 \
Index: trunk/Ohana/src/dvolens/include/dvolens.h
===================================================================
--- trunk/Ohana/src/dvolens/include/dvolens.h	(revision 38145)
+++ trunk/Ohana/src/dvolens/include/dvolens.h	(revision 38153)
@@ -4,4 +4,16 @@
 # include <signal.h>
 # include <pthread.h>
+
+# ifndef MAX_INT
+# define MAX_INT 2147483647
+# endif
+
+typedef struct {
+  int minID;
+  int maxID;
+  int *index;
+  int Nindex;
+  int NINDEX;
+} myIndexType;
 
 typedef enum {
@@ -63,2 +75,9 @@
 int  	      client_logger_message   PROTO((char *format,...));
 
+myIndexType *myIndexAlloc ();
+int myIndexFree (myIndexType *myIndex);
+void myIndexInit (myIndexType *myIndex);
+int myIndexUpdateLimits (myIndexType *myIndex, int value);
+int myIndexSetRange (myIndexType *myIndex);
+int myIndexSetEntry (myIndexType *myIndex, int value, int entry);
+int myIndexGetEntry (myIndexType *myIndex, int value);
Index: trunk/Ohana/src/dvolens/src/myIndex.c
===================================================================
--- trunk/Ohana/src/dvolens/src/myIndex.c	(revision 38153)
+++ trunk/Ohana/src/dvolens/src/myIndex.c	(revision 38153)
@@ -0,0 +1,84 @@
+# include "dvolens.h"
+
+// this is a copy of the file in dvomerge
+
+myIndexType *myIndexAlloc () {
+
+  myIndexType *myIndex;
+  ALLOCATE (myIndex, myIndexType, 1);
+  ALLOCATE (myIndex->index, int, 1);
+
+  // an uninit'ed index is invalid
+  myIndex->minID = 0;
+  myIndex->maxID = 0;
+
+  return myIndex;
+}
+
+int myIndexFree (myIndexType *myIndex) {
+
+  free (myIndex->index);
+  free (myIndex);
+  return TRUE;
+}
+
+void myIndexInit (myIndexType *myIndex) {
+
+  myIndex->minID = MAX_INT;
+  myIndex->maxID = 0;
+
+  myIndex->NINDEX = 1000;
+  myIndex->Nindex = 0;
+
+  return;
+}
+
+// set minID and maxID externally
+int myIndexUpdateLimits (myIndexType *myIndex, int value) {
+
+  myIndex->maxID = MAX(value, myIndex->maxID);
+  myIndex->minID = MIN(value, myIndex->minID);
+
+  return TRUE;
+}
+
+// once minID and maxID are set, this function defines the range and inits
+int myIndexSetRange (myIndexType *myIndex) {
+
+  myIndex->Nindex = myIndex->maxID - myIndex->minID + 1;
+  myIndex->NINDEX = myIndex->Nindex;
+  
+  REALLOCATE (myIndex->index, int, myIndex->NINDEX);
+
+  int i;
+  for (i = 0; i < myIndex->Nindex; i++) {
+    myIndex->index[i] = -1;
+  }
+
+  return TRUE;
+}
+
+// once minID and maxID are set, this function defines the range and inits
+int myIndexSetEntry (myIndexType *myIndex, int value, int entry) {
+
+  int n = value - myIndex->minID;
+
+  myAssert (n >= 0, "impossible!");
+
+  if (myIndex->index[n] > -1) return -1;
+  // myAssert(myIndex->index[n] == -1, "stomping on an earlier index");
+
+  myIndex->index[n] = entry;
+  return n;
+}
+
+// once minID and maxID are set, this function defines the range and inits
+int myIndexGetEntry (myIndexType *myIndex, int value) {
+
+  if (value < myIndex->minID) return -1; // not in this index
+  if (value > myIndex->maxID) return -1; // not in this index
+
+  int n = value - myIndex->minID;
+
+  return myIndex->index[n];
+}
Index: trunk/Ohana/src/dvolens/src/update_objects_catalog.c
===================================================================
--- trunk/Ohana/src/dvolens/src/update_objects_catalog.c	(revision 38145)
+++ trunk/Ohana/src/dvolens/src/update_objects_catalog.c	(revision 38153)
@@ -1,3 +1,5 @@
 # include "dvolens.h"
+# define SCALE 0.001
+float MagToFlux (float Mag); // in libdvo, but not exposed?
 
 int update_objects_catalog (Catalog *catalog) {
@@ -11,4 +13,12 @@
   int Nsecfilt = GetPhotcodeNsecfilt ();
   
+  float *Mxx_obj = NULL;
+  float *Mxy_obj = NULL;
+  float *Myy_obj = NULL;
+
+  ALLOCATE (Mxx_obj, float, Nsecfilt);
+  ALLOCATE (Mxy_obj, float, Nsecfilt);
+  ALLOCATE (Myy_obj, float, Nsecfilt);
+
   // I think we have already allocated lensobj
   REALLOCATE (catalog->lensobj, Lensobj, catalog->Naverage * Nsecfilt);
@@ -19,4 +29,6 @@
   int Nlensobj = 0;
 
+  myIndexType *measureIndex = myIndexAlloc();
+
   for (i = 0; i < catalog->Naverage; i++) {
     Average *average = &catalog->average[i];
@@ -27,10 +39,29 @@
     for (j = 0; j < Nsecfilt; j++) {
       dvo_lensobj_init (&lensobj[j], TRUE); // init accumulated values to 0
+      Mxx_obj[j] = 0.0;
+      Mxy_obj[j] = 0.0;
+      Myy_obj[j] = 0.0;
     }
 
     // reset the average values
-
     off_t Loff = average->lensingOffset;
     off_t Moff = average->measureOffset;
+
+    // I have Nmeasure entries for this object.  I need to match measure to lensing (by imageID)
+    // I could generated a sorted list (imageID, measureSeq) and use bisection to find the desired imageID
+    // I could make an index measureSeq[imageID-imageIDmin]
+    
+    myIndexInit (measureIndex);
+
+    // generate an index for these measure entries (based on Mj and imageID)
+    for (Mj = 0; Mj < average->Nmeasure; Mj++) {
+      myIndexUpdateLimits (measureIndex, catalog->measure[Moff + Mj].imageID);
+    }
+    myIndexSetRange (measureIndex);
+    for (Mj = 0; Mj < average->Nmeasure; Mj++) {
+      // if there are duplicates (multiple measures from the same image), 
+      // myIndexSetEntry will only select one
+      myIndexSetEntry (measureIndex, catalog->measure[Moff + Mj].imageID, Mj);
+    }
 
     // loop over the lensing measurements.  for each one, I need to find the corresponding measurement (make an index in lensing?)
@@ -41,4 +72,17 @@
       if (!isfinite(lensing->X11_sm_obj)) continue;
 
+      // pointer from lensing entry to corresponding measure entry (keep updated?)
+      // XX ALT int Mseq = lensing->measureSeq;
+      // XX ALT myAssert (Mseq < average->Nmeasure, "oops");
+      // XX ALT Measure *measure = &catalog->measure[Moff + Mseq];
+      // XX ALT myAssert (measure->imageID == lensing->imageID, "oops, deux");
+
+      Mj = myIndexGetEntry (measureIndex, lensing->imageID);
+      myAssert (Mj > -1, "missing index");
+
+      Measure *measure = &catalog->measure[Moff + Mj];
+      myAssert (measure->imageID == lensing->imageID, "oops, deux");
+
+# if (0)      
       Measure *measure = NULL;
       int found = FALSE;
@@ -54,4 +98,5 @@
 	abort();
       }
+# endif
       
       // skip measurements that do not match the current photcode
@@ -67,5 +112,12 @@
       if (measure->psfQFperf < 0.85) continue; 
       
-
+      // I should probably only use lensing entries which correspond to warps 
+      // included in the mean warp flux (setMrelCatalog.c)
+      if ((measure->dbFlags & ID_MEAS_WARP_USED) == 0) continue;
+
+      Mxx_obj[Nsec] += measure->Mxx;
+      Mxy_obj[Nsec] += measure->Mxy;
+      Myy_obj[Nsec] += measure->Myy;
+      
       lensobj[Nsec].X11_sm_obj += lensing->X11_sm_obj;
       lensobj[Nsec].X12_sm_obj += lensing->X12_sm_obj;
@@ -92,13 +144,25 @@
       lensobj[Nsec]. E2_sh_psf += lensing-> E2_sh_psf;
 
-      lensobj[Nsec]. F_ApR5 += lensing-> F_ApR5;
-      lensobj[Nsec].dF_ApR5 += SQ(lensing->dF_ApR5);
-      lensobj[Nsec].sF_ApR5 += SQ(lensing->sF_ApR5);
-      lensobj[Nsec].fF_ApR5 += lensing->fF_ApR5;
-
-      lensobj[Nsec]. F_ApR6 += lensing-> F_ApR6;
-      lensobj[Nsec].dF_ApR6 += SQ(lensing->dF_ApR6);
-      lensobj[Nsec].sF_ApR6 += SQ(lensing->sF_ApR6);
-      lensobj[Nsec].fF_ApR6 += lensing->fF_ApR6;
+      // relphot sets measure->Mcal (setMcalOutput.c, called by setMrelFinal.c)
+      float Mcal = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure->Mcal;
+      float Fcal = 3630.8 * MagToFlux(Mcal);
+
+      // lensing->F_ApR5, etc need to be in units of DN/sec
+      // Fcal * lensing->F_ApR5 is in Jy
+
+      lensobj[Nsec]. F_ApR5 +=    Fcal * lensing-> F_ApR5;
+      lensobj[Nsec].dF_ApR5 += SQ(Fcal * lensing->dF_ApR5);
+      lensobj[Nsec].sF_ApR5 += SQ(Fcal * lensing->sF_ApR5);
+      lensobj[Nsec].fF_ApR5 +=           lensing->fF_ApR5;
+
+      lensobj[Nsec]. F_ApR6 +=    Fcal * lensing-> F_ApR6;
+      lensobj[Nsec].dF_ApR6 += SQ(Fcal * lensing->dF_ApR6);
+      lensobj[Nsec].sF_ApR6 += SQ(Fcal * lensing->sF_ApR6);
+      lensobj[Nsec].fF_ApR6 +=           lensing->fF_ApR6;
+
+      lensobj[Nsec]. F_ApR7 +=    Fcal * lensing-> F_ApR7;
+      lensobj[Nsec].dF_ApR7 += SQ(Fcal * lensing->dF_ApR7);
+      lensobj[Nsec].sF_ApR7 += SQ(Fcal * lensing->sF_ApR7);
+      lensobj[Nsec].fF_ApR7 +=           lensing->fF_ApR7;
 
       lensobj[Nsec].Nmeas   ++;
@@ -139,4 +203,5 @@
       lensobj[j].sF_ApR5 /= Nmeas;
       lensobj[j].fF_ApR5 /= Nmeas;
+
       lensobj[j]. F_ApR6 /= Nmeas;
       lensobj[j].dF_ApR6 /= Nmeas;
@@ -144,10 +209,21 @@
       lensobj[j].fF_ApR6 /= Nmeas;
 
+      lensobj[j]. F_ApR7 /= Nmeas;
+      lensobj[j].dF_ApR7 /= Nmeas;
+      lensobj[j].sF_ApR7 /= Nmeas;
+      lensobj[j].fF_ApR7 /= Nmeas;
+
       lensobj[j].dF_ApR5 = sqrt(lensobj[j].dF_ApR5);
       lensobj[j].sF_ApR5 = sqrt(lensobj[j].sF_ApR5);
       lensobj[j].dF_ApR6 = sqrt(lensobj[j].dF_ApR6);
       lensobj[j].sF_ApR6 = sqrt(lensobj[j].sF_ApR6);
+      lensobj[j].dF_ApR7 = sqrt(lensobj[j].dF_ApR7);
+      lensobj[j].sF_ApR7 = sqrt(lensobj[j].sF_ApR7);
 
       // somewhere in here I should calculate the values of E1, E2, and gamma
+
+      float e0 = Mxx_obj[j] + Myy_obj[j];
+      lensobj[j].E1 = (Mxx_obj[j] - Myy_obj[j]) / e0;
+      lensobj[j].E2 = 2.0 * Mxy_obj[j] / e0;
     }
 
@@ -159,4 +235,10 @@
   }
 
+  free (Mxx_obj);
+  free (Mxy_obj);
+  free (Myy_obj);
+
+  myIndexFree (measureIndex);
+
   catalog->Nlensobj = Nlensobj;
   catalog->Nlensobj_disk = 0;
Index: trunk/Ohana/src/dvopsps/src/insert_FWobjects_dvopsps_catalog.c
===================================================================
--- trunk/Ohana/src/dvopsps/src/insert_FWobjects_dvopsps_catalog.c	(revision 38145)
+++ trunk/Ohana/src/dvopsps/src/insert_FWobjects_dvopsps_catalog.c	(revision 38153)
@@ -188,8 +188,14 @@
 		 "FLUX_STD_AP_R5     FLOAT, "
 		 "FLUX_FIL_AP_R5     FLOAT, "
+
 		 "FLUX_AP_R6         FLOAT, "
 		 "FLUX_ERR_AP_R6     FLOAT, "
 		 "FLUX_STD_AP_R6     FLOAT, "
 		 "FLUX_FIL_AP_R6     FLOAT, "
+
+		 "FLUX_AP_R7         FLOAT, "
+		 "FLUX_ERR_AP_R7     FLOAT, "
+		 "FLUX_STD_AP_R7     FLOAT, "
+		 "FLUX_FIL_AP_R7     FLOAT, "
 
 		 "X11_SM_OBJ         FLOAT, "
@@ -281,8 +287,14 @@
 		 "FLUX_STD_AP_R5, "
 		 "FLUX_FIL_AP_R5, "
+
 		 "FLUX_AP_R6, "
 		 "FLUX_ERR_AP_R6, "
 		 "FLUX_STD_AP_R6, "
 		 "FLUX_FIL_AP_R6, "
+
+		 "FLUX_AP_R7, "
+		 "FLUX_ERR_AP_R7, "
+		 "FLUX_STD_AP_R7, "
+		 "FLUX_FIL_AP_R7, "
 
 		 "X11_SM_OBJ, "
@@ -367,15 +379,15 @@
 
     // use %e?
-    PRINT_FLOAT(sec_buffer, meanPSFFlux,      "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanPSFFluxErr,   "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanPSFFluxStd,   "%.6f, "); // uflux precision
-
-    PRINT_FLOAT(sec_buffer, meanKronFlux,     "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanKronFluxErr,  "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanKronFluxStd,  "%.6f, "); // uflux precision
-
-    PRINT_FLOAT(sec_buffer, meanApFlux,     "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanApFluxErr,  "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanApFluxStd,  "%.6f, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanPSFFlux,      "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanPSFFluxErr,   "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanPSFFluxStd,   "%.6e, "); // uflux precision
+
+    PRINT_FLOAT(sec_buffer, meanKronFlux,     "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanKronFluxErr,  "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanKronFluxStd,  "%.6e, "); // uflux precision
+
+    PRINT_FLOAT(sec_buffer, meanApFlux,     "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanApFluxErr,  "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanApFluxStd,  "%.6e, "); // uflux precision
 
     PrintIOBuffer (sec_buffer, "%u ", secfilt->flags);       
@@ -390,38 +402,39 @@
     PrintIOBuffer (cpy_buffer, "%hd, ", lensobj->photcode);          
 
-    PRINT_FLOAT(cpy_buffer, lensobj-> F_ApR5,     "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->dF_ApR5,     "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->sF_ApR5,     "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->fF_ApR5,     "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj-> F_ApR6,     "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->dF_ApR6,     "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->sF_ApR6,     "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->fF_ApR6,     "%.8f, ");
-
-    PRINT_FLOAT(cpy_buffer, lensobj->X11_sm_obj,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->X12_sm_obj,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->X22_sm_obj,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->E1_sm_obj,   "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->E2_sm_obj,   "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->X11_sh_obj,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->X12_sh_obj,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->X22_sh_obj,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->E1_sh_obj,   "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->E2_sh_obj,   "%.8f, ");
-
-    PRINT_FLOAT(cpy_buffer, lensobj->X11_sm_psf,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->X12_sm_psf,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->X22_sm_psf,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->E1_sm_psf,   "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->E2_sm_psf,   "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->X11_sh_psf,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->X12_sh_psf,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->X22_sh_psf,  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->E1_sh_psf,   "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->E2_sh_psf,   "%.8f, ");
-
-    PRINT_FLOAT(cpy_buffer, lensobj->gamma,       "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->E1, 	  "%.8f, ");
-    PRINT_FLOAT(cpy_buffer, lensobj->E2, 	  "%.8f, ");
+    PRINT_FLOAT(cpy_buffer, lensobj-> F_ApR5,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->dF_ApR5,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->sF_ApR5,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->fF_ApR5,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj-> F_ApR6,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->dF_ApR6,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->sF_ApR6,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->fF_ApR6,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj-> F_ApR7,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->dF_ApR7,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->sF_ApR7,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->fF_ApR7,     "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X11_sm_obj,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X12_sm_obj,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X22_sm_obj,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->E1_sm_obj,   "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->E2_sm_obj,   "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X11_sh_obj,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X12_sh_obj,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X22_sh_obj,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->E1_sh_obj,   "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->E2_sh_obj,   "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X11_sm_psf,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X12_sm_psf,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X22_sm_psf,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->E1_sm_psf,   "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->E2_sm_psf,   "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X11_sh_psf,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X12_sh_psf,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->X22_sh_psf,  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->E1_sh_psf,   "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->E2_sh_psf,   "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->gamma,       "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->E1, 	  "%.6e, ");
+    PRINT_FLOAT(cpy_buffer, lensobj->E2, 	  "%.6e, ");
 
     PrintIOBuffer (cpy_buffer, "%u ", lensobj->Nmeas); // NOTE: PRINT_FLOAT always adds a trailing comma -- need to use a different method on the last entry
Index: trunk/Ohana/src/dvopsps/src/insert_diffobj_dvopsps_catalog.c
===================================================================
--- trunk/Ohana/src/dvopsps/src/insert_diffobj_dvopsps_catalog.c	(revision 38145)
+++ trunk/Ohana/src/dvopsps/src/insert_diffobj_dvopsps_catalog.c	(revision 38153)
@@ -258,15 +258,15 @@
 
     // use %e?
-    PRINT_FLOAT(sec_buffer, meanPSFFlux,      "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanPSFFluxErr,   "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanPSFFluxStd,   "%.6f, "); // uflux precision
-
-    PRINT_FLOAT(sec_buffer, meanKronFlux,     "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanKronFluxErr,  "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanKronFluxStd,  "%.6f, "); // uflux precision
-
-    PRINT_FLOAT(sec_buffer, meanApFlux,     "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanApFluxErr,  "%.6f, "); // uflux precision
-    PRINT_FLOAT(sec_buffer, meanApFluxStd,  "%.6f, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanPSFFlux,      "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanPSFFluxErr,   "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanPSFFluxStd,   "%.6e, "); // uflux precision
+
+    PRINT_FLOAT(sec_buffer, meanKronFlux,     "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanKronFluxErr,  "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanKronFluxStd,  "%.6e, "); // uflux precision
+
+    PRINT_FLOAT(sec_buffer, meanApFlux,     "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanApFluxErr,  "%.6e, "); // uflux precision
+    PRINT_FLOAT(sec_buffer, meanApFluxStd,  "%.6e, "); // uflux precision
 
     PrintIOBuffer (sec_buffer, "%u ", secfilt->flags);       
Index: trunk/Ohana/src/kapa2/doc/rainbow.cm
===================================================================
--- trunk/Ohana/src/kapa2/doc/rainbow.cm	(revision 38153)
+++ trunk/Ohana/src/kapa2/doc/rainbow.cm	(revision 38153)
@@ -0,0 +1,3 @@
+0.25 0.0 0.0 1.0
+0.50 0.0 1.0 0.0
+0.75 1.0 0.0 0.0
Index: trunk/Ohana/src/kapa2/doc/vista.cm
===================================================================
--- trunk/Ohana/src/kapa2/doc/vista.cm	(revision 38153)
+++ trunk/Ohana/src/kapa2/doc/vista.cm	(revision 38153)
@@ -0,0 +1,7 @@
+0.10 0.5 0.8 0.0
+0.28 0.0 1.0 0.2
+0.35 0.2 1.0 0.7
+0.45 0.0 0.0 1.0
+0.60 1.0 0.0 0.9
+0.75 0.6 0.0 0.0
+0.90 0.8 0.0 0.0
Index: trunk/Ohana/src/kapa2/src/DrawObjects.c
===================================================================
--- trunk/Ohana/src/kapa2/src/DrawObjects.c	(revision 38145)
+++ trunk/Ohana/src/kapa2/src/DrawObjects.c	(revision 38153)
@@ -248,5 +248,5 @@
   
   /* connect first point to second point */
-  sxa = sx0 - 0.5*(sx1 - sx0);
+  sxa = MIN (MAX (sx0 - 0.5*(sx1 - sx0), X0), X1);
   sya = MAX (sy0, Y0);
   DrawLine (sx0, sy0, sxa, sy0);
@@ -254,5 +254,5 @@
   
   /* draw segment equal distance behind first point and down to x-axis */
-  sxa = 0.5*(sx0 + sx1);
+  sxa = MIN (MAX (0.5*(sx0 + sx1), X0), X1);
   DrawLine (sx0, sy0, sxa, sy0);
   DrawLine (sxa, sy0, sxa, sy1);
@@ -269,5 +269,5 @@
     sx1 = MIN (MAX (sx1, X0), X1);
     sy1 = MAX (MIN (sy1, Y0), Y1);
-    sxa = 0.5*(sx0 + sx1);
+    sxa = MIN (MAX (0.5*(sx0 + sx1), X0), X1);
     DrawLine (sx0, sy0, sxa, sy0);
     DrawLine (sxa, sy0, sxa, sy1);
@@ -278,5 +278,5 @@
   
   /* draw segment equal distance after last point and down to x-axis */
-  sxa = sx1 + 0.5*(sx1 - sxo);
+  sxa = MIN (MAX (sx1 + 0.5*(sx1 - sxo), X0), X1);
   sya = MAX (sy1, Y0);
   DrawLine (sx1, sy1, sxa, sy1);
Index: trunk/Ohana/src/kapa2/src/InterpretKeys.c
===================================================================
--- trunk/Ohana/src/kapa2/src/InterpretKeys.c	(revision 38145)
+++ trunk/Ohana/src/kapa2/src/InterpretKeys.c	(revision 38153)
@@ -1,3 +1,4 @@
 # include "Ximage.h"
+# define FILTER_MODS 1
 
 int InterpretKeys (Graphic *graphic, XKeyEvent *event) {
@@ -32,19 +33,21 @@
     // skip the following keys: 
     if (name == NULL) goto skip_cursor;
-    if (!strcmp (name, "Shift_L")) goto skip_cursor;
-    if (!strcmp (name, "Shift_R")) goto skip_cursor;
-    if (!strcmp (name, "Control_L")) goto skip_cursor;
-    if (!strcmp (name, "Control_R")) goto skip_cursor;
-    if (!strcmp (name, "Alt_L")) goto skip_cursor;
-    if (!strcmp (name, "Alt_R")) goto skip_cursor;
-    if (!strcmp (name, "Super_L")) goto skip_cursor;
-    if (!strcmp (name, "Super_R")) goto skip_cursor;
-    if (!strcmp (name, "Caps_Lock")) goto skip_cursor;
-    if (!strcmp (name, "Pause")) goto skip_cursor;
-    if (!strcmp (name, "Continue")) goto skip_cursor;
-    if (!strcmp (name, "Num_Lock")) goto skip_cursor;
-    if (!strcmp (name, "Scroll_Lock")) goto skip_cursor;
-    if (!strcmp (name, "Print")) goto skip_cursor;
-    if (!strcmp (name, "(null)")) goto skip_cursor;
+    if (FILTER_MODS) {
+      if (!strcmp (name, "Shift_L")) goto skip_cursor;
+      if (!strcmp (name, "Shift_R")) goto skip_cursor;
+      if (!strcmp (name, "Control_L")) goto skip_cursor;
+      if (!strcmp (name, "Control_R")) goto skip_cursor;
+      if (!strcmp (name, "Alt_L")) goto skip_cursor;
+      if (!strcmp (name, "Alt_R")) goto skip_cursor;
+      if (!strcmp (name, "Super_L")) goto skip_cursor;
+      if (!strcmp (name, "Super_R")) goto skip_cursor;
+      if (!strcmp (name, "Caps_Lock")) goto skip_cursor;
+      if (!strcmp (name, "Pause")) goto skip_cursor;
+      if (!strcmp (name, "Continue")) goto skip_cursor;
+      if (!strcmp (name, "Num_Lock")) goto skip_cursor;
+      if (!strcmp (name, "Scroll_Lock")) goto skip_cursor;
+      if (!strcmp (name, "Print")) goto skip_cursor;
+      if (!strcmp (name, "(null)")) goto skip_cursor;
+    }
 
     Z = -1;
Index: trunk/Ohana/src/kapa2/src/PSObjects.c
===================================================================
--- trunk/Ohana/src/kapa2/src/PSObjects.c	(revision 38145)
+++ trunk/Ohana/src/kapa2/src/PSObjects.c	(revision 38153)
@@ -211,5 +211,5 @@
   
   /* connect first point to second point */
-  sxa = sx0 - 0.5*(sx1 - sx0);
+  sxa = MIN (MAX (sx0 - 0.5*(sx1 - sx0), X0), X1);
   sya = MAX (sy0, Y0);
   DrawLine (sx0, sy0, sxa, sy0);
@@ -217,5 +217,5 @@
   
   /* draw segment equal distance behind first point and down to x-axis */
-  sxa = 0.5*(sx0 + sx1);
+  sxa = MIN (MAX (0.5*(sx0 + sx1), X0), X1);
   DrawLine (sx0, sy0, sxa, sy0);
   DrawLine (sxa, sy0, sxa, sy1);
@@ -232,5 +232,5 @@
     sx1 = MIN (MAX (sx1, X0), X1);
     sy1 = MAX (MIN (sy1, Y0), Y1);
-    sxa = 0.5*(sx0 + sx1);
+    sxa = MIN (MAX (0.5*(sx0 + sx1), X0), X1);
     DrawLine (sx0, sy0, sxa, sy0);
     DrawLine (sxa, sy0, sxa, sy1);
@@ -241,5 +241,5 @@
   
   /* draw segment equal distance after last point and down to x-axis */
-  sxa = sx1 + 0.5*(sx1 - sxo);
+  sxa = MIN (MAX (sx1 + 0.5*(sx1 - sxo), X0), X1);
   sya = MAX (sy1, Y0);
   DrawLine (sx1, sy1, sxa, sy1);
Index: trunk/Ohana/src/kapa2/src/SetColormap.c
===================================================================
--- trunk/Ohana/src/kapa2/src/SetColormap.c	(revision 38145)
+++ trunk/Ohana/src/kapa2/src/SetColormap.c	(revision 38153)
@@ -166,4 +166,106 @@
     goto store_colors;
   }
+  /* anuenue */
+  if (!strcasecmp (name, "anuenue")) {
+    redRef   = 0.25*MaxValue*scale*4.0; // value at 0.0
+    greenRef = 0.50*MaxValue*scale*4.0;
+    blueRef  = 1.33*MaxValue*scale;
+    for (i = 0; i < (int)(0.50*MaxValue); i++) {  
+      SETVALUE (graphic[0].cmap[i].green, 0.0, 0, 0xffff); // red is a ramp from 0 to 0xffff
+      graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
+    }
+    for (i = (int)(0.50*MaxValue); i < (int)(0.75*MaxValue); i++) {  
+      SETVALUE (graphic[0].cmap[i].green, 4.0*i*scale - 0x20000, 0, 0xffff); // red is a ramp from 0 to 0xffff
+      graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
+    }
+    for (i = (int)(0.75*MaxValue); i < MaxValue; i++) {  
+      SETVALUE (graphic[0].cmap[i].green, 0xffff, 0, 0xffff); // red is a ramp from 0 to 0xffff
+      graphic[0].cmap[i].flags = DoRed | DoGreen | DoBlue;
+    }
+
+    for (i = 0; i < (int)(0.25*MaxValue); i++) {  
+      SETVALUE (graphic[0].cmap[i].red,  4*i*scale, 0, 0xffff);
+    }
+    for (i = (int)(0.25*MaxValue); i < (int)(0.50*MaxValue); i++) {  
+      SETVALUE (graphic[0].cmap[i].red,  0x20000 - 4*i*scale, 0, 0xffff);
+    }
+    for (i = (int)(0.50*MaxValue); i < MaxValue; i++) {  
+      SETVALUE (graphic[0].cmap[i].red,  2*i*scale - 0xffff, 0, 0xffff);
+    }
+
+    for (i = 0; i < (int)(0.50*MaxValue); i++) {  
+      SETVALUE (graphic[0].cmap[i].blue,  2*i*scale, 0, 0xffff);
+    }
+    for (i = (int)(0.50*MaxValue); i < (int)(0.75*MaxValue); i++) {  
+      SETVALUE (graphic[0].cmap[i].blue,  0x30000 - 4*i*scale, 0, 0xffff);
+    }
+    for (i = (int)(0.75*MaxValue); i < MaxValue; i++) {  
+      SETVALUE (graphic[0].cmap[i].blue,  4*i*scale - 0x30000, 0, 0xffff);
+    }
+    goto store_colors;
+  }
+
+  /* anuenue */
+  if (!strncmp (name, "file:", 5)) {
+    FILE *f = fopen (&name[5], "r");
+    if (!f) {
+      fprintf (stderr, "failed to open colormap file %s\n", &name[5]);
+      return FALSE;
+    }
+    char line[1024];
+
+    int lastIndex = 0;
+    float lastRed = 0.0;
+    float lastBlue = 0.0;
+    float lastGreen = 0.0;
+
+    float fracIndex, fracRed, fracBlue, fracGreen;
+
+    while (scan_line_maxlen (f, line, 1024) != EOF) {
+      // file contains f R G B : f = 0.0 - 1.0, R,G,B = 0.0 - 1.0
+      int Nscan = sscanf (line, "%f %f %f %f", &fracIndex, &fracRed, &fracBlue, &fracGreen);
+      if (Nscan != 4) continue;
+
+      int nextIndex = fracIndex * MaxValue;
+      if (nextIndex <= lastIndex) {
+	lastRed = fracRed;
+	lastBlue = fracBlue;
+	lastGreen = fracGreen;
+	continue;
+      }
+      float dRdI = (fracRed   - lastRed)   / (float) (nextIndex - lastIndex);
+      float dBdI = (fracBlue  - lastBlue)  / (float) (nextIndex - lastIndex);
+      float dGdI = (fracGreen - lastGreen) / (float) (nextIndex - lastIndex);
+      for (i = lastIndex; i < nextIndex; i++) {
+	float redValue   = 0xffff * (dRdI * (i - lastIndex) + lastRed);
+	float blueValue  = 0xffff * (dBdI * (i - lastIndex) + lastBlue);
+	float greenValue = 0xffff * (dGdI * (i - lastIndex) + lastGreen);
+	SETVALUE (graphic[0].cmap[i].red,   redValue,   0, 0xffff);
+	SETVALUE (graphic[0].cmap[i].blue,  blueValue,  0, 0xffff);
+	SETVALUE (graphic[0].cmap[i].green, greenValue, 0, 0xffff);
+      }
+      lastRed = fracRed;
+      lastBlue = fracBlue;
+      lastGreen = fracGreen;
+      lastIndex = nextIndex;
+    }
+    fclose (f);
+
+    if ((int) (MaxValue*fracIndex) < MaxValue) {
+      float dRdI = (1.0 - lastRed)   / (float) (MaxValue - lastIndex);
+      float dBdI = (1.0 - lastBlue)  / (float) (MaxValue - lastIndex);
+      float dGdI = (1.0 - lastGreen) / (float) (MaxValue - lastIndex);
+      for (i = lastIndex; i < MaxValue; i++) {
+	float redValue   = 0xffff * (dRdI * (i - lastIndex) + lastRed);
+	float blueValue  = 0xffff * (dBdI * (i - lastIndex) + lastBlue);
+	float greenValue = 0xffff * (dGdI * (i - lastIndex) + lastGreen);
+	SETVALUE (graphic[0].cmap[i].red,   redValue,   0, 0xffff);
+	SETVALUE (graphic[0].cmap[i].blue,  blueValue,  0, 0xffff);
+	SETVALUE (graphic[0].cmap[i].green, greenValue, 0, 0xffff);
+      }
+    }
+    goto store_colors;
+  }
+
   return (FALSE);
 
Index: trunk/Ohana/src/kapa2/src/bDrawObjects.c
===================================================================
--- trunk/Ohana/src/kapa2/src/bDrawObjects.c	(revision 38145)
+++ trunk/Ohana/src/kapa2/src/bDrawObjects.c	(revision 38153)
@@ -198,5 +198,5 @@
   
   /* connect first point to second point */
-  sxa = sx0 - 0.5*(sx1 - sx0);
+  sxa = MIN (MAX (sx0 - 0.5*(sx1 - sx0), X0), X1);
   sya = MAX (sy0, Y0);
   DrawLine (buffer, sx0, sy0, sxa, sy0);
@@ -204,5 +204,5 @@
   
   /* draw segment equal distance behind first point and down to x-axis */
-  sxa = 0.5*(sx0 + sx1);
+  sxa = MIN (MAX (0.5*(sx0 + sx1), X0), X1);
   DrawLine (buffer, sx0, sy0, sxa, sy0);
   DrawLine (buffer, sxa, sy0, sxa, sy1);
@@ -219,5 +219,5 @@
     sx1 = MIN (MAX (sx1, X0), X1);
     sy1 = MAX (MIN (sy1, Y0), Y1);
-    sxa = 0.5*(sx0 + sx1);
+    sxa = MIN (MAX (0.5*(sx0 + sx1), X0), X1);
     DrawLine (buffer, sx0, sy0, sxa, sy0);
     DrawLine (buffer, sxa, sy0, sxa, sy1);
@@ -228,5 +228,5 @@
   
   /* draw segment equal distance after last point and down to x-axis */
-  sxa = sx1 + 0.5*(sx1 - sxo);
+  sxa = MIN (MAX (sx1 + 0.5*(sx1 - sxo), X0), X1);
   sya = MAX (sy1, Y0);
   DrawLine (buffer, sx1, sy1, sxa, sy1);
Index: trunk/Ohana/src/libautocode/Makefile.Targets
===================================================================
--- trunk/Ohana/src/libautocode/Makefile.Targets	(revision 38145)
+++ trunk/Ohana/src/libautocode/Makefile.Targets	(revision 38153)
@@ -48,6 +48,8 @@
 $(ASRC)/lensing-ps1-v5-r1.$(ARCH).o \
 $(ASRC)/lensing-ps1-v5-r2.$(ARCH).o \
+$(ASRC)/lensing-ps1-v5-r3.$(ARCH).o \
 $(ASRC)/lensobj.$(ARCH).o \
-$(ASRC)/lensobj-ps1-v5.$(ARCH).o \
+$(ASRC)/lensobj-ps1-v5-r0.$(ARCH).o \
+$(ASRC)/lensobj-ps1-v5-r1.$(ARCH).o \
 $(ASRC)/starpar.$(ARCH).o \
 $(ASRC)/starpar-ps1-v5.$(ARCH).o \
@@ -156,6 +158,8 @@
 $(AINC)/lensing-ps1-v5-r1.h \
 $(AINC)/lensing-ps1-v5-r2.h \
+$(AINC)/lensing-ps1-v5-r3.h \
 $(AINC)/lensobj.h \
-$(AINC)/lensobj-ps1-v5.h \
+$(AINC)/lensobj-ps1-v5-r0.h \
+$(AINC)/lensobj-ps1-v5-r1.h \
 $(AINC)/starpar.h \
 $(AINC)/starpar-ps1-v5.h \
Index: trunk/Ohana/src/libautocode/def/lensing-ps1-v5-r3.d
===================================================================
--- trunk/Ohana/src/libautocode/def/lensing-ps1-v5-r3.d	(revision 38153)
+++ trunk/Ohana/src/libautocode/def/lensing-ps1-v5-r3.d	(revision 38153)
@@ -0,0 +1,60 @@
+STRUCT       Lensing_PS1_V5_R3
+EXTNAME      DVO_LENSING_PS1_V5
+TYPE         BINTABLE
+SIZE         160
+DESCRIPTION  DVO Lensing Table 
+
+FIELD X11_sm_obj,     X11_SM_OBJ,    float,          lensing smear object X11
+FIELD X12_sm_obj,     X12_SM_OBJ,    float,          lensing smear object X12
+FIELD X22_sm_obj,     X22_SM_OBJ,    float,          lensing smear object X22
+FIELD  E1_sm_obj,      E1_SM_OBJ,    float,          lensing smear object E1
+FIELD  E2_sm_obj,      E2_SM_OBJ,    float,          lensing smear object E2
+
+FIELD X11_sh_obj,     X11_SH_OBJ,    float,          lensing shear object X11
+FIELD X12_sh_obj,     X12_SH_OBJ,    float,          lensing shear object X12
+FIELD X22_sh_obj,     X22_SH_OBJ,    float,          lensing shear object X22
+FIELD  E1_sh_obj,      E1_SH_OBJ,    float,          lensing shear object E1
+FIELD  E2_sh_obj,      E2_SH_OBJ,    float,          lensing shear object E2
+
+FIELD X11_sm_psf,     X11_SM_PSF,    float,          lensing smear psf stars X11
+FIELD X12_sm_psf,     X12_SM_PSF,    float,          lensing smear psf stars X12
+FIELD X22_sm_psf,     X22_SM_PSF,    float,          lensing smear psf stars X22
+FIELD  E1_sm_psf,      E1_SM_PSF,    float,          lensing smear psf stars E1
+FIELD  E2_sm_psf,      E2_SM_PSF,    float,          lensing smear psf stars E2
+
+FIELD X11_sh_psf,     X11_SH_PSF,    float,          lensing shear psf stars X11
+FIELD X12_sh_psf,     X12_SH_PSF,    float,          lensing shear psf stars X12
+FIELD X22_sh_psf,     X22_SH_PSF,    float,          lensing shear psf stars X22
+FIELD  E1_sh_psf,      E1_SH_PSF,    float,          lensing shear psf stars E1
+FIELD  E2_sh_psf,      E2_SH_PSF,    float,          lensing shear psf stars E2
+
+FIELD  E1_psf,         E1_PSF,       float,          polarization psf stars E1
+FIELD  E2_psf,         E2_PSF,       float,          polarization psf stars E2
+
+FIELD  F_ApR5,           FLUX_AP_R5, float,          Flux inside r = 5
+FIELD dF_ApR5,       FLUX_ERR_AP_R5, float,          error on Flux inside r = 5
+FIELD sF_ApR5,       FLUX_STD_AP_R5, float,          stdev of Flux inside r = 5
+FIELD fF_ApR5,       FLUX_FIL_AP_R5, float,          fill factor for Flux inside r = 5
+
+FIELD  F_ApR6,           FLUX_AP_R6, float,          Flux inside r = 6
+FIELD dF_ApR6,       FLUX_ERR_AP_R6, float,          error on Flux inside r = 6
+FIELD sF_ApR6,       FLUX_STD_AP_R6, float,          stdev of Flux inside r = 6
+FIELD fF_ApR6,       FLUX_FIL_AP_R6, float,          fill factor for Flux inside r = 6
+
+FIELD  F_ApR7,           FLUX_AP_R7, float,          Flux inside r = 7
+FIELD dF_ApR7,       FLUX_ERR_AP_R7, float,          error on Flux inside r = 7
+FIELD sF_ApR7,       FLUX_STD_AP_R7, float,          stdev of Flux inside r = 7
+FIELD fF_ApR7,       FLUX_FIL_AP_R7, float,          fill factor for Flux inside r = 7
+
+FIELD  detID,          DET_ID,       unsigned int,   detection ID
+FIELD  objID,          OBJ_ID,       unsigned int,   unique ID for object in table
+FIELD  catID,          CAT_ID,       unsigned int,   unique ID for table in which object was first realized
+FIELD  averef,         AVE_REF,      unsigned int,   reference to average entry      
+
+FIELD imageID,	       IMAGE_ID,     unsigned int,   reference to DVO image ID
+FIELD padding,	       PADDING,      unsigned int,   reference to DVO image ID
+
+# 28 x float
+# 4 x int
+# = 128 bytes / detection
+# for 2.5G objects + 60 overlaps, expect 15TB for forced warp
Index: trunk/Ohana/src/libautocode/def/lensing.d
===================================================================
--- trunk/Ohana/src/libautocode/def/lensing.d	(revision 38145)
+++ trunk/Ohana/src/libautocode/def/lensing.d	(revision 38153)
@@ -2,5 +2,5 @@
 EXTNAME      DVO_LENSING
 TYPE         BINTABLE
-SIZE         144
+SIZE         160
 DESCRIPTION  DVO Lensing Table 
 
@@ -32,13 +32,18 @@
 FIELD  E2_psf,         E2_PSF,       float,          polarization psf stars E2
 
-FIELD F_ApR5,        FLUX_AP_R5,     float,          Flux inside r = 5
+FIELD  F_ApR5,           FLUX_AP_R5, float,          Flux inside r = 5
 FIELD dF_ApR5,       FLUX_ERR_AP_R5, float,          error on Flux inside r = 5
 FIELD sF_ApR5,       FLUX_STD_AP_R5, float,          stdev of Flux inside r = 5
 FIELD fF_ApR5,       FLUX_FIL_AP_R5, float,          fill factor for Flux inside r = 5
 
-FIELD F_ApR6,        FLUX_AP_R6,     float,          Flux inside r = 5
-FIELD dF_ApR6,       FLUX_ERR_AP_R6, float,          error on Flux inside r = 5
-FIELD sF_ApR6,       FLUX_STD_AP_R6, float,          stdev of Flux inside r = 5
-FIELD fF_ApR6,       FLUX_FIL_AP_R6, float,          fill factor for Flux inside r = 5
+FIELD  F_ApR6,           FLUX_AP_R6, float,          Flux inside r = 6
+FIELD dF_ApR6,       FLUX_ERR_AP_R6, float,          error on Flux inside r = 6
+FIELD sF_ApR6,       FLUX_STD_AP_R6, float,          stdev of Flux inside r = 6
+FIELD fF_ApR6,       FLUX_FIL_AP_R6, float,          fill factor for Flux inside r = 6
+
+FIELD  F_ApR7,           FLUX_AP_R7, float,          Flux inside r = 7
+FIELD dF_ApR7,       FLUX_ERR_AP_R7, float,          error on Flux inside r = 7
+FIELD sF_ApR7,       FLUX_STD_AP_R7, float,          stdev of Flux inside r = 7
+FIELD fF_ApR7,       FLUX_FIL_AP_R7, float,          fill factor for Flux inside r = 7
 
 FIELD   detID,          DET_ID,      int,   	     detection ID
@@ -48,8 +53,6 @@
 
 FIELD imageID,	       IMAGE_ID,     int,   	     reference to DVO image ID
-FIELD padding,	       PADDING,      int,   	     padding
+FIELD padding,	        PADDING,     int,   	     filler
 
-# 28 x float
-# 5 x int + padding
-# = 136 bytes / detection
+# 160 bytes / detection
 # for 2.5G objects + 60 overlaps, expect 15TB for forced warp
Index: trunk/Ohana/src/libautocode/def/lensobj-ps1-v5-r0.d
===================================================================
--- trunk/Ohana/src/libautocode/def/lensobj-ps1-v5-r0.d	(revision 38153)
+++ trunk/Ohana/src/libautocode/def/lensobj-ps1-v5-r0.d	(revision 38153)
@@ -0,0 +1,53 @@
+STRUCT       Lensobj_PS1_V5_R0
+EXTNAME      DVO_LENSOBJ_PS1_V5
+TYPE         BINTABLE
+SIZE         136
+DESCRIPTION  DVO Lensobj Table 
+
+FIELD X11_sm_obj,     X11_SM_OBJ,    float,          mean lensing smear object X11
+FIELD X12_sm_obj,     X12_SM_OBJ,    float,          mean lensing smear object X12
+FIELD X22_sm_obj,     X22_SM_OBJ,    float,          mean lensing smear object X22
+FIELD  E1_sm_obj,      E1_SM_OBJ,    float,          mean lensing smear object E1
+FIELD  E2_sm_obj,      E2_SM_OBJ,    float,          mean lensing smear object E2
+
+FIELD X11_sh_obj,     X11_SH_OBJ,    float,          mean lensing shear object X11
+FIELD X12_sh_obj,     X12_SH_OBJ,    float,          mean lensing shear object X12
+FIELD X22_sh_obj,     X22_SH_OBJ,    float,          mean lensing shear object X22
+FIELD  E1_sh_obj,      E1_SH_OBJ,    float,          mean lensing shear object E1
+FIELD  E2_sh_obj,      E2_SH_OBJ,    float,          mean lensing shear object E2
+
+FIELD X11_sm_psf,     X11_SM_PSF,    float,          mean lensing smear psf stars X11
+FIELD X12_sm_psf,     X12_SM_PSF,    float,          mean lensing smear psf stars X12
+FIELD X22_sm_psf,     X22_SM_PSF,    float,          mean lensing smear psf stars X22
+FIELD  E1_sm_psf,      E1_SM_PSF,    float,          mean lensing smear psf stars E1
+FIELD  E2_sm_psf,      E2_SM_PSF,    float,          mean lensing smear psf stars E2
+
+FIELD X11_sh_psf,     X11_SH_PSF,    float,          mean lensing shear psf stars X11
+FIELD X12_sh_psf,     X12_SH_PSF,    float,          mean lensing shear psf stars X12
+FIELD X22_sh_psf,     X22_SH_PSF,    float,          mean lensing shear psf stars X22
+FIELD  E1_sh_psf,      E1_SH_PSF,    float,          mean lensing shear psf stars E1
+FIELD  E2_sh_psf,      E2_SH_PSF,    float,          mean lensing shear psf stars E2
+
+FIELD  F_ApR5,           FLUX_AP_R5, float,          Flux inside r = 5
+FIELD dF_ApR5,       FLUX_ERR_AP_R5, float,          error on Flux inside r = 5
+FIELD sF_ApR5,       FLUX_STD_AP_R5, float,          stdev of Flux inside r = 5
+FIELD fF_ApR5,       FLUX_FIL_AP_R5, float,          fill factor for Flux inside r = 5
+
+FIELD  F_ApR6,           FLUX_AP_R6, float,          Flux inside r = 6
+FIELD dF_ApR6,       FLUX_ERR_AP_R6, float,          error on Flux inside r = 6
+FIELD sF_ApR6,       FLUX_STD_AP_R6, float,          stdev of Flux inside r = 6
+FIELD fF_ApR6,       FLUX_FIL_AP_R6, float,          fill factor for Flux inside r = 6
+
+FIELD  gamma,            GAMMA,      float
+FIELD     E1,               E1,      float
+FIELD     E2,               E2,      float
+
+FIELD    objID,          OBJ_ID,       unsigned int,   unique ID for object in table
+FIELD    catID,          CAT_ID,       unsigned int,   unique ID for table in which object was first realized
+FIELD photcode,         PHOTCODE,    short
+FIELD    Nmeas,            NMEAS,    short
+
+# 31 x float
+#  3 x int
+# = 136 bytes / detection
+# for 2.5G objects + 60 overlaps, expect 15TB for forced warp
Index: trunk/Ohana/src/libautocode/def/lensobj-ps1-v5-r1.d
===================================================================
--- trunk/Ohana/src/libautocode/def/lensobj-ps1-v5-r1.d	(revision 38153)
+++ trunk/Ohana/src/libautocode/def/lensobj-ps1-v5-r1.d	(revision 38153)
@@ -0,0 +1,58 @@
+STRUCT       Lensobj_PS1_V5_R1
+EXTNAME      DVO_LENSOBJ_PS1_V5
+TYPE         BINTABLE
+SIZE         152
+DESCRIPTION  DVO Lensobj Table 
+
+FIELD X11_sm_obj,     X11_SM_OBJ,    float,          mean lensing smear object X11
+FIELD X12_sm_obj,     X12_SM_OBJ,    float,          mean lensing smear object X12
+FIELD X22_sm_obj,     X22_SM_OBJ,    float,          mean lensing smear object X22
+FIELD  E1_sm_obj,      E1_SM_OBJ,    float,          mean lensing smear object E1
+FIELD  E2_sm_obj,      E2_SM_OBJ,    float,          mean lensing smear object E2
+
+FIELD X11_sh_obj,     X11_SH_OBJ,    float,          mean lensing shear object X11
+FIELD X12_sh_obj,     X12_SH_OBJ,    float,          mean lensing shear object X12
+FIELD X22_sh_obj,     X22_SH_OBJ,    float,          mean lensing shear object X22
+FIELD  E1_sh_obj,      E1_SH_OBJ,    float,          mean lensing shear object E1
+FIELD  E2_sh_obj,      E2_SH_OBJ,    float,          mean lensing shear object E2
+
+FIELD X11_sm_psf,     X11_SM_PSF,    float,          mean lensing smear psf stars X11
+FIELD X12_sm_psf,     X12_SM_PSF,    float,          mean lensing smear psf stars X12
+FIELD X22_sm_psf,     X22_SM_PSF,    float,          mean lensing smear psf stars X22
+FIELD  E1_sm_psf,      E1_SM_PSF,    float,          mean lensing smear psf stars E1
+FIELD  E2_sm_psf,      E2_SM_PSF,    float,          mean lensing smear psf stars E2
+
+FIELD X11_sh_psf,     X11_SH_PSF,    float,          mean lensing shear psf stars X11
+FIELD X12_sh_psf,     X12_SH_PSF,    float,          mean lensing shear psf stars X12
+FIELD X22_sh_psf,     X22_SH_PSF,    float,          mean lensing shear psf stars X22
+FIELD  E1_sh_psf,      E1_SH_PSF,    float,          mean lensing shear psf stars E1
+FIELD  E2_sh_psf,      E2_SH_PSF,    float,          mean lensing shear psf stars E2
+
+FIELD  F_ApR5,           FLUX_AP_R5, float,          Flux inside r = 5
+FIELD dF_ApR5,       FLUX_ERR_AP_R5, float,          error on Flux inside r = 5
+FIELD sF_ApR5,       FLUX_STD_AP_R5, float,          stdev of Flux inside r = 5
+FIELD fF_ApR5,       FLUX_FIL_AP_R5, float,          fill factor for Flux inside r = 5
+
+FIELD  F_ApR6,           FLUX_AP_R6, float,          Flux inside r = 6
+FIELD dF_ApR6,       FLUX_ERR_AP_R6, float,          error on Flux inside r = 6
+FIELD sF_ApR6,       FLUX_STD_AP_R6, float,          stdev of Flux inside r = 6
+FIELD fF_ApR6,       FLUX_FIL_AP_R6, float,          fill factor for Flux inside r = 6
+
+FIELD  F_ApR7,           FLUX_AP_R7, float,          Flux inside r = 7
+FIELD dF_ApR7,       FLUX_ERR_AP_R7, float,          error on Flux inside r = 7
+FIELD sF_ApR7,       FLUX_STD_AP_R7, float,          stdev of Flux inside r = 7
+FIELD fF_ApR7,       FLUX_FIL_AP_R7, float,          fill factor for Flux inside r = 7
+
+FIELD  gamma,            GAMMA,      float
+FIELD     E1,               E1,      float
+FIELD     E2,               E2,      float
+
+FIELD    objID,          OBJ_ID,       unsigned int,   unique ID for object in table
+FIELD    catID,          CAT_ID,       unsigned int,   unique ID for table in which object was first realized
+FIELD photcode,         PHOTCODE,    short
+FIELD    Nmeas,            NMEAS,    short
+
+# 31 x float
+#  3 x int
+# = 136 bytes / detection
+# for 2.5G objects + 60 overlaps, expect 15TB for forced warp
Index: trunk/Ohana/src/libautocode/def/lensobj-ps1-v5.d
===================================================================
--- trunk/Ohana/src/libautocode/def/lensobj-ps1-v5.d	(revision 38145)
+++ 	(revision )
@@ -1,53 +1,0 @@
-STRUCT       Lensobj_PS1_V5
-EXTNAME      DVO_LENSOBJ_PS1_V5
-TYPE         BINTABLE
-SIZE         136
-DESCRIPTION  DVO Lensobj Table 
-
-FIELD X11_sm_obj,     X11_SM_OBJ,    float,          mean lensing smear object X11
-FIELD X12_sm_obj,     X12_SM_OBJ,    float,          mean lensing smear object X12
-FIELD X22_sm_obj,     X22_SM_OBJ,    float,          mean lensing smear object X22
-FIELD  E1_sm_obj,      E1_SM_OBJ,    float,          mean lensing smear object E1
-FIELD  E2_sm_obj,      E2_SM_OBJ,    float,          mean lensing smear object E2
-
-FIELD X11_sh_obj,     X11_SH_OBJ,    float,          mean lensing shear object X11
-FIELD X12_sh_obj,     X12_SH_OBJ,    float,          mean lensing shear object X12
-FIELD X22_sh_obj,     X22_SH_OBJ,    float,          mean lensing shear object X22
-FIELD  E1_sh_obj,      E1_SH_OBJ,    float,          mean lensing shear object E1
-FIELD  E2_sh_obj,      E2_SH_OBJ,    float,          mean lensing shear object E2
-
-FIELD X11_sm_psf,     X11_SM_PSF,    float,          mean lensing smear psf stars X11
-FIELD X12_sm_psf,     X12_SM_PSF,    float,          mean lensing smear psf stars X12
-FIELD X22_sm_psf,     X22_SM_PSF,    float,          mean lensing smear psf stars X22
-FIELD  E1_sm_psf,      E1_SM_PSF,    float,          mean lensing smear psf stars E1
-FIELD  E2_sm_psf,      E2_SM_PSF,    float,          mean lensing smear psf stars E2
-
-FIELD X11_sh_psf,     X11_SH_PSF,    float,          mean lensing shear psf stars X11
-FIELD X12_sh_psf,     X12_SH_PSF,    float,          mean lensing shear psf stars X12
-FIELD X22_sh_psf,     X22_SH_PSF,    float,          mean lensing shear psf stars X22
-FIELD  E1_sh_psf,      E1_SH_PSF,    float,          mean lensing shear psf stars E1
-FIELD  E2_sh_psf,      E2_SH_PSF,    float,          mean lensing shear psf stars E2
-
-FIELD F_ApR5,        FLUX_AP_R5,     float,          Flux inside r = 5
-FIELD dF_ApR5,       FLUX_ERR_AP_R5, float,          error on Flux inside r = 5
-FIELD sF_ApR5,       FLUX_STD_AP_R5, float,          stdev of Flux inside r = 5
-FIELD fF_ApR5,       FLUX_FIL_AP_R5, float,          fill factor for Flux inside r = 5
-
-FIELD F_ApR6,        FLUX_AP_R6,     float,          Flux inside r = 5
-FIELD dF_ApR6,       FLUX_ERR_AP_R6, float,          error on Flux inside r = 5
-FIELD sF_ApR6,       FLUX_STD_AP_R6, float,          stdev of Flux inside r = 5
-FIELD fF_ApR6,       FLUX_FIL_AP_R6, float,          fill factor for Flux inside r = 5
-
-FIELD  gamma,            GAMMA,      float
-FIELD     E1,               E1,      float
-FIELD     E2,               E2,      float
-
-FIELD    objID,          OBJ_ID,       unsigned int,   unique ID for object in table
-FIELD    catID,          CAT_ID,       unsigned int,   unique ID for table in which object was first realized
-FIELD photcode,         PHOTCODE,    short
-FIELD    Nmeas,            NMEAS,    short
-
-# 31 x float
-#  3 x int
-# = 136 bytes / detection
-# for 2.5G objects + 60 overlaps, expect 15TB for forced warp
Index: trunk/Ohana/src/libautocode/def/lensobj.d
===================================================================
--- trunk/Ohana/src/libautocode/def/lensobj.d	(revision 38145)
+++ trunk/Ohana/src/libautocode/def/lensobj.d	(revision 38153)
@@ -2,5 +2,5 @@
 EXTNAME      DVO_LENSOBJ
 TYPE         BINTABLE
-SIZE         136
+SIZE         152
 DESCRIPTION  DVO Lensobj Table 
 
@@ -29,13 +29,18 @@
 FIELD  E2_sh_psf,      E2_SH_PSF,    float,          mean lensing shear psf stars E2
 
-FIELD F_ApR5,        FLUX_AP_R5,     float,          Flux inside r = 5
+FIELD  F_ApR5,           FLUX_AP_R5, float,          Flux inside r = 5
 FIELD dF_ApR5,       FLUX_ERR_AP_R5, float,          error on Flux inside r = 5
 FIELD sF_ApR5,       FLUX_STD_AP_R5, float,          stdev of Flux inside r = 5
 FIELD fF_ApR5,       FLUX_FIL_AP_R5, float,          fill factor for Flux inside r = 5
 
-FIELD F_ApR6,        FLUX_AP_R6,     float,          Flux inside r = 5
-FIELD dF_ApR6,       FLUX_ERR_AP_R6, float,          error on Flux inside r = 5
-FIELD sF_ApR6,       FLUX_STD_AP_R6, float,          stdev of Flux inside r = 5
-FIELD fF_ApR6,       FLUX_FIL_AP_R6, float,          fill factor for Flux inside r = 5
+FIELD  F_ApR6,           FLUX_AP_R6, float,          Flux inside r = 6
+FIELD dF_ApR6,       FLUX_ERR_AP_R6, float,          error on Flux inside r = 6
+FIELD sF_ApR6,       FLUX_STD_AP_R6, float,          stdev of Flux inside r = 6
+FIELD fF_ApR6,       FLUX_FIL_AP_R6, float,          fill factor for Flux inside r = 6
+
+FIELD  F_ApR7,           FLUX_AP_R7, float,          Flux inside r = 7
+FIELD dF_ApR7,       FLUX_ERR_AP_R7, float,          error on Flux inside r = 7
+FIELD sF_ApR7,       FLUX_STD_AP_R7, float,          stdev of Flux inside r = 7
+FIELD fF_ApR7,       FLUX_FIL_AP_R7, float,          fill factor for Flux inside r = 7
 
 FIELD      gamma,        GAMMA,      float
Index: trunk/Ohana/src/libdvo/include/dvo.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvo.h	(revision 38145)
+++ trunk/Ohana/src/libdvo/include/dvo.h	(revision 38153)
@@ -1150,4 +1150,22 @@
 LENSFIELD(E2_sh_psf)
 
+LENSFIELD( F_ApR5);
+LENSFIELD(dF_ApR5);
+LENSFIELD(sF_ApR5);
+LENSFIELD(fF_ApR5);
+
+LENSFIELD( F_ApR6);
+LENSFIELD(dF_ApR6);
+LENSFIELD(sF_ApR6);
+LENSFIELD(fF_ApR6);
+
+LENSFIELD( F_ApR7);
+LENSFIELD(dF_ApR7);
+LENSFIELD(sF_ApR7);
+LENSFIELD(fF_ApR7);
+
+LENSFIELD(E1);
+LENSFIELD(E2);
+
 # undef LENSFIELD
 
Index: trunk/Ohana/src/libdvo/include/dvodb.h
===================================================================
--- trunk/Ohana/src/libdvo/include/dvodb.h	(revision 38145)
+++ trunk/Ohana/src/libdvo/include/dvodb.h	(revision 38153)
@@ -89,4 +89,12 @@
   MAG_OPTION_F_STDEV_AP_R6, 
   MAG_OPTION_F_FILL_AP_R6, 
+
+  MAG_OPTION_F_AP_R7, 
+  MAG_OPTION_F_ERR_AP_R7, 
+  MAG_OPTION_F_STDEV_AP_R7, 
+  MAG_OPTION_F_FILL_AP_R7, 
+
+  MAG_OPTION_E1, 
+  MAG_OPTION_E2, 
 } dvoMagOptionType;
 
@@ -207,4 +215,5 @@
       MEAS_REF_COLOR_BLUE,
       MEAS_REF_COLOR_RED,
+
       MEAS_X11_SM_OBJ, 
       MEAS_X12_SM_OBJ, 
@@ -227,4 +236,20 @@
       MEAS_E1_SH_PSF, 
       MEAS_E2_SH_PSF, 
+
+      MEAS_F_AP_R5, 
+      MEAS_F_ERR_AP_R5, 
+      MEAS_F_STDEV_AP_R5, 
+      MEAS_F_FILL_AP_R5, 
+
+      MEAS_F_AP_R6, 
+      MEAS_F_ERR_AP_R6, 
+      MEAS_F_STDEV_AP_R6, 
+      MEAS_F_FILL_AP_R6, 
+
+      MEAS_F_AP_R7, 
+      MEAS_F_ERR_AP_R7, 
+      MEAS_F_STDEV_AP_R7, 
+      MEAS_F_FILL_AP_R7, 
+
       MEAS_E_BV,		      // extinction (mags)
       MEAS_E_BV_ERR,
Index: trunk/Ohana/src/libdvo/include/ps1_v5_defs.h
===================================================================
--- trunk/Ohana/src/libdvo/include/ps1_v5_defs.h	(revision 38145)
+++ trunk/Ohana/src/libdvo/include/ps1_v5_defs.h	(revision 38153)
@@ -8,14 +8,15 @@
 SecFilt_PS1_V5          *SecFiltInternalTo_PS1_V5 (SecFilt *in, off_t Nvalues);
 
-typedef Lensing_PS1_V5_R2 Lensing_PS1_V5;
+Lensobj 	       	*Lensobj_PS1_V5_R0_ToInternal (Lensobj_PS1_V5_R0 *in, off_t Nvalues);
+Lensobj 	       	*Lensobj_PS1_V5_R1_ToInternal (Lensobj_PS1_V5_R1 *in, off_t Nvalues);
 
-Lensing 	       	*Lensing_PS1_V5_ToInternal (Lensing_PS1_V5 *in, off_t Nvalues);
-Lensing_PS1_V5_R2       *LensingInternalTo_PS1_V5_R2 (Lensing *in, off_t Nvalues);
-Lensobj 	       	*Lensobj_PS1_V5_ToInternal (Lensobj_PS1_V5 *in, off_t Nvalues);
-Lensobj_PS1_V5          *LensobjInternalTo_PS1_V5 (Lensobj *in, off_t Nvalues);
+Lensobj_PS1_V5_R1       *LensobjInternalTo_PS1_V5_R1 (Lensobj *in, off_t Nvalues);
 
 Lensing 	       	*Lensing_PS1_V5_R0_ToInternal (Lensing_PS1_V5_R0 *in, off_t Nvalues);
 Lensing 	       	*Lensing_PS1_V5_R1_ToInternal (Lensing_PS1_V5_R1 *in, off_t Nvalues);
 Lensing 	       	*Lensing_PS1_V5_R2_ToInternal (Lensing_PS1_V5_R2 *in, off_t Nvalues);
+Lensing 	       	*Lensing_PS1_V5_R3_ToInternal (Lensing_PS1_V5_R3 *in, off_t Nvalues);
+
+Lensing_PS1_V5_R3       *LensingInternalTo_PS1_V5_R3 (Lensing *in, off_t Nvalues);
 
 StarPar 	       	*StarPar_PS1_V5_ToInternal (StarPar_PS1_V5 *in, off_t Nvalues);
Index: trunk/Ohana/src/libdvo/src/dbExtractAverages.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dbExtractAverages.c	(revision 38145)
+++ trunk/Ohana/src/libdvo/src/dbExtractAverages.c	(revision 38153)
@@ -386,4 +386,22 @@
 	case MAG_OPTION_E1_SH_PSF:  { value.Flt = LensValue_E1_sh_psf  (field->photcode, lensobj); break; }
 	case MAG_OPTION_E2_SH_PSF:  { value.Flt = LensValue_E2_sh_psf  (field->photcode, lensobj); break; }
+
+	case MAG_OPTION_F_AP_R5:       { value.Flt = LensValue_F_ApR5  (field->photcode, lensobj); break; }
+	case MAG_OPTION_F_ERR_AP_R5:   { value.Flt = LensValue_dF_ApR5 (field->photcode, lensobj); break; }
+	case MAG_OPTION_F_STDEV_AP_R5: { value.Flt = LensValue_sF_ApR5 (field->photcode, lensobj); break; }
+	case MAG_OPTION_F_FILL_AP_R5:  { value.Flt = LensValue_fF_ApR5 (field->photcode, lensobj); break; }
+
+	case MAG_OPTION_F_AP_R6:       { value.Flt = LensValue_F_ApR6  (field->photcode, lensobj); break; }
+	case MAG_OPTION_F_ERR_AP_R6:   { value.Flt = LensValue_dF_ApR6 (field->photcode, lensobj); break; }
+	case MAG_OPTION_F_STDEV_AP_R6: { value.Flt = LensValue_sF_ApR6 (field->photcode, lensobj); break; }
+	case MAG_OPTION_F_FILL_AP_R6:  { value.Flt = LensValue_fF_ApR6 (field->photcode, lensobj); break; }
+
+	case MAG_OPTION_F_AP_R7:       { value.Flt = LensValue_F_ApR7  (field->photcode, lensobj); break; }
+	case MAG_OPTION_F_ERR_AP_R7:   { value.Flt = LensValue_dF_ApR7 (field->photcode, lensobj); break; }
+	case MAG_OPTION_F_STDEV_AP_R7: { value.Flt = LensValue_sF_ApR7 (field->photcode, lensobj); break; }
+	case MAG_OPTION_F_FILL_AP_R7:  { value.Flt = LensValue_fF_ApR7 (field->photcode, lensobj); break; }
+
+	case MAG_OPTION_E1:  	       { value.Flt = LensValue_E1      (field->photcode, lensobj); break; }
+	case MAG_OPTION_E2:  	       { value.Flt = LensValue_E2      (field->photcode, lensobj); break; }
 
 	case MAG_OPTION_NONE:
Index: trunk/Ohana/src/libdvo/src/dbExtractMeasures.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dbExtractMeasures.c	(revision 38145)
+++ trunk/Ohana/src/libdvo/src/dbExtractMeasures.c	(revision 38153)
@@ -277,4 +277,10 @@
 	case MAG_OPTION_F_STDEV_AP_R6: 
 	case MAG_OPTION_F_FILL_AP_R6: 
+	case MAG_OPTION_F_AP_R7: 
+	case MAG_OPTION_F_ERR_AP_R7: 
+	case MAG_OPTION_F_STDEV_AP_R7: 
+	case MAG_OPTION_F_FILL_AP_R7: 
+	case MAG_OPTION_E1: 
+	case MAG_OPTION_E2: 
 
 	case MAG_OPTION_NONE:
@@ -735,4 +741,38 @@
       }
       break;
+
+    case MEAS_X11_SM_OBJ: { value.Flt = lensing->X11_sm_obj; break; } 
+    case MEAS_X12_SM_OBJ: { value.Flt = lensing->X12_sm_obj; break; } 
+    case MEAS_X22_SM_OBJ: { value.Flt = lensing->X22_sm_obj; break; } 
+    case MEAS_E1_SM_OBJ:  { value.Flt = lensing->E1_sm_obj; break; } 
+    case MEAS_E2_SM_OBJ:  { value.Flt = lensing->E2_sm_obj; break; } 
+    case MEAS_X11_SH_OBJ: { value.Flt = lensing->X11_sh_obj; break; } 
+    case MEAS_X12_SH_OBJ: { value.Flt = lensing->X12_sh_obj; break; } 
+    case MEAS_X22_SH_OBJ: { value.Flt = lensing->X22_sh_obj; break; } 
+    case MEAS_E1_SH_OBJ:  { value.Flt = lensing->E1_sh_obj; break; } 
+    case MEAS_E2_SH_OBJ:  { value.Flt = lensing->E2_sh_obj; break; } 
+    case MEAS_X11_SM_PSF: { value.Flt = lensing->X11_sm_psf; break; } 
+    case MEAS_X12_SM_PSF: { value.Flt = lensing->X12_sm_psf; break; } 
+    case MEAS_X22_SM_PSF: { value.Flt = lensing->X22_sm_psf; break; } 
+    case MEAS_E1_SM_PSF:  { value.Flt = lensing->E1_sm_psf; break; } 
+    case MEAS_E2_SM_PSF:  { value.Flt = lensing->E2_sm_psf; break; } 
+    case MEAS_X11_SH_PSF: { value.Flt = lensing->X11_sh_psf; break; } 
+    case MEAS_X12_SH_PSF: { value.Flt = lensing->X12_sh_psf; break; } 
+    case MEAS_X22_SH_PSF: { value.Flt = lensing->X22_sh_psf; break; } 
+    case MEAS_E1_SH_PSF:  { value.Flt = lensing->E1_sh_psf; break; } 
+    case MEAS_E2_SH_PSF:  { value.Flt = lensing->E2_sh_psf; break; } 
+
+    case MEAS_F_AP_R5:       { value.Flt = lensing-> F_ApR5; break; } 
+    case MEAS_F_ERR_AP_R5:   { value.Flt = lensing->dF_ApR5; break; } 
+    case MEAS_F_STDEV_AP_R5: { value.Flt = lensing->sF_ApR5; break; } 
+    case MEAS_F_FILL_AP_R5:  { value.Flt = lensing->fF_ApR5; break; } 
+    case MEAS_F_AP_R6:       { value.Flt = lensing-> F_ApR6; break; } 
+    case MEAS_F_ERR_AP_R6:   { value.Flt = lensing->dF_ApR6; break; } 
+    case MEAS_F_STDEV_AP_R6: { value.Flt = lensing->sF_ApR6; break; } 
+    case MEAS_F_FILL_AP_R6:  { value.Flt = lensing->fF_ApR6; break; } 
+    case MEAS_F_AP_R7:       { value.Flt = lensing-> F_ApR7; break; } 
+    case MEAS_F_ERR_AP_R7:   { value.Flt = lensing->dF_ApR7; break; } 
+    case MEAS_F_STDEV_AP_R7: { value.Flt = lensing->sF_ApR7; break; } 
+    case MEAS_F_FILL_AP_R7:  { value.Flt = lensing->fF_ApR7; break; } 
 
     case MEAS_E_BV:             { value.Flt = starpar->Ebv;      break; }
Index: trunk/Ohana/src/libdvo/src/dbFields.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dbFields.c	(revision 38145)
+++ trunk/Ohana/src/libdvo/src/dbFields.c	(revision 38153)
@@ -61,4 +61,19 @@
     if (fields[i].ID == MEAS_E1_SH_PSF)  return TRUE;
     if (fields[i].ID == MEAS_E2_SH_PSF)  return TRUE;
+
+    if (fields[i].ID == MEAS_F_AP_R5)       return TRUE;
+    if (fields[i].ID == MEAS_F_ERR_AP_R5)   return TRUE;
+    if (fields[i].ID == MEAS_F_STDEV_AP_R5) return TRUE;
+    if (fields[i].ID == MEAS_F_FILL_AP_R5)  return TRUE;
+
+    if (fields[i].ID == MEAS_F_AP_R6)       return TRUE;
+    if (fields[i].ID == MEAS_F_ERR_AP_R6)   return TRUE;
+    if (fields[i].ID == MEAS_F_STDEV_AP_R6) return TRUE;
+    if (fields[i].ID == MEAS_F_FILL_AP_R6)  return TRUE;
+
+    if (fields[i].ID == MEAS_F_AP_R7)       return TRUE;
+    if (fields[i].ID == MEAS_F_ERR_AP_R7)   return TRUE;
+    if (fields[i].ID == MEAS_F_STDEV_AP_R7) return TRUE;
+    if (fields[i].ID == MEAS_F_FILL_AP_R7)  return TRUE;
   }
   return FALSE;
@@ -90,4 +105,22 @@
     if (fields[i].magOption == MAG_OPTION_E1_SH_PSF)  return TRUE;
     if (fields[i].magOption == MAG_OPTION_E2_SH_PSF)  return TRUE;
+
+    if (fields[i].magOption == MAG_OPTION_F_AP_R5)       return TRUE;
+    if (fields[i].magOption == MAG_OPTION_F_ERR_AP_R5)   return TRUE;
+    if (fields[i].magOption == MAG_OPTION_F_STDEV_AP_R5) return TRUE;
+    if (fields[i].magOption == MAG_OPTION_F_FILL_AP_R5)  return TRUE;
+
+    if (fields[i].magOption == MAG_OPTION_F_AP_R6)       return TRUE;
+    if (fields[i].magOption == MAG_OPTION_F_ERR_AP_R6)   return TRUE;
+    if (fields[i].magOption == MAG_OPTION_F_STDEV_AP_R6) return TRUE;
+    if (fields[i].magOption == MAG_OPTION_F_FILL_AP_R6)  return TRUE;
+
+    if (fields[i].magOption == MAG_OPTION_F_AP_R7)       return TRUE;
+    if (fields[i].magOption == MAG_OPTION_F_ERR_AP_R7)   return TRUE;
+    if (fields[i].magOption == MAG_OPTION_F_STDEV_AP_R7) return TRUE;
+    if (fields[i].magOption == MAG_OPTION_F_FILL_AP_R7)  return TRUE;
+
+    if (fields[i].magOption == MAG_OPTION_E1)            return TRUE;
+    if (fields[i].magOption == MAG_OPTION_E2)            return TRUE;
   }
   return FALSE;
@@ -199,12 +232,18 @@
   if (!strcasecmp (string, "E1_SH_PSF"))     return MAG_OPTION_E1_SH_PSF; 
   if (!strcasecmp (string, "E2_SH_PSF"))     return MAG_OPTION_E2_SH_PSF; 
-  // if (!strcasecmp (string, "F_AP_R5"))       return MAG_OPTION_F_AP_R5; 
-  // if (!strcasecmp (string, "F_ERR_AP_R5"))   return MAG_OPTION_F_ERR_AP_R5; 
-  // if (!strcasecmp (string, "F_STDEV_AP_R5")) return MAG_OPTION_F_STDEV_AP_R5; 
-  // if (!strcasecmp (string, "F_FILL_AP_R5"))  return MAG_OPTION_F_FILL_AP_R5; 
-  // if (!strcasecmp (string, "F_AP_R6"))       return MAG_OPTION_F_AP_R6; 
-  // if (!strcasecmp (string, "F_ERR_AP_R6"))   return MAG_OPTION_F_ERR_AP_R6; 
-  // if (!strcasecmp (string, "F_STDEV_AP_R6")) return MAG_OPTION_F_STDEV_AP_R6; 
-  // if (!strcasecmp (string, "F_FILL_AP_R6"))  return MAG_OPTION_F_FILL_AP_R6; 
+  if (!strcasecmp (string, "F_AP_R5"))       return MAG_OPTION_F_AP_R5; 
+  if (!strcasecmp (string, "F_ERR_AP_R5"))   return MAG_OPTION_F_ERR_AP_R5; 
+  if (!strcasecmp (string, "F_STDEV_AP_R5")) return MAG_OPTION_F_STDEV_AP_R5; 
+  if (!strcasecmp (string, "F_FILL_AP_R5"))  return MAG_OPTION_F_FILL_AP_R5; 
+  if (!strcasecmp (string, "F_AP_R6"))       return MAG_OPTION_F_AP_R6; 
+  if (!strcasecmp (string, "F_ERR_AP_R6"))   return MAG_OPTION_F_ERR_AP_R6; 
+  if (!strcasecmp (string, "F_STDEV_AP_R6")) return MAG_OPTION_F_STDEV_AP_R6; 
+  if (!strcasecmp (string, "F_FILL_AP_R6"))  return MAG_OPTION_F_FILL_AP_R6; 
+  if (!strcasecmp (string, "F_AP_R7"))       return MAG_OPTION_F_AP_R7; 
+  if (!strcasecmp (string, "F_ERR_AP_R7"))   return MAG_OPTION_F_ERR_AP_R7; 
+  if (!strcasecmp (string, "F_STDEV_AP_R7")) return MAG_OPTION_F_STDEV_AP_R7; 
+  if (!strcasecmp (string, "F_FILL_AP_R7"))  return MAG_OPTION_F_FILL_AP_R7; 
+  if (!strcasecmp (string, "E1"))            return MAG_OPTION_E1; 
+  if (!strcasecmp (string, "E2"))            return MAG_OPTION_E2; 
 
   return MAG_OPTION_NONE;
@@ -534,4 +573,17 @@
   if (!strcasecmp (fieldName, "E2_SH_PSF"))      ESCAPE (MEAS_E2_SH_PSF,  OPIHI_FLT);
 
+  if (!strcasecmp (fieldName, "F_AP_R5"))        ESCAPE (MEAS_F_AP_R5,       OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_ERR_AP_R5"))    ESCAPE (MEAS_F_ERR_AP_R5,   OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_STDEV_AP_R5"))  ESCAPE (MEAS_F_STDEV_AP_R5, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_FILL_AP_R5"))   ESCAPE (MEAS_F_FILL_AP_R5,  OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_AP_R6"))        ESCAPE (MEAS_F_AP_R6,       OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_ERR_AP_R6"))    ESCAPE (MEAS_F_ERR_AP_R6,   OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_STDEV_AP_R6"))  ESCAPE (MEAS_F_STDEV_AP_R6, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_FILL_AP_R6"))   ESCAPE (MEAS_F_FILL_AP_R6,  OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_AP_R7"))        ESCAPE (MEAS_F_AP_R7,       OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_ERR_AP_R7"))    ESCAPE (MEAS_F_ERR_AP_R7,   OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_STDEV_AP_R7"))  ESCAPE (MEAS_F_STDEV_AP_R7, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "F_FILL_AP_R7"))   ESCAPE (MEAS_F_FILL_AP_R7,  OPIHI_FLT);
+
   if (!strcasecmp (fieldName, "E_BV"))             ESCAPE (MEAS_E_BV          ,   OPIHI_FLT);
   if (!strcasecmp (fieldName, "E_BV_ERR"))         ESCAPE (MEAS_E_BV_ERR      ,   OPIHI_FLT);
Index: trunk/Ohana/src/libdvo/src/dvo_catalog_split.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 38145)
+++ trunk/Ohana/src/libdvo/src/dvo_catalog_split.c	(revision 38153)
@@ -992,17 +992,19 @@
     assert (catalog[0].Nlensing_disk >= catalog[0].Nlensing_off);
 
-    // convert to external table format (note that the block above does not damage or free catalog.average) 
-    if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat)) {
-      fprintf (stderr, "trouble converting format\n");
-      goto failure;
-    }
-
-    // write out Lensing table
-    if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) {
-      fprintf (stderr, "trouble writing Lensing table\n");
-      goto failure;
-    }
-    gfits_free_header (&header);
-    gfits_free_table (&ftable);
+    if (catalog[0].Nlensing) {
+      // convert to external table format (note that the block above does not damage or free catalog.average) 
+      if (!LensingToFtable (&ftable, &catalog[0].lensing[first], Nrows, catalog[0].catformat)) {
+	fprintf (stderr, "trouble converting format\n");
+	goto failure;
+      }
+
+      // write out Lensing table
+      if (!dvo_catalog_save_subcat (catalog[0].lensing_catalog, &ftable, start, Nrows, catalog[0].Nlensing_disk, Nlensing_disk_new)) {
+	fprintf (stderr, "trouble writing Lensing table\n");
+	goto failure;
+      }
+      gfits_free_header (&header);
+      gfits_free_table (&ftable);
+    }
   }
 
@@ -1019,17 +1021,19 @@
     assert (catalog[0].Nlensobj_disk >= catalog[0].Nlensobj_off);
 
-    // convert to external table format (note that the block above does not damage or free catalog.average) 
-    if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat)) {
-      fprintf (stderr, "trouble converting format\n");
-      goto failure;
-    }
-
-    // write out Lensobj table
-    if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) {
-      fprintf (stderr, "trouble writing Lensobj table\n");
-      goto failure;
-    }
-    gfits_free_header (&header);
-    gfits_free_table (&ftable);
+    if (catalog[0].Nlensobj) {
+      // convert to external table format (note that the block above does not damage or free catalog.average) 
+      if (!LensobjToFtable (&ftable, &catalog[0].lensobj[first], Nrows, catalog[0].catformat)) {
+	fprintf (stderr, "trouble converting format\n");
+	goto failure;
+      }
+
+      // write out Lensobj table
+      if (!dvo_catalog_save_subcat (catalog[0].lensobj_catalog, &ftable, start, Nrows, catalog[0].Nlensobj_disk, Nlensobj_disk_new)) {
+	fprintf (stderr, "trouble writing Lensobj table\n");
+	goto failure;
+      }
+      gfits_free_header (&header);
+      gfits_free_table (&ftable);
+    }
   }
 
@@ -1046,17 +1050,19 @@
     assert (catalog[0].Nstarpar_disk >= catalog[0].Nstarpar_off);
 
-    // convert to external table format (note that the block above does not damage or free catalog.average) 
-    if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat)) {
-      fprintf (stderr, "trouble converting format\n");
-      goto failure;
-    }
-
-    // write out StarPar table
-    if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) {
-      fprintf (stderr, "trouble writing StarPar table\n");
-      goto failure;
-    }
-    gfits_free_header (&header);
-    gfits_free_table (&ftable);
+    if (catalog[0].Nstarpar) {
+      // convert to external table format (note that the block above does not damage or free catalog.average) 
+      if (!StarParToFtable (&ftable, &catalog[0].starpar[first], Nrows, catalog[0].catformat)) {
+	fprintf (stderr, "trouble converting format\n");
+	goto failure;
+      }
+
+      // write out StarPar table
+      if (!dvo_catalog_save_subcat (catalog[0].starpar_catalog, &ftable, start, Nrows, catalog[0].Nstarpar_disk, Nstarpar_disk_new)) {
+	fprintf (stderr, "trouble writing StarPar table\n");
+	goto failure;
+      }
+      gfits_free_header (&header);
+      gfits_free_table (&ftable);
+    }
   }
 
Index: trunk/Ohana/src/libdvo/src/dvo_convert.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert.c	(revision 38145)
+++ trunk/Ohana/src/libdvo/src/dvo_convert.c	(revision 38153)
@@ -455,4 +455,23 @@
     return (lensing); }
 
+  if (!strcmp (extname, "DVO_LENSING_PS1_V5") && (ftable[0].header[0].Naxis[0] == 144)) {
+    Lensing_PS1_V5_R2 *tmpLensing;						
+    tmpLensing = gfits_table_get_Lensing_PS1_V5_R2 (ftable, Nlensing, NULL); 
+    if (!tmpLensing) {							
+      fprintf (stderr, "ERROR: failed to read lensings\n");		
+      exit (2);								
+    }									
+    lensing = Lensing_PS1_V5_R2_ToInternal (tmpLensing, *Nlensing); 
+    free (tmpLensing);							
+    *format = DVO_FORMAT_PS1_V5;					
+    return (lensing); }
+
+# define SKIPPING_FORMAT(NAME, FORMAT, TYPE)		\
+  if (!strcmp (extname, NAME)) {					\
+    fprintf (stderr, "ERROR: format %s not defined for lensing, skipping\n", NAME); \
+    *Nlensing = 0; \
+    return NULL; \
+  }
+
 # define CONVERT_FORMAT(NAME, FORMAT, TYPE)		\
   if (!strcmp (extname, NAME)) {					\
@@ -468,11 +487,4 @@
     return (lensing); }
 
-# define SKIPPING_FORMAT(NAME, FORMAT, TYPE)		\
-  if (!strcmp (extname, NAME)) {					\
-    fprintf (stderr, "ERROR: format %s not defined for lensing, skipping\n", NAME); \
-    *Nlensing = 0; \
-    return NULL; \
-  }
-
   if (!strcmp (extname, "DVO_LENSING")) {
     lensing = gfits_table_get_Lensing (ftable, Nlensing, NULL);
@@ -496,6 +508,8 @@
   SKIPPING_FORMAT ("DVO_LENSING_PS1_V3",          PS1_V3,          PS1_V3);
   SKIPPING_FORMAT ("DVO_LENSING_PS1_V4",          PS1_V4,          PS1_V4);
-  CONVERT_FORMAT  ("DVO_LENSING_PS1_V5",          PS1_V5,          PS1_V5_R2);
+  CONVERT_FORMAT  ("DVO_LENSING_PS1_V5",          PS1_V5,          PS1_V5_R3);
+  SKIPPING_FORMAT ("DVO_LENSING_PS1_SIM",         PS1_SIM,         PS1_SIM);
 # undef CONVERT_FORMAT
+# undef SKIPPING_FORMAT
 
   fprintf (stderr, "table format unknown: %s\n", extname);
@@ -533,5 +547,5 @@
 //    FORMAT_CASE (PS1_V3,          PS1_V3);
 //    FORMAT_CASE (PS1_V4,          PS1_V4);
-      FORMAT_CASE (PS1_V5,          PS1_V5_R2);
+      FORMAT_CASE (PS1_V5,          PS1_V5_R3);
 # undef FORMAT_CASE
 
@@ -554,4 +568,23 @@
     fprintf (stderr, "EXTNAME missing for lensobj table\n");
     return (FALSE);
+  }
+
+  if (!strcmp (extname, "DVO_LENSOBJ_PS1_V5") && (ftable[0].header[0].Naxis[0] == 136)) {
+    Lensobj_PS1_V5_R0 *tmpLensobj;						
+    tmpLensobj = gfits_table_get_Lensobj_PS1_V5_R0 (ftable, Nlensobj, NULL); 
+    if (!tmpLensobj) {							
+      fprintf (stderr, "ERROR: failed to read lensobjs\n");		
+      exit (2);								
+    }									
+    lensobj = Lensobj_PS1_V5_R0_ToInternal (tmpLensobj, *Nlensobj); 
+    free (tmpLensobj);							
+    *format = DVO_FORMAT_PS1_V5;					
+    return (lensobj); }
+
+# define SKIPPING_FORMAT(NAME, FORMAT, TYPE)		\
+  if (!strcmp (extname, NAME)) {					\
+    fprintf (stderr, "ERROR: format %s not defined for lensobj, skipping\n", NAME); \
+    *Nlensobj = 0; \
+    return NULL; \
   }
 
@@ -579,17 +612,19 @@
   }
 
-// CONVERT_FORMAT ("DVO_LENSOBJ_PS1_REF",         PS1_REF,         PS1_REF);
-// CONVERT_FORMAT ("DVO_LENSOBJ_ELIXIR", 	  ELIXIR,  	   Elixir);
-// CONVERT_FORMAT ("DVO_LENSOBJ_LONEOS", 	  LONEOS,          Loneos);
-// CONVERT_FORMAT ("DVO_LENSOBJ_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0);
-// CONVERT_FORMAT ("DVO_LENSOBJ_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1);
-// CONVERT_FORMAT ("DVO_LENSOBJ_PS1_DEV_1",       PS1_DEV_1,       PS1_DEV_1);
-// CONVERT_FORMAT ("DVO_LENSOBJ_PS1_DEV_2",       PS1_DEV_2,       PS1_DEV_2);
-// CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V1",          PS1_V1,          PS1_V1);
-// CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V2",          PS1_V2,          PS1_V2);
-// CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V3",          PS1_V3,          PS1_V3);
-// CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V4",          PS1_V4,          PS1_V4);
-  CONVERT_FORMAT ("DVO_LENSOBJ_PS1_V5",          PS1_V5,          PS1_V5);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_PS1_REF",         PS1_REF,         PS1_REF);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_ELIXIR", 	  ELIXIR,  	   Elixir);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_LONEOS", 	  LONEOS,          Loneos);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_PS1_DEV_1",       PS1_DEV_1,       PS1_DEV_1);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_PS1_DEV_2",       PS1_DEV_2,       PS1_DEV_2);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_PS1_V1",          PS1_V1,          PS1_V1);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_PS1_V2",          PS1_V2,          PS1_V2);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_PS1_V3",          PS1_V3,          PS1_V3);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_PS1_V4",          PS1_V4,          PS1_V4);
+  CONVERT_FORMAT  ("DVO_LENSOBJ_PS1_V5",          PS1_V5,          PS1_V5_R1);
+  SKIPPING_FORMAT ("DVO_LENSOBJ_PS1_SIM",         PS1_SIM,         PS1_SIM);
 # undef CONVERT_FORMAT
+# undef SKIPPING_FORMAT
 
   fprintf (stderr, "table format unknown: %s\n", extname);
@@ -627,5 +662,5 @@
 //    FORMAT_CASE (PS1_V3,          PS1_V3);
 //    FORMAT_CASE (PS1_V4,          PS1_V4);
-      FORMAT_CASE (PS1_V5,          PS1_V5);
+      FORMAT_CASE (PS1_V5,          PS1_V5_R1);
 # undef FORMAT_CASE
 
@@ -648,4 +683,11 @@
     fprintf (stderr, "EXTNAME missing for starpar table\n");
     return (FALSE);
+  }
+
+# define SKIPPING_FORMAT(NAME, FORMAT, TYPE)		\
+  if (!strcmp (extname, NAME)) {					\
+    fprintf (stderr, "ERROR: format %s not defined for starpar, skipping\n", NAME); \
+    *Nstarpar = 0; \
+    return NULL; \
   }
 
@@ -673,20 +715,19 @@
   }
 
-   CONVERT_FORMAT ("DVO_STARPAR_PS1_SIM",         PS1_SIM,         PS1_SIM);
-// CONVERT_FORMAT ("DVO_STARPAR_PS1_REF",         PS1_REF,         PS1_REF);
-// CONVERT_FORMAT ("DVO_STARPAR_ELIXIR", 	  ELIXIR,  	   Elixir);
-// CONVERT_FORMAT ("DVO_STARPAR_LONEOS", 	  LONEOS,          Loneos);
-// CONVERT_FORMAT ("DVO_STARPAR_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0);
-// CONVERT_FORMAT ("DVO_STARPAR_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1);
-// CONVERT_FORMAT ("DVO_STARPAR_PS1_DEV_1",       PS1_DEV_1,       PS1_DEV_1);
-// CONVERT_FORMAT ("DVO_STARPAR_PS1_DEV_2",       PS1_DEV_2,       PS1_DEV_2);
-// CONVERT_FORMAT ("DVO_STARPAR_PS1_V1",          PS1_V1,          PS1_V1);
-// CONVERT_FORMAT ("DVO_STARPAR_PS1_V2",          PS1_V2,          PS1_V2);
-// CONVERT_FORMAT ("DVO_STARPAR_PS1_V3",          PS1_V3,          PS1_V3);
-// CONVERT_FORMAT ("DVO_STARPAR_PS1_V4",          PS1_V4,          PS1_V4);
-  CONVERT_FORMAT ("DVO_STARPAR_PS1_V5",          PS1_V5,          PS1_V5);
-//  CONVERT_FORMAT ("DVO_STELLAR_PARAMS_PS1_V5",          PS1_V5,          PS1_V5);
-  // XXX fix in libauto: STELLAR_PARAMS to STARPAR
+  CONVERT_FORMAT  ("DVO_STARPAR_PS1_SIM",         PS1_SIM,         PS1_SIM);
+  SKIPPING_FORMAT ("DVO_STARPAR_PS1_REF",         PS1_REF,         PS1_REF);
+  SKIPPING_FORMAT ("DVO_STARPAR_ELIXIR", 	  ELIXIR,  	   Elixir);
+  SKIPPING_FORMAT ("DVO_STARPAR_LONEOS", 	  LONEOS,          Loneos);
+  SKIPPING_FORMAT ("DVO_STARPAR_PANSTARRS_DEV_0", PANSTARRS_DEV_0, Panstarrs_DEV_0);
+  SKIPPING_FORMAT ("DVO_STARPAR_PANSTARRS_DEV_1", PANSTARRS_DEV_1, Panstarrs_DEV_1);
+  SKIPPING_FORMAT ("DVO_STARPAR_PS1_DEV_1",       PS1_DEV_1,       PS1_DEV_1);
+  SKIPPING_FORMAT ("DVO_STARPAR_PS1_DEV_2",       PS1_DEV_2,       PS1_DEV_2);
+  SKIPPING_FORMAT ("DVO_STARPAR_PS1_V1",          PS1_V1,          PS1_V1);
+  SKIPPING_FORMAT ("DVO_STARPAR_PS1_V2",          PS1_V2,          PS1_V2);
+  SKIPPING_FORMAT ("DVO_STARPAR_PS1_V3",          PS1_V3,          PS1_V3);
+  SKIPPING_FORMAT ("DVO_STARPAR_PS1_V4",          PS1_V4,          PS1_V4);
+  CONVERT_FORMAT  ("DVO_STARPAR_PS1_V5",          PS1_V5,          PS1_V5);
 # undef CONVERT_FORMAT
+# undef SKIPPING_FORMAT
 
   fprintf (stderr, "table format unknown: %s\n", extname);
Index: trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c	(revision 38145)
+++ trunk/Ohana/src/libdvo/src/dvo_convert_PS1_V5.c	(revision 38153)
@@ -448,5 +448,5 @@
 }
 
-Lensing *Lensing_PS1_V5_R2_ToInternal (Lensing_PS1_V5_R2 *in, off_t Nvalues) {
+Lensing *Lensing_PS1_V5_R0_ToInternal (Lensing_PS1_V5_R0 *in, off_t Nvalues) {
 
   off_t i;
@@ -481,7 +481,4 @@
     out[i].E1_sh_psf   = in[i].E1_sh_psf;
     out[i].E2_sh_psf   = in[i].E2_sh_psf;
-
-    out[i].E1_psf      = in[i].E1_psf;
-    out[i].E2_psf      = in[i].E2_psf;
 
     out[i].F_ApR5      = in[i].F_ApR5;
@@ -499,18 +496,17 @@
     out[i].catID       = in[i].catID;
     out[i].averef      = in[i].averef;
-
-    out[i].imageID     = in[i].imageID;
-  }
-  return (out);
-}
-
-Lensing_PS1_V5_R2 *LensingInternalTo_PS1_V5_R2 (Lensing *in, off_t Nvalues) {
-
-  off_t i;
-  Lensing_PS1_V5_R2 *out;
-
-  ALLOCATE_ZERO (out, Lensing_PS1_V5, Nvalues);
-
-  for (i = 0; i < Nvalues; i++) {
+  }
+  return (out);
+}
+
+Lensing *Lensing_PS1_V5_R1_ToInternal (Lensing_PS1_V5_R1 *in, off_t Nvalues) {
+
+  off_t i;
+  Lensing *out;
+
+  ALLOCATE_ZERO (out, Lensing, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    dvo_lensing_init (&out[i]);
 
     out[i].X11_sm_obj  = in[i].X11_sm_obj;      
@@ -537,7 +533,4 @@
     out[i].E1_sh_psf   = in[i].E1_sh_psf;
     out[i].E2_sh_psf   = in[i].E2_sh_psf;
-
-    out[i].E1_psf      = in[i].E1_psf;
-    out[i].E2_psf      = in[i].E2_psf;
 
     out[i].F_ApR5      = in[i].F_ApR5;
@@ -561,5 +554,185 @@
 }
 
-Lensobj *Lensobj_PS1_V5_ToInternal (Lensobj_PS1_V5 *in, off_t Nvalues) {
+Lensing *Lensing_PS1_V5_R2_ToInternal (Lensing_PS1_V5_R2 *in, off_t Nvalues) {
+
+  off_t i;
+  Lensing *out;
+
+  ALLOCATE_ZERO (out, Lensing, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    dvo_lensing_init (&out[i]);
+
+    out[i].X11_sm_obj  = in[i].X11_sm_obj;      
+    out[i].X12_sm_obj  = in[i].X12_sm_obj;      
+    out[i].X22_sm_obj  = in[i].X22_sm_obj;      
+    out[i].E1_sm_obj   = in[i].E1_sm_obj;      
+    out[i].E2_sm_obj   = in[i].E2_sm_obj;      
+	             	                 
+    out[i].X11_sh_obj  = in[i].X11_sh_obj;      
+    out[i].X12_sh_obj  = in[i].X12_sh_obj;      
+    out[i].X22_sh_obj  = in[i].X22_sh_obj;      
+    out[i].E1_sh_obj   = in[i].E1_sh_obj;      
+    out[i].E2_sh_obj   = in[i].E2_sh_obj;     
+	             	                 
+    out[i].X11_sm_psf  = in[i].X11_sm_psf;
+    out[i].X12_sm_psf  = in[i].X12_sm_psf;
+    out[i].X22_sm_psf  = in[i].X22_sm_psf;
+    out[i].E1_sm_psf   = in[i].E1_sm_psf;
+    out[i].E2_sm_psf   = in[i].E2_sm_psf;     
+	             	                 
+    out[i].X11_sh_psf  = in[i].X11_sh_psf;
+    out[i].X12_sh_psf  = in[i].X12_sh_psf;
+    out[i].X22_sh_psf  = in[i].X22_sh_psf;
+    out[i].E1_sh_psf   = in[i].E1_sh_psf;
+    out[i].E2_sh_psf   = in[i].E2_sh_psf;
+
+    out[i].E1_psf      = in[i].E1_psf;
+    out[i].E2_psf      = in[i].E2_psf;
+
+    out[i].F_ApR5      = in[i].F_ApR5;
+    out[i].dF_ApR5     = in[i].dF_ApR5;
+    out[i].sF_ApR5     = in[i].sF_ApR5;
+    out[i].fF_ApR5     = in[i].fF_ApR5;
+	               	            
+    out[i].F_ApR6      = in[i].F_ApR6;
+    out[i].dF_ApR6     = in[i].dF_ApR6;
+    out[i].sF_ApR6     = in[i].sF_ApR6;
+    out[i].fF_ApR6     = in[i].fF_ApR6;
+	          	            
+    out[i].detID       = in[i].detID;
+    out[i].objID       = in[i].objID;
+    out[i].catID       = in[i].catID;
+    out[i].averef      = in[i].averef;
+
+    out[i].imageID     = in[i].imageID;
+  }
+  return (out);
+}
+
+Lensing *Lensing_PS1_V5_R3_ToInternal (Lensing_PS1_V5_R3 *in, off_t Nvalues) {
+
+  off_t i;
+  Lensing *out;
+
+  ALLOCATE_ZERO (out, Lensing, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    dvo_lensing_init (&out[i]);
+
+    out[i].X11_sm_obj  = in[i].X11_sm_obj;      
+    out[i].X12_sm_obj  = in[i].X12_sm_obj;      
+    out[i].X22_sm_obj  = in[i].X22_sm_obj;      
+    out[i].E1_sm_obj   = in[i].E1_sm_obj;      
+    out[i].E2_sm_obj   = in[i].E2_sm_obj;      
+	             	                 
+    out[i].X11_sh_obj  = in[i].X11_sh_obj;      
+    out[i].X12_sh_obj  = in[i].X12_sh_obj;      
+    out[i].X22_sh_obj  = in[i].X22_sh_obj;      
+    out[i].E1_sh_obj   = in[i].E1_sh_obj;      
+    out[i].E2_sh_obj   = in[i].E2_sh_obj;     
+	             	                 
+    out[i].X11_sm_psf  = in[i].X11_sm_psf;
+    out[i].X12_sm_psf  = in[i].X12_sm_psf;
+    out[i].X22_sm_psf  = in[i].X22_sm_psf;
+    out[i].E1_sm_psf   = in[i].E1_sm_psf;
+    out[i].E2_sm_psf   = in[i].E2_sm_psf;     
+	             	                 
+    out[i].X11_sh_psf  = in[i].X11_sh_psf;
+    out[i].X12_sh_psf  = in[i].X12_sh_psf;
+    out[i].X22_sh_psf  = in[i].X22_sh_psf;
+    out[i].E1_sh_psf   = in[i].E1_sh_psf;
+    out[i].E2_sh_psf   = in[i].E2_sh_psf;
+
+    out[i].E1_psf      = in[i].E1_psf;
+    out[i].E2_psf      = in[i].E2_psf;
+
+    out[i].F_ApR5      = in[i].F_ApR5;
+    out[i].dF_ApR5     = in[i].dF_ApR5;
+    out[i].sF_ApR5     = in[i].sF_ApR5;
+    out[i].fF_ApR5     = in[i].fF_ApR5;
+	               	            
+    out[i].F_ApR6      = in[i].F_ApR6;
+    out[i].dF_ApR6     = in[i].dF_ApR6;
+    out[i].sF_ApR6     = in[i].sF_ApR6;
+    out[i].fF_ApR6     = in[i].fF_ApR6;
+	          	            
+    out[i].F_ApR7      = in[i].F_ApR7;
+    out[i].dF_ApR7     = in[i].dF_ApR7;
+    out[i].sF_ApR7     = in[i].sF_ApR7;
+    out[i].fF_ApR7     = in[i].fF_ApR7;
+	          	            
+    out[i].detID       = in[i].detID;
+    out[i].objID       = in[i].objID;
+    out[i].catID       = in[i].catID;
+    out[i].averef      = in[i].averef;
+
+    out[i].imageID     = in[i].imageID;
+  }
+  return (out);
+}
+
+Lensing_PS1_V5_R3 *LensingInternalTo_PS1_V5_R3 (Lensing *in, off_t Nvalues) {
+
+  off_t i;
+  Lensing_PS1_V5_R3 *out;
+
+  ALLOCATE_ZERO (out, Lensing_PS1_V5_R3, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+
+    out[i].X11_sm_obj  = in[i].X11_sm_obj;      
+    out[i].X12_sm_obj  = in[i].X12_sm_obj;      
+    out[i].X22_sm_obj  = in[i].X22_sm_obj;      
+    out[i].E1_sm_obj   = in[i].E1_sm_obj;      
+    out[i].E2_sm_obj   = in[i].E2_sm_obj;      
+	             	                 
+    out[i].X11_sh_obj  = in[i].X11_sh_obj;      
+    out[i].X12_sh_obj  = in[i].X12_sh_obj;      
+    out[i].X22_sh_obj  = in[i].X22_sh_obj;      
+    out[i].E1_sh_obj   = in[i].E1_sh_obj;      
+    out[i].E2_sh_obj   = in[i].E2_sh_obj;     
+	             	                 
+    out[i].X11_sm_psf  = in[i].X11_sm_psf;
+    out[i].X12_sm_psf  = in[i].X12_sm_psf;
+    out[i].X22_sm_psf  = in[i].X22_sm_psf;
+    out[i].E1_sm_psf   = in[i].E1_sm_psf;
+    out[i].E2_sm_psf   = in[i].E2_sm_psf;     
+	             	                 
+    out[i].X11_sh_psf  = in[i].X11_sh_psf;
+    out[i].X12_sh_psf  = in[i].X12_sh_psf;
+    out[i].X22_sh_psf  = in[i].X22_sh_psf;
+    out[i].E1_sh_psf   = in[i].E1_sh_psf;
+    out[i].E2_sh_psf   = in[i].E2_sh_psf;
+
+    out[i].E1_psf      = in[i].E1_psf;
+    out[i].E2_psf      = in[i].E2_psf;
+
+    out[i].F_ApR5      = in[i].F_ApR5;
+    out[i].dF_ApR5     = in[i].dF_ApR5;
+    out[i].sF_ApR5     = in[i].sF_ApR5;
+    out[i].fF_ApR5     = in[i].fF_ApR5;
+	               	            
+    out[i].F_ApR6      = in[i].F_ApR6;
+    out[i].dF_ApR6     = in[i].dF_ApR6;
+    out[i].sF_ApR6     = in[i].sF_ApR6;
+    out[i].fF_ApR6     = in[i].fF_ApR6;
+	          	            
+    out[i].F_ApR7      = in[i].F_ApR7;
+    out[i].dF_ApR7     = in[i].dF_ApR7;
+    out[i].sF_ApR7     = in[i].sF_ApR7;
+    out[i].fF_ApR7     = in[i].fF_ApR7;
+	          	            
+    out[i].detID       = in[i].detID;
+    out[i].objID       = in[i].objID;
+    out[i].catID       = in[i].catID;
+    out[i].averef      = in[i].averef;
+
+    out[i].imageID     = in[i].imageID;
+  }
+  return (out);
+}
+
+Lensobj *Lensobj_PS1_V5_R0_ToInternal (Lensobj_PS1_V5_R0 *in, off_t Nvalues) {
 
   off_t i;
@@ -618,12 +791,13 @@
 }
 
-Lensobj_PS1_V5 *LensobjInternalTo_PS1_V5 (Lensobj *in, off_t Nvalues) {
-
-  off_t i;
-  Lensobj_PS1_V5 *out;
-
-  ALLOCATE_ZERO (out, Lensobj_PS1_V5, Nvalues);
-
-  for (i = 0; i < Nvalues; i++) {
+Lensobj *Lensobj_PS1_V5_R1_ToInternal (Lensobj_PS1_V5_R1 *in, off_t Nvalues) {
+
+  off_t i;
+  Lensobj *out;
+
+  ALLOCATE_ZERO (out, Lensobj, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+    dvo_lensobj_init (&out[i], FALSE);
 
     out[i].X11_sm_obj  = in[i].X11_sm_obj;      
@@ -660,4 +834,70 @@
     out[i].sF_ApR6     = in[i].sF_ApR6;
     out[i].fF_ApR6     = in[i].fF_ApR6;
+	          	            
+    out[i].F_ApR7      = in[i].F_ApR7;
+    out[i].dF_ApR7     = in[i].dF_ApR7;
+    out[i].sF_ApR7     = in[i].sF_ApR7;
+    out[i].fF_ApR7     = in[i].fF_ApR7;
+	          	            
+    out[i].gamma       = in[i].gamma;
+    out[i].E1          = in[i].E1;
+    out[i].E2          = in[i].E2;
+
+    out[i].objID       = in[i].objID;
+    out[i].catID       = in[i].catID;
+
+    out[i].photcode    = in[i].photcode;
+    out[i].Nmeas       = in[i].Nmeas;
+  }
+  return (out);
+}
+
+Lensobj_PS1_V5_R1 *LensobjInternalTo_PS1_V5_R1 (Lensobj *in, off_t Nvalues) {
+
+  off_t i;
+  Lensobj_PS1_V5_R1 *out;
+
+  ALLOCATE_ZERO (out, Lensobj_PS1_V5_R1, Nvalues);
+
+  for (i = 0; i < Nvalues; i++) {
+
+    out[i].X11_sm_obj  = in[i].X11_sm_obj;      
+    out[i].X12_sm_obj  = in[i].X12_sm_obj;      
+    out[i].X22_sm_obj  = in[i].X22_sm_obj;      
+    out[i].E1_sm_obj   = in[i].E1_sm_obj;      
+    out[i].E2_sm_obj   = in[i].E2_sm_obj;      
+	             	                 
+    out[i].X11_sh_obj  = in[i].X11_sh_obj;      
+    out[i].X12_sh_obj  = in[i].X12_sh_obj;      
+    out[i].X22_sh_obj  = in[i].X22_sh_obj;      
+    out[i].E1_sh_obj   = in[i].E1_sh_obj;      
+    out[i].E2_sh_obj   = in[i].E2_sh_obj;     
+	             	                 
+    out[i].X11_sm_psf  = in[i].X11_sm_psf;
+    out[i].X12_sm_psf  = in[i].X12_sm_psf;
+    out[i].X22_sm_psf  = in[i].X22_sm_psf;
+    out[i].E1_sm_psf   = in[i].E1_sm_psf;
+    out[i].E2_sm_psf   = in[i].E2_sm_psf;     
+	             	                 
+    out[i].X11_sh_psf  = in[i].X11_sh_psf;
+    out[i].X12_sh_psf  = in[i].X12_sh_psf;
+    out[i].X22_sh_psf  = in[i].X22_sh_psf;
+    out[i].E1_sh_psf   = in[i].E1_sh_psf;
+    out[i].E2_sh_psf   = in[i].E2_sh_psf;
+
+    out[i].F_ApR5      = in[i].F_ApR5;
+    out[i].dF_ApR5     = in[i].dF_ApR5;
+    out[i].sF_ApR5     = in[i].sF_ApR5;
+    out[i].fF_ApR5     = in[i].fF_ApR5;
+	               	            
+    out[i].F_ApR6      = in[i].F_ApR6;
+    out[i].dF_ApR6     = in[i].dF_ApR6;
+    out[i].sF_ApR6     = in[i].sF_ApR6;
+    out[i].fF_ApR6     = in[i].fF_ApR6;
+	          	            
+    out[i].F_ApR7      = in[i].F_ApR7;
+    out[i].dF_ApR7     = in[i].dF_ApR7;
+    out[i].sF_ApR7     = in[i].sF_ApR7;
+    out[i].fF_ApR7     = in[i].fF_ApR7;
 	          	            
     out[i].gamma       = in[i].gamma;
@@ -1271,110 +1511,4 @@
   }
   return (data);
-}
-
-Lensing *Lensing_PS1_V5_R0_ToInternal (Lensing_PS1_V5_R0 *in, off_t Nvalues) {
-
-  off_t i;
-  Lensing *out;
-
-  ALLOCATE_ZERO (out, Lensing, Nvalues);
-
-  for (i = 0; i < Nvalues; i++) {
-    dvo_lensing_init (&out[i]);
-
-    out[i].X11_sm_obj  = in[i].X11_sm_obj;      
-    out[i].X12_sm_obj  = in[i].X12_sm_obj;      
-    out[i].X22_sm_obj  = in[i].X22_sm_obj;      
-    out[i].E1_sm_obj   = in[i].E1_sm_obj;      
-    out[i].E2_sm_obj   = in[i].E2_sm_obj;      
-	             	                 
-    out[i].X11_sh_obj  = in[i].X11_sh_obj;      
-    out[i].X12_sh_obj  = in[i].X12_sh_obj;      
-    out[i].X22_sh_obj  = in[i].X22_sh_obj;      
-    out[i].E1_sh_obj   = in[i].E1_sh_obj;      
-    out[i].E2_sh_obj   = in[i].E2_sh_obj;     
-	             	                 
-    out[i].X11_sm_psf  = in[i].X11_sm_psf;
-    out[i].X12_sm_psf  = in[i].X12_sm_psf;
-    out[i].X22_sm_psf  = in[i].X22_sm_psf;
-    out[i].E1_sm_psf   = in[i].E1_sm_psf;
-    out[i].E2_sm_psf   = in[i].E2_sm_psf;     
-	             	                 
-    out[i].X11_sh_psf  = in[i].X11_sh_psf;
-    out[i].X12_sh_psf  = in[i].X12_sh_psf;
-    out[i].X22_sh_psf  = in[i].X22_sh_psf;
-    out[i].E1_sh_psf   = in[i].E1_sh_psf;
-    out[i].E2_sh_psf   = in[i].E2_sh_psf;
-
-    out[i].F_ApR5      = in[i].F_ApR5;
-    out[i].dF_ApR5     = in[i].dF_ApR5;
-    out[i].sF_ApR5     = in[i].sF_ApR5;
-    out[i].fF_ApR5     = in[i].fF_ApR5;
-	               	            
-    out[i].F_ApR6      = in[i].F_ApR6;
-    out[i].dF_ApR6     = in[i].dF_ApR6;
-    out[i].sF_ApR6     = in[i].sF_ApR6;
-    out[i].fF_ApR6     = in[i].fF_ApR6;
-	          	            
-    out[i].detID       = in[i].detID;
-    out[i].objID       = in[i].objID;
-    out[i].catID       = in[i].catID;
-    out[i].averef      = in[i].averef;
-  }
-  return (out);
-}
-
-Lensing *Lensing_PS1_V5_R1_ToInternal (Lensing_PS1_V5_R1 *in, off_t Nvalues) {
-
-  off_t i;
-  Lensing *out;
-
-  ALLOCATE_ZERO (out, Lensing, Nvalues);
-
-  for (i = 0; i < Nvalues; i++) {
-    dvo_lensing_init (&out[i]);
-
-    out[i].X11_sm_obj  = in[i].X11_sm_obj;      
-    out[i].X12_sm_obj  = in[i].X12_sm_obj;      
-    out[i].X22_sm_obj  = in[i].X22_sm_obj;      
-    out[i].E1_sm_obj   = in[i].E1_sm_obj;      
-    out[i].E2_sm_obj   = in[i].E2_sm_obj;      
-	             	                 
-    out[i].X11_sh_obj  = in[i].X11_sh_obj;      
-    out[i].X12_sh_obj  = in[i].X12_sh_obj;      
-    out[i].X22_sh_obj  = in[i].X22_sh_obj;      
-    out[i].E1_sh_obj   = in[i].E1_sh_obj;      
-    out[i].E2_sh_obj   = in[i].E2_sh_obj;     
-	             	                 
-    out[i].X11_sm_psf  = in[i].X11_sm_psf;
-    out[i].X12_sm_psf  = in[i].X12_sm_psf;
-    out[i].X22_sm_psf  = in[i].X22_sm_psf;
-    out[i].E1_sm_psf   = in[i].E1_sm_psf;
-    out[i].E2_sm_psf   = in[i].E2_sm_psf;     
-	             	                 
-    out[i].X11_sh_psf  = in[i].X11_sh_psf;
-    out[i].X12_sh_psf  = in[i].X12_sh_psf;
-    out[i].X22_sh_psf  = in[i].X22_sh_psf;
-    out[i].E1_sh_psf   = in[i].E1_sh_psf;
-    out[i].E2_sh_psf   = in[i].E2_sh_psf;
-
-    out[i].F_ApR5      = in[i].F_ApR5;
-    out[i].dF_ApR5     = in[i].dF_ApR5;
-    out[i].sF_ApR5     = in[i].sF_ApR5;
-    out[i].fF_ApR5     = in[i].fF_ApR5;
-	               	            
-    out[i].F_ApR6      = in[i].F_ApR6;
-    out[i].dF_ApR6     = in[i].dF_ApR6;
-    out[i].sF_ApR6     = in[i].sF_ApR6;
-    out[i].fF_ApR6     = in[i].fF_ApR6;
-	          	            
-    out[i].detID       = in[i].detID;
-    out[i].objID       = in[i].objID;
-    out[i].catID       = in[i].catID;
-    out[i].averef      = in[i].averef;
-
-    out[i].imageID     = in[i].imageID;
-  }
-  return (out);
 }
 
Index: trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c
===================================================================
--- trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c	(revision 38145)
+++ trunk/Ohana/src/libdvo/src/dvo_photcode_ops.c	(revision 38153)
@@ -1822,2 +1822,20 @@
 LENSFIELD(E1_sh_psf);
 LENSFIELD(E2_sh_psf);
+
+LENSFIELD( F_ApR5);
+LENSFIELD(dF_ApR5);
+LENSFIELD(sF_ApR5);
+LENSFIELD(fF_ApR5);
+
+LENSFIELD( F_ApR6);
+LENSFIELD(dF_ApR6);
+LENSFIELD(sF_ApR6);
+LENSFIELD(fF_ApR6);
+
+LENSFIELD( F_ApR7);
+LENSFIELD(dF_ApR7);
+LENSFIELD(sF_ApR7);
+LENSFIELD(fF_ApR7);
+
+LENSFIELD(E1);
+LENSFIELD(E2);
Index: trunk/Ohana/src/libkapa/src/KapaColors.c
===================================================================
--- trunk/Ohana/src/libkapa/src/KapaColors.c	(revision 38145)
+++ trunk/Ohana/src/libkapa/src/KapaColors.c	(revision 38153)
@@ -1,5 +1,5 @@
 # include <kapa_internal.h>
 
-# define N_KAPA_COLORS 23
+# define N_KAPA_COLORS 42
 
 static char KAPA_COLORS[N_KAPA_COLORS][3][16] = {
@@ -14,8 +14,27 @@
 {"green",    	 "green",    	 "0.00 1.00 0.00"}, 
 {"darkgreen",	 "darkgreen",	 "0.00 0.40 0.00"}, 
+{"darkblue",     "darkblue", 	 "0.50 0.50 1.00"}, 
 {"blue",     	 "blue",     	 "0.00 0.00 1.00"}, 
 {"skyblue",  	 "skyblue",  	 "0.53 0.81 0.92"}, 
 {"indigo",   	 "mediumpurple", "0.57 0.44 0.86"}, 
 {"violet",   	 "darkviolet", 	 "0.58 0.00 0.88"},
+{"blue10",     	 "rgb:00/00/33", "0.00 0.00 0.20"}, 
+{"blue20",     	 "rgb:00/00/66", "0.00 0.00 0.40"}, 
+{"blue30",     	 "rgb:00/00/99", "0.00 0.00 0.60"}, 
+{"blue40",     	 "rgb:00/00/cc", "0.00 0.00 0.80"}, 
+{"blue50",     	 "rgb:00/00/ff", "0.00 0.00 1.00"}, 
+{"blue60",     	 "rgb:33/33/ff", "0.20 0.20 1.00"}, 
+{"blue70",     	 "rgb:66/66/ff", "0.40 0.40 1.00"}, 
+{"blue80",     	 "rgb:99/99/ff", "0.60 0.60 1.00"}, 
+{"blue90",     	 "rgb:cc/cc/ff", "0.80 0.80 1.00"}, 
+{"red10",     	 "rgb:33/00/00",     	 "0.20 0.00 0.00"}, 
+{"red20",     	 "rgb:66/00/00",     	 "0.40 0.00 0.00"}, 
+{"red30",     	 "rgb:99/00/00",     	 "0.60 0.00 0.00"}, 
+{"red40",     	 "rgb:cc/00/00",     	 "0.80 0.00 0.00"}, 
+{"red50",     	 "rgb:ff/00/00",     	 "1.00 0.00 0.00"}, 
+{"red60",     	 "rgb:ff/33/33",     	 "1.00 0.20 0.20"}, 
+{"red70",     	 "rgb:ff/66/66",     	 "1.00 0.40 0.40"}, 
+{"red80",     	 "rgb:ff/99/99",     	 "1.00 0.60 0.60"}, 
+{"red90",     	 "rgb:ff/cc/cc",     	 "1.00 0.80 0.80"}, 
 {"grey10",   	 "grey10",   	 "0.10 0.10 0.10"},
 {"grey20",   	 "grey20",   	 "0.20 0.20 0.20"},
Index: trunk/Ohana/src/opihi/cmd.data/imhist.c
===================================================================
--- trunk/Ohana/src/opihi/cmd.data/imhist.c	(revision 38145)
+++ trunk/Ohana/src/opihi/cmd.data/imhist.c	(revision 38153)
@@ -3,12 +3,12 @@
 int imhist (int argc, char **argv) {
   
-  int i, j, N, Nbins, Quiet;
-  int sx, sy, nx, ny, bin;
-  float *V, delta;
-  double max, min, dx;
+  int i, j, N, Nbins;
+  int bin;
+  float *V;
+  double dx;
   Vector *vec1, *vec2;
   Buffer *buf;
 
-  Quiet = FALSE;
+  int Quiet = FALSE;
   if ((N = get_argument (argc, argv, "-q"))) {
     Quiet = TRUE;
@@ -20,5 +20,5 @@
   }
 
-  delta = 0;
+  float delta = 0;
   if ((N = get_argument (argc, argv, "-delta"))) {
     remove_argument (N, &argc, argv);
@@ -27,5 +27,11 @@
   }
 
-  min = max = 0.0;
+  int ClipNAN = FALSE;
+  if ((N = get_argument (argc, argv, "-clip-nan"))) {
+    remove_argument (N, &argc, argv);
+    ClipNAN = TRUE;
+  }  
+
+  double min = 0.0, max = 0.0;
   if ((N = get_argument (argc, argv, "-range"))) {
     remove_argument (N, &argc, argv);
@@ -36,6 +42,6 @@
   }
 
-  sx = sy = 0.0;
-  nx = ny = 0.0;
+  int sx = 0, sy = 0;
+  int nx = 0, ny = 0;
   if ((N = get_argument (argc, argv, "-region"))) {
     remove_argument (N, &argc, argv);
@@ -84,4 +90,5 @@
       V = (float *)(buf[0].matrix.buffer) + j*buf[0].matrix.Naxis[0] + sx; 
       for (i = 0; i < nx; i++, V++) {
+	if (ClipNAN && isnan(*V)) continue;
 	max = MAX (max, *V);
 	min = MIN (min, *V);
@@ -113,4 +120,5 @@
     V = (float *)(buf[0].matrix.buffer) + j*buf[0].matrix.Naxis[0] + sx; 
     for (i = 0; i < nx; i++, V++) {
+      if (ClipNAN && isnan(*V)) continue;
       bin = MAX (MIN (Nbins, (*V - min) / dx), 0);
       vec2[0].elements.Flt[bin] += 1.0;
Index: trunk/Ohana/src/opihi/lib.data/graphtools.c
===================================================================
--- trunk/Ohana/src/opihi/lib.data/graphtools.c	(revision 38145)
+++ trunk/Ohana/src/opihi/lib.data/graphtools.c	(revision 38153)
@@ -10,6 +10,7 @@
   if (xvec != NULL) {
     if (xvec->type == OPIHI_FLT) {
-      maxX = minX = xvec[0].elements.Flt[0];
-      for (i = 1; i < xvec[0].Nelements; i++) {
+      maxX = DBL_MIN;
+      minX = DBL_MAX;
+      for (i = 0; i < xvec[0].Nelements; i++) {
 	if (!finite(xvec[0].elements.Flt[i])) continue;
 	maxX = MAX (maxX, xvec[0].elements.Flt[i]);
@@ -19,5 +20,4 @@
       maxX = minX = xvec[0].elements.Int[0];
       for (i = 1; i < xvec[0].Nelements; i++) {
-	if (!finite(xvec[0].elements.Int[i])) continue;
 	maxX = MAX (maxX, xvec[0].elements.Int[i]);
 	minX = MIN (minX, xvec[0].elements.Int[i]);
@@ -33,6 +33,7 @@
   if (yvec != NULL) {
     if (yvec->type == OPIHI_FLT) {
-      maxY = minY = yvec[0].elements.Flt[0];
-      for (i = 1; i < yvec[0].Nelements; i++) {
+      maxY = DBL_MIN;
+      minY = DBL_MAX;
+      for (i = 0; i < yvec[0].Nelements; i++) {
 	if (!finite(yvec[0].elements.Flt[i])) continue;
 	maxY = MAX (maxY, yvec[0].elements.Flt[i]);
@@ -42,5 +43,4 @@
       maxY = minY = yvec[0].elements.Int[0];
       for (i = 1; i < yvec[0].Nelements; i++) {
-	if (!finite(yvec[0].elements.Int[i])) continue;
 	maxY = MAX (maxY, yvec[0].elements.Int[i]);
 	minY = MIN (minY, yvec[0].elements.Int[i]);
Index: trunk/Ohana/src/relphot/src/setMrelCatalog.c
===================================================================
--- trunk/Ohana/src/relphot/src/setMrelCatalog.c	(revision 38145)
+++ trunk/Ohana/src/relphot/src/setMrelCatalog.c	(revision 38153)
@@ -756,5 +756,9 @@
 
       if (IS_DIFF_DB) {
-	if (!MatchImageSkycellID (meas, cat, priTessID, priProjID, priSkycellID)) continue;
+	if (MatchImageSkycellID (meas, cat, priTessID, priProjID, priSkycellID)) {
+	  measure[k].dbFlags |= ID_MEAS_STACK_PRIMARY;
+	} else {
+	  continue;
+	}
       } else {
 	if (!MatchImageSkycellID (meas, cat, stkTessID, stkProjID, stkSkycellID)) continue;
