Index: trunk/Ohana/src/relphot/src/MosaicOps.c
===================================================================
--- trunk/Ohana/src/relphot/src/MosaicOps.c	(revision 20191)
+++ trunk/Ohana/src/relphot/src/MosaicOps.c	(revision 20192)
@@ -313,5 +313,5 @@
 int setMmos (Catalog *catalog, int PoorImages) {
 
-  int i, j, m, c, n, N, Nmax, mark, bad;
+  int i, j, m, c, n, N, Nmax, mark, bad, Nfew, Nbad, Ncal, Nrel, Ngrid, Nsys;
   float Msys, Mrel, Mcal, Mgrid;
   double *list, *dlist, *Mlist, *dMlist;
@@ -335,4 +335,6 @@
   ALLOCATE (Mlist, double, Nmax);
   ALLOCATE (dMlist, double, Nmax);
+
+  Nfew = Nbad = Ncal = Nrel = Ngrid = Nsys = 0;
 
   for (i = 0; i < Nmosaic; i++) {
@@ -350,14 +352,30 @@
       c = clist[i][j];
       
-      if (catalog[c].measure[m].dbFlags & MEAS_BAD) continue;
+      if (catalog[c].measure[m].dbFlags & MEAS_BAD) {
+	  Nbad ++;
+	  continue;
+      }
       Mcal  = getMcal  (m, c);
-      if (isnan(Mcal)) continue;
+      if (isnan(Mcal)) {
+	  Ncal++;
+	  continue;
+      }
       Mgrid = getMgrid (m, c);
-      if (isnan(Mgrid)) continue;
+      if (isnan(Mgrid)) {
+	  Ngrid ++;
+	  continue;
+      }
       Mrel  = getMrel  (catalog, m, c);
-      if (isnan(Mrel)) continue;
+      if (isnan(Mrel)) {
+	  Nrel ++;
+	  continue;
+      }
       
       n = catalog[c].measure[m].averef;
       Msys = PhotSys (&catalog[c].measure[m], &catalog[c].average[n], &catalog[c].secfilt[n*PhotNsec]);
+      if (isnan(Msys)) {
+	Nsys++;
+	continue;
+      }
       list[N]  = Msys - Mrel - Mcal - Mgrid;
       dlist[N] = MAX (catalog[c].measure[m].dM, MIN_ERROR);
@@ -375,4 +393,5 @@
 	fprintf (stderr, "marked image %s (%d), (%d < %d) || (%d < %f*%d)\n", image[imlist[i][0]].name, i, N, IMAGE_TOOFEW, N, IMAGE_GOOD_FRACTION, Nlist[i]);
 	mosaic[i].code |= ID_IMAGE_FEW;
+	Nfew ++;
       } else {
 	mosaic[i].code &= ~ID_IMAGE_FEW;
@@ -389,4 +408,6 @@
   free (Mlist);
   free (dMlist);
+
+  fprintf (stderr, "%d mosaics marked having too few measurements (Nbad: %d, Ncal: %d, Ngrid: %d, Nrel: %d, Nsys: %d)\n", Nfew, Nbad, Ncal, Ngrid, Nrel, Nsys);
 
   if (PoorImages) {
@@ -640,9 +661,9 @@
   graphdata.ymin = PlotdMmin;
   graphdata.ymax = PlotdMmax;
-  plot_list (&graphdata, xlist, Mlist, Nmosaic, "airmass vs Mcal", "airmass.png");
+  plot_list (&graphdata, xlist, Mlist, Nmosaic, "airmass vs Mcal", "%s.airmass.png", OUTROOT);
   plot_defaults (&graphdata);
   graphdata.size = 1.5;
   graphdata.ptype = 7;
-  plot_list (&graphdata, Mlist, dlist, Nmosaic, "Mcal vs dMcal", "MdM.png");
+  plot_list (&graphdata, Mlist, dlist, Nmosaic, "Mcal vs dMcal", "%s.MdM.png", OUTROOT);
 
 # define NBIN 200
@@ -660,5 +681,5 @@
   plot_defaults (&graphdata);
   graphdata.style = 1;
-  plot_list (&graphdata, xlist, Mlist, NBIN, "dMcal hist", "dMcalhist.png");
+  plot_list (&graphdata, xlist, Mlist, NBIN, "dMcal hist", "%s.dMcalhist.png", OUTROOT);
 
   free (dlist);
Index: trunk/Ohana/src/relphot/src/StarOps.c
===================================================================
--- trunk/Ohana/src/relphot/src/StarOps.c	(revision 20191)
+++ trunk/Ohana/src/relphot/src/StarOps.c	(revision 20192)
@@ -34,7 +34,9 @@
 int setMrel (Catalog *catalog, int Ncatalog) {
 
-  int i, j, k, m, N;
+  int i, j, k, m, N, Nfew, Nsys, Nbad, Ncal, Nmos, Ngrid;
   float Msys, Mcal, Mmos, Mgrid;
   StatType stats;
+
+  Nfew = Nsys = Nbad = Ncal = Nmos = Ngrid = 0;
 
   for (i = 0; i < Ncatalog; i++) {
@@ -47,5 +49,8 @@
       N = 0;
       for (k = 0; k < catalog[i].average[j].Nmeasure; k++, m++) {
-	if (catalog[i].measure[m].dbFlags & MEAS_BAD) continue;
+	if (catalog[i].measure[m].dbFlags & MEAS_BAD) {
+	  Nbad ++;
+	  continue;
+	}
 	// XXX allow REF stars (no Image Entry) to be included in the calculation this
 	// should be optionally set, and should allow for REF stars to be downweighted by
@@ -55,12 +60,25 @@
 	} else {
 	  Mcal  = getMcal  (m, i);
-	  if (isnan(Mcal)) continue;
+	  if (isnan(Mcal)) { 
+	    Ncal ++;
+	    continue;
+	  }
 	  Mmos  = getMmos  (m, i);
-	  if (isnan(Mmos)) continue;
+	  if (isnan(Mmos)) {
+	    Nmos ++;
+	    continue;
+	  }
 	  Mgrid = getMgrid (m, i);
-	  if (isnan(Mgrid)) continue;
+	  if (isnan(Mgrid)) {
+	    Ngrid++;
+	    continue;
+	  }
 	}
 
 	Msys = PhotSys (&catalog[i].measure[m], &catalog[i].average[j], &catalog[i].secfilt[j*PhotNsec]);
+	if (isnan(Msys)) {
+	  Nsys++;
+	  continue;
+	}
 	list[N] = Msys - Mcal - Mmos - Mgrid;
 	dlist[N] = MAX (catalog[i].measure[m].dM, MIN_ERROR);
@@ -69,4 +87,5 @@
       if (N < STAR_TOOFEW) { /* too few measurements */
 	catalog[i].average[j].code |= ID_STAR_FEW;
+	Nfew ++;
       } else {
 	catalog[i].average[j].code &= ~ID_STAR_FEW;
@@ -80,4 +99,6 @@
     }
   }
+  fprintf (stderr, "%d stars marked having too few measurements (Nbad: %d, Ncal: %d, Nmos: %d, Ngrid: %d, Nsys: %d)\n", Nfew, Nbad, Ncal, Nmos, Ngrid, Nsys);
+
   return (TRUE);
 }
@@ -523,4 +544,5 @@
   double *xlist, *Mlist;
   Graphdata graphdata;
+  char *filename, tmp;
 
 # define NBIN 200
@@ -542,5 +564,5 @@
   plot_defaults (&graphdata);
   graphdata.style = 1;
-  plot_list (&graphdata, xlist, Mlist, NBIN, "dMrel hist", "dMhist.png");
+  plot_list (&graphdata, xlist, Mlist, NBIN, "dMrel hist", "%s.dMhist.png", OUTROOT);
 
   free (xlist);
@@ -574,5 +596,5 @@
   plot_defaults (&graphdata);
   graphdata.ymin = -3.0;
-  plot_list (&graphdata, xlist, ylist, N, "chisq", NULL);
+  plot_list (&graphdata, xlist, ylist, N, "chisq", "%s.chisq.png", OUTROOT);
   free (xlist);
   free (ylist);
@@ -604,5 +626,5 @@
   }
   plot_defaults (&graphdata);
-  plot_list (&graphdata, xlist, ylist, N, "coords", NULL);
+  plot_list (&graphdata, xlist, ylist, N, "coords", "%s.coords.png", OUTROOT);
 
   free (xlist);
