Index: branches/eam_branches/relphot.20210521/src/GridOps.c
===================================================================
--- branches/eam_branches/relphot.20210521/src/GridOps.c	(revision 41603)
+++ branches/eam_branches/relphot.20210521/src/GridOps.c	(revision 41607)
@@ -301,2 +301,12 @@
   return Mgrid;
 }
+
+// for historical reasons, Mflat and Mgrid have opposite signs
+void setMflatFromGrid (Catalog *catalog) {
+  if (!GRID_ZEROPT) return;
+  for (off_t j = 0; j < catalog->Nmeasure; j++) {
+    float Mgrid = getMgrid (&catalog->measure[j]);
+    catalog->measure[j].Mflat -= Mgrid;
+  }
+}
+
