Index: /branches/eam_branches/ipp-20150625/Ohana/src/relastro/include/relastro.h
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/relastro/include/relastro.h	(revision 38674)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/relastro/include/relastro.h	(revision 38675)
@@ -725,2 +725,3 @@
 FitStats *FitStatsInit (int Nmax, int Nboot);
 int FitAstromResultSetPM (FitAstromResult *fit, int Nfit, Average *average);
+void AstromErrorSetLoop (int N);
Index: /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/GetAstromError.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/GetAstromError.c	(revision 38674)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/GetAstromError.c	(revision 38675)
@@ -5,4 +5,11 @@
 static float BrightMo[] = {-15.6, -16.8, -17.0, -16.7, -16.0};
 static float BrightMs[] = {1.3, 1.3, 1.3, 1.8, 2.0}; 
+
+static int Nloop = -1;
+
+// Nloop is used to modify the per detection errors
+void AstromErrorSetLoop (int N) {
+  Nloop = N;
+}
 
 float GetAstromErrorTiny (MeasureTiny *measure, int mode) {
@@ -55,6 +62,46 @@
     dPtotal = hypot(dPtotal, dPbright);
   }
+  dPtotal = MAX (dPtotal, MIN_ERROR);
 
-  dPtotal = MAX (dPtotal, MIN_ERROR);
+  // early on, we want 2MASS to have a very high weight.  This will force images to match
+  // the 2MASS reference frame.  As Nloop gets higher, the weight needs to drop to allow
+  // the ps1 measurements to drive the solution
+  if ((measure[0].photcode >= 2011) && (measure[0].photcode <= 2013)) {
+    switch (Nloop) {
+      case 0:
+      case 1:
+	dPtotal = dPtotal / 100.0;
+	break;
+      case 2:
+      case 3:
+	dPtotal = dPtotal / 30.0;
+	break;
+      case 4:
+      case 5:
+	dPtotal = dPtotal / 10.0;
+	break;
+      default:
+	break;
+    }
+  }
+  if ((measure[0].photcode >= 2020) && (measure[0].photcode <= 2021)) {
+    switch (Nloop) {
+      case 0:
+      case 1:
+	dPtotal = dPtotal / 200.0;
+	break;
+      case 2:
+      case 3:
+	dPtotal = dPtotal / 100.0;
+	break;
+      case 4:
+      case 5:
+	dPtotal = dPtotal / 50.0;
+	break;
+      default:
+	break;
+    }
+  }
+
   return (dPtotal);
 }
Index: /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/ImageOps.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/ImageOps.c	(revision 38674)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/ImageOps.c	(revision 38675)
@@ -774,4 +774,8 @@
     ref[i].ColorBlue = NAN;
     ref[i].ColorRed = NAN;
+
+    if (USE_GALAXY_MODEL && (measure[0].dbFlags & ID_MEAS_POOR_PHOTOM)) {
+      ref[0].dPos = ref[0].dPos / 100.0;
+    }
 
     if ((DCR_BLUE_NSEC_POS >= 0) && (DCR_BLUE_NSEC_NEG >= -1)) {
Index: /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/UpdateObjects.c
===================================================================
--- /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/UpdateObjects.c	(revision 38674)
+++ /branches/eam_branches/ipp-20150625/Ohana/src/relastro/src/UpdateObjects.c	(revision 38675)
@@ -20,4 +20,6 @@
   FitStats *fitStatsChips = FitStatsInit (NmeasureMax, N_BOOTSTRAP_SAMPLES);
   FitStats *fitStatsStack = FitStatsInit (NmeasureMax, N_BOOTSTRAP_SAMPLES);
+
+  AstromErrorSetLoop (Nloop);
 
   int i;
@@ -464,4 +466,6 @@
   // I've already allocated fit->points (and fit->sample) with space for fit->NpointsAlloc entries
 
+  int has2MASS = FALSE;
+
   int Npoints = fit->Npoints = 0;
   FitAstromPoint *points = fit->points;
@@ -555,6 +559,20 @@
     Npoints++;
 
+    if ((measure[0].photcode >= 2011) && (measure[0].photcode <= 2013)) {
+      has2MASS = TRUE;
+    }
+
     myAssert (Npoints <= fit->NpointsAlloc, "oops");
   } // loop over measurements : average[0].Nmeasure 
+
+  // 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;
+    } else {
+      measure[k].dbFlags |=  ID_MEAS_POOR_PHOTOM;
+    }
+  }
 
   fit->Npoints = Npoints;
