Index: branches/eam_branches/ohana.20170822/src/relphot/src/BrightCatalog.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/BrightCatalog.c	(revision 40239)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/BrightCatalog.c	(revision 40244)
@@ -66,5 +66,6 @@
     GET_COLUMN(D,         "DEC",  	double);
     GET_COLUMN(M,         "MAG_SYS",  	float);
-    GET_COLUMN(Mcal,      "MAG_CAL",  	float);
+    GET_COLUMN(McalPSF,   "MCAL_PSF",  	float);
+    GET_COLUMN(McalAPER,  "MCAL_APER", 	float);
     GET_COLUMN(Mflat,     "MAG_FLAT",  	float);
     GET_COLUMN(dM,        "MAG_ERR",  	float);
@@ -89,5 +90,6 @@
       measure[i].D         = D[i];
       measure[i].M         = M[i];
-      measure[i].Mcal      = Mcal[i];
+      measure[i].McalPSF   = McalPSF[i];
+      measure[i].McalAPER  = McalAPER[i];
       measure[i].Mflat     = Mflat[i];
       measure[i].dM        = dM[i];
@@ -110,5 +112,6 @@
     free (D       );
     free (M       );
-    free (Mcal    );
+    free (McalPSF );
+    free (McalAPER);
     free (Mflat   );
     free (dM      );
@@ -293,5 +296,6 @@
     double *D         ; ALLOCATE (D        ,  double, catalog->Nmeasure);
     float  *M         ; ALLOCATE (M        ,  float,  catalog->Nmeasure);
-    float  *Mcal      ; ALLOCATE (Mcal     ,  float,  catalog->Nmeasure);
+    float  *McalPSF   ; ALLOCATE (McalPSF  ,  float,  catalog->Nmeasure);
+    float  *McalAPER  ; ALLOCATE (McalAPER ,  float,  catalog->Nmeasure);
     float  *Mflat     ; ALLOCATE (Mflat    ,  float,  catalog->Nmeasure);
     float  *dM        ; ALLOCATE (dM       ,  float,  catalog->Nmeasure);
@@ -311,8 +315,9 @@
     MeasureTiny *measure = catalog->measure;
     for (i = 0; i < catalog->Nmeasure; i++) {
-      R[i]        = measure[i].R       ;
-      D[i]        = measure[i].D       ;
+      R[i]        = measure[i].R        ;
+      D[i]        = measure[i].D        ;
       M[i]  	  = measure[i].M        ;
-      Mcal[i]     = measure[i].Mcal     ;
+      McalPSF[i]  = measure[i].McalPSF  ;
+      McalAPER[i] = measure[i].McalAPER ;
       Mflat[i]    = measure[i].Mflat    ;
       dM[i]       = measure[i].dM       ;
@@ -334,5 +339,6 @@
     gfits_set_bintable_column (&theader, &ftable, "DEC",  	D,         catalog->Nmeasure);
     gfits_set_bintable_column (&theader, &ftable, "MAG_SYS",  	M,         catalog->Nmeasure);
-    gfits_set_bintable_column (&theader, &ftable, "MAG_CAL",  	Mcal,      catalog->Nmeasure);
+    gfits_set_bintable_column (&theader, &ftable, "MCAL_PSF",  	McalPSF,   catalog->Nmeasure);
+    gfits_set_bintable_column (&theader, &ftable, "MCAL_APER",  McalAPER,  catalog->Nmeasure);
     gfits_set_bintable_column (&theader, &ftable, "MAG_FLAT",  	Mflat,     catalog->Nmeasure);
     gfits_set_bintable_column (&theader, &ftable, "MAG_ERR",  	dM,        catalog->Nmeasure);
@@ -352,5 +358,6 @@
     free (D       );
     free (M       );
-    free (Mcal    );
+    free (McalPSF );
+    free (McalAPER);
     free (Mflat   );
     free (dM      );
Index: branches/eam_branches/ohana.20170822/src/relphot/src/StarOps.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/StarOps.c	(revision 40239)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/StarOps.c	(revision 40244)
@@ -473,5 +473,4 @@
   int i;
   off_t j, k, m;
-  float Mcal, Mmos, Mgrid;
 
   MEAS_BAD = ID_MEAS_NOCAL;
@@ -484,10 +483,16 @@
       for (k = 0; k < catalog[i].averageT[j].Nmeasure; k++, m++) {
 	if (catalog[i].measureT[m].dbFlags & MEAS_BAD) continue;
-	Mcal  = getMcal  (m, i, MAG_CLASS_PSF);
-	if (isnan(Mcal)) continue;
-	Mmos  = getMmos  (m, i);
+	float McalPSF  = getMcal  (m, i, MAG_CLASS_PSF);
+	float McalAPER = getMcal  (m, i, MAG_CLASS_APER);
+	if (isnan(McalPSF)) continue;
+	float Mmos  = getMmos  (m, i);
 	if (isnan(Mmos)) continue;
-	Mgrid = getMgrid (m, i);
+	float Mgrid = getMgrid (m, i);
 	if (isnan(Mgrid)) continue;
+
+	// XXX note that this operation is setting measure->McalAPER to image->McalAPER
+	// regardless of how the average value was calculate.
+	// IF average.Mkron (e.g.) is calculated using image.McalPSF, we should store McalPSF for both
+	// of these items below
 
 	// note that measurements for which the image is not selected will not be modified
@@ -495,8 +500,9 @@
 
 	// set the output calibration
-	catalog[i].measure[m].Mcal = Mcal + Mmos + Mgrid;
+	catalog[i].measure[m].McalPSF  = McalPSF  + Mmos + Mgrid;
+	catalog[i].measure[m].McalAPER = McalAPER + Mmos + Mgrid;
 
 	if (catalog[i].measureT[m].dbFlags & ID_MEAS_PHOTOM_UBERCAL) {
-	  myAssert (isfinite(catalog[i].measure[m].Mcal), "oops, broke an ubercal mag");
+	  myAssert (isfinite(catalog[i].measure[m].McalPSF), "oops, broke an ubercal mag");
 	}
       }
@@ -560,5 +566,5 @@
       int m = catalog[i].averageT[j].measureOffset;
       for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) {
-	fprintf (fout, "meas %5d %5d | %6.3f %6.3f | %6.3f\n", m+n, catalog[i].measureT[m+n].photcode, catalog[i].measureT[m+n].M, catalog[i].measureT[m+n].Mkron, catalog[i].measureT[m+n].Mcal); 
+	fprintf (fout, "meas %5d %5d | %6.3f %6.3f | %6.3f %6.3f\n", m+n, catalog[i].measureT[m+n].photcode, catalog[i].measureT[m+n].M, catalog[i].measureT[m+n].Mkron, catalog[i].measureT[m+n].McalPSF, catalog[i].measureT[m+n].McalAPER); 
       }
     }
@@ -643,4 +649,6 @@
 // sigma of the INNER 50% mean.  it then flags any measurements which are more than
 // NSIGMA_REJECT (5) sigma of the mean
+
+// this function only operations on the PSF magnitudes
 
 # define NSIGMA_CLIP 3.0
Index: branches/eam_branches/ohana.20170822/src/relphot/src/bcatalog.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/bcatalog.c	(revision 40239)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/bcatalog.c	(revision 40244)
@@ -153,10 +153,12 @@
 	if (subcatalog[0].measureT[Nmeasure].dbFlags & ID_MEAS_PHOTOM_UBERCAL) {
 	  if (!KEEP_UBERCAL) {
-	    subcatalog[0].measureT[Nmeasure].Mcal = 0.0;
+	    subcatalog[0].measureT[Nmeasure].McalPSF  = 0.0;
+	    subcatalog[0].measureT[Nmeasure].McalAPER = 0.0;
 	    subcatalog[0].measureT[Nmeasure].dbFlags &= ~ID_MEAS_PHOTOM_UBERCAL;
 	  } 
 	} else {
 	  if (getImageEntry (Nmeasure, Ncat) >= 0) {
-	    subcatalog[0].measureT[Nmeasure].Mcal = 0.0;
+	    subcatalog[0].measureT[Nmeasure].McalPSF  = 0.0;
+	    subcatalog[0].measureT[Nmeasure].McalAPER = 0.0;
 	  }
 	}
Index: branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c	(revision 40239)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c	(revision 40244)
@@ -102,4 +102,8 @@
 // 3) UBERCAL measurements can have their weight increased by a big factor to help tie down the averages
 // 4) some reference photcode of some kind can be specified as fixed and have a high weight
+
+// Although I calculate McalAPER for exposures, I am only using McalPSF for exposures
+// XXX this means that a query of the database for mag:rel:kron will be inconsistent if there
+// is any significant difference
 
 // set mean of chip measurements (selected by photcode range for now):
@@ -224,5 +228,5 @@
       // overlaps).  Msys + measure.Mcal is our best guess of the true magnitude
       Mmos = Mgrid = 0;
-      Mcal = measureT[k].Mcal; // check that this is zero for loaded REF value
+      Mcal = measureT[k].McalPSF; // check that this is zero for loaded REF value
     } else {
       // getMcal returns image[].Mcal; note the flat-field correction is stored in measure.Mflat
@@ -521,4 +525,9 @@
 // 2) select the BEST detections per filter (regardless of PRIMARY)
 // 3) apply the zero point and AB->Jy transformations
+
+// I calculate McalAPER and McalPSF independently for stacks.  I use McalAPER for Mkron
+// and Map, and McalPSF for Mpsf.  A query of the database for mag:rel:kron will be
+// inconsistent if there is any significant difference
+
 int setMrelAverageStack (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr) {
 
@@ -633,5 +642,5 @@
 	// overlaps).  Msys + measure.Mcal is our best guess of the true magnitude
 	Mmos = Mgrid = 0;
-	McalPSF = measure[k].Mcal; // check that this is zero for loaded REF value
+	McalPSF = measure[k].McalPSF; // check that this is zero for loaded REF value
 	McalAPER = McalPSF; // check that this is zero for loaded REF value
       } else {
@@ -791,4 +800,9 @@
 // * no grid, no mosaic, no 2MASS, no SYNTH, no Ubercal, no flatcorr
 // analysis is done on flux, not mags (as the faintest objects will be nearly insignificant)
+
+// Although I calculate McalAPER for exposures, I am only using McalPSF for exposures
+// XXX this means that a query of the database for mag:rel:kron will be inconsistent if there
+// is any significant difference
+
 int setMrelAverageForcedWarp (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr, SetMrelInfo *results) {
   OHANA_UNUSED_PARAM(flatcorr);
@@ -868,5 +882,5 @@
       // data for which the associated image has not been loaded (probably because of
       // overlaps).  Msys + measure.Mcal is our best guess of the true magnitude
-      Mcal = measure[k].Mcal; // check that this is zero for loaded REF value
+      Mcal = measure[k].McalPSF; // check that this is zero for loaded REF value
     } else {
       Mcal  = getMcal (meas, cat, MAG_CLASS_PSF);
Index: branches/eam_branches/ohana.20170822/src/relphot/src/setMrelFinal.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/setMrelFinal.c	(revision 40239)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/setMrelFinal.c	(revision 40244)
@@ -65,10 +65,12 @@
 	  if (catalog[0].measure[m].dbFlags & ID_MEAS_PHOTOM_UBERCAL) {
 	    if (!KEEP_UBERCAL) {
-	      catalog[0].measure[m].Mcal = 0.0;
+	      catalog[0].measure[m].McalPSF  = 0.0;
+	      catalog[0].measure[m].McalAPER = 0.0;
 	      catalog[0].measure[m].dbFlags &= ~ID_MEAS_PHOTOM_UBERCAL;
 	    } 
 	  } else {
 	    if (RESET_ZEROPTS && (getImageEntry (m, 0) >= 0)) {
-	      catalog[0].measure[m].Mcal = 0.0;
+	      catalog[0].measure[m].McalPSF  = 0.0;
+	      catalog[0].measure[m].McalAPER = 0.0;
 	    }
 	  }
