Index: branches/eam_branches/ipp-20110213/Ohana/src/relphot/src/select_images.c
===================================================================
--- branches/eam_branches/ipp-20110213/Ohana/src/relphot/src/select_images.c	(revision 30648)
+++ branches/eam_branches/ipp-20110213/Ohana/src/relphot/src/select_images.c	(revision 30649)
@@ -33,5 +33,5 @@
   struct timeval start, stop;
   
-  double RmaxSkyRegion, RminSkyRegion, DminSkyRegion, DmaxSkyRegion, RmidSkyRegion;
+  double RmaxSkyRegion, RminSkyRegion, RmidSkyRegion, DminSkyRegion, DmaxSkyRegion;
 
   double *RmaxSky;
@@ -131,13 +131,21 @@
     }
 
-    /* define image corners */
-    Xi[0] = 0;            Yi[0] = 0;
-    Xi[1] = timage[i].NX; Yi[1] = 0;
-    Xi[2] = timage[i].NX; Yi[2] = timage[i].NY;
-    Xi[3] = 0;            Yi[3] = timage[i].NY;
-    Xi[4] = 0;            Yi[4] = 0;
+    /* define image corners - note the DIS images (mosaic phu) are special */
+    if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) {
+      Xi[0] = -0.5*timage[i].NX; Yi[0] = -0.5*timage[i].NY;
+      Xi[1] = +0.5*timage[i].NX; Yi[1] = -0.5*timage[i].NY;
+      Xi[2] = +0.5*timage[i].NX; Yi[2] = +0.5*timage[i].NY;
+      Xi[3] = -0.5*timage[i].NX; Yi[3] = +0.5*timage[i].NY;
+      Xi[4] = -0.5*timage[i].NX; Yi[4] = -0.5*timage[i].NY;
+    } else {
+      Xi[0] = 0;            Yi[0] = 0;
+      Xi[1] = timage[i].NX; Yi[1] = 0;
+      Xi[2] = timage[i].NX; Yi[2] = timage[i].NY;
+      Xi[3] = 0;            Yi[3] = timage[i].NY;
+      Xi[4] = 0;            Yi[4] = 0;
+    }
     found = FALSE;
 
-    /* transform corners to ra,dec -- costs ~3sec for 3M images */
+    /* transform corners to ra,dec -- costs ~3sec for 3M images (pikake) */
     double RminImage = 360.0;
     double RmaxImage =   0.0;
@@ -147,5 +155,5 @@
       XY_to_RD (&Ri[j], &Di[j], Xi[j], Yi[j], &timage[i].coords);
       Ri[j] = ohana_normalize_angle_to_midpoint (Ri[j], RmidSkyRegion);
-      
+
       RminImage = MIN(RminImage, Ri[j]);
       RmaxImage = MAX(RmaxImage, Ri[j]);
@@ -158,5 +166,5 @@
 	RminImage = tmp - 360.0;
     }
-    
+
     // check that this image is even in range of the searched region
     if (DminImage > DmaxSkyRegion) continue;
@@ -182,5 +190,5 @@
       tcoords.crval2 = skycoords[m].Dc;
 
-      /* transform to ra,dec */
+      /* transform corner coords to X,Y in this catalog system */
       InRange = TRUE;
       for (j = 0; (j < 5) && InRange; j++) {
@@ -352,21 +360,2 @@
   return (Nlo);
 }
-
-off_t getRegionStopByRA (double R, double *Rref, off_t Nregions) {
-
-  // use bisection to find the overlapping mosaic
-
-  off_t Nlo, Nhi, N;
-
-  // find the last mosaic before start
-  Nlo = 0; Nhi = Nregions;
-  while (Nhi - Nlo > 10) {
-    N = 0.5*(Nlo + Nhi);
-    if (Rref[N] < R) {
-      Nlo = MAX(N, 0);
-    } else {
-      Nhi = MIN(N, Nregions);
-    }
-  }
-  return (Nlo);
-}
