Index: /branches/eam_branches/ohana.20170822/src/libdvo/include/dvodb.h
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/include/dvodb.h	(revision 40244)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/include/dvodb.h	(revision 40245)
@@ -377,5 +377,6 @@
       IMAGE_XM, 
       IMAGE_AIRMASS, 
-      IMAGE_MCAL, 
+      IMAGE_MCAL_PSF, 
+      IMAGE_MCAL_APER, 
       IMAGE_dMCAL, 
       IMAGE_PHOTCODE, 
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dbExtractImages.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dbExtractImages.c	(revision 40244)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dbExtractImages.c	(revision 40245)
@@ -219,7 +219,9 @@
       break;
 
-    case IMAGE_MCAL:
-      // XXX : note add McalAPER methods
+    case IMAGE_MCAL_PSF:
       value.Flt = image[N].McalPSF;
+      break;
+    case IMAGE_MCAL_APER:
+      value.Flt = image[N].McalAPER;
       break;
     case IMAGE_dMCAL:
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dbFields.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dbFields.c	(revision 40244)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dbFields.c	(revision 40245)
@@ -847,9 +847,12 @@
   if (!strcasecmp (fieldName, "dapresid" )) ESCAPE (IMAGE_DAPRESID,  OPIHI_FLT);
 
-  if (!strcasecmp (fieldName, "Mcal"     )) ESCAPE (IMAGE_MCAL,      OPIHI_FLT);
-  if (!strcasecmp (fieldName, "dMcal"    )) ESCAPE (IMAGE_dMCAL,     OPIHI_FLT);
-  if (!strcasecmp (fieldName, "Xm"       )) ESCAPE (IMAGE_XM,        OPIHI_FLT);
-  if (!strcasecmp (fieldName, "photcode" )) ESCAPE (IMAGE_PHOTCODE,  OPIHI_INT);
-  if (!strcasecmp (fieldName, "exptime"  )) ESCAPE (IMAGE_EXPTIME,   OPIHI_FLT);
+  if (!strcasecmp (fieldName, "Mcal"     )) ESCAPE (IMAGE_MCAL_PSF,     OPIHI_FLT);
+  if (!strcasecmp (fieldName, "McalPSF"  )) ESCAPE (IMAGE_MCAL_APER,    OPIHI_FLT);
+  if (!strcasecmp (fieldName, "McalAPER" )) ESCAPE (IMAGE_MCAL_APER,    OPIHI_FLT);
+  if (!strcasecmp (fieldName, "McalAPERTURE")) ESCAPE (IMAGE_MCAL_APER, OPIHI_FLT);
+  if (!strcasecmp (fieldName, "dMcal"    )) ESCAPE (IMAGE_dMCAL,        OPIHI_FLT);
+  if (!strcasecmp (fieldName, "Xm"       )) ESCAPE (IMAGE_XM,           OPIHI_FLT);
+  if (!strcasecmp (fieldName, "photcode" )) ESCAPE (IMAGE_PHOTCODE,     OPIHI_INT);
+  if (!strcasecmp (fieldName, "exptime"  )) ESCAPE (IMAGE_EXPTIME,      OPIHI_FLT);
   if (!strcasecmp (fieldName, "expname"  )) ESCAPE (IMAGE_EXPNAME_AS_INT, OPIHI_INT);
   if (!strcasecmp (fieldName, "sidtime"  )) ESCAPE (IMAGE_SIDTIME,   OPIHI_FLT);
Index: /branches/eam_branches/ohana.20170822/src/relphot/src/StarOps.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relphot/src/StarOps.c	(revision 40244)
+++ /branches/eam_branches/ohana.20170822/src/relphot/src/StarOps.c	(revision 40245)
@@ -491,8 +491,10 @@
 	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 this operation is setting measure->McalAPER to image->McalAPER only
+	// for the stacks.  Elsewhere (setMrelCatalog) we are using image->McalPSF for all
+	// types of measurements EXCEPT stacks.
+
+	// we need to use McalAPER for stacks (and only stacks)
+	int isStack = isGPC1stack(catalog[i].measureT[m].photcode);
 
 	// note that measurements for which the image is not selected will not be modified
@@ -501,5 +503,5 @@
 	// set the output calibration
 	catalog[i].measure[m].McalPSF  = McalPSF  + Mmos + Mgrid;
-	catalog[i].measure[m].McalAPER = McalAPER + Mmos + Mgrid;
+	catalog[i].measure[m].McalAPER = isStack ? McalAPER + Mmos + Mgrid : McalPSF  + Mmos + Mgrid;
 
 	if (catalog[i].measureT[m].dbFlags & ID_MEAS_PHOTOM_UBERCAL) {
Index: /branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c	(revision 40244)
+++ /branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c	(revision 40245)
@@ -103,7 +103,7 @@
 // 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
+// Although I calculate McalAPER for exposures, I am only using McalPSF for chips.  Note
+// in StarOps.c:setMcalOutput I am setting measure->McalAPER to image->McalPSF for chips
+// and warps, but not stacks
 
 // set mean of chip measurements (selected by photcode range for now):
@@ -527,6 +527,6 @@
 
 // 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
+// and Map, and McalPSF for Mpsf.  Note in StarOps.c:setMcalOutput I am setting
+// measure->McalAPER to image->McalPSF for chips and warps, but not stacks
 
 int setMrelAverageStack (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr) {
@@ -801,7 +801,7 @@
 // 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
+// Although I calculate McalAPER for exposures, I am only using McalPSF for warps..
+// Note in StarOps.c:setMcalOutput I am setting measure->McalAPER to image->McalPSF for
+// chips and warps, but not stacks
 
 int setMrelAverageForcedWarp (Catalog *catalog, int cat, off_t ave, int Nsecfilt, FlatCorrectionTable *flatcorr, SetMrelInfo *results) {
