Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/include/relastro.h
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/include/relastro.h	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/include/relastro.h	(revision 36574)
@@ -29,5 +29,7 @@
 typedef enum {FIT_NONE, FIT_AVERAGE, FIT_PM_ONLY, FIT_PAR_ONLY, FIT_PM_AND_PAR} FitMode;
 
-typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS, TARGET_HIGH_SPEED, TARGET_MERGE_SOURCE, TARGET_UPDATE_OBJECTS, TARGET_UPDATE_OFFSETS, TARGET_LOAD_OBJECTS, TARGET_HPM, TARGET_PARALLEL_REGIONS, TARGET_PARALLEL_IMAGES} FitTarget;
+typedef enum {OP_NONE, OP_IMAGES, OP_HIGH_SPEED, OP_MERGE_SOURCE, OP_UPDATE_OBJECTS, OP_UPDATE_OFFSETS, OP_LOAD_OBJECTS, OP_HPM, OP_PARALLEL_REGIONS, OP_PARALLEL_IMAGES} RelastroOp;
+
+typedef enum {TARGET_NONE, TARGET_SIMPLE, TARGET_CHIPS, TARGET_MOSAICS} FitTarget;
 
 typedef enum {
@@ -118,4 +120,5 @@
   unsigned int start;
   unsigned int stop;
+  off_t myImage;
   float Mcal;
   float dMcal;
@@ -233,4 +236,5 @@
 FitMode FIT_MODE;
 
+RelastroOp RELASTRO_OP;
 FitTarget FIT_TARGET;
 
@@ -495,5 +499,5 @@
 int share_mean_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
 int slurp_mean_pos (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
-int set_mean_pos (MeanPos *meanpos, AverageTiny *average);
+int set_mean_pos (MeanPos *meanpos, Average *average);
 MeanPos *merge_mean_pos (MeanPos *target, int *ntarget, MeanPos *source, int Nsource);
 
@@ -516,2 +520,3 @@
 Image *ImageTableLoad(char *filename, off_t *nimage);
 int ImageTableSave (char *filename, Image *images, off_t Nimages);
+int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage);
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/ConfigInit.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/ConfigInit.c	(revision 36574)
@@ -18,6 +18,7 @@
   if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file);
 
-  GetConfig (config, "RELASTRO_SIGMA_LIM",         "%lf", 0, &SIGMA_LIM); // exclude measurements on this basis
-  GetConfig (config, "RELASTRO_SRC_MEAS_TOOFEW",   "%d",  0, &SRC_MEAS_TOOFEW);
+  // set defaults for all of these if they are not used by parallel / remote clients
+  if (!ScanConfig (config, "RELASTRO_SIGMA_LIM",         "%lf", 0, &SIGMA_LIM))       SIGMA_LIM = 0.01; 
+  if (!ScanConfig (config, "RELASTRO_SRC_MEAS_TOOFEW",   "%d",  0, &SRC_MEAS_TOOFEW)) SRC_MEAS_TOOFEW = 3;
 
   if (!ScanConfig (config, "RELASTRO_IMFIT_CLIP_NITER",    "%d",  0, &IMFIT_CLIP_NITER))    IMFIT_CLIP_NITER  = 3;
@@ -25,18 +26,14 @@
   if (!ScanConfig (config, "RELASTRO_IMFIT_SYS_SIGMA_LIM", "%lf", 0, &IMFIT_SYS_SIGMA_LIM)) IMFIT_SYS_SIGMA_LIM = 0.01;
 
-  GetConfig (config, "PM_DT_MIN",              "%lf", 0, &PM_DT_MIN);
-  GetConfig (config, "PM_TOOFEW",              "%d",  0, &PM_TOOFEW);
-  GetConfig (config, "POS_TOOFEW",             "%d",  0, &POS_TOOFEW);
+  if (!ScanConfig (config, "PM_DT_MIN",              "%lf", 0, &PM_DT_MIN))        PM_DT_MIN = 0.25;   
+  if (!ScanConfig (config, "PM_TOOFEW",              "%d",  0, &PM_TOOFEW))	   PM_TOOFEW = 4;   
+  if (!ScanConfig (config, "POS_TOOFEW",             "%d",  0, &POS_TOOFEW))	   POS_TOOFEW = 1;  
+  if (!ScanConfig (config, "PAR_FACTOR_MIN",         "%lf", 0, &PAR_FACTOR_MIN))   PAR_FACTOR_MIN = 0.2;
+  if (!ScanConfig (config, "RELASTRO_MAP_NX",        "%d",  0, &NX_MAP))	   NX_MAP = 5;
+  if (!ScanConfig (config, "RELASTRO_MAP_NY",        "%d",  0, &NY_MAP))	   NY_MAP = 5;
+  if (!ScanConfig (config, "RELASTRO_DPOS_MAX",      "%lf", 0, &DPOS_MAX))	   DPOS_MAX = 6.0;    
+  if (!ScanConfig (config, "ADDSTAR_RADIUS",         "%lf", 0, &ADDSTAR_RADIUS))   ADDSTAR_RADIUS = 1.0;
 
-  GetConfig (config, "PAR_FACTOR_MIN",         "%lf", 0, &PAR_FACTOR_MIN);
-
-  GetConfig (config, "RELASTRO_MAP_NX",        "%d",  0, &NX_MAP);
-  GetConfig (config, "RELASTRO_MAP_NY",        "%d",  0, &NY_MAP);
-  GetConfig (config, "RELASTRO_DPOS_MAX",      "%lf", 0, &DPOS_MAX);
-  GetConfig (config, "ADDSTAR_RADIUS",         "%lf", 0, &ADDSTAR_RADIUS);
-
-  if (!ScanConfig (config, "USE_FIXED_PIXCOORDS", "%d", 0, &USE_FIXED_PIXCOORDS)) {
-    USE_FIXED_PIXCOORDS = FALSE;
-  }
+  if (!ScanConfig (config, "USE_FIXED_PIXCOORDS", "%d", 0, &USE_FIXED_PIXCOORDS))  USE_FIXED_PIXCOORDS = FALSE;
 
   // force CATDIR to be absolute (so parallel mode will work)
@@ -56,10 +53,6 @@
   sprintf (ImageCat, "%s/Images.dat", CATDIR);
 
-  if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) {
-    SKY_DEPTH = 2;
-  }
-  if (!ScanConfig (config, "SKY_TABLE",         "%s",  0, SKY_TABLE)) {
-    SKY_TABLE[0] = 0;
-  }
+  if (!ScanConfig (config, "SKY_DEPTH",         "%d",  0, &SKY_DEPTH)) SKY_DEPTH = 2;
+  if (!ScanConfig (config, "SKY_TABLE",         "%s",  0, SKY_TABLE)) SKY_TABLE[0] = 0;
 
   if (*CATMODE == 0) strcpy (CATMODE, "RAW");
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/ImagePosIO.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/ImagePosIO.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/ImagePosIO.c	(revision 36574)
@@ -199,6 +199,6 @@
   ALLOCATE (pc2_1     ,         float ,          Nimage_pos);
   ALLOCATE (pc2_2     ,         float ,          Nimage_pos);
-  ALLOCATE (polyterms ,         float ,          Nimage_pos);
-  ALLOCATE (ctype     ,         char  ,          Nimage_pos);
+  ALLOCATE (polyterms ,         float ,          14*Nimage_pos);
+  ALLOCATE (ctype     ,         char  ,          15*Nimage_pos);
   ALLOCATE (Npolyterms,         char  ,          Nimage_pos);
   ALLOCATE (dXpixSys  ,         float ,          Nimage_pos);
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/MosaicOps.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/MosaicOps.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/MosaicOps.c	(revision 36574)
@@ -105,4 +105,5 @@
     mosaic[Nmosaic].secz  = image[i].secz;
     mosaic[Nmosaic].coords = image[i].coords;
+    mosaic[Nmosaic].myImage = i;
 
     // init the mosaic_own_images array data
@@ -250,5 +251,5 @@
   if (im >= Nmosaic_for_images) abort();
 
-  // search for the mosaic that 
+  // search for the mosaic that matches this image
   mos = mosaic_for_images[im];
   if (mos < 0) return NULL;
@@ -257,16 +258,28 @@
 }
 
+// extend each host image table to include the mosaic 'images' needed by the host
 int select_mosaics_hostregion (RegionHostTable *regionHosts, Image *image, off_t Nimage) {
 
+  int i;
+  off_t j;
+  char *mosaicUsed;
+
   ALLOCATE (mosaicUsed, char, Nmosaic);
-  memset (mosaicUsed, 0, Nmosaic * sizeof(char));
 
   // we need to add the mosaics to each of the region hosts lists of images
   for (i = 0; i < regionHosts->Nhosts; i++) {
 
+    int Nadd = 0;
+    int NADD = 100;
+    off_t *addMosaic = NULL;
+    ALLOCATE (addMosaic, off_t, NADD);
+
+    // reset the mosaicUsed flags (valid only for this host)
+    memset (mosaicUsed, 0, Nmosaic * sizeof(char));
+
     RegionHostInfo *host = &regionHosts->hosts[i];
 
     // find the mosaics associated with a given 
-    for (j = 0; j < host->Nimages; j++) {
+    for (j = 0; j < host->Nimage; j++) {
 
       int im = host->imseq[j];
@@ -275,12 +288,29 @@
       if (im >= Nmosaic_for_images) abort();
 
-      // search for the mosaic that 
+      // search for the mosaic that matches this image (skip unmatched images)
       off_t mos = mosaic_for_images[im];
-      if (mos < 0) return NULL;
-
-      // &mosaic[mos];
-      // XXX do what?
-    }
-
-}
-
+      if (mos < 0) continue; 
+
+      if (mosaicUsed[mos]) continue;
+
+      mosaicUsed[mos] = TRUE;
+      addMosaic[Nadd] = mos;
+      Nadd ++;
+      
+      CHECK_REALLOCATE (addMosaic, off_t, NADD, Nadd, 100);
+    }
+
+    REALLOCATE (host->image, Image, host->Nimage + Nadd);
+
+    for (j = 0; j < Nadd; j++) {
+      off_t mos = addMosaic[j];
+      off_t mos_im = mosaic[mos].myImage;
+
+      host->image[host->Nimage + j] = image[mos_im];
+    }
+    
+    host->Nimage += Nadd;
+  }
+  return TRUE;
+}
+
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/UpdateObjects.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/UpdateObjects.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/UpdateObjects.c	(revision 36574)
@@ -205,5 +205,5 @@
       if (((mode == FIT_PM_ONLY) || (mode == FIT_PM_AND_PAR)) && (N <= PM_TOOFEW)) mode = FIT_AVERAGE;
 
-      if (FIT_TARGET == TARGET_HIGH_SPEED) {
+      if (RELASTRO_OP == OP_HIGH_SPEED) {
 	  Tmean = 0.5*(Tmax - Tmin);
       } else {
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/args.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/args.c	(revision 36574)
@@ -13,4 +13,5 @@
   /* possible operations */
   FIT_TARGET = TARGET_NONE;
+  RELASTRO_OP = OP_NONE;
   FIT_MODE = FIT_AVERAGE;
 
@@ -21,5 +22,5 @@
     if (N > argc - 6) usage_merge_source();
     if (strcmp(argv[N+3], "into")) usage_merge_source();
-    FIT_TARGET = TARGET_MERGE_SOURCE;
+    RELASTRO_OP = OP_MERGE_SOURCE;
     remove_argument (N, &argc, argv);
     OBJ_ID_SRC = strtol(argv[N], &endptr, 0);
@@ -43,10 +44,10 @@
   if ((N = get_argument (argc, argv, "-update-objects"))) {
     remove_argument (N, &argc, argv);
-    FIT_TARGET = TARGET_UPDATE_OBJECTS;
+    RELASTRO_OP = OP_UPDATE_OBJECTS;
   }
 
   if ((N = get_argument (argc, argv, "-update-offsets"))) {
     remove_argument (N, &argc, argv);
-    FIT_TARGET = TARGET_UPDATE_OFFSETS;
+    RELASTRO_OP = OP_UPDATE_OFFSETS;
   }
 
@@ -69,5 +70,5 @@
   if ((N = get_argument (argc, argv, "-parallel-images"))) {
     remove_argument (N, &argc, argv);
-    FIT_TARGET = TARGET_PARALLEL_IMAGES;
+    RELASTRO_OP = OP_PARALLEL_IMAGES;
     if (N >= argc) usage();
     IMAGE_TABLE = strcreate (argv[N]);
@@ -76,8 +77,13 @@
   }
 
+  if ((N = get_argument (argc, argv, "-images"))) {
+    remove_argument (N, &argc, argv);
+    RELASTRO_OP = OP_IMAGES;
+  }
+
   PARALLEL_REGIONS_MANUAL = FALSE;
   if ((N = get_argument (argc, argv, "-parallel-regions"))) {
     remove_argument (N, &argc, argv);
-    FIT_TARGET = TARGET_PARALLEL_REGIONS;
+    RELASTRO_OP = OP_PARALLEL_REGIONS;
     if (!REGION_FILE) usage();
     if ((N = get_argument (argc, argv, "-parallel-regions-manual"))) {
@@ -126,5 +132,5 @@
     // XXX include a parallax / no-parallax option
     if (N >= argc - 4) usage();
-    FIT_TARGET = TARGET_HIGH_SPEED;
+    RELASTRO_OP = OP_HIGH_SPEED;
     remove_argument (N, &argc, argv);
     PHOTCODE_A_LIST = strcreate(argv[N]);
@@ -140,5 +146,5 @@
   if ((N = get_argument (argc, argv, "-hpm"))) {
     if (N >= argc - 2) usage();
-    FIT_TARGET = TARGET_HPM;
+    RELASTRO_OP = OP_HPM;
     remove_argument (N, &argc, argv);
     RADIUS = atof(argv[N]);
@@ -152,5 +158,5 @@
     remove_argument (N, &argc, argv);
     PARALLEL_OUTPUT = TRUE;
-    if ((FIT_TARGET != TARGET_HIGH_SPEED) && (FIT_TARGET != TARGET_HPM)) {
+    if ((RELASTRO_OP != OP_HIGH_SPEED) && (RELASTRO_OP != OP_HPM)) {
       fprintf (stderr, "-parallel-output only valid for -high-speed or -hpm modes\n");
       exit (1);
@@ -179,5 +185,7 @@
   }
 
-  if (FIT_TARGET == TARGET_NONE) usage();
+  if (RELASTRO_OP == OP_NONE) usage();
+
+  if (((RELASTRO_OP == OP_IMAGES) || (RELASTRO_OP == OP_PARALLEL_REGIONS) || (RELASTRO_OP == OP_PARALLEL_IMAGES)) && (FIT_TARGET == TARGET_NONE)) usage();
 
   /* specify portion of the sky : allow default of all sky? */
@@ -463,5 +471,5 @@
 
   /* possible operations */
-  FIT_TARGET = TARGET_NONE;
+  RELASTRO_OP = TARGET_NONE;
   FIT_MODE = FIT_AVERAGE;
 
@@ -498,15 +506,15 @@
     BCATALOG = strcreate(argv[N]);
     remove_argument (N, &argc, argv);
-    FIT_TARGET = TARGET_LOAD_OBJECTS;
+    RELASTRO_OP = OP_LOAD_OBJECTS;
   }
 
   if ((N = get_argument (argc, argv, "-update-objects"))) {
     remove_argument (N, &argc, argv);
-    FIT_TARGET = TARGET_UPDATE_OBJECTS;
+    RELASTRO_OP = OP_UPDATE_OBJECTS;
   }
 
   if ((N = get_argument (argc, argv, "-update-offsets"))) {
     remove_argument (N, &argc, argv);
-    FIT_TARGET = TARGET_UPDATE_OFFSETS;
+    RELASTRO_OP = OP_UPDATE_OFFSETS;
   }
 
@@ -528,5 +536,5 @@
     // XXX include a parallax / no-parallax option
     if (N >= argc - 5) usage_client();
-    FIT_TARGET = TARGET_HIGH_SPEED;
+    RELASTRO_OP = OP_HIGH_SPEED;
     remove_argument (N, &argc, argv);
     PHOTCODE_A_LIST = strcreate(argv[N]);
@@ -542,5 +550,5 @@
   if ((N = get_argument (argc, argv, "-hpm"))) {
     if (N >= argc - 3) usage();
-    FIT_TARGET = TARGET_HPM;
+    RELASTRO_OP = OP_HPM;
     remove_argument (N, &argc, argv);
     RADIUS = atof(argv[N]);
@@ -580,5 +588,5 @@
   }
 
-  if (FIT_TARGET == TARGET_NONE) usage_client();
+  if (RELASTRO_OP == OP_NONE) usage_client();
 
   /* specify portion of the sky : allow default of all sky? */
@@ -759,7 +767,13 @@
 
 void usage () {
-  fprintf (stderr, "ERROR: USAGE: relastro -update-simple [options]\n");
-  fprintf (stderr, "       OR:    relastro -update-chips [options]\n");
-  fprintf (stderr, "       OR:    relastro -update-mosaic [options]\n");
+  fprintf (stderr, "ERROR: USAGE: relastro -images -update-simple [options]\n");
+  fprintf (stderr, "       OR:    relastro -images -update-chips [options]\n");
+  fprintf (stderr, "       OR:    relastro -images -update-mosaic [options]\n");
+  fprintf (stderr, "       OR:    relastro -parallel-regions -update-simple [options]\n");
+  fprintf (stderr, "       OR:    relastro -parallel-regions -update-chips [options]\n");
+  fprintf (stderr, "       OR:    relastro -parallel-regions -update-mosaic [options]\n");
+  fprintf (stderr, "       OR:    relastro -parallel-images -update-simple [options]\n");
+  fprintf (stderr, "       OR:    relastro -parallel-images -update-chips [options]\n");
+  fprintf (stderr, "       OR:    relastro -parallel-images -update-mosaic [options]\n");
   fprintf (stderr, "       OR:    relastro -update-objects [options]\n");
   fprintf (stderr, "       OR:    relastro -high-speed [options]\n");
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/assign_images.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/assign_images.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/assign_images.c	(revision 36574)
@@ -38,6 +38,5 @@
   // supply the mosaics to the image table for the regionHosts : we already have the image
   // <-> mosaic relationship, we just need to select these mosaics (once per regionHost)
-  // XXX DEFINE ME: select_mosaics_hostregion (regionHosts, image, Nimage);
-  abort ();
+  select_mosaics_hostregion (regionHosts, image, Nimage);
 
   return TRUE;
@@ -136,5 +135,5 @@
       regionHosts->hosts[i].NIMAGE += D_NIMAGE;
       REALLOCATE (regionHosts->hosts[i].image, Image, regionHosts->hosts[i].NIMAGE);
-      // REALLOCATE (regionHosts->hosts[i].line_number, off_t, regionHosts->hosts[i].NIMAGE);
+      REALLOCATE (regionHosts->hosts[i].imseq, off_t, regionHosts->hosts[i].NIMAGE);
     }
   }
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/indexCatalogs.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/indexCatalogs.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/indexCatalogs.c	(revision 36574)
@@ -31,5 +31,5 @@
     objIDmax[i] = 0;
     for (j = 0; j < catalog[i].Naverage; j++) {
-      objIDmax[i] = MAX (catalog[i].averageT[j].objID, objIDmax[i]);
+      objIDmax[i] = MAX (catalog[i].average[j].objID, objIDmax[i]);
     }
 
@@ -40,5 +40,5 @@
 
     for (j = 0; j < catalog[i].Naverage; j++) {
-      int objID = catalog[i].averageT[j].objID;
+      int objID = catalog[i].average[j].objID;
       objIDseq[i][objID] = j;
     }
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/initialize.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/initialize.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/initialize.c	(revision 36574)
@@ -6,5 +6,5 @@
   args (argc, argv);
 
-  if (FIT_TARGET == TARGET_MERGE_SOURCE) return;
+  if (RELASTRO_OP == OP_MERGE_SOURCE) return;
 
   fprintf (stderr, "PHOTCODE_KEEP_LIST: %s\n", PHOTCODE_KEEP_LIST);
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/launch_region_hosts.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/launch_region_hosts.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/launch_region_hosts.c	(revision 36574)
@@ -58,4 +58,18 @@
 	      filename, REGION_FILE, host->hostID, CATDIR, host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat, STATMODE, MIN_ERROR);
 
+    switch (FIT_TARGET) {
+      case TARGET_SIMPLE:
+	strextend (command, "-update-simple");
+	break;
+      case TARGET_CHIPS:
+	strextend (command, "-update-chips");
+	break;
+      case TARGET_MOSAICS:
+	strextend (command, "-update-mosaics");
+	break;
+      case TARGET_NONE:
+	abort();
+    }
+
     if (VERBOSE)       	    strextend (command, "-v");
     if (VERBOSE2)      	    strextend (command, "-vv");
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/load_images.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/load_images.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/load_images.c	(revision 36574)
@@ -28,5 +28,5 @@
   
   /* unlock, if we can (else, unlocked below) */
-  int unlockImages = !UPDATE || (FIT_TARGET == TARGET_UPDATE_OFFSETS);
+  int unlockImages = !UPDATE || (RELASTRO_OP == OP_UPDATE_OFFSETS);
   if (unlockImages) dvo_image_unlock (db); 
 
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/markObjects.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/markObjects.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/markObjects.c	(revision 36574)
@@ -8,12 +8,14 @@
   // How strongly do I own this object?
   for (i = 0; i < Ncatalog; i++) {
+    ALLOCATE (catalog[i].nOwn, int, catalog[i].Naverage);
+    memset (catalog[i].nOwn, 0, catalog[i].Naverage*sizeof(int));
     for (j = 0; j < catalog[i].Naverage; j++) {
       int nOwn = 0;
-      int m = catalog[i].averageT[j].measureOffset;
-      for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) {
+      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 ++;
       }
-      catalog[i].averageT[j].nOwn = nOwn;
+      catalog[i].nOwn[j] = nOwn;
     }
   }
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro.c	(revision 36574)
@@ -10,41 +10,39 @@
   SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
 
-  switch (FIT_TARGET) {
-    case TARGET_UPDATE_OBJECTS:
+  switch (RELASTRO_OP) {
+    case OP_UPDATE_OBJECTS:
       /* the object analysis is a separate process iterating over catalogs */
       relastro_objects (skylist, 0, NULL);
       exit (0);
 
-    case TARGET_HIGH_SPEED:
+    case OP_HIGH_SPEED:
       /* high-speed is a 2pt cross-correlation process for linking moving objects (high PM) */
       high_speed_catalogs (sky, skylist, 0, NULL);
       exit (0);
 
-    case TARGET_HPM:
+    case OP_HPM:
       hpm_catalogs (sky, skylist, 0, NULL);
       exit (0);
 
-    case TARGET_MERGE_SOURCE:
+    case OP_MERGE_SOURCE:
       /* a special method to manually merge unlinked detections of sources togther (not parallel) */
       relastro_merge_source (sky);
       exit (0);
 
-    case TARGET_SIMPLE:
-    case TARGET_CHIPS:
-    case TARGET_MOSAICS:
+    case OP_IMAGES:
       relastro_images (skylist);
       exit (0);
 
-    case TARGET_UPDATE_OFFSETS:
+    case OP_UPDATE_OFFSETS:
       // iterate over catalogs to make detection coordinates consistant
       UpdateObjectOffsets (skylist, 0, NULL);
       exit (0);
 
-    case TARGET_PARALLEL_REGIONS:
+    case OP_PARALLEL_REGIONS:
       // run image updates in parallel across multiple remote machines
       relastro_parallel_regions ();
       exit (0);
 
-    case TARGET_PARALLEL_IMAGES:
+    case OP_PARALLEL_IMAGES:
       // operation on the remote machines in the PARALLEL_REGION mode
       relastro_parallel_images ();
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro_client.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro_client.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro_client.c	(revision 36574)
@@ -28,7 +28,7 @@
   SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
 
-  switch (FIT_TARGET) {
+  switch (RELASTRO_OP) {
 
-    case TARGET_LOAD_OBJECTS: {
+    case OP_LOAD_OBJECTS: {
       // USAGE: relastro_client -load-objects
       int Ncatalog;
@@ -46,5 +46,5 @@
     }
       
-    case TARGET_UPDATE_OBJECTS: {
+    case OP_UPDATE_OBJECTS: {
       // USAGE: relastro_client -update-objects
       relastro_objects (skylist, HOST_ID, HOSTDIR);
@@ -52,5 +52,5 @@
     }
 
-    case TARGET_HIGH_SPEED: {
+    case OP_HIGH_SPEED: {
       // USAGE: relastro_client -high-speed
       high_speed_catalogs (sky, skylist, HOST_ID, HOSTDIR);
@@ -58,5 +58,5 @@
     }
 
-    case TARGET_HPM: {
+    case OP_HPM: {
       // USAGE: relastro_client -high-speed
       hpm_catalogs (sky, skylist, HOST_ID, HOSTDIR);
@@ -65,5 +65,5 @@
 
       // XXX loading the images is fairly costly -- see if we can do an image subset
-    case TARGET_UPDATE_OFFSETS: {
+    case OP_UPDATE_OFFSETS: {
       FITS_DB db;
       
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro_objects.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro_objects.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro_objects.c	(revision 36574)
@@ -144,5 +144,4 @@
     // PM_TOOFEW
     // SRC_MEAS_TOOFEW
-    // FIT_TARGET
 
     char command[1024];
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro_parallel_regions.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro_parallel_regions.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/relastro_parallel_regions.c	(revision 36574)
@@ -60,5 +60,5 @@
   if (PARALLEL) {
     // save the updated image parameters
-    dvo_image_update (&db, VERBOSE);
+    dvo_image_save (&db, VERBOSE);
     dvo_image_unlock (&db); 
   }
@@ -69,7 +69,5 @@
   if (!PARALLEL) {
     // save the changes to the image parameters
-    // XXX if we have generated a vtable, we can use update; otherwise use save
-    // dvo_image_save (&db, VERBOSE);
-    dvo_image_update (&db, VERBOSE);
+    dvo_image_save (&db, VERBOSE);
     dvo_image_unlock (&db); 
   }
Index: /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/share_mean_pos.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/share_mean_pos.c	(revision 36573)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relastro/src/share_mean_pos.c	(revision 36574)
@@ -25,15 +25,15 @@
 
       // do I own this object? (in region range?) --- CAREFUL HERE!!
-      if (catalog[i].averageT[j].R <  Rmin) continue;
-      if (catalog[i].averageT[j].R >= Rmax) continue;
-      if (catalog[i].averageT[j].D <  Dmin) continue;
-      if (catalog[i].averageT[j].D >= Dmax) continue;
+      if (catalog[i].average[j].R <  Rmin) continue;
+      if (catalog[i].average[j].R >= Rmax) continue;
+      if (catalog[i].average[j].D <  Dmin) continue;
+      if (catalog[i].average[j].D >= Dmax) continue;
 
       // does this object have missing detections (does someone else need it?)
       // XXX : sky objects without missing detections
       // XXX watch out for detections which are not associated with an image (REF)
-      if (catalog[i].averageT[j].nOwn == catalog[i].averageT[j].Nmeasure) continue;
+      if (catalog[i].nOwn[j] == catalog[i].average[j].Nmeasure) continue;
 
-      set_mean_pos (&meanpos[Nmeanpos], &catalog[i].averageT[j]);
+      set_mean_pos (&meanpos[Nmeanpos], &catalog[i].average[j]);
       Nmeanpos ++;
       CHECK_REALLOCATE (meanpos, MeanPos, NMEANPOS, Nmeanpos, D_NMEANPOS);
@@ -94,6 +94,6 @@
     }
 
-    catalog[catSeq].averageT[objSeq].R = meanpos[i].R;
-    catalog[catSeq].averageT[objSeq].D = meanpos[i].D;
+    catalog[catSeq].average[objSeq].R = meanpos[i].R;
+    catalog[catSeq].average[objSeq].D = meanpos[i].D;
   }
 
@@ -103,5 +103,5 @@
 }
 
-int set_mean_pos (MeanPos *meanpos, AverageTiny *average) {
+int set_mean_pos (MeanPos *meanpos, Average *average) {
 
   meanpos->R     = average->R;
