Index: branches/eam_branches/relphot.20210521/src/TGroupOps.c
===================================================================
--- branches/eam_branches/relphot.20210521/src/TGroupOps.c	(revision 41606)
+++ branches/eam_branches/relphot.20210521/src/TGroupOps.c	(revision 41608)
@@ -874,5 +874,6 @@
     // apply that offset as well here for this image (in other words, each detection is
     // being compared to the model, excluding the zero point, Mcal.  The model includes
-    // the flat-correction.  NOTE the sign of Mflat (Image.Mcal = Measure.Mcal - Mflat)
+    // the flat-correction.  NOTE the sign of Mflat (Image.Mcal = Measure.Mcal + Mflat)
+    // this was inconsistent with PhotRel pre-r41606
 
     float Mflat = getMflat (m, c, catalog);
@@ -899,5 +900,5 @@
     assert (Nbright >= 0);
 
-    float Moff =  Mcal + Mmos + Mgrid - Mflat;
+    float Moff =  Mcal + Mmos + Mgrid + Mflat;
 
     psfStars->alldata-> yVector[N] = MsysPSF - MrelPSF - Moff;
@@ -1022,5 +1023,5 @@
 
     // for historical reasons, Mflat is defined with the wrong sign
-    float delta = MsysPSF - MrelPSF - Mcal - Mmos - Mgrid + Mflat - myTGroup->McalPSF;
+    float delta = MsysPSF - MrelPSF - Mcal - Mmos - Mgrid - Mflat - myTGroup->McalPSF;
 
     int isBad = (catalog[c].measureT[m].dbFlags & MEAS_BAD);
@@ -1503,5 +1504,5 @@
 	float MrelPSF  = getMrel  (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP); // average magnitude
 	// float Mgrid    = getMgridTiny (&catalog[c].measureT[m]); // camera offset (deprecated?)
-	// float Mflat    = getMflat (m, c, catalog); // flat-field correction
+	float Mflat    = getMflat (m, c, catalog); // flat-field correction
 
 	off_t n = catalog[c].measureT[m].averef;
@@ -1511,5 +1512,5 @@
 
 	// for historical reasons, Mflat is defined with the wrong sign
-	float delta = MsysPSF - MrelPSF - Mcal - Mmos - Mgrp;
+	float delta = MsysPSF - MrelPSF - Mcal - Mmos - Mgrp - Mflat;
 
 	fprintf (fout, "%f %f : %f %f : %f %f %f  : %f %f\n", catalog[c].averageT[n].R, catalog[c].averageT[n].D, MsysPSF, MrelPSF, Mcal, Mmos, Mgrp, catalog[c].measureT[m].airmass, delta);
