Index: branches/czw_branch/20160809/Ohana/src/relastro/include/relastro.h
===================================================================
--- branches/czw_branch/20160809/Ohana/src/relastro/include/relastro.h	(revision 39734)
+++ branches/czw_branch/20160809/Ohana/src/relastro/include/relastro.h	(revision 39735)
@@ -298,5 +298,5 @@
 } CheckMeasureResult;
 
-# define ID_MEAS_OBJECT_HAS_2MASS ID_MEAS_POOR_PHOTOM
+// # define ID_MEAS_OBJECT_HAS_2MASS ID_MEAS_POOR_PHOTOM
 
 /* global variables set in parameter file */
@@ -420,7 +420,11 @@
 
 float *LoopWeight2MASS;
+char *LoopWeight2MASSstr;
+
 float *LoopWeightTycho;
-char *LoopWeight2MASSstr;
 char *LoopWeightTychostr;
+
+float *LoopWeightGAIA;
+char *LoopWeightGAIAstr;
 
 int ImagSelect;
Index: branches/czw_branch/20160809/Ohana/src/relastro/src/GetAstromError.c
===================================================================
--- branches/czw_branch/20160809/Ohana/src/relastro/src/GetAstromError.c	(revision 39734)
+++ branches/czw_branch/20160809/Ohana/src/relastro/src/GetAstromError.c	(revision 39735)
@@ -69,7 +69,11 @@
   // 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 isGAIA   = USE_GALAXY_MODEL && !isImage && (measure[0].photcode == 1030);
   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 hasGAIA  = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_GAIA);
   int has2MASS = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_2MASS);
+  int hasTycho = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_TYCHO);
 
   // modest hack: if the object has 2MASS or Tycho, we set this internal bit and adjust the
@@ -79,6 +83,16 @@
     dPtotal = dPtotal / LoopWeight2MASS[Nloop];
   }
+  if (hasGAIA && LoopWeightGAIA && (Nloop >= 0)) {
+    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
+  }
+  if (hasTycho && LoopWeightTycho && (Nloop >= 0)) {
+    dPtotal = dPtotal / LoopWeightTycho[Nloop];
+  }
+
   if (is2MASS && LoopWeight2MASS && (Nloop >= 0)) {
     dPtotal = dPtotal / LoopWeight2MASS[Nloop];
+  }
+  if (isGAIA && LoopWeightGAIA && (Nloop >= 0)) {
+    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
   }
   if (isTycho && LoopWeightTycho && (Nloop >= 0)) {
@@ -143,7 +157,11 @@
   // 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 isGAIA   = USE_GALAXY_MODEL && !isImage && (measure[0].photcode == 1030);
   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 hasGAIA  = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_GAIA);
   int has2MASS = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_2MASS);
+  int hasTycho = USE_GALAXY_MODEL &&  isImage && (measure[0].dbFlags & ID_MEAS_OBJECT_HAS_TYCHO);
 
   // modest hack: if the object has 2MASS or Tycho, we set this internal bit and adjust the
@@ -153,6 +171,16 @@
     dPtotal = dPtotal / LoopWeight2MASS[Nloop];
   }
+  if (hasGAIA && LoopWeightGAIA && (Nloop >= 0)) {
+    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
+  }
+  if (hasTycho && LoopWeightTycho && (Nloop >= 0)) {
+    dPtotal = dPtotal / LoopWeightTycho[Nloop];
+  }
+
   if (is2MASS && LoopWeight2MASS) {
     dPtotal = dPtotal / LoopWeight2MASS[Nloop];
+  }
+  if (isGAIA && LoopWeightGAIA && (Nloop >= 0)) {
+    dPtotal = dPtotal / LoopWeightGAIA[Nloop];
   }
   if (isTycho && LoopWeightTycho) {
Index: branches/czw_branch/20160809/Ohana/src/relastro/src/UpdateObjects.c
===================================================================
--- branches/czw_branch/20160809/Ohana/src/relastro/src/UpdateObjects.c	(revision 39734)
+++ branches/czw_branch/20160809/Ohana/src/relastro/src/UpdateObjects.c	(revision 39735)
@@ -11,7 +11,9 @@
 
 typedef enum {
-  SELECT_MEAS_HAS_DATA  = 1,
-  SELECT_MEAS_HAS_STACK = 2,
-  SELECT_MEAS_HAS_2MASS = 4,
+  SELECT_MEAS_HAS_DATA  = 0x01,
+  SELECT_MEAS_HAS_STACK = 0x02,
+  SELECT_MEAS_HAS_2MASS = 0x04,
+  SELECT_MEAS_HAS_GAIA  = 0x08,
+  SELECT_MEAS_HAS_TYCHO = 0x10,
 } SelectMeasureStatus;
 
@@ -666,4 +668,6 @@
 
   int has2MASS = FALSE;
+  int hasGAIA  = FALSE;
+  int hasTycho = FALSE;
   int hasStack = FALSE;
   if (stackEntry) *stackEntry = -1;
@@ -774,7 +778,7 @@
     Npoints++;
 
-    if ((measure[k].photcode >= 2011) && (measure[k].photcode <= 2013)) {
-      has2MASS = TRUE;
-    }
+    hasGAIA  =  (measure[k].photcode == 1030);
+    has2MASS = ((measure[k].photcode >= 2011) && (measure[k].photcode <= 2013));
+    hasTycho = ((measure[k].photcode >= 2020) && (measure[k].photcode <= 2021));
 
     myAssert (Npoints <= fit->NpointsAlloc, "oops");
@@ -796,4 +800,14 @@
       measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_2MASS;
     }
+    if (hasGAIA) {
+      measure[k].dbFlags |=  ID_MEAS_OBJECT_HAS_GAIA;
+    } else {
+      measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_GAIA;
+    }
+    if (hasTycho) {
+      measure[k].dbFlags |=  ID_MEAS_OBJECT_HAS_TYCHO;
+    } else {
+      measure[k].dbFlags &= ~ID_MEAS_OBJECT_HAS_TYCHO;
+    }
   }
 
@@ -803,4 +817,6 @@
   if (hasStack) status |= SELECT_MEAS_HAS_STACK; 
   if (has2MASS) status |= SELECT_MEAS_HAS_2MASS; 
+  if (hasGAIA)  status |= SELECT_MEAS_HAS_GAIA; 
+  if (hasTycho) status |= SELECT_MEAS_HAS_TYCHO; 
   return status;
 }
Index: branches/czw_branch/20160809/Ohana/src/relastro/src/args.c
===================================================================
--- branches/czw_branch/20160809/Ohana/src/relastro/src/args.c	(revision 39734)
+++ branches/czw_branch/20160809/Ohana/src/relastro/src/args.c	(revision 39735)
@@ -651,8 +651,17 @@
   }
   LoopWeightTycho = NULL;
+  LoopWeightTychostr = NULL;
   if ((N = get_argument (argc, argv, "-loop-weights-tycho"))) {
     remove_argument (N, &argc, argv);
     LoopWeightTychostr = strcreate(argv[N]);
     LoopWeightTycho = ParseLoopWeights (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+  LoopWeightGAIA = NULL;
+  LoopWeightGAIAstr = NULL;
+  if ((N = get_argument (argc, argv, "-loop-weights-gaia"))) {
+    remove_argument (N, &argc, argv);
+    LoopWeightGAIAstr = strcreate(argv[N]);
+    LoopWeightGAIA = ParseLoopWeights (argv[N]);
     remove_argument (N, &argc, argv);
   }
@@ -674,4 +683,5 @@
   FREE (LoopWeight2MASSstr);
   FREE (LoopWeightTychostr);
+  FREE (LoopWeightGAIAstr);
 
   FREE (PHOTCODE_SKIP_LIST);
Index: branches/czw_branch/20160809/Ohana/src/relastro/src/launch_region_hosts.c
===================================================================
--- branches/czw_branch/20160809/Ohana/src/relastro/src/launch_region_hosts.c	(revision 39734)
+++ branches/czw_branch/20160809/Ohana/src/relastro/src/launch_region_hosts.c	(revision 39735)
@@ -139,4 +139,5 @@
     if (LoopWeight2MASS) {  strextend (&command, "-loop-weights-2mass %s", LoopWeight2MASSstr); }
     if (LoopWeightTycho) {  strextend (&command, "-loop-weights-tycho %s", LoopWeightTychostr); }
+    if (LoopWeightGAIA)  {  strextend (&command, "-loop-weights-gaia %s", LoopWeightGAIAstr); }
     if (APPLY_PROPER_MOTION) strextend (&command, "-apply-proper-motion");
 
