Index: /branches/eam_branches/ipp-20140904/Ohana/src/addstar/include/addstar.h
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/addstar/include/addstar.h	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/addstar/include/addstar.h	(revision 37378)
@@ -326,4 +326,8 @@
 int strextend (char *input, char *format,...);
 
+void initMosaicCoords ();
+void saveMosaicCoords (Coords *input);
+
+
 /** 
     there is an inconsistency to be resolved: fixed structures (like Image)
Index: /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/LoadData.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/LoadData.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/LoadData.c	(revision 37378)
@@ -33,4 +33,10 @@
   // we need to perform that analysis here
   GetZeroPointExposure (headers, headerSets, Nimages);
+
+  if (!options[0].mosaic) {
+    // we are requiring a single set of N x WRPs + 1 DIS per file set.
+    // NOTE: if the -mosaic was supplied, do not reset the mosaic coords here 
+    initMosaicCoords ();
+  }
 
   // now run through the images, interpret the headers and read the stars
Index: /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/LoadStars.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/LoadStars.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/LoadStars.c	(revision 37378)
@@ -88,4 +88,9 @@
       exit (1);
     }
+    /* supplied photcode is incompatible with multi-chip images */
+    if ((NheaderSets > 1) && options[0].mosaic) {
+      fprintf (stderr, "ERROR: -mosaic cannot be supplied to multiple images\n");
+      exit (1);
+    }
 
     // if these are SDSS data, load with SDSS-specific wrapper
Index: /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/NewImage.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/NewImage.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/NewImage.c	(revision 37378)
@@ -33,4 +33,5 @@
       goto reject;
     }
+    saveMosaicCoords (mosaic);
   }    
 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/ReadImageHeader.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/ReadImageHeader.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/ReadImageHeader.c	(revision 37378)
@@ -1,3 +1,14 @@
 # include "addstar.h"
+
+// for DIS/WRP sets, we need to save the DIS set and supply it to the WRP entries
+static Coords *mosaic = NULL;
+
+void initMosaicCoords () {
+  mosaic = NULL;
+}
+
+void saveMosaicCoords (Coords *input) {
+  mosaic = input;
+}
 
 /* read an image header corresponding to a CMF / CMP data block */
@@ -54,5 +65,5 @@
   /* only load astrometry, NAXIS1,2, and time if this is a MOSAIC_PHU (ctype is ....-DIS) */
   if (!strcmp (&image[0].coords.ctype[4], "-DIS")) {
-    RegisterMosaic (&image[0].coords);
+    saveMosaicCoords (&image[0].coords);
     return (TRUE);
   }
@@ -79,8 +90,9 @@
   }
   if (!strcmp (&image[0].coords.ctype[4], "-WRP")) {
-    if (!isRegisteredMosaic()) {
+    if (!mosaic) {
       fprintf (stderr, "no mosaic for WRP image (use -mosaic)\n");
       return (FALSE);
     }
+    image[0].coords.mosaic = mosaic;
   } else {
     /* force image to lie in 0-360 range */
Index: /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/UpdateDatabase_Image.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/UpdateDatabase_Image.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/UpdateDatabase_Image.c	(revision 37378)
@@ -21,5 +21,4 @@
 
   /* find correpsonding regions for image */
-  RegisterMosaic (mosaic);
   skylist = NULL;
   newlist = NULL;
Index: /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/args.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/args.c	(revision 37378)
@@ -175,5 +175,5 @@
       exit (1);
     }
-    RegisterMosaic (&MOSAIC);
+    saveMosaicCoords (&MOSAIC);
     remove_argument (N, &argc, argv);
     gfits_free_header (&header);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/args_client.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/args_client.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/args_client.c	(revision 37378)
@@ -83,5 +83,5 @@
       exit (1);
     }
-    RegisterMosaic (&MOSAIC);
+    saveMosaicCoords (&MOSAIC);
     remove_argument (N, &argc, argv);
     gfits_free_header (&header);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/fakeimage.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/fakeimage.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/fakeimage.c	(revision 37378)
@@ -60,6 +60,4 @@
   MOSAIC.polyterms[6][1] = pltscale;  // M : X^2 Y^0
 
-  RegisterMosaic (&MOSAIC);
-
   /* some basic data about the chisp */
   ScanConfig (config, "NCHIPS", "%d", 0, &Nchips);
@@ -103,4 +101,5 @@
       image[i+1].coords.polyterms[j][1] = 0;
     }
+    image[i+1].coords.mosaic = &MOSAIC;
 
     image[i+1].sidtime  = 0.0;
Index: /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/find_missing.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/find_missing.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/addstar/src/find_missing.c	(revision 37378)
@@ -14,5 +14,4 @@
     REALLOCATE (catalog[0].missing, Missing, NMISS);
   }
-  if (!FindMosaicForImage (overlap, Noverlap, j)) continue;
   if (!in_image (catalog[0].average[Nave].R, catalog[0].average[Nave].D, &overlap[j])) continue;
   add_miss_link (&catalog[0].average[Nave], next_miss, Nmiss);
@@ -27,5 +26,5 @@
 /* add reference for undetected catalog stars */
 /* XXX allow this option only for single images? */
-if (!strcmp (&image[0].coords.ctype[4], "-WRP")) RegisterMosaic (mosaic);
+if (!strcmp (&image[0].coords.ctype[4], "-WRP")) image[0].coords = mosaic;
 for (j = 0; (j < Nave) && !options.skip_missed; j++) {
   n = N2[j];
Index: /branches/eam_branches/ipp-20140904/Ohana/src/checkastro/src/ImageOps.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/checkastro/src/ImageOps.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/checkastro/src/ImageOps.c	(revision 37378)
@@ -130,6 +130,4 @@
   }
 
-  BuildChipMatch (image, Nimage);
-
   char output[128];
   snprintf (output, 128, "checkastrom.%+3.0f.%+3.0f.%03.0f.%03.0f.dat", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
@@ -148,14 +146,9 @@
     name = GetPhotcodeNamebyCode (image[i].photcode);
 
-    off_t myMosaic = FindMosaicForImage (image, Nimage, i);
-
     /* only check exposure center */
     double Rexp = NAN, Dexp = NAN, Rccd = NAN, Dccd = NAN;
 
-    if (myMosaic) {
-      myMosaic --;
-      XY_to_RD (&Rccd, &Dccd, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords);
-      XY_to_RD (&Rexp, &Dexp, 0.0, 0.0, &image[myMosaic].coords);
-    }
+    XY_to_RD (&Rccd, &Dccd, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords);
+    XY_to_RD (&Rexp, &Dexp, 0.0, 0.0, &image[i].parent->coords);
 
     char *date = ohana_sec_to_date(image[i].tzero);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/checkastro/src/load_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/checkastro/src/load_images.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/checkastro/src/load_images.c	(revision 37378)
@@ -17,4 +17,6 @@
   MARKTIME("  convert image table: %f sec\n", dtime);
 
+  BuildChipMatch (image, Nimage);
+
   // select the images which overlap the selected sky regions
   subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/checkastro/src/select_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/checkastro/src/select_images.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/checkastro/src/select_images.c	(revision 37378)
@@ -43,6 +43,4 @@
 
   if (VERBOSE) fprintf (stderr, "finding images\n");
-  BuildChipMatch (timage, Ntimage);
-  MARKTIME("build chip match: %f sec\n", dtime);
 
   nimage = 0;
@@ -83,17 +81,9 @@
     }
     
-    // this adds 1.3 sec for 3M images
-    off_t myMosaic = FindMosaicForImage (timage, Ntimage, i);
-    if (!myMosaic) {
-      fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
-      continue;
-    }
-    myMosaic --;
-
     /* only check exposure center */
     if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) {
       XY_to_RD (&Rexp, &Dexp, 0.0, 0.0, &timage[i].coords);
     } else {
-      XY_to_RD (&Rexp, &Dexp, 0.0, 0.0, &timage[myMosaic].coords);
+      XY_to_RD (&Rexp, &Dexp, 0.0, 0.0, &timage[i].parent->coords);
     }
     Rexp = ohana_normalize_angle_to_midpoint (Rexp, RmidSkyRegion);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/delstar/src/ImageOpsFixLAP.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/delstar/src/ImageOpsFixLAP.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/delstar/src/ImageOpsFixLAP.c	(revision 37378)
@@ -320,12 +320,8 @@
     if ((Nimage_valid[i] + Nimage_invalid[i] == 0) || (found_ratio < 0.995)) {
       double r, d;
-      if (!FindMosaicForImage (image, Nimage, i)) { 
-	fprintf (stderr, "failed to get astrometry for %s\n", image[i].name);
+      if (!strcmp(&image[i].coords.ctype[4], "-DIS")) {
+	XY_to_RD (&r, &d, 0.0, 0.0, &image[i].coords);
       } else {
-	if (!strcmp(&image[i].coords.ctype[4], "-DIS")) {
-	  XY_to_RD (&r, &d, 0.0, 0.0, &image[i].coords);
-	} else {
-	  XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords);
-	}
+	XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords);
       }
       char *date = ohana_sec_to_date (image[i].tzero);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/delstar/src/delete_imagename.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/delstar/src/delete_imagename.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/delstar/src/delete_imagename.c	(revision 37378)
@@ -24,4 +24,6 @@
   }
 
+  BuildChipMatch (image, Nimage);
+
   /* find image in db by name */
   imlist = find_images_name (db, IMAGENAME, &Nimlist);
@@ -33,6 +35,4 @@
     if (VERBOSE) fprintf (stderr, "deleting %s\n", image[j].name);
     
-    // XXX EAM : need to handle failure
-    FindMosaicForImage (image, Nimage, j);
     skylist = SkyListByImage (sky, -1, &image[j]);
 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/delstar/src/delete_times.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/delstar/src/delete_times.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/delstar/src/delete_times.c	(revision 37378)
@@ -31,4 +31,6 @@
   }
 
+  BuildChipMatch (image, Nimage);
+
   /* find images for time range, delete each image */ 
   imlist = find_images_time (db, START, END, PHOTCODE, &Nimlist);
@@ -39,6 +41,4 @@
     if (VERBOSE) fprintf (stderr, "finding regions for %s\n", image[j].name);
 
-    // XXX EAM : need to handle failure
-    FindMosaicForImage (image, Nimage, j);
     skyset = SkyListByImage (sky, -1, &image[j]);
 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/Makefile
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/Makefile	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/Makefile	(revision 37378)
@@ -23,5 +23,5 @@
 dvoverify_client : $(BIN)/dvoverify_client.$(ARCH)
 
-all: dvomerge dvomerge_client dvoconvert dvosecfilt dvosecfilt_client dvoverify dvoverify_client
+all: dvomerge dvomerge_client dvoconvert dvosecfilt dvosecfilt_client dvorepair dvoverify dvoverify_client
 
 #  $(SRC)/dvomergeContinue.$(ARCH).o
Index: /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/ImageOps.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/ImageOps.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/ImageOps.c	(revision 37378)
@@ -18,5 +18,4 @@
   }
   if (m == -1) return (NULL);
-  if (!FindMosaicForImage (image, Nimage, m)) return (NULL);
   return (&image[m]);
 }
Index: /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c	(revision 37378)
@@ -113,9 +113,4 @@
   create_IDmap_lookup (IDmap);
 
-  if (!out[0].swapped) {
-    gfits_convert_Image ((Image *) out[0].ftable.buffer, sizeof(Image), Nout);
-    out[0].swapped = TRUE;
-  }
-
   Nout += Nimages;
   IDstart += Nimages;
Index: /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/dvorepairDeleteImageList.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/dvorepairDeleteImageList.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/dvorepairDeleteImageList.c	(revision 37378)
@@ -114,8 +114,4 @@
     index = deleteIDs[i];
     seq = imageIdx[index];
-    if (!FindMosaicForImage (image, Nimage, seq)) {
-      fprintf (stderr, "cannot find mosaic for %s, skipping\n", image[seq].name);
-      continue;
-    }
 
     XY_to_RD(&Rthis, &Dthis, 0, 0, &image[seq].coords);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/dvorepairFixImages.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/dvorepairFixImages.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/dvomerge/src/dvorepairFixImages.c	(revision 37378)
@@ -130,4 +130,8 @@
 int MarkMosaicsToDelete(Image *image, off_t Nimage, int *deleteIndex) {
 
+  myAbort ("this function needs to be redone with a concept to match the old BuildChipMatch");
+
+# if (0)  
+
   off_t i;
   
@@ -140,4 +144,6 @@
      marked.  Now find all WRP images for which none/some/all images are to be deleted.
   */
+
+  
 
   // make a copy of the ChipMatch table (generated by BuildChipMatch, see libdvo/src/mosaic_astrom.c) 
@@ -237,4 +243,6 @@
   free (ChipByMosaicID);
 
+# endif
+
   return TRUE;
 }
Index: /branches/eam_branches/ipp-20140904/Ohana/src/getstar/include/dvoImageOverlaps.h
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/getstar/include/dvoImageOverlaps.h	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/getstar/include/dvoImageOverlaps.h	(revision 37378)
@@ -37,2 +37,5 @@
 int edge_check (double *x1, double *y1, double *x2, double *y2);
 double opening_angle (double x1, double y1, double x2, double y2, double x3, double y3);
+
+void initMosaicCoords ();
+void saveMosaicCoords (Coords *input);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/MatchCoords.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/MatchCoords.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/MatchCoords.c	(revision 37378)
@@ -29,7 +29,4 @@
     if (!WITH_PHU && !strcmp (&dbImages[i].coords.ctype[4], "-DIS")) continue;
     if ( SOLO_PHU &&  strcmp (&dbImages[i].coords.ctype[4], "-DIS")) continue;
-
-    /* if any of these images are WRP images, need to find matching DIS */
-    if (!FindMosaicForImage (dbImages, NdbImages, i)) continue;
 
     /* define image corners */
Index: /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/MatchImages.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/MatchImages.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/MatchImages.c	(revision 37378)
@@ -24,12 +24,6 @@
   /* for mosaic astrometry, the grid should be w.r.t. the tangent-plane, not chip coords */
   if (!strcmp (&image[0].coords.ctype[4], "-WRP")) {
-    // if the input image is a mosaic, we need to register that mosaic for the calculations below
-    if (MOSAIC == NULL) {
-      fprintf (stderr, "no mosaic for WRP image (use -mosaic)\n");
-      return NULL;
-    }
-    RegisterMosaic (MOSAIC);
-
-    tcoords = MOSAIC[0];
+    myAssert (image[0].coords.mosaic, "should already have tested this");
+    tcoords = image[0].coords.mosaic[0];
     tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0;
     tcoords.pc1_1 = tcoords.pc2_2 = 1.0;
@@ -77,7 +71,4 @@
     if (!WITH_PHU && !strcmp (&dbImages[i].coords.ctype[4], "-DIS")) continue;
     if ( SOLO_PHU &&  strcmp (&dbImages[i].coords.ctype[4], "-DIS")) continue;
-
-    /* if any of these images are WRP images, need to find matching DIS */
-    if (!FindMosaicForImage (dbImages, NdbImages, i)) continue;
 
     /* define image corners */
Index: /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/ReadImageFiles.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/ReadImageFiles.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/ReadImageFiles.c	(revision 37378)
@@ -42,4 +42,6 @@
 
   mode = GetFileMode (header);
+
+  initMosaicCoords ();
 
   /*** load data from a single PHU or a collection of PHU files ***/
Index: /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/ReadImageHeader.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/ReadImageHeader.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/ReadImageHeader.c	(revision 37378)
@@ -1,3 +1,14 @@
 # include "dvoImageOverlaps.h"
+
+// for DIS/WRP sets, we need to save the DIS set and supply it to the WRP entries
+static Coords *mosaic = NULL;
+
+void initMosaicCoords () {
+  mosaic = NULL;
+}
+
+void saveMosaicCoords (Coords *input) {
+  mosaic = input;
+}
 
 /* read an image header corresponding to a CMF / CMP data block */
@@ -44,5 +55,5 @@
   /* only load astrometry, NAXIS1,2, and time if this is a MOSAIC_PHU (ctype is ....-DIS) */
   if (!strcmp (&image[0].coords.ctype[4], "-DIS")) {
-    MOSAIC = &image[0].coords;
+    saveMosaicCoords (&image[0].coords);
     return (TRUE);
   }
@@ -56,9 +67,9 @@
   }
   if (!strcmp (&image[0].coords.ctype[4], "-WRP")) {
-    if (MOSAIC == NULL) {
+    if (mosaic == NULL) {
       fprintf (stderr, "no mosaic for WRP image (use -mosaic)\n");
       return (FALSE);
     }
-    RegisterMosaic (MOSAIC);
+    image[0].coords.mosaic = mosaic;
   } else {
     /* force image to lie in 0-360 range */
Index: /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/WriteImages.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/WriteImages.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/getstar/src/WriteImages.c	(revision 37378)
@@ -5,5 +5,5 @@
   
   int i, N;
-  int nWRP, newWRP, isWRP;
+  int isWRP;
   FILE *f;
 
@@ -16,21 +16,16 @@
   }
 
-  nWRP = -1;
+  Image *mosaic = NULL;
   isWRP = FALSE;
   for (i = 0; i < Nmatches; i++) {
-    if (!strcmp (&images[0].coords.ctype[4], "-WRP")) {
-      if (!FindMosaicForImage (images, Nimages, i)) {
-	fprintf (stderr, "failed to find matching mosaic\n");
-	exit (1);
-      }
+    N = matches[i];
+    if (!strcmp (&images[N].coords.ctype[4], "-WRP")) {
       if (isWRP) {
-	newWRP = GetRegisteredMosaic();
-	if (newWRP != nWRP) {
+	if (mosaic != images[N].parent) {
 	  fprintf (stderr, "only one mosaic allowed in an output file\n");
 	  exit (1);
 	}
       } else {
-	nWRP = GetRegisteredMosaic();
-	isWRP = TRUE;
+	mosaic = images[N].parent;
       }
     }      
@@ -38,5 +33,5 @@
 
   if (isWRP) {
-    WriteImageFITS (f, &images[nWRP]);
+    WriteImageFITS (f, mosaic);
   } else {
     // write a blank
Index: /branches/eam_branches/ipp-20140904/Ohana/src/imregister/imphot/dumpfits.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/imregister/imphot/dumpfits.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/imregister/imphot/dumpfits.c	(revision 37378)
@@ -34,5 +34,5 @@
 
   ftable.header = &theader;
-  gfits_table_set_Image (&ftable, subset, Nmatch);
+  // gfits_table_set_Image (&ftable, subset, Nmatch);
 
   gfits_fwrite_header  (f, &header);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/imregister/imphot/modify.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/imregister/imphot/modify.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/imregister/imphot/modify.c	(revision 37378)
@@ -30,5 +30,7 @@
   gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, match, Nmatch);
   for (i = 0; i < Nmatch; i++) {
-    gfits_convert_Image ((Image *) db[0].vtable.buffer[i], sizeof (Image), 1);
+    fprintf (stderr, "need to work with real output format\n");
+    exit (2);
+    // gfits_convert_Image ((Image *) db[0].vtable.buffer[i], sizeof (Image), 1);
   }
   gfits_db_update (db);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/mosastro/src/testcoords.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/mosastro/src/testcoords.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/mosastro/src/testcoords.c	(revision 37378)
@@ -53,5 +53,6 @@
     exit (1);
   }
-  RegisterMosaic (&field.project);
+
+  chip[0].map.mosaic = &field.project;
   strcpy (chip[0].map.ctype, "DEC--WRP");
   for (i = 0; i < chip[0].Nmatch; i++) {
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/cmd.astro/coords.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/cmd.astro/coords.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/cmd.astro/coords.c	(revision 37378)
@@ -71,5 +71,5 @@
     if ((mosbuffer = SelectBuffer (MOSAIC, OLDBUFFER, TRUE)) == NULL) goto escape;
     GetCoords (&moscoords, &mosbuffer[0].header);
-    RegisterMosaic (&moscoords);
+    coords.mosaic = &moscoords;
   }
   
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/cmd.astro/getcoords.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/cmd.astro/getcoords.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/cmd.astro/getcoords.c	(revision 37378)
@@ -54,5 +54,5 @@
   if (!strcmp(&coords.ctype[4], "-WRP")) {
     if (MOSAIC == NULL) {
-      gprint (GP_ERR, "must supply mosaic for WRP coords\n");
+      gprint (GP_ERR, "must supply mosaic for WRP coords with -mosaic [buffer]\n");
       return (FALSE);
     }
@@ -65,5 +65,5 @@
     }
     GetCoords (&moscoords, &mosbuffer[0].header);
-    RegisterMosaic (&moscoords);
+    coords.mosaic = &moscoords;
   }
   
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/gimages.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/gimages.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/gimages.c	(revision 37378)
@@ -102,5 +102,4 @@
       } 
     }      
-    if (!FindMosaicForImage (image, Nimage, i)) continue;
 
     typehash = wordhash (&image[i].coords.ctype[4]);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/images.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/images.c	(revision 37378)
@@ -152,4 +152,6 @@
   SetVector (&Yvec, OPIHI_FLT, NPTS);
 
+  Image *mosaic = NULL;
+
   ALLOCATE (plist, int, NPTS);
   n = N = 0;
@@ -157,6 +159,8 @@
     if (ByName && strncmp (image[i].name, name, strlen(name))) continue;
     if (TimeSelect && ((image[i].tzero < tzero) || (image[i].tzero+image[i].trate*image[i].NY > tzero + trange))) continue;
-    if (!(Nmosaic = FindMosaicForImage (image, Nimage, i))) continue;
-    Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
+
+    mosaic = image[i].parent;
+    Nmosaic = (SOLO_MOSAIC && mosaic) ? mosaic - image : -1;
+
     if (photcode) {
       if ( photcodeEquiv && (photcode[0].code != GetPhotcodeEquivCodebyCode(image[i].photcode))) continue;
@@ -170,15 +174,15 @@
     typehash = wordhash (&image[i].coords.ctype[4]);
 
-    if (photcode && SOLO_MOSAIC) {
+    if (photcode && SOLO_MOSAIC && (Nmosaic >= 0)) {
       // mosaic (DIS) images are not currently given a photcode : plot these via the WRP entries
       /* DIS images represent a field, not a chip */
       if (typehash != ChipImage) continue;
       if (foundMosaic[Nmosaic]) continue;
-      x[0] = -0.5*image[Nmosaic].NX; y[0] = -0.5*image[Nmosaic].NY;
-      x[1] = +0.5*image[Nmosaic].NX; y[1] = -0.5*image[Nmosaic].NY;
-      x[2] = +0.5*image[Nmosaic].NX; y[2] = +0.5*image[Nmosaic].NY;
-      x[3] = -0.5*image[Nmosaic].NX; y[3] = +0.5*image[Nmosaic].NY;
+      x[0] = -0.5*mosaic->NX; y[0] = -0.5*mosaic->NY;
+      x[1] = +0.5*mosaic->NX; y[1] = -0.5*mosaic->NY;
+      x[2] = +0.5*mosaic->NX; y[2] = +0.5*mosaic->NY;
+      x[3] = -0.5*mosaic->NX; y[3] = +0.5*mosaic->NY;
       for (j = 0; j < Npts; j++) {
-	status = XY_to_RD (&r[j], &d[j], x[j], y[j], &image[Nmosaic].coords);
+	status = XY_to_RD (&r[j], &d[j], x[j], y[j], &mosaic->coords);
 	if (!status) break;
 	r[j] = ohana_normalize_angle (r[j]);
@@ -198,6 +202,7 @@
 
     /* DIS images represent a field, not a chip */
-    if ((typehash == DistortImage) && !WITH_MOSAIC) continue;
-    if ((typehash != DistortImage) &&  SOLO_MOSAIC) continue;
+    if ((typehash == DistortImage) && !WITH_MOSAIC) continue; // do not plot the mosaic images
+    if ((typehash != DistortImage) &&  SOLO_MOSAIC) continue; // plot only the mosaic images
+
     if (typehash == DistortImage) {
       x[0] = -0.5*image[i].NX; y[0] = -0.5*image[i].NY;
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imbox.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imbox.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imbox.c	(revision 37378)
@@ -43,10 +43,18 @@
   SetVector (&Yvec, OPIHI_FLT, NPTS);
 
+  mosaic.ctype[0] = 0;  
+
   while (gfits_fread_header (f, &header)) {
     if (!GetCoords (&coords, &header)) goto skip;
     if (!SOLO_PHU && !strcmp (&coords.ctype[4], "-DIS")) {
       mosaic = coords;
-      RegisterMosaic (&mosaic);
       goto skip;
+    }
+    if (!strcmp (&coords.ctype[4], "-WRP")) {
+      if (!mosaic.ctype[0]) {
+	fprintf (stderr, "PHU mosaic not found\n");
+	return FALSE;
+      }
+      coords.mosaic = &mosaic;
     }
 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imdata.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imdata.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imdata.c	(revision 37378)
@@ -103,5 +103,4 @@
     I = subset[i];
 
-    if (!FindMosaicForImage (image, Nimage, I)) continue;
     skyset = SkyListByImage (sky, -1, &image[I]);
 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imdense.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imdense.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imdense.c	(revision 37378)
@@ -42,5 +42,4 @@
     /* project this image to screen display coords */
     status = FALSE;
-    if (!FindMosaicForImage (image, Nimage, i)) continue;
     XY_to_RD (&r, &d, x, y, &image[i].coords);
     r = ohana_normalize_angle (r);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imlist.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imlist.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imlist.c	(revision 37378)
@@ -97,5 +97,4 @@
       }
     }
-    if (!FindMosaicForImage (image, Nimage, i)) continue;
     t = TimeValue (image[i].tzero, TimeReference, TimeFormat);
     if (!strcmp(&image[i].coords.ctype[4], "-DIS")) {
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imstats.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imstats.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/imstats.c	(revision 37378)
@@ -44,5 +44,4 @@
     else 
       Yvec.elements.Flt[i] = image[i].dMcal;
-    if (!FindMosaicForImage (image, Nimage, i)) continue;
     XY_to_RD (&r, &d, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords);
     gprint (GP_ERR, "%d %8.4f %8.4f %10d %6d  %5.3f %6.3f %6.3f\n", 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/skycoverage.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/skycoverage.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/skycoverage.c	(revision 37378)
@@ -284,6 +284,4 @@
       }
     }
-
-    if (!FindMosaicForImage (image, Nimage, i)) continue;
 
     typehash = wordhash (&image[i].coords.ctype[4]);
Index: /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/subpix.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/subpix.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/opihi/dvo/subpix.c	(revision 37378)
@@ -118,5 +118,4 @@
 
   for (i = 0; i < Nimage; i++) {
-    if (!FindMosaicForImage (image, Nimage, i)) continue;
     status = RD_to_XY (&X, &Y, Ra, Dec, &image[i].coords);
     if (!status || (X < 0) || (X > image[i].NX) || (Y < 0) || (Y > image[i].NY)) continue;
@@ -134,5 +133,4 @@
   for (i = 0; i < Nsub; i++) {
     I = index[i];
-    if (!FindMosaicForImage (image, Nimage, I)) continue;
     Timage = image[I].tzero;
     for (j = 0; j < Nmeasure; j++) {
Index: /branches/eam_branches/ipp-20140904/Ohana/src/photdbc/src/copy_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/photdbc/src/copy_images.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/photdbc/src/copy_images.c	(revision 37378)
@@ -52,4 +52,7 @@
   }
 
+  BuildChipMatch (image, Nimage);
+  // MARKTIME("build chip match: %f sec\n", dtime);
+
   subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset, FALSE);
 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/photdbc/src/select_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/photdbc/src/select_images.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/photdbc/src/select_images.c	(revision 37378)
@@ -92,6 +92,4 @@
 
   if (VERBOSE) fprintf (stderr, "finding images\n");
-  BuildChipMatch (timage, Ntimage);
-  MARKTIME("build chip match: %f sec\n", dtime);
 
   nimage = 0;
@@ -115,10 +113,4 @@
 keep_image:
 
-    // this adds 1.3 sec for 3M images
-    if (!FindMosaicForImage (timage, Ntimage, i)) {
-      fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
-      continue;
-    }
-
     /* define image corners - note the DIS images (mosaic phu) are special */
     if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) {
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateChips.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateChips.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateChips.c	(revision 37378)
@@ -494,3 +494,2 @@
 }
 
-// XXX if (!FindMosaicForImage (image, Nimage, i)) { }
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 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/assign_images.c	(revision 37378)
@@ -89,10 +89,4 @@
     if (!strcmp(&image[j].coords.ctype[4], "-DIS")) continue;
 
-    // match the image to its corresponding ASTROMETRIC mosaic (not the same as the Mosaic above)
-    if (!FindMosaicForImage (image, Nimage, j)) {
-      if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
-      continue;
-    }
-    
     // Exclude images with crazy astrometry
     // XXX NOTE : this is gpc1-specific
@@ -199,64 +193,4 @@
 }
 
-int calculate_host_image_bounds (RegionHostTable *regionHosts) {
-
-  int i, n;
-  off_t j;
-
-  for (i = 0; i < regionHosts->Nhosts; i++) {
-
-    RegionHostInfo *host = &regionHosts->hosts[i];
-
-    // XXX clear the chip match?
-
-    BuildChipMatch (host->image, host->Nimage);
-
-    double Rmin = 360.0;
-    double Rmax =   0.0;
-    double Dmin = +90.0;
-    double Dmax = -90.0;
-
-    for (j = 0; j < host->Nimage; j++) {
-
-      Image *image = &host->image[j];
-
-      if (!FindMosaicForImage (host->image, host->Nimage, j)) {
-	fprintf (stderr, "missing astrometry? programming error?\n");
-	abort ();
-      }
-      
-      // define image corners
-      for (n = 0; n < 4; n++) {
-	double Xc, Yc, Rc, Dc;
-	Xc = Xf[n]*image->NX; 
-	Yc = Yf[n]*image->NY;
-	XY_to_RD (&Rc, &Dc, Xc, Yc, &image->coords);
-	Rc = ohana_normalize_angle_to_midpoint (Rc, 180.0);
-      
-	Rmin = MIN (Rmin, Rc);
-	Dmin = MIN (Dmin, Rc);
-	
-	Rmax = MAX (Rmax, Rc);
-	Dmax = MAX (Dmax, Rc);
-      }
-
-    }
-
-    host->RminCat = Rmin;
-    host->DminCat = Dmin;
-    host->RmaxCat = Rmax;
-    host->DmaxCat = Dmax;
-
-    // regionHosts needs to have the full outer boundary
-    // (so reload_catalogs covers the correct region)
-    regionHosts->Rmin = MIN(Rmin, regionHosts->Rmin);
-    regionHosts->Rmax = MAX(Rmax, regionHosts->Rmax);
-    regionHosts->Dmin = MIN(Dmin, regionHosts->Dmin);
-    regionHosts->Dmax = MAX(Dmax, regionHosts->Dmax);
-  }
-  return TRUE;
-}
-
-
 // XXX add a search tree to speed this up?
 int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc) {
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 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/load_images.c	(revision 37378)
@@ -16,4 +16,7 @@
   }
   MARKTIME("  convert image table: %f sec\n", dtime);
+
+  BuildChipMatch (image, Nimage);
+  MARKTIME("build chip match: %f sec\n", dtime);
 
   // select the images which overlap the selected sky regions
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/select_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/select_images.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/select_images.c	(revision 37378)
@@ -104,6 +104,4 @@
 
   if (VERBOSE) fprintf (stderr, "finding images\n");
-  BuildChipMatch (timage, Ntimage);
-  MARKTIME("build chip match: %f sec\n", dtime);
 
   nimage = 0;
@@ -148,10 +146,4 @@
     }
     
-    // this adds 1.3 sec for 3M images
-    if (!FindMosaicForImage (timage, Ntimage, i)) {
-      fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
-      continue;
-    }
-
     /* define image corners - note the DIS images (mosaic phu) are special */
     if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) {
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/MosaicOps.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/MosaicOps.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/MosaicOps.c	(revision 37378)
@@ -520,12 +520,7 @@
       m = MosaicToImage[i][j];
 
-      if (!FindMosaicForImage (image, Nimage, m)) {
-	if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
-	continue;
-      }
-
       NX = image[m].NX;
       NY = image[m].NY;
-      XY_to_RD (&R, &D, 0.5*NX, 0.5*NY, &image[m].coords);
+      if (!XY_to_RD (&R, &D, 0.5*NX, 0.5*NY, &image[m].coords)) continue;
       R = ohana_normalize_angle_to_midpoint (R, 180.0);
 
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/assign_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/assign_images.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/assign_images.c	(revision 37378)
@@ -80,10 +80,4 @@
     if (!strcmp(&image[j].coords.ctype[4], "-DIS")) continue;
 
-    // match the image to its corresponding ASTROMETRIC mosaic (not the same as the Mosaic above)
-    if (!FindMosaicForImage (image, Nimage, j)) {
-      if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
-      continue;
-    }
-    
     // Exclude images with crazy astrometry
     // XXX NOTE : this is gpc1-specific
@@ -206,65 +200,4 @@
 }
 
-int calculate_host_image_bounds (RegionHostTable *regionHosts, double Rmid) {
-
-  int i, n;
-  off_t j;
-
-  for (i = 0; i < regionHosts->Nhosts; i++) {
-
-    RegionHostInfo *host = &regionHosts->hosts[i];
-
-    // XXX clear the chip match?
-
-    BuildChipMatch (host->image, host->Nimage);
-
-    double Rmin =  720.0;
-    double Rmax = -360.0;
-    double Dmin =  +90.0;
-    double Dmax = -90.0;
-
-    for (j = 0; j < host->Nimage; j++) {
-
-      Image *image = &host->image[j];
-
-      if (!FindMosaicForImage (host->image, host->Nimage, j)) {
-	fprintf (stderr, "missing astrometry? programming error?\n");
-	abort ();
-      }
-      
-      // define image corners
-      for (n = 0; n < 4; n++) {
-	double Xc, Yc, Rc, Dc;
-	Xc = Xf[n]*image->NX; 
-	Yc = Yf[n]*image->NY;
-	XY_to_RD (&Rc, &Dc, Xc, Yc, &image->coords);
-	Rc = ohana_normalize_angle_to_midpoint (Rc, Rmid);
-      
-	Rmin = MIN (Rmin, Rc);
-	Dmin = MIN (Dmin, Rc);
-	
-	Rmax = MAX (Rmax, Rc);
-	Dmax = MAX (Dmax, Rc);
-      }
-
-    }
-
-    // RminCat, RmaxCat may extended beyond 0.0 - 360.0
-    host->RminCat = Rmin;
-    host->DminCat = Dmin;
-    host->RmaxCat = Rmax;
-    host->DmaxCat = Dmax;
-
-    // regionHosts needs to have the full outer boundary
-    // (so reload_catalogs covers the correct region)
-    regionHosts->Rmin = MIN(Rmin, regionHosts->Rmin);
-    regionHosts->Rmax = MAX(Rmax, regionHosts->Rmax);
-    regionHosts->Dmin = MIN(Dmin, regionHosts->Dmin);
-    regionHosts->Dmax = MAX(Dmax, regionHosts->Dmax);
-  }
-  return TRUE;
-}
-
-
 // Rc is in range 0.0 - 360.0, hosts Rmin,Rmax in range 0.0 - 360.0
 int find_host_for_coords (RegionHostTable *regionHosts, double Rc, double Dc) {
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/load_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/load_images.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/load_images.c	(revision 37378)
@@ -27,4 +27,7 @@
   }
   MARKTIME("read image table: %f sec\n", dtime);
+
+  BuildChipMatch (image, Nimage);
+  MARKTIME("build chip match for %d images: %f sec\n", (int) Nimage, dtime);
 
   // allocate and init an array to identify the images included in the subset
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/select_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/select_images.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relphot/src/select_images.c	(revision 37378)
@@ -93,6 +93,4 @@
 
   if (VERBOSE) fprintf (stderr, "finding images\n");
-  BuildChipMatch (timage, Ntimage);
-  MARKTIME("build chip match for %d images: %f sec\n", (int) Ntimage, dtime);
 
   D_NIMAGE = 6000;
@@ -123,10 +121,4 @@
     }
     
-    // this adds 1.3 sec for 3M images
-    if (!FindMosaicForImage (timage, Ntimage, i)) {
-      if (VERBOSE2) fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
-      continue;
-    }
-
     /* define image corners - note the DIS images (mosaic phu) are special */
     if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) {
Index: /branches/eam_branches/ipp-20140904/Ohana/src/uniphot/src/find_image_sgroups.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/uniphot/src/find_image_sgroups.c	(revision 37377)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/uniphot/src/find_image_sgroups.c	(revision 37378)
@@ -42,10 +42,4 @@
     // if (!strcmp(&image[i].coords.ctype[4], "-DIS")) continue;
 
-    // this adds 1.3 sec for 3M images
-    if (!FindMosaicForImage (image, Nimage, i)) {
-      fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i);
-      continue;
-    }
-
     /* define image center - note the DIS images (mosaic phu) are special */
     if (!strcmp(&image[i].coords.ctype[4], "-DIS")) {
@@ -83,10 +77,4 @@
       // if (!strcmp(&image[j].coords.ctype[4], "-DIS")) continue;
 
-      // this adds 1.3 sec for 3M images
-      if (!FindMosaicForImage (image, Nimage, j)) {
-	  fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", j);
-	  continue;
-      }
-
       /* project image center to local coords, check radius */
       if (!strcmp(&image[j].coords.ctype[4], "-DIS")) {
