Index: branches/eam_branches/ipp-20120405/Ohana/src/relphot/include/relphot.h
===================================================================
--- branches/eam_branches/ipp-20120405/Ohana/src/relphot/include/relphot.h	(revision 33798)
+++ branches/eam_branches/ipp-20120405/Ohana/src/relphot/include/relphot.h	(revision 33799)
@@ -32,4 +32,5 @@
   float ubercalDist;
   unsigned int flags;
+  char skipCal;		      // if TRUE, this mosaic is incomplete and should not be calibrated
   Coords coords;
 } Mosaic; 
Index: branches/eam_branches/ipp-20120405/Ohana/src/relphot/src/MosaicOps.c
===================================================================
--- branches/eam_branches/ipp-20120405/Ohana/src/relphot/src/MosaicOps.c	(revision 33798)
+++ branches/eam_branches/ipp-20120405/Ohana/src/relphot/src/MosaicOps.c	(revision 33799)
@@ -208,36 +208,4 @@
   MARKTIME("create subset array of mosaic obstimes: %f sec\n", dtime);
 
-  int Nskip, Nmiss, Nmark;
-  Nskip = Nmiss = Nmark = 0;
-  // find any start times which match unselected images 
-  for (i = 0; i < Nimage; i++) {
-    if (inSubset[i]) {
-      Nskip ++;
-      continue;
-    }
-    
-    /* select valid mosaic images by photcode */
-    pname = GetPhotcodeNamebyCode (image[i].photcode);
-    if (!pname) continue;
-    status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME));
-    if (status) continue;
-
-    /* set image time range */
-    start = image[i].tzero;
-    stop  = image[i].tzero + MAX(1.01*image[i].trate*image[i].NY, 1);
-
-    /* find a matching mosaic */
-    j = findMosaic(startTimesMosaic, Nmosaic, start);
-    if (j == -1) {
-      // no matching mosaic
-      Nmiss ++;
-    } else {
-      // mark this mosaic as bad
-      Nmark ++;
-    }
-  }
-  fprintf (stderr, "%d images, %d skip, %d miss, %d mark\n", (int) Nimage, (int) Nskip, (int) Nmiss, (int) Nmark);
-  MARKTIME("find unselected images matching selected mosaics: %f sec\n", dtime);
-
   // now I have a list of uniq start times, and they are in order
   // create the mosaic arrays for these times
@@ -259,4 +227,5 @@
     mosaic[i].secz  = NAN;
     mosaic[i].photcode = 0;
+    mosaic[i].skipCal = FALSE;
 
     MosaicN_IMAGE[i] = 10;
@@ -266,4 +235,34 @@
   }
 
+  int Nskip, Nmark;
+  Nskip = Nmark = 0;
+  // find any mosaics (startTimesMosaic) which match unselected images 
+  for (i = 0; i < Nimage; i++) {
+    if (inSubset[i]) {
+      Nskip ++;
+      continue;
+    }
+    
+    /* select valid mosaic images by photcode */
+    pname = GetPhotcodeNamebyCode (image[i].photcode);
+    if (!pname) continue;
+    status = strncmp (pname, MOSAICNAME, strlen (MOSAICNAME));
+    if (status) continue;
+
+    /* set image time range */
+    start = image[i].tzero;
+    stop  = image[i].tzero + MAX(1.01*image[i].trate*image[i].NY, 1);
+
+    /* find a matching mosaic */
+    j = findMosaic(startTimesMosaic, Nmosaic, start);
+    if (j != -1) {
+      // mark this mosaic as bad
+      mosaic[i].skipCal = TRUE;
+      Nmark ++;
+    }
+  }
+  fprintf (stderr, "%d total images, %d overlap skyregion, %d do not overlap, but match overlapping mosaics\n", (int) Nimage, (int) Nskip, (int) Nmark);
+  MARKTIME("find unselected images matching selected mosaics: %f sec\n", dtime);
+
   ALLOCATE (ImageToMosaic, off_t, Nsubset); // mosaic to which image belongs
 
@@ -277,8 +276,4 @@
     if (status) continue;
 
-    /* set image time range */
-    // start = subset[i].tzero - MAX(0.01*subset[i].trate*subset[i].NY, 1);
-    // stop  = subset[i].tzero + MAX(1.01*subset[i].trate*subset[i].NY, 1);
-
     start = subset[i].tzero;
     stop  = subset[i].tzero + MAX(1.01*subset[i].trate*subset[i].NY, 1);
@@ -286,5 +281,5 @@
     j = findMosaic(startTimesMosaic, Nmosaic, start);
     if (j == -1) {
-      fprintf (stderr, "error?\n");
+      fprintf (stderr, "programming error? all subset images should belong to a mosaic\n");
       abort();
     }
@@ -448,4 +443,5 @@
 }
 
+// XXX : what about mosaics with skipCal == TRUE?
 void setMcalFinal () {
 
@@ -630,4 +626,5 @@
   int Nrel;
   int Nsys;
+  int Nskip;
   off_t Nmax;
   int PoorImages;
@@ -659,4 +656,5 @@
   info->Nrel = 0;
   info->Ngrid = 0;
+  info->Nskip = 0;
   info->Nsys = 0;
 
@@ -686,4 +684,5 @@
   summary->Nrel  += results->Nrel ;
   summary->Ngrid += results->Ngrid;
+  summary->Nskip += results->Nskip;
 }
 
@@ -710,4 +709,5 @@
 }
 
+# if (0)
 int setMmos_old (Catalog *catalog, int PoorImages, FlatCorrectionTable *flatcorr) {
 
@@ -765,4 +765,7 @@
       if (KEEP_UBERCAL) continue;
     }
+
+    // do not modify the calibration for mosaics with partial images loaded (skipCal TRUE)
+    if (mosaic[i].skipCal) continue;
 
     int minUbercalDist = 1000;
@@ -936,4 +939,5 @@
   return (TRUE);
 }
+# endif
   
 int setMmos (Catalog *catalog, int PoorImages, FlatCorrectionTable *flatcorr) {
@@ -1017,4 +1021,10 @@
 
   int minUbercalDist = 1000;
+
+  // do not modify the calibration for mosaics with partial images loaded (skipCal TRUE)
+  if (mosaic[0].skipCal) {
+    info->Nskip ++;
+    return TRUE;
+  }
 
   int testImage = FALSE;
@@ -1235,5 +1245,5 @@
   // report stats & summary from the threads
   for (i = 0; i < NTHREADS; i++) {
-    fprintf (stderr, "setMmos thread %d : %d mosaics marked having too few measurements (Nbad: %d, Ncal: %d, Ngrid: %d, Nrel: %d, Nsys: %d)\n", 
+    fprintf (stderr, "setMmos thread %d : %d mosaics marked having too few measurements (Nbad: %d, Ncal: %d, Ngrid: %d, Nrel: %d, Nsys: %d), %d partials skipped\n", 
 	     i, 
 	     threadinfo[i].info.Nfew, 
@@ -1242,8 +1252,9 @@
 	     threadinfo[i].info.Ngrid, 
 	     threadinfo[i].info.Nrel, 
-	     threadinfo[i].info.Nsys);
+	     threadinfo[i].info.Nsys,
+      	     threadinfo[i].info.Nskip);
     SetMmosInfoAccum (&summary, &threadinfo[i].info);
   }
-  fprintf (stderr, "total : %d mosaics marked having too few measurements (Nbad: %d, Ncal: %d, Ngrid: %d, Nrel: %d, Nsys: %d)\n", 
+  fprintf (stderr, "total : %d mosaics marked having too few measurements (Nbad: %d, Ncal: %d, Ngrid: %d, Nrel: %d, Nsys: %d), %d partials skipped\n", 
 	   summary.Nfew, 
 	   summary.Nbad, 
@@ -1251,5 +1262,6 @@
 	   summary.Ngrid, 
 	   summary.Nrel, 
-	   summary.Nsys);
+	   summary.Nsys, 
+	   summary.Nskip);
   free (threadinfo);
 
