Index: branches/eam_branches/relphot.20210521/src/GridOps.c
===================================================================
--- branches/eam_branches/relphot.20210521/src/GridOps.c	(revision 41607)
+++ branches/eam_branches/relphot.20210521/src/GridOps.c	(revision 41608)
@@ -188,4 +188,7 @@
 	if (isnan(Mmos)) continue;
 
+	float Mflat = getMflat (nm, nc, catalog);
+	if (isnan(Mflat)) continue;
+
 	// Mrel* is the average magnitude for this star.  For PS1 stacks, we have too much
 	// PSF variability.  We need to calibrate the PSF magnitudes separately from the
@@ -200,6 +203,5 @@
 	if (isnan(MsysPSF)) continue;
 
-	// what about Mflat?
-	float Moff =  Mcal + Mgrp + Mmos;
+	float Moff =  Mcal + Mgrp + Mmos + Mflat;
 
 	// Msys = Mrel + Moff + Mgrid
@@ -307,6 +309,6 @@
   for (off_t j = 0; j < catalog->Nmeasure; j++) {
     float Mgrid = getMgrid (&catalog->measure[j]);
-    catalog->measure[j].Mflat -= Mgrid;
-  }
-}
-
+    catalog->measure[j].Mflat += Mgrid;
+  }
+}
+
