Index: /branches/eam_branches/ipp-20150625/Ohana/src/relastro/include/relastro.h
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/relastro/include/relastro.h	(revision 38704)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/relastro/include/relastro.h	(revision 38705)
@@ -223,4 +223,6 @@
 } ICRFobj;
 
+# define ID_MEAS_OBJECT_HAS_2MASS ID_MEAS_POOR_PHOTOM
+
 /* global variables set in parameter file */
 # define DVO_MAX_PATH 1024
@@ -265,4 +267,6 @@
 
 int    PARALLEL_OUTPUT;
+
+int    VERBOSE_IMAGE;
 
 int    VERBOSE;
Index: /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/UpdateObjects.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/UpdateObjects.c	(revision 38704)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/UpdateObjects.c	(revision 38705)
@@ -1,4 +1,6 @@
 # include "relastro.h"
 # define PAR_TOOFEW 5
+
+int DumpObjectsWith2MASS (Catalog *catalog, int Ncatalog);
 
 // This function operates on both Measure and MeasureTiny.  In the big stages, this should
@@ -40,9 +42,4 @@
       SecFilt *secfilt = &catalog[i].secfilt[j*Nsecfilt];
 
-      int XVERB = FALSE;
-      XVERB |= (average[0].objID == OBJ_ID_SRC) && (average[0].catID == CAT_ID_SRC);
-      XVERB |= (average[0].objID == OBJ_ID_DST) && (average[0].catID == CAT_ID_DST);
-      if ((OBJ_ID_SRC || OBJ_ID_DST) && !XVERB) continue;
-
       UpdateObjects_Stack(average, secfilt, measure, measureBig, Nsecfilt, fitStatsStack);
       UpdateObjects_Chips(average, secfilt, measure, measureBig, Nsecfilt, fitStatsChips, i, m);
@@ -54,4 +51,6 @@
   }
 
+  // DumpObjectsWith2MASS (catalog, Ncatalog);
+
   FitStatsFree (fitStatsChips);
   FitStatsFree (fitStatsStack);
@@ -63,4 +62,27 @@
   FitStatsFree (sumStatsStack);
 
+  return (TRUE);
+}
+
+// This function operates on both Measure and MeasureTiny.  In the big stages, this should
+// be called with just MeasureTiny set and Measure == NULL
+int DumpObjectsWith2MASS (Catalog *catalog, int Ncatalog) {
+
+  int i;
+  for (i = 0; i < Ncatalog; i++) {
+    off_t j;
+    for (j = 0; j < catalog[i].Naverage; j++) {
+      /* calculate the average value of R,D for a single star */
+      off_t m = catalog[i].average[j].measureOffset;
+
+      off_t k;
+      for (k = 0; k < catalog[i].average[j].Nmeasure; k++) {
+	MeasureTiny *measure = &catalog[i].measureT[m+k];
+	if (measure->dbFlags & ID_MEAS_OBJECT_HAS_2MASS) {
+	  fprintf (stderr, "0x%08x 0x%08x : %12.8f %12.8f %5d\n", catalog[i].average[j].objID, catalog[i].average[j].catID, measure->R, measure->D, measure->photcode);
+	}
+      }
+    }
+  }
   return (TRUE);
 }
@@ -471,4 +493,11 @@
   FitAstromPoint *points = fit->points;
 
+  int TESTPT2 = FALSE;
+  TESTPT2 |= CAT_ID_SRC && OBJ_ID_SRC && (average[0].catID == CAT_ID_SRC) && (average[0].objID == OBJ_ID_SRC);
+  TESTPT2 |= CAT_ID_DST && OBJ_ID_DST && (average[0].catID == CAT_ID_DST) && (average[0].objID == OBJ_ID_DST);
+  if (TESTPT2) {
+    fprintf (stderr, "got test det\n");
+  }
+
   // find the basic properties of the detections for this object (Tmin, Tmax, Tmean)
   off_t k;
@@ -559,5 +588,5 @@
     Npoints++;
 
-    if ((measure[0].photcode >= 2011) && (measure[0].photcode <= 2013)) {
+    if ((measure[k].photcode >= 2011) && (measure[k].photcode <= 2013)) {
       has2MASS = TRUE;
     }
@@ -566,11 +595,18 @@
   } // loop over measurements : average[0].Nmeasure 
 
+  int TESTPT = FALSE;
+  TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (average[0].catID == CAT_ID_SRC) && (average[0].objID == OBJ_ID_SRC);
+  TESTPT |= CAT_ID_DST && OBJ_ID_DST && (average[0].catID == CAT_ID_DST) && (average[0].objID == OBJ_ID_DST);
+  if (TESTPT) {
+    fprintf (stderr, "got test det\n");
+  }
+  
   // XXX flag measurements from stars with 2MASS 
   for (k = 0; k < average[0].Nmeasure; k++) {
     // reset the bit to note that a detection was used (or not)
     if (has2MASS) {
-      measure[k].dbFlags &= ~ID_MEAS_POOR_PHOTOM;
+      measure[k].dbFlags |=  ID_MEAS_OBJECT_HAS_2MASS;
     } else {
-      measure[k].dbFlags |=  ID_MEAS_POOR_PHOTOM;
+      measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_2MASS;
     }
   }
@@ -596,8 +632,15 @@
 
   *Tmean = 0.0;
+
+  double Tsum = 0.0;
+  double Wsum = 0.0;
   for (k = 0; k < Npoints; k++) {
     Tmin = MIN(Tmin, points[k].T);
     Tmax = MAX(Tmax, points[k].T);
-    *Tmean += points[k].T;
+
+    float wx = 1.0 / SQ(points[k].dX);
+
+    Tsum += points[k].T * wx;
+    Wsum += wx;
 
     // at this point, T is in years since J2000
@@ -611,5 +654,5 @@
 
   // mean epoch
-  *Tmean /= (float) Npoints;
+  *Tmean = Tsum / Wsum;
 
   // for HIGH_SPEED, just use the center of the range
Index: /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/bcatalog.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/bcatalog.c	(revision 38704)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/bcatalog.c	(revision 38705)
@@ -119,4 +119,11 @@
     }
 
+    int TESTPT = FALSE;
+    TESTPT |= CAT_ID_SRC && OBJ_ID_SRC && (catalog[0].average[i].catID == CAT_ID_SRC) && (catalog[0].average[i].objID == OBJ_ID_SRC);
+    TESTPT |= CAT_ID_DST && OBJ_ID_DST && (catalog[0].average[i].catID == CAT_ID_DST) && (catalog[0].average[i].objID == OBJ_ID_DST);
+    if (TESTPT) {
+      fprintf (stderr, "got test det\n");
+    }
+
     Nm = 0;
     for (j = 0; j < catalog[0].average[i].Nmeasure; j++) {
