Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FrameCorrectionIO.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FrameCorrectionIO.c	(revision 37661)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FrameCorrectionIO.c	(revision 37662)
@@ -89,6 +89,8 @@
     gfits_free_matrix (&matrix);
   } else {
-    fprintf (stderr, "ERROR: FrameCorrectionSet %s has defined SHMAP_DD but not SHMAP_DR\n", filename);
-    exit (2);
+    if (strcmp (SHMAP_DD, "NONE")) {
+      fprintf (stderr, "ERROR: FrameCorrectionSet %s has defined SHMAP_DD but not SHMAP_DR\n", filename);
+      exit (2);
+    }
   }
 
@@ -127,6 +129,8 @@
     gfits_free_matrix (&matrix);
   } else {
-    fprintf (stderr, "ERROR: FrameCorrectionSet %s has defined LOCAL_DD but not LOCAL_DR\n", filename);
-    exit (2);
+    if (strcmp (LOCAL_DD, "NONE")) {
+      fprintf (stderr, "ERROR: FrameCorrectionSet %s has defined LOCAL_DD but not LOCAL_DR\n", filename);
+      exit (2);
+    }
   }
   fclose (f);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImagePosIO.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImagePosIO.c	(revision 37661)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImagePosIO.c	(revision 37662)
@@ -70,5 +70,5 @@
   GET_COLUMN (polyterms,        "POLYTERMS",         float); // verify that we got 14 columns?
   GET_COLUMN (ctype,            "CTYPE",             char);  // verify that we got 15 columns?
-  GET_COLUMN (Npolyterms,       "NPOLYTERMS",        char);
+  GET_COLUMN (Npolyterms,       "NPOLYTERMS",        byte);
   GET_COLUMN (dXpixSys,         "XPIX_SYS_ERR",      float);
   GET_COLUMN (dYpixSys,         "YPIX_SYS_ERR",      float);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/assign_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/assign_images.c	(revision 37661)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/assign_images.c	(revision 37662)
@@ -144,13 +144,21 @@
 
     // this is a bit memory expensive : I am making a complete copy of the image table here
-    off_t Nsubset = regionHosts->hosts[i].Nimage;
-    regionHosts->hosts[i].image[Nsubset] = image[j];
-    regionHosts->hosts[i].imseq[Nsubset] = j;
-
-    regionHosts->hosts[i].Nimage ++;
-    if (regionHosts->hosts[i].Nimage == regionHosts->hosts[i].NIMAGE) {
-      regionHosts->hosts[i].NIMAGE += D_NIMAGE;
-      REALLOCATE (regionHosts->hosts[i].image, Image, regionHosts->hosts[i].NIMAGE);
-      REALLOCATE (regionHosts->hosts[i].imseq, off_t, regionHosts->hosts[i].NIMAGE);
+    off_t Nsubset = host->Nimage;
+    host->image[Nsubset] = image[j];
+    host->imseq[Nsubset] = j;
+
+    host->Nimage ++;
+    if (host->Nimage == host->NIMAGE) {
+      host->NIMAGE += D_NIMAGE;
+      REALLOCATE (host->image, Image, host->NIMAGE);
+      REALLOCATE (host->imseq, off_t, host->NIMAGE);
+    }
+
+    // save the astrometry maps, where they exist
+    if (image[j].coords.offsetMap) {
+      if (!host->astromTable) {
+	host->astromTable = AstromOffsetTableInit();
+      }
+      AstromOffsetTableAddMapFromImage(host->astromTable, image[j]);
     }
   }
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 37661)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/launch_region_hosts.c	(revision 37662)
@@ -8,17 +8,25 @@
   // 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, "meanmags.sync");
+    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, "meanmags.fits");
+    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 *imsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.sync");
+    char *icrfsync = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "icrfobj.sync");
+    if (truncate (icrfsync, 0)) fprintf (stderr, "trouble clearing icrfsync %s\n", icrfsync);
+    free (icrfsync);
+
+    char *icrffits = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "icrfobj.fits");
+    if (truncate (icrffits, 0)) fprintf (stderr, "trouble clearing icrffits %s\n", icrffits);
+    free (icrffits);
+
+    char *imsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagepos.sync");
     if (truncate (imsyncfile, 0)) fprintf (stderr, "trouble clearing imsyncfile %s\n", imsyncfile);
     free (imsyncfile);
 
-    char *imfitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.fits");
+    char *imfitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagepos.fits");
     if (truncate (imfitsfile, 0)) fprintf (stderr, "trouble clearing imfitsfile %s\n", imfitsfile);
     free (imfitsfile);
@@ -27,5 +35,17 @@
     if (truncate (loopsyncfile, 0)) fprintf (stderr, "trouble clearing loopsyncfile %s\n", loopsyncfile);
     free (loopsyncfile);
+
+    char imagename[1024];
+    snprintf (imagename, 1024, "%s/Image.%d.fits", CATDIR, regionHosts->hosts[i].hostID);
+    if (unlink (imagename)) fprintf (stderr, "trouble clearing image %s\n", imagename);
   }
+
+  char *framesync = make_filename (CATDIR, "master", 0, "frame.corr.sync");
+  if (truncate (framesync, 0)) fprintf (stderr, "trouble clearing framesync %s\n", framesync);
+  free (framesync);
+  
+  char *framefits = make_filename (CATDIR, "master", 0, "frame.corr.fits");
+  if (truncate (framefits, 0)) fprintf (stderr, "trouble clearing framefits %s\n", framefits);
+  free (framefits);
 
   for (i = 0; i < regionHosts->Nhosts; i++) {
@@ -40,4 +60,12 @@
     // write the image subset for this host
     ImageTableSave (filename, host->image, host->Nimage);
+
+    if (host->astromTable) {
+      char mapname[1024];
+      snprintf (mapname, 1024, "%s/AstroMap.%d.fits", CATDIR, host->hostID);
+
+      // write the image subset for this host
+      AstromOffsetMapTableSave (host->astromTable, mapname);
+    }
 
     char command[1024];
@@ -100,4 +128,6 @@
     strextend (command, "-D ADDSTAR_RADIUS %f", ADDSTAR_RADIUS);
 
+    strextend (command, "-D USE_GALAXY_MODEL %d", USE_GALAXY_MODEL);
+
     strextend (command, "-D USE_ICRF_CORRECT %d", USE_ICRF_CORRECT);
     strextend (command, "-D USE_ICRF_LOCAL %d",   USE_ICRF_LOCAL);
@@ -138,4 +168,14 @@
   }
 
+  if (USE_ICRF_CORRECT) return TRUE;
+
+  int status = HarvestRegionHosts (regionHosts);
+  return status;
+}
+
+int HarvestRegionHosts (RegionHostTable *regionHosts) {
+
+  int i;
+
   if (PARALLEL_REGIONS_MANUAL) {
     fprintf (stderr, "run the relastro_client commands above.  when these are done, hit return\n");
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/load_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/load_images.c	(revision 37661)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/load_images.c	(revision 37662)
@@ -86,2 +86,6 @@
 }
 
+void put_astrom_table (AstromOffsetTable *myTable) {
+  table = myTable;
+}
+
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 37661)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_parallel_images.c	(revision 37662)
@@ -30,4 +30,19 @@
   }
 
+  // assign image->parent and image->coords.mosaic 
+  BuildChipMatch (image, Nimage);
+
+  char mapfile[DVO_MAX_PATH];
+  snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.%d.fits", CATDIR, REGION_HOST_ID);
+  AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, VERBOSE);
+
+  // assign images.coords.offsetMap -> table->map[i]
+  if (table) {
+    AstromOffsetTableMatchChips (image, Nimage, table);
+  } else {
+    table = AstromOffsetTableInit ();
+  }
+  put_astrom_table (table);
+
   // once we have read this table, we should remove it for repeat runs
   // unlink (IMAGE_TABLE); // XXX a bit risky, add some protection?
@@ -50,4 +65,7 @@
   free (syncfile);
   
+  // find ICRF QSOs for reference downstream (only if USE_ICRF_CORRECT)
+  select_catalog_ICRF (catalog, Ncatalog);
+
   if (photcodesReset) {
     photcodesKeep  = photcodesReset;
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 37661)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/share_images_pos.c	(revision 37662)
@@ -33,4 +33,14 @@
   free (image_pos);
   free (iposfile);
+
+  // save the per-chip residual table
+  AstromOffsetTable *table = get_astrom_table ();
+  if (table) {
+    char mapname[1024];
+    snprintf (mapname, 1024, "%s/AstroMapUpdate.%d.fits", CATDIR, REGION_HOST_ID);
+    
+    // write the image subset for this host
+    AstromOffsetMapTableSave (table, mapname);
+  }
 
   char *syncfile = make_filename (CATDIR, hostname, REGION_HOST_ID, "imagepos.sync");
@@ -83,4 +93,18 @@
   free (image_pos);
 
+  // load the astrometry offset maps, if they exist, and apply 
+  for (i = 0; i < regionHosts->Nhosts; i++) {
+    char mapname[1024];
+    snprintf (mapname, 1024, "%s/AstroMapUpdate.%d.fits", CATDIR, regionHosts->hosts[i].hostID);
+    
+    AstromOffsetTable *table = AstromOffsetMapLoad (mapname, VERBOSE);
+  
+    // apply table entries here to existing images
+    for (j = 0; j < table->Nmap; j++) {
+      off_t seq = getImageByID (table->map[j][0].imageID);
+      images[seq].coords.offsetMap = table->map[j];
+      // is this sufficient?
+    }
+  }
   fprintf (stderr, "DONE grabbing image mags from other hosts\n");
 
