Index: trunk/Ohana/src/opihi/dvo/images.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/images.c	(revision 28958)
+++ trunk/Ohana/src/opihi/dvo/images.c	(revision 29938)
@@ -11,9 +11,9 @@
 int images (int argc, char **argv) {
 
-  off_t i, Nimage;
+  off_t i, Nimage, Nmosaic;
   int j, status, InPic, leftside, *plist, TimeSelect, ByName;
   int WITH_MOSAIC, SOLO_MOSAIC, HIDDEN;
   time_t tzero, tend;
-  int N, NPTS, n, npts, Npts, kapa;
+  int N, NPTS, n, npts, Npts, kapa, *foundMosaic;
   Vector Xvec, Yvec;
   double r[8], d[8], x[8], y[8], Rmin, Rmax, Rmid, trange, Radius;
@@ -35,4 +35,5 @@
 
   SOLO_MOSAIC = FALSE;
+  foundMosaic = NULL;
   if ((N = get_argument (argc, argv, "-mosaic"))) {
     remove_argument (N, &argc, argv);
@@ -132,4 +133,9 @@
   BuildChipMatch (image, Nimage);
 
+  if (SOLO_MOSAIC && photcode) {
+    ALLOCATE(foundMosaic, int, Nimage);
+    memset(foundMosaic, 0, Nimage*sizeof(int));
+  }
+
   Rmin = graphmode.coords.crval1 - 180.0;
   Rmax = graphmode.coords.crval1 + 180.0;
@@ -137,4 +143,5 @@
   
   int DistortImage = wordhash ("-DIS");
+  int ChipImage    = wordhash ("-WRP");
   int TriangleUp   = wordhash ("TRP-");
   int TriangleDn   = wordhash ("TRM-");
@@ -150,5 +157,6 @@
     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 (!FindMosaicForImage (image, Nimage, i)) continue;
+    if (!(Nmosaic = FindMosaicForImage (image, Nimage, i))) continue;
+    Nmosaic --; // XXX kind of a hack: FindMosaicForImage returns 0 or the mosaic seq number + 1
     if (photcode) {
       if ( photcodeEquiv && (photcode[0].code != GetPhotcodeEquivCodebyCode(image[i].photcode))) continue;
@@ -161,4 +169,31 @@
 
     typehash = wordhash (&image[i].coords.ctype[4]);
+
+    if (photcode && SOLO_MOSAIC) {
+      // 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;
+      for (j = 0; j < Npts; j++) {
+	status = XY_to_RD (&r[j], &d[j], x[j], y[j], &image[Nmosaic].coords);
+	if (!status) break;
+	r[j] = ohana_normalize_angle (r[j]);
+	while (r[j] < Rmin) { r[j] += 360.0; }
+	while (r[j] > Rmax) { r[j] -= 360.0; }
+	if (j == 0) {
+	  leftside = (r[j] < Rmid);
+	} 
+	if (j > 0) { 
+	  if ( leftside && (r[j] > Rmid + 90)) { r[j] -= 360.0; }
+	  if (!leftside && (r[j] < Rmid - 90)) { r[j] += 360.0; }
+	}
+      }
+      foundMosaic[Nmosaic] = TRUE;
+      goto plot_points;
+    }
 
     /* DIS images represent a field, not a chip */
@@ -270,4 +305,6 @@
     if (Npts == 0) continue;
 
+  plot_points:
+
     status = FALSE;
     for (j = 0; j < Npts; j++) {
@@ -320,4 +357,5 @@
   free (Yvec.elements.Flt);
   FreeImages (image);
+  FREE (foundMosaic);
   return (TRUE);
 
