Index: /trunk/Ohana/src/relphot/src/MagResidSave.c
===================================================================
--- /trunk/Ohana/src/relphot/src/MagResidSave.c	(revision 41560)
+++ /trunk/Ohana/src/relphot/src/MagResidSave.c	(revision 41561)
@@ -251,4 +251,13 @@
     float Moff = Mcal + Mmos + Mgrp + Mgrid;
 
+    // Mrel is the true average apparent magnitude of this star
+    // Msys is the observed apparent magnitude, with nominal corrections, ie, the instrumental magnitude plus a constant
+    // yVector (dMag) = Msys - Mrel - Moff
+    // as the clouds come and go, Mrel is constant.  As the clouds increase, the observed
+    // star is fainter, so Msys gets larger, and the value of Moff also gets larger to compensate
+    // in other words:
+    // Mapp = Minst + ZP
+    // is equivalent to:
+    // Mrel = Msys - Moff, so a larger Moff means a smaller ZP and increase clouds (decreased transmission)
     psfStars->alldata-> yVector[Nref] = MsysPSF - MrelPSF - Moff;
     psfStars->alldata->dyVector[Nref] = MAX (catalog[c].measureT[m].dM, MIN_ERROR);
Index: /trunk/Ohana/src/relphot/src/TGroupOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/TGroupOps.c	(revision 41560)
+++ /trunk/Ohana/src/relphot/src/TGroupOps.c	(revision 41561)
@@ -802,11 +802,10 @@
   // for testing, supply the MJD of a night or nights here to dump the full list of measurements
   int testImage = FALSE;
-  testImage |= (abs(mjdStart - 58064) < 0.1);
-  testImage |= (abs(mjdStart - 58082) < 0.1);
-  testImage |= (abs(mjdStart - 58770) < 0.1);
-  testImage |= (abs(mjdStart - 55843) < 0.1);
-  testImage |= (abs(mjdStart - 56967) < 0.1);
-  testImage |= (abs(mjdStart - 57329) < 0.1);
-  testImage |= (abs(mjdStart - 56614) < 0.1);
+  // testImage |= (abs(mjdStart - 56586) < 0.1);
+  // testImage |= (abs(mjdStart - 57974) < 0.1);
+  // testImage |= (abs(mjdStart - 57975) < 0.1);
+  // testImage |= (abs(mjdStart - 57977) < 0.1);
+  // testImage |= (abs(mjdStart - 57981) < 0.1);
+  // testImage |= (abs(mjdStart - 58710) < 0.1);
 
   FILE *fout = NULL;
@@ -975,5 +974,5 @@
 
   TGTimes *mygroup = (TGTimes *) myTGroup->parent;
-  fprintf (stderr, "TGroup Stats %f,%d : %d %d %6.3f %6.3f %6.3f %d\n", ohana_sec_to_mjd(mygroup->start), myTGroup->photcode, (int) N, (int) myTGroup->Nmeasure, psfStars->bSaveArray[0][0], stats.median, altSigma, useMgrp);
+  fprintf (stderr, "TGroup Stats %f,%d : %d %d %6.3f %6.3f %6.3f %f %d\n", ohana_sec_to_mjd(mygroup->start), myTGroup->photcode, (int) N, (int) myTGroup->Nmeasure, psfStars->bSaveArray[0][0], stats.median, altSigma, myTGroup->McalChiSq, useMgrp);
 
   if (testImage) {
Index: /trunk/Ohana/src/relphot/src/bcatalog.c
===================================================================
--- /trunk/Ohana/src/relphot/src/bcatalog.c	(revision 41560)
+++ /trunk/Ohana/src/relphot/src/bcatalog.c	(revision 41561)
@@ -109,4 +109,12 @@
       if (isnan(catalog[0].measure[offset].psfQFperf) || (catalog[0].measure[offset].psfQFperf < 0.95)) { Npsfqf ++; continue; }
       if (isnan(catalog[0].measure[offset].M)) { Nnan ++; continue; }
+      if (isnan(catalog[0].measure[offset].Mkron)) { Nnan ++; continue; }
+
+      // require 0x01 in photFlags (fitted with a PSF)
+      if ((catalog[0].measure[offset].photFlags & 0x01) == 0) { Nbad ++; continue; }
+
+      // very loose cut on PSF - Kron 
+      float Mkp = catalog[0].measure[offset].M - catalog[0].measure[offset].Mkron;
+      if (fabs(Mkp) > 1.0) { Nbad ++; continue; }
 
       if (catalog[0].measure[offset].photFlags & code->photomBadMask) { 
Index: /trunk/Ohana/src/relphot/src/setMrelCatalog.c
===================================================================
--- /trunk/Ohana/src/relphot/src/setMrelCatalog.c	(revision 41560)
+++ /trunk/Ohana/src/relphot/src/setMrelCatalog.c	(revision 41561)
@@ -58,6 +58,4 @@
 }
 
-FILE *TESTFILE = NULL;
-
 int useOLS = TRUE; // chosen based on iteration below
 
@@ -73,6 +71,4 @@
   SetMrelInfoReset (results); // reset the counters
 
-  TESTFILE = fopen ("mytest.dat", "w");
-  
   useOLS = UseStandardOLS (ZPT_STARS);
   for (j = 0; j < catalog[Nc].Naverage; j++) {
@@ -92,6 +88,4 @@
     }
   }
-
-  fclose (TESTFILE);
   return (TRUE);
 }
@@ -427,5 +421,4 @@
       secfilt[Nsec].dMpsfChp = psfstats->error;
       secfilt[Nsec].Mchisq   = (psfstats->Nmeas > 1) ? psfstats->chisq : NAN;
-      fprintf (TESTFILE, "%d %d : %d : %f %f : %f\n", cat, (int) ave, NrankingPSF, psfstats->mean, psfstats->median, psfstats->mean - psfstats->median);
     }
 
