Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/Makefile
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/Makefile	(revision 37664)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/Makefile	(revision 37665)
@@ -75,5 +75,7 @@
 $(SRC)/relastro_parallel_regions.$(ARCH).o \
 $(SRC)/MeanPosIO.$(ARCH).o \
+$(SRC)/MeasPosIO.$(ARCH).o \
 $(SRC)/share_mean_pos.$(ARCH).o \
+$(SRC)/share_meas_pos.$(ARCH).o \
 $(SRC)/share_images_pos.$(ARCH).o \
 $(SRC)/share_icrf_obj.$(ARCH).o \
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/include/relastro.h
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/include/relastro.h	(revision 37664)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/include/relastro.h	(revision 37665)
@@ -34,9 +34,17 @@
 
 typedef struct {
-  float R;
-  float D;
+  double R;
+  double D;
   unsigned int objID;
   unsigned int catID;
 } MeanPos;
+
+typedef struct {
+  double R;
+  double D;
+  unsigned int objID;
+  unsigned int catID;
+  unsigned int imageID;
+} MeasPos;
 
 typedef struct {
@@ -451,4 +459,5 @@
 int setImageRaw (Catalog *catalog, int Ncatalog, off_t im, StarData *raw, off_t Nraw, CoordMode mode);
 off_t getImageByID (off_t ID);
+int updateImageRaw (Catalog *catalog, int Ncatalog, off_t im);
 
 Mosaic *getmosaics (off_t *N);
@@ -552,4 +561,12 @@
 MeanPos *MeanPosLoad(char *filename, off_t *nmeanpos);
 
+int share_meas_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
+int slurp_meas_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
+int set_meas_pos (MeasPos *measpos, Average *average, MeasureTiny *measure);
+MeasPos *merge_meas_pos (MeasPos *target, int *ntarget, MeasPos *source, int Nsource);
+
+int MeasPosSave(char *filename, MeasPos *measpos, off_t Nmeaspos);
+MeasPos *MeasPosLoad(char *filename, off_t *nmeaspos);
+
 int indexCatalogs (Catalog *catalog, int Ncatalog);
 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq);
@@ -561,5 +578,5 @@
 
 int share_image_pos (RegionHostTable *regionHosts, int nloop);
-int slurp_image_pos (RegionHostTable *regionHosts, int nloop);
+int slurp_image_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
 ImagePos *merge_image_pos (ImagePos *target, int *ntarget, ImagePos *source, int Nsource);
 int set_image_pos (ImagePos *image_pos, Image *image);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImageOps.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImageOps.c	(revision 37664)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImageOps.c	(revision 37665)
@@ -251,4 +251,5 @@
     return;
   }
+  measure->myDet = TRUE; // I 'own' this detection (I am calibrating its image)
 
   // index for (catalog, measure) -> image
@@ -906,4 +907,43 @@
       catalog[c].measure[m].R = raw[i].R;
       catalog[c].measure[m].D = raw[i].D;
+    }      
+  }
+  return TRUE;
+}
+
+// return StarData values for detections in the specified image, converting coordinates from the
+// chip positions: X,Y -> L,M -> P,Q -> R,D.  This function is used by the image fitting steps, for
+// which the detections have already been filtered when they were loaded (bcatalog)
+int updateImageRaw (Catalog *catalog, int Ncatalog, off_t im) {
+
+  off_t i, m, c;
+
+  for (i = 0; i < N_onImage[im]; i++) {
+    m = ImageToMeasure[im][i];
+    c = ImageToCatalog[im][i];
+
+    MeasureTiny *measure = &catalog[c].measureT[m];
+
+    /* apply the current image transformation or use the current value of R+dR, D+dD? */
+    double X = measure[0].Xccd;
+    double Y = measure[0].Yccd;
+    if (USE_FIXED_PIXCOORDS) {
+      if (isfinite(measure[0].Xfix) && isfinite(measure[0].Yfix)) {
+	float dX = measure[0].Xfix - measure[0].Xccd;
+	float dY = measure[0].Yfix - measure[0].Yccd;
+	if (hypot(dX,dY) < 2.0) {
+	  X = measure[0].Xfix;
+	  Y = measure[0].Yfix;
+	} 
+      }
+    }
+
+    double R, D;
+    XY_to_RD (&R, &D, X, Y, &image[im].coords);
+    measure->R = R;
+    measure->D = D;
+    if (catalog[c].measure) {
+      catalog[c].measure[m].R = R;
+      catalog[c].measure[m].D = D;
     }      
   }
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/MeasPosIO.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/MeasPosIO.c	(revision 37665)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/MeasPosIO.c	(revision 37665)
@@ -0,0 +1,191 @@
+# include "relastro.h"
+
+# define GET_COLUMN(OUT,NAME,TYPE) \
+  TYPE *OUT = gfits_get_bintable_column_data (&theader, &ftable, NAME, type, &Nrow, &Ncol); \
+  myAssert (!strcmp(type, #TYPE), "wrong column type");
+
+// this is nearly identical to the one in 'uniphot/src' used by setphot / setphot_client.
+// Here, we use a handful of different columns (if not, we could move to libdvo)
+MeasPos *MeasPosLoad(char *filename, off_t *nmeaspos) {
+
+  int i, Ncol;
+  off_t Nrow;
+  Header header;
+  Header theader;
+  Matrix matrix;
+  FTable ftable;
+
+  *nmeaspos = 0;
+  MeasPos *measpos = NULL;
+
+  FILE *f = fopen (filename, "r");
+  if (!f) {
+    fprintf (stderr, "ERROR: cannot open image subset file %s\n", filename);
+    return NULL;
+  }
+
+  /* load in PHU segment (ignore) */
+  if (!gfits_fread_header (f, &header)) {
+    if (VERBOSE) fprintf (stderr, "can't read image subset header\n");
+    fclose (f);
+    return NULL;
+  }
+  if (!gfits_fread_matrix (f, &matrix, &header)) {
+    if (VERBOSE) fprintf (stderr, "can't read image subset matrix\n");
+    gfits_free_header (&header);
+    fclose (f);
+    return NULL;
+  }
+
+  ftable.header = &theader;
+
+  // load data for this header 
+  if (!gfits_load_header (f, &theader)) {
+    fclose (f);
+    return NULL;
+  }
+
+  // read the fits table bytes
+  if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
+    fclose (f);
+    return (NULL);
+  }
+  fclose (f);
+
+  // a bit annoying : we read the entire block of data, then extract the columns, then set the image structure values.
+  // this means I need 3 copies in memory at some point.  ugh.
+
+  char type[16];
+
+  GET_COLUMN (R,    	 "RA",           double);
+  GET_COLUMN (D,   	 "DEC",          double);
+  GET_COLUMN (objID, 	 "OBJ_ID",       int);
+  GET_COLUMN (catID, 	 "CAT_ID",       int);
+  GET_COLUMN (imageID, 	 "IMAGE_ID",     int);
+
+  ALLOCATE (measpos, MeasPos, Nrow);
+  for (i = 0; i < Nrow; i++) {
+    measpos[i].R              = R    [i];
+    measpos[i].D              = D    [i];
+    measpos[i].objID          = objID[i];
+    measpos[i].catID          = catID[i];
+    measpos[i].imageID        = imageID[i];
+  }
+  fprintf (stderr, "loaded data for %lld objects (* filters)\n", (long long) Nrow);
+
+  free (R    );
+  free (D    );
+  free (objID);
+  free (catID);
+  free (imageID);
+
+  // free FITS table pieces...
+  gfits_free_header (&header);
+  gfits_free_matrix (&matrix);
+  gfits_free_header (&theader);
+  gfits_free_table  (&ftable);
+
+  *nmeaspos = Nrow;
+  return measpos;
+}
+
+// STATUS is value expected for success
+# define CHECK_STATUS(STATUS,MSG,...)					\
+  if (!(STATUS)) {							\
+    fprintf (stderr, MSG, __VA_ARGS__);					\
+    return FALSE;							\
+  }
+
+int MeasPosSave(char *filename, MeasPos *measpos, off_t Nmeaspos) {
+
+  int i;
+  Header header;
+  Header theader;
+  Matrix matrix;
+  FTable ftable;
+
+  gfits_init_header (&header);
+  header.extend = TRUE;
+  gfits_create_header (&header);
+  gfits_create_matrix (&header, &matrix);
+
+  gfits_create_table_header (&theader, "BINTABLE", "MEASPOS");
+
+  gfits_define_bintable_column (&theader, "D", "RA",        "meas position, ra",  "degrees", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "D", "DEC",       "meas position, dec", "degrees", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "J", "OBJ_ID",    "object ID",          NULL,      1.0, FT_BZERO_INT32);
+  gfits_define_bintable_column (&theader, "J", "CAT_ID",    "catalog ID",         NULL,      1.0, FT_BZERO_INT32);
+  gfits_define_bintable_column (&theader, "J", "IMAGE_ID",  "image ID",           NULL,      1.0, FT_BZERO_INT32);
+
+  // generate the output array that carries the data
+  gfits_create_table (&theader, &ftable);
+
+  double *R, *D;
+  unsigned int *objID, *catID, *imageID;
+
+  // create intermediate storage arrays
+  ALLOCATE (R,         double, 	       Nmeaspos);
+  ALLOCATE (D,         double, 	       Nmeaspos);
+  ALLOCATE (objID,     unsigned int,   Nmeaspos);
+  ALLOCATE (catID,     unsigned int,   Nmeaspos);
+  ALLOCATE (imageID,   unsigned int,   Nmeaspos);
+
+  // assign the storage arrays
+  for (i = 0; i < Nmeaspos; i++) {
+    R    [i]   = measpos[i].R    ;
+    D    [i]   = measpos[i].D    ;
+    objID[i]   = measpos[i].objID;
+    catID[i]   = measpos[i].catID;
+    imageID[i] = measpos[i].imageID;
+  }
+
+  // add the columns to the output array
+  gfits_set_bintable_column (&theader, &ftable, "RA",        R,         Nmeaspos);
+  gfits_set_bintable_column (&theader, &ftable, "DEC",       D,         Nmeaspos);
+  gfits_set_bintable_column (&theader, &ftable, "OBJ_ID",    objID,     Nmeaspos);
+  gfits_set_bintable_column (&theader, &ftable, "CAT_ID",    catID,     Nmeaspos);
+  gfits_set_bintable_column (&theader, &ftable, "IMAGE_ID",  imageID,   Nmeaspos);
+
+  free (R    );
+  free (D    );
+  free (objID);
+  free (catID);
+  free (imageID);
+
+  FILE *f = fopen (filename, "w");
+  if (!f) {
+    fprintf (stderr, "ERROR: cannot open measmag file for output %s\n", filename);
+    return FALSE;
+  }
+
+  int status;
+  status = gfits_fwrite_header  (f, &header);
+  CHECK_STATUS (status, "ERROR: cannot write header for measpos %s\n", filename);
+
+  status = gfits_fwrite_matrix  (f, &matrix);
+  CHECK_STATUS (status, "ERROR: cannot write matrix for measpos %s\n", filename);
+
+  status = gfits_fwrite_Theader (f, &theader);
+  CHECK_STATUS (status, "ERROR: cannot write table header for measpos %s\n", filename);
+
+  status = gfits_fwrite_table  (f, &ftable);
+  CHECK_STATUS (status, "ERROR: cannot write table data for measpos %s\n", filename);
+
+  gfits_free_header (&header);
+  gfits_free_matrix (&matrix);
+  gfits_free_header (&theader);
+  gfits_free_table (&ftable);
+
+  int fd = fileno (f);
+
+  status = fflush (f);
+  CHECK_STATUS (!status, "ERROR: cannot flush file measpos %s\n", filename);
+
+  status = fsync (fd);
+  CHECK_STATUS (!status, "ERROR: cannot flush file measpos %s\n", filename);
+
+  status = fclose (f);
+  CHECK_STATUS (!status, "ERROR: problem closing measpos file %s\n", filename);
+
+  return TRUE;
+}
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/launch_region_hosts.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/launch_region_hosts.c	(revision 37664)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/launch_region_hosts.c	(revision 37665)
@@ -8,11 +8,19 @@
   // clear the I/O files
   for (i = 0; i < regionHosts->Nhosts; i++) {
-    char *syncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanpos.sync");
-    if (truncate (syncfile, 0)) fprintf (stderr, "trouble clearing syncfile %s\n", syncfile);
-    free (syncfile);
-
-    char *fitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanpos.fits");
-    if (truncate (fitsfile, 0)) fprintf (stderr, "trouble clearing fitsfile %s\n", fitsfile);
-    free (fitsfile);
+    char *meansync = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanpos.sync");
+    if (truncate (meansync, 0)) fprintf (stderr, "trouble clearing meansync %s\n", meansync);
+    free (meansync);
+
+    char *meanfits = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanpos.fits");
+    if (truncate (meanfits, 0)) fprintf (stderr, "trouble clearing meanfits %s\n", meanfits);
+    free (meanfits);
+
+    char *meassync = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "measpos.sync");
+    if (truncate (meassync, 0)) fprintf (stderr, "trouble clearing meassync %s\n", meassync);
+    free (meassync);
+
+    char *measfits = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "measpos.fits");
+    if (truncate (measfits, 0)) fprintf (stderr, "trouble clearing measfits %s\n", measfits);
+    free (measfits);
 
     char *icrfsync = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "icrfobj.sync");
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/markObjects.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/markObjects.c	(revision 37664)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/markObjects.c	(revision 37665)
@@ -14,6 +14,16 @@
       int m = catalog[i].average[j].measureOffset;
       for (n = 0; n < catalog[i].average[j].Nmeasure; n++) {
-	if (!catalog[i].measureT[m+n].myDet) continue;
-	nOwn ++;
+	// this is a detection I own (it is on one of my images)
+	if (catalog[i].measureT[m+n].myDet) {
+	  nOwn ++;
+	  continue;
+	}
+	// 2MASS detections are counted as 'owned' (I completely control this object is nOwn_t == Nmeasure; no sharing needed)
+	if ((catalog[i].measureT[m+n].photcode == 2011) || 
+	    (catalog[i].measureT[m+n].photcode == 2012) || 
+	    (catalog[i].measureT[m+n].photcode == 2013)) {
+	  nOwn ++;
+	  continue;
+	}
       }
       catalog[i].nOwn_t[j] = nOwn;
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_parallel_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_parallel_images.c	(revision 37664)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_parallel_images.c	(revision 37665)
@@ -99,5 +99,5 @@
 	UpdateSimple (catalog, Ncatalog);
 	share_image_pos (regionHosts, i);
-	slurp_image_pos (regionHosts, i);
+	slurp_image_pos (catalog, Ncatalog, regionHosts, i);
       }
       break;
@@ -112,5 +112,7 @@
 	UpdateChips (catalog, Ncatalog);
 	share_image_pos (regionHosts, i);
-	slurp_image_pos (regionHosts, i);
+	slurp_image_pos (catalog, Ncatalog, regionHosts, i);
+	share_meas_pos (catalog, Ncatalog, regionHosts, i);
+	slurp_meas_pos (catalog, Ncatalog, regionHosts, i);
 	MARKTIME("update chips: %f sec\n", dtime);
       }
@@ -126,5 +128,5 @@
 	UpdateMosaic (catalog, Ncatalog);
 	share_image_pos (regionHosts, i);
-	slurp_image_pos (regionHosts, i);
+	slurp_image_pos (catalog, Ncatalog, regionHosts, i);
       }
       break;
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_parallel_regions.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_parallel_regions.c	(revision 37664)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_parallel_regions.c	(revision 37665)
@@ -49,5 +49,5 @@
 
   // retrieve updated image parameters from the remote hosts (also set Image.mcal)
-  if (!slurp_image_pos (regionHosts, -1)) Shutdown ("error loading image updates");
+  if (!slurp_image_pos (NULL, 0, regionHosts, -1)) Shutdown ("error loading image updates");
 
   if (!UPDATE) { 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/share_images_pos.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/share_images_pos.c	(revision 37664)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/share_images_pos.c	(revision 37665)
@@ -51,5 +51,5 @@
 }
 
-int slurp_image_pos (RegionHostTable *regionHosts, int nloop) {
+int slurp_image_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop) {
 
   off_t Nimage, i, j;
@@ -91,5 +91,4 @@
     images[seq].flags      = image_pos[i].flags     ;
   }
-  free (image_pos);
 
   // load the astrometry offset maps, if they exist, and apply 
@@ -113,4 +112,13 @@
     }
   }
+
+  // apply the modified image parameters to my detections
+  for (i = 0; FALSE && (Ncatalog > 0) && (i < Nimage_pos); i++) {
+    off_t seq = getImageByID (image_pos[i].imageID);
+    if (seq < 0) continue;
+    updateImageRaw (catalog, Ncatalog, seq);
+  }
+  free (image_pos);
+
   fprintf (stderr, "DONE grabbing image mags from other hosts\n");
 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/share_meas_pos.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/share_meas_pos.c	(revision 37665)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/share_meas_pos.c	(revision 37665)
@@ -0,0 +1,133 @@
+# include "relastro.h"
+// we are sharing meas positions for all objects which (a) I own and (b) which have unowned detections
+
+# define D_NMEASPOS 10000
+int share_meas_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop) {
+
+  int i;
+  off_t j, k;
+
+  off_t Nmeaspos = 0;
+  off_t NMEASPOS = D_NMEASPOS;
+
+  MeasPos *measpos = NULL;
+  ALLOCATE (measpos, MeasPos, NMEASPOS);
+
+  int myHost = regionHosts->index[REGION_HOST_ID];
+
+  // XXX skip some catalogs based on UserPatch?
+  for (i = 0; i < Ncatalog; i++) {
+    for (j = 0; j < catalog[i].Naverage; j++) {
+
+      // does this object have missing detections (does someone else need it?)
+      if (catalog[i].nOwn_t[j] == catalog[i].average[j].Nmeasure) continue;
+
+      off_t m = catalog[i].average[j].measureOffset;
+      for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) {
+	if (!catalog[i].measureT[m].myDet) continue;
+
+	set_meas_pos (&measpos[Nmeaspos], &catalog[i].average[j], &catalog[i].measureT[m]);
+	Nmeaspos ++;
+	CHECK_REALLOCATE (measpos, MeasPos, NMEASPOS, Nmeaspos, D_NMEASPOS);
+      }
+    }
+  }
+
+  // write out the measmag fits table AND write state in some file
+  char *hostname = regionHosts->hosts[myHost].hostname;
+
+  char *posfile = make_filename (CATDIR, hostname, REGION_HOST_ID, "measpos.fits");
+  MeasPosSave (posfile, measpos, Nmeaspos);
+  free (measpos);
+  free (posfile);
+
+  char *syncfile = make_filename (CATDIR, hostname, REGION_HOST_ID, "measpos.sync");
+  update_sync_file (syncfile, nloop);
+  free (syncfile);
+
+  return TRUE;
+}
+
+int slurp_meas_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop) {
+
+  off_t i, k;
+
+  int Nmeaspos = 0;
+  MeasPos *measpos = NULL;
+  ALLOCATE (measpos, MeasPos, 1);
+
+  fprintf (stderr, "grabbing meas object pos from other hosts...\n");
+
+  for (i = 0; i < regionHosts->Nhosts; i++) {
+    if (regionHosts->hosts[i].hostID == REGION_HOST_ID) continue;
+    if (REGION_HOST_ID && !regionHosts->hosts[i].isNeighbor) continue;
+
+    char *syncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "measpos.sync");
+    check_sync_file (syncfile, nloop);
+    free (syncfile);
+    
+    off_t Nsubset = 0;
+    char *posfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "measpos.fits");
+    MeasPos *measposSubset = MeasPosLoad (posfile, &Nsubset);
+    free (posfile);
+
+    // merge_meas_pos reallocs measpos and frees the input measposSubset
+    measpos = merge_meas_pos (measpos, &Nmeaspos, measposSubset, Nsubset);
+  }
+
+  for (i = 0; i < Nmeaspos; i++) {
+    int objID = measpos[i].objID;
+    int catID = measpos[i].catID;
+
+    // set the meas mag
+    int catSeq;
+    off_t objSeq;
+    if (!catID_and_objID_to_seq (catID, objID, &catSeq, &objSeq)) {
+	// XXX what should I do if this does not match?
+	continue;
+    }
+    off_t m = catalog[catSeq].average[objSeq].measureOffset;
+    for (k = 0; k < catalog[catSeq].average[objSeq].Nmeasure; k++, m++) {
+      if (catalog[catSeq].measureT[m].imageID != measpos[i].imageID) continue;
+      catalog[catSeq].measureT[m].R = measpos[i].R;
+      catalog[catSeq].measureT[m].D = measpos[i].D;
+      if (catalog[catSeq].measure) {
+	catalog[catSeq].measure[m].R = measpos[i].R;
+	catalog[catSeq].measure[m].D = measpos[i].D;
+      }
+    }
+  }
+  free (measpos);
+
+  fprintf (stderr, "DONE grabbing meas object pos from other hosts...\n");
+
+  return TRUE;
+}
+
+int set_meas_pos (MeasPos *measpos, Average *average, MeasureTiny *measure) {
+
+  measpos->R       = measure->R;
+  measpos->D       = measure->D;
+  measpos->objID   = average->objID;
+  measpos->catID   = average->catID;
+  measpos->imageID = measure->imageID;
+
+  return TRUE;
+}
+
+MeasPos *merge_meas_pos (MeasPos *target, int *ntarget, MeasPos *source, int Nsource) {
+
+  off_t i;
+
+  REALLOCATE (target, MeasPos, *ntarget + Nsource);
+  for (i = 0; i < Nsource; i++) {
+    off_t n = i + *ntarget;
+    target[n] = source[i];
+  }
+  
+  free (source);
+
+  *ntarget += Nsource;
+  return (target);
+}
+
