Index: /branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_images.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_images.c	(revision 36505)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_images.c	(revision 36505)
@@ -0,0 +1,140 @@
+# include "relphot.h"
+
+/* This function is essentially identical to relphot_images, except:
+
+ * load the subset images saved by the master node
+ * distinguish detections we own (touch our images) and those we don't
+ * distinguish objects we own (in region) and those we don't
+ * update the unowned detections for owned objects from neighbor regions
+ * update the unowned objects for owned detections 
+ */
+
+int relphot_parallel_images () {
+
+  int i, status, Ncatalog;
+  Catalog *catalog = NULL;
+  FITS_DB db;
+  SkyList *skylist = NULL;
+
+  INITTIME;
+
+  // load the subset images belonging to this host
+  // XXX need to determine the file name for each host (here or in master)
+  off_t Nimage;
+  ImageSubset *image = ImageSubsetLoad (IMAGES, &Nimage);
+  if (!image) {
+    fprintf (stderr, "ERROR loading image subset %s\n", CATDIR);
+    exit (2);
+  }
+  client_logger_message ("loaded image subset data\n");
+
+  // load the flat correction table (if defined)
+  char flatcorrfile[256];
+  sprintf (flatcorrfile, "%s/flatcorr.fits", CATDIR);
+  FlatCorrectionTable *flatcorr = FlatCorrectionLoad (flatcorrfile, VERBOSE);
+
+  // XXX need to define the skylist for this region
+  skylist = function(region);
+
+  /* load catalog data from region files (hostID is 0 since we are not a client */
+  catalog = load_catalogs (skylist, &Ncatalog, 0, NULL);
+  MARKTIME("-- load catalog data: %f sec\n", dtime);
+  
+  /* match measurements with images, mosaics */
+  initImageBins  (catalog, Ncatalog, TRUE);
+  MARKTIME("-- make image bins: %f sec\n", dtime);
+
+  initMosaicBins (catalog, Ncatalog, TRUE);
+  initGridBins   (catalog, Ncatalog);
+  initMrel (catalog, Ncatalog);
+
+  findImages (catalog, Ncatalog, TRUE);
+  MARKTIME("-- set up image indexes: %f sec\n", dtime);
+
+  findMosaics (catalog, Ncatalog, TRUE);  /* also sets Grid values */
+  MARKTIME("-- set up mosaic indexes: %f sec\n", dtime);
+
+  SAVEPLOT = FALSE;
+
+  setExclusions (catalog, Ncatalog, TRUE);
+
+  global_stats (catalog, Ncatalog, flatcorr);
+
+  if (PLOTSTUFF) {
+    plot_star_coords (catalog, Ncatalog);
+    // plot_mosaic_fields (catalog);
+  }
+
+  // XXX : add this in the loop at various points
+  // if (PLOTSTUFF) plot_scatter (catalog, Ncatalog, flatcorr); 
+
+  /* determine fit values */
+  for (i = 0; i < NLOOP; i++) {
+
+    // set the mean stellar mags given the measurements and the image calibrations
+    setMrel  (catalog, Ncatalog, flatcorr);
+
+    // share mean mags for objects at the boundary (number of unowned meas > 0)
+    share_mean_mags (catalog, Ncatalog);
+
+    // load mean mags from other region hosts
+    slurp_mean_mags (catalog, Ncatalog);
+
+    // set the image (Mcal) and mosaic (Mmos) zero point offsets given the mean mags and measurements
+    setMcal  (catalog, FALSE, flatcorr);
+    setMmos  (catalog, FALSE, flatcorr);
+    MARKTIME("-- set Mrel, Mcal, Mmos, Mgrid : %f sec\n", dtime);
+    
+    // share image mags for images with non-zero unowned detections
+    share_image_mags ();
+
+    slurp_image_mags ();
+
+    if (PLOTSTUFF) {
+      plot_scatter (catalog, Ncatalog, flatcorr); 
+      plot_mosaics ();
+      plot_images ();
+      plot_stars (catalog, Ncatalog);
+      plot_chisq (catalog, Ncatalog);
+    }
+
+    if ((i > 8) && (i % 8 == 2)) clean_measures (catalog, Ncatalog, FALSE, flatcorr); 
+    if ((i > 8) && (i % 8 == 3)) clean_stars (catalog, Ncatalog);
+    if ((i > 8) && (i % 8 == 5)) clean_mosaics ();
+    if ((i > 8) && (i % 8 == 5)) clean_images ();
+
+    if (i % 3 == 2) global_stats (catalog, Ncatalog, flatcorr);
+    MARKTIME("-- finished loop %d: %f sec\n", i, dtime);
+  }
+
+  if (PLOTSTUFF) {
+    plot_scatter (catalog, Ncatalog, flatcorr); 
+    plot_grid (catalog, flatcorr); 
+    plot_mosaics ();
+    plot_images ();
+    plot_stars (catalog, Ncatalog);
+    plot_chisq (catalog, Ncatalog);
+  }
+  
+  /* set Mcal & Mmos for bad images */
+  setMcal  (catalog, TRUE, flatcorr);
+  setMmos  (catalog, TRUE, flatcorr);
+  MARKTIME("-- finalize Mcal values: %f sec\n", dtime);
+
+  setMcalFinal (); // copy per-mosaic calibrations to the images
+
+  /* at this point, we have correct cal coeffs in the image/mosaic structures */
+  for (i = 0; i < Ncatalog; i++) {
+    // these tiny values are set by BrightCatalogSplit from load_catalogs
+    free_tiny_values (&catalog[i]);
+    dvo_catalog_free (&catalog[i]);
+  }
+  freeImageBins (Ncatalog, TRUE);
+  freeMosaicBins (Ncatalog, TRUE);
+  freeGridBins (Ncatalog);
+
+  save_image_subset ();
+
+  exit (0);
+
+}
Index: anches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_region.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_region.c	(revision 36504)
+++ 	(revision )
@@ -1,140 +1,0 @@
-# include "relphot.h"
-
-/* This function is essentially identical to relphot_images, except:
-
- * load the subset images saved by the master node
- * distinguish detections we own (touch our images) and those we don't
- * distinguish objects we own (in region) and those we don't
- * update the unowned detections for owned objects from neighbor regions
- * update the unowned objects for owned detections 
- */
-
-int relphot_parallel_images () {
-
-  int i, status, Ncatalog;
-  Catalog *catalog = NULL;
-  FITS_DB db;
-  SkyList *skylist = NULL;
-
-  INITTIME;
-
-  // load the subset images belonging to this host
-  // XXX need to determine the file name for each host (here or in master)
-  off_t Nimage;
-  ImageSubset *image = ImageSubsetLoad (IMAGES, &Nimage);
-  if (!image) {
-    fprintf (stderr, "ERROR loading image subset %s\n", CATDIR);
-    exit (2);
-  }
-  client_logger_message ("loaded image subset data\n");
-
-  // load the flat correction table (if defined)
-  char flatcorrfile[256];
-  sprintf (flatcorrfile, "%s/flatcorr.fits", CATDIR);
-  FlatCorrectionTable *flatcorr = FlatCorrectionLoad (flatcorrfile, VERBOSE);
-
-  // XXX need to define the skylist for this region
-  skylist = function(region);
-
-  /* load catalog data from region files (hostID is 0 since we are not a client */
-  catalog = load_catalogs (skylist, &Ncatalog, 0, NULL);
-  MARKTIME("-- load catalog data: %f sec\n", dtime);
-  
-  /* match measurements with images, mosaics */
-  initImageBins  (catalog, Ncatalog, TRUE);
-  MARKTIME("-- make image bins: %f sec\n", dtime);
-
-  initMosaicBins (catalog, Ncatalog, TRUE);
-  initGridBins   (catalog, Ncatalog);
-  initMrel (catalog, Ncatalog);
-
-  findImages (catalog, Ncatalog, TRUE);
-  MARKTIME("-- set up image indexes: %f sec\n", dtime);
-
-  findMosaics (catalog, Ncatalog, TRUE);  /* also sets Grid values */
-  MARKTIME("-- set up mosaic indexes: %f sec\n", dtime);
-
-  SAVEPLOT = FALSE;
-
-  setExclusions (catalog, Ncatalog, TRUE);
-
-  global_stats (catalog, Ncatalog, flatcorr);
-
-  if (PLOTSTUFF) {
-    plot_star_coords (catalog, Ncatalog);
-    // plot_mosaic_fields (catalog);
-  }
-
-  // XXX : add this in the loop at various points
-  // if (PLOTSTUFF) plot_scatter (catalog, Ncatalog, flatcorr); 
-
-  /* determine fit values */
-  for (i = 0; i < NLOOP; i++) {
-
-    // set the mean stellar mags given the measurements and the image calibrations
-    setMrel  (catalog, Ncatalog, flatcorr);
-
-    // share mean mags for objects at the boundary (number of unowned meas > 0)
-    share_mean_mags (catalog, Ncatalog);
-
-    // load mean mags from other region hosts
-    slurp_mean_mags (catalog, Ncatalog);
-
-    // set the image (Mcal) and mosaic (Mmos) zero point offsets given the mean mags and measurements
-    setMcal  (catalog, FALSE, flatcorr);
-    setMmos  (catalog, FALSE, flatcorr);
-    MARKTIME("-- set Mrel, Mcal, Mmos, Mgrid : %f sec\n", dtime);
-    
-    // share image mags for images with non-zero unowned detections
-    share_image_mags ();
-
-    slurp_image_mags ();
-
-    if (PLOTSTUFF) {
-      plot_scatter (catalog, Ncatalog, flatcorr); 
-      plot_mosaics ();
-      plot_images ();
-      plot_stars (catalog, Ncatalog);
-      plot_chisq (catalog, Ncatalog);
-    }
-
-    if ((i > 8) && (i % 8 == 2)) clean_measures (catalog, Ncatalog, FALSE, flatcorr); 
-    if ((i > 8) && (i % 8 == 3)) clean_stars (catalog, Ncatalog);
-    if ((i > 8) && (i % 8 == 5)) clean_mosaics ();
-    if ((i > 8) && (i % 8 == 5)) clean_images ();
-
-    if (i % 3 == 2) global_stats (catalog, Ncatalog, flatcorr);
-    MARKTIME("-- finished loop %d: %f sec\n", i, dtime);
-  }
-
-  if (PLOTSTUFF) {
-    plot_scatter (catalog, Ncatalog, flatcorr); 
-    plot_grid (catalog, flatcorr); 
-    plot_mosaics ();
-    plot_images ();
-    plot_stars (catalog, Ncatalog);
-    plot_chisq (catalog, Ncatalog);
-  }
-  
-  /* set Mcal & Mmos for bad images */
-  setMcal  (catalog, TRUE, flatcorr);
-  setMmos  (catalog, TRUE, flatcorr);
-  MARKTIME("-- finalize Mcal values: %f sec\n", dtime);
-
-  setMcalFinal (); // copy per-mosaic calibrations to the images
-
-  /* at this point, we have correct cal coeffs in the image/mosaic structures */
-  for (i = 0; i < Ncatalog; i++) {
-    // these tiny values are set by BrightCatalogSplit from load_catalogs
-    free_tiny_values (&catalog[i]);
-    dvo_catalog_free (&catalog[i]);
-  }
-  freeImageBins (Ncatalog, TRUE);
-  freeMosaicBins (Ncatalog, TRUE);
-  freeGridBins (Ncatalog);
-
-  save_image_subset ();
-
-  exit (0);
-
-}
