Index: /branches/eam_branches/ipp-20151113/Ohana/src/relastro/include/relastro.h
===================================================================
--- /branches/eam_branches/ipp-20151113/Ohana/src/relastro/include/relastro.h	(revision 39184)
+++ /branches/eam_branches/ipp-20151113/Ohana/src/relastro/include/relastro.h	(revision 39185)
@@ -323,4 +323,7 @@
 PhotCode     *DCR_RED_PHOTCODE_POS, *DCR_RED_PHOTCODE_NEG; 
 int           DCR_RED_NSEC_POS,      DCR_RED_NSEC_NEG; 
+
+float *LoopWeight2MASS;
+float *LoopWeightTycho;
 
 int ImagSelect;
Index: /branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/GetAstromError.c
===================================================================
--- /branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/GetAstromError.c	(revision 39184)
+++ /branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/GetAstromError.c	(revision 39185)
@@ -73,74 +73,16 @@
   int has2MASS = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_2MASS);
 
-  // serious hack: if the object has 2MASS, we set this internal bit and adjust the
+  // modest hack: if the object has 2MASS or Tycho, we set this internal bit and adjust the
   // weight to ensure the image is tied down to the 2mass frame
 
-  if (has2MASS) {
-    switch (Nloop) {
-      case 0:
-	dPtotal = dPtotal / 1000.0;
-	break;
-      case 1:
-	dPtotal = dPtotal / 300.0;
-	break;
-      case 2:
-	dPtotal = dPtotal / 100.0;
-	break;
-      case 3:
-	dPtotal = dPtotal / 30.0;
-	break;
-      case 4:
-	dPtotal = dPtotal / 10.0;
-	break;
-      case 5:
-	dPtotal = dPtotal / 10.0;
-	break;
-      default:
-	break;
-    }
+  if (has2MASS && LoopWeight2MASS) {
+    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
   }
-  if (is2MASS) {
-    switch (Nloop) {
-      case 0:
-	dPtotal = dPtotal / 1000.0;
-	break;
-      case 1:
-	dPtotal = dPtotal / 300.0;
-	break;
-      case 2:
-	dPtotal = dPtotal / 100.0;
-	break;
-      case 3:
-	dPtotal = dPtotal / 30.0;
-	break;
-      case 4:
-	dPtotal = dPtotal / 10.0;
-	break;
-      case 5:
-	dPtotal = dPtotal / 10.0;
-	break;
-      default:
-	break;
-    }
+  if (is2MASS && LoopWeight2MASS) {
+    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
   }
-  if (isTycho) {
-    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;
-    }
+  if (isTycho && LoopWeightTycho) {
+    dPtotal = dPtotal / LoopWeightTycho[Nloop];
   }
-
   return (dPtotal);
 }
@@ -197,8 +139,29 @@
 
   dPtotal = MAX (dPtotal, MIN_ERROR);
+
+  // early on, we want 2MASS and Tycho to have a very high weight.  This will force images
+  // to match the 2MASS / Tycho / ICRS reference frame.  As Nloop gets higher, the weight
+  // needs to drop to allow the ps1 measurements to drive the solution
+  int is2MASS  = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2011) && (measure[0].photcode <= 2013);
+  int isTycho  = USE_GALAXY_MODEL && !isImage && (measure[0].photcode >= 2020) && (measure[0].photcode <= 2021);
+  int has2MASS = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_2MASS);
+
+  // modest hack: if the object has 2MASS or Tycho, we set this internal bit and adjust the
+  // weight to ensure the image is tied down to the 2mass frame
+
+  if (has2MASS && LoopWeight2MASS) {
+    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
+  }
+  if (is2MASS && LoopWeight2MASS) {
+    dPtotal = dPtotal / LoopWeight2MASS[Nloop];
+  }
+  if (isTycho && LoopWeightTycho) {
+    dPtotal = dPtotal / LoopWeightTycho[Nloop];
+  }
+
   return (dPtotal);
 }
 
-/* for a long time, psphot was either not reported position errors, or was reporting
+/* for a long time, psphot was either not reporting position errors, or was reporting
  * completely wrong astrometry errors.  This function lets us handle, in the
  * configuration, different strategies to generating a position error 
Index: /branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/args.c	(revision 39184)
+++ /branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/args.c	(revision 39185)
@@ -4,4 +4,5 @@
 void usage_merge_source (void);
 void usage_merge_source_id (char *name);
+float *ParseLoopWeights (char *rawlist);
 
 int args (int argc, char **argv) {
@@ -529,4 +530,19 @@
     remove_argument (N, &argc, argv);
     NLOOP = atof (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
+  // e.g., -loop-weights-2mass 1000,300,300,200,200,100
+  // NOTE: this must come after -nloop above
+  LoopWeight2MASS = NULL;
+  if ((N = get_argument (argc, argv, "-loop-weights-2mass"))) {
+    remove_argument (N, &argc, argv);
+    LoopWeight2MASS = ParseLoopWeights (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  LoopWeightTycho = NULL;
+  if ((N = get_argument (argc, argv, "-loop-weights-tycho"))) {
+    remove_argument (N, &argc, argv);
+    LoopWeightTycho = ParseLoopWeights (argv[N]);
     remove_argument (N, &argc, argv);
   }
@@ -999,2 +1015,33 @@
 }
 
+float *ParseLoopWeights (char *rawlist) {
+
+  float *weights = NULL;
+  ALLOCATE (weights, float, NLOOP);
+
+  int Nloop = 0;
+
+  /* parse the comma-separated list of photcodes */
+  char *myList = strcreate(rawlist);
+  char *list = myList;
+  char *entry = NULL;
+  char *ptr = NULL;
+  while ((Nloop < NLOOP) && ((entry = strtok_r (list, ",", &ptr)) != NULL)) {
+    list = NULL; // pass NULL on successive strtok_r calls
+
+    weights[Nloop] = atof(entry);
+    Nloop ++;
+  }
+  free (myList);
+
+  if (Nloop == 0) {
+    fprintf (stderr, "syntax error parsing weights: %s\n", rawlist);
+    exit (3);
+  }
+
+  while (Nloop < NLOOP) {
+    weights[Nloop] = weights[Nloop - 1];
+    Nloop ++;
+  }
+  return weights;
+}
Index: /branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/launch_region_hosts.c
===================================================================
--- /branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/launch_region_hosts.c	(revision 39184)
+++ /branches/eam_branches/ipp-20151113/Ohana/src/relastro/src/launch_region_hosts.c	(revision 39185)
@@ -134,4 +134,21 @@
     if (MaxMeanOffset != 10.0) strextend (&command, "-max-mean-offset  %f", MaxMeanOffset);
 
+    if (LoopWeight2MASS) {
+      char *weightline = NULL;
+      for (i = 0; i < NLOOP; i++) {
+	strextend (&weightline, "%f,", LoopWeight2MASS[i]);
+      }
+      strextend (&command, "-loop-weights-2mass %s", weightline);
+      free (weightline);
+    }
+    if (LoopWeightTycho) {
+      char *weightline = NULL;
+      for (i = 0; i < NLOOP; i++) {
+	strextend (&weightline, "%f,", LoopWeightTycho[i]);
+      }
+      strextend (&command, "-loop-weights-tycho %s", weightline);
+      free (weightline);
+    }
+
     strextend (&command, "-D RELASTRO_SRC_MEAS_TOOFEW %d", SRC_MEAS_TOOFEW);
     strextend (&command, "-D RELASTRO_SIGMA_LIM %f", SIGMA_LIM);
