Index: branches/eam_branches/ohana.20170822/src/relphot/include/relphot.h
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/include/relphot.h	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/include/relphot.h	(revision 40212)
@@ -77,11 +77,12 @@
   unsigned int stop;
   short photcode;
-  float Mcal;
+  float McalPSF;
+  float McalAPER;
   float dMcal;
   float dMsys;
-  unsigned short nFitPhotom;
-  short Xm;
+  float McalChiSq;
   float secz;
   float ubercalDist;
+  unsigned short nFitPhotom;
   unsigned int flags;
   char skipCal;		      // if TRUE, this mosaic is incomplete and should not be calibrated
@@ -201,8 +202,9 @@
 
 typedef struct {
-  float Mcal;
+  float McalPSF;
+  float McalAPER;
   float dMcal;
   float dMagSys;
-  short Xm;
+  float McalChiSq;
   int nFitPhotom;
   int flags;
@@ -220,5 +222,6 @@
 
 typedef struct {
-  float Mcal;
+  float McalPSF;
+  float McalAPER;
   float dMcal;
   unsigned int imageID;
@@ -427,5 +430,5 @@
 float         getMgrid            PROTO((off_t meas, int cat));
 float         getMmos             PROTO((off_t meas, int cat));
-float         getMrel             PROTO((Catalog *catalog, off_t meas, int cat));
+float         getMrel             PROTO((Catalog *catalog, off_t meas, int cat, dvoMagClassType class, dvoMagSourceType source));
 short         getUbercalDist      PROTO((off_t meas, int cat));
 float         getCenterOffset     PROTO((off_t meas, int cat, Measure *measure, unsigned int *myID));
Index: branches/eam_branches/ohana.20170822/src/relphot/src/BrightCatalog.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/BrightCatalog.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/BrightCatalog.c	(revision 40212)
@@ -199,12 +199,12 @@
     ALLOCATE (secfilt, SecFilt, Nrow);
     for (i = 0; i < Nrow; i++) {
-      secfilt[i].M      = M[i];         
-      secfilt[i].dM     = dM[i];
-      secfilt[i].Mchisq = Mchisq[i];
-      secfilt[i].flags  = flags[i];
-      secfilt[i].Ncode  = Ncode[i];
-      secfilt[i].Nused  = Nused[i];
-      secfilt[i].Mmin   = Mmin[i];
-      secfilt[i].Mmax   = Mmax[i];
+      secfilt[i].MpsfChp  = M[i];         
+      secfilt[i].dMpsfChp = dM[i];
+      secfilt[i].Mchisq   = Mchisq[i];
+      secfilt[i].flags    = flags[i];
+      secfilt[i].Ncode    = Ncode[i];
+      secfilt[i].Nused    = Nused[i];
+      secfilt[i].Mmin     = Mmin[i];
+      secfilt[i].Mmax     = Mmax[i];
     }
     fprintf (stderr, "loaded data for %lld secfilt\n", (long long) Nrow);
@@ -465,12 +465,12 @@
     SecFilt *secfilt = catalog->secfilt;
     for (i = 0; i < Nsec; i++) {
-      M     [i]       = secfilt[i].M      ;
-      dM    [i]       = secfilt[i].dM     ;
-      Mchisq[i]       = secfilt[i].Mchisq ;
-      flags [i]       = secfilt[i].flags  ;
-      Ncode [i]       = secfilt[i].Ncode  ;
-      Nused [i]       = secfilt[i].Nused  ;
-      Mmin  [i]       = secfilt[i].Mmin   ;
-      Mmax  [i]       = secfilt[i].Mmax   ;
+      M     [i]       = secfilt[i].MpsfChp ;
+      dM    [i]       = secfilt[i].dMpsfChp;
+      Mchisq[i]       = secfilt[i].Mchisq  ;
+      flags [i]       = secfilt[i].flags   ;
+      Ncode [i]       = secfilt[i].Ncode   ;
+      Nused [i]       = secfilt[i].Nused   ;
+      Mmin  [i]       = secfilt[i].Mmin    ;
+      Mmax  [i]       = secfilt[i].Mmax    ;
     }
 
Index: branches/eam_branches/ohana.20170822/src/relphot/src/GridOps.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/GridOps.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/GridOps.c	(revision 40212)
@@ -568,5 +568,5 @@
 	continue;
       }
-      Mrel  = getMrel  (catalog, m, c);
+      Mrel  = getMrel  (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP);
       if (isnan(Mrel)) {
 	Nrel ++;
@@ -649,5 +649,5 @@
       Mmos  = getMmos  (m, c);
       if (isnan(Mmos)) continue;
-      Mrel  = getMrel  (catalog, m, c);
+      Mrel  = getMrel  (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP);
       if (isnan(Mrel)) continue;
 
Index: branches/eam_branches/ohana.20170822/src/relphot/src/ImageMagIO.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/ImageMagIO.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/ImageMagIO.c	(revision 40212)
@@ -58,12 +58,13 @@
   char type[16];
 
-  GET_COLUMN (Mcal,              "MCAL",           float);
+  GET_COLUMN (McalPSF,           "MCAL_PSF",       float);
+  GET_COLUMN (McalAPER,          "MCAL_APER",      float);
   GET_COLUMN (dMcal,             "MCAL_ERR",       float);
   GET_COLUMN (dMagSys,           "MCAL_SYSERR",    float);
-  GET_COLUMN (nFitPhotom,        "NFIT",             int);
-  GET_COLUMN (flags,             "FLAGS",            int);
-  GET_COLUMN (ubercalDist,       "UDIST",            int);
-  GET_COLUMN (imageID,           "ID",               int);
-  GET_COLUMN (Xm,                "CHISQ",          short);
+  GET_COLUMN (McalChiSq,         "MCAL_CHISQ",     float);
+  GET_COLUMN (nFitPhotom,        "NFIT",           int);
+  GET_COLUMN (flags,             "FLAGS",          int);
+  GET_COLUMN (ubercalDist,       "UDIST",          int);
+  GET_COLUMN (imageID,           "ID",             int);
 
   // free the memory associated with the FITS files
@@ -75,8 +76,9 @@
   ALLOCATE (image_mags, ImageMag, Nrow);
   for (i = 0; i < Nrow; i++) {
-    image_mags[i].Mcal                      = Mcal       [i];
+    image_mags[i].McalPSF                   = McalPSF    [i];
+    image_mags[i].McalAPER                  = McalAPER   [i];
     image_mags[i].dMcal                     = dMcal      [i];
     image_mags[i].dMagSys                   = dMagSys    [i];
-    image_mags[i].Xm                        = Xm         [i];
+    image_mags[i].McalChiSq                 = McalChiSq  [i];
     image_mags[i].nFitPhotom                = nFitPhotom [i];
     image_mags[i].flags                     = flags      [i];
@@ -86,8 +88,9 @@
   fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow);
 
-  free (Mcal       );
+  free (McalPSF    );
+  free (McalAPER   );
   free (dMcal      );
   free (dMagSys    );
-  free (Xm         );
+  free (McalChiSq  );
   free (nFitPhotom );
   free (flags      );
@@ -121,20 +124,22 @@
   gfits_create_table_header (&theader, "BINTABLE", "IMAGE_MAGS");
 
-  gfits_define_bintable_column (&theader, "E", "MCAL",           "cal offset", 		       "magnitudes", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "E", "MCAL_PSF",       "PSF cal offset", 	       "magnitudes", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "E", "MCAL_APER",      "APER cal offset", 	       "magnitudes", 1.0, 0.0);
   gfits_define_bintable_column (&theader, "E", "MCAL_ERR",       "cal error",  		       "magnitudes", 1.0, 0.0);
   gfits_define_bintable_column (&theader, "E", "MCAL_SYSERR",    "systematic error", 	       "magnitudes", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "E", "MCAL_CHISQ",     "cal chisq", 		       "unitless",   1.0, 0.0);
   gfits_define_bintable_column (&theader, "J", "NFIT",           "number of fitted stars",     "unitless",   1.0, 0.0);
   gfits_define_bintable_column (&theader, "J", "FLAGS",          "analysis flags", 	       "unitless",   1.0, 0.0);
   gfits_define_bintable_column (&theader, "J", "UDIST",          "distance to ubercal images", "images",     1.0, 0.0);
   gfits_define_bintable_column (&theader, "J", "ID",             "image ID",  		       "unitless",   1.0, 0.0);
-  gfits_define_bintable_column (&theader, "I", "CHISQ",          "cal chisq", 		       "unitless",   1.0, FT_BZERO_INT16);
 
   // generate the output array that carries the data
   gfits_create_table (&theader, &ftable);
 
-  float *Mcal        ;
+  float *McalPSF     ;
+  float *McalAPER    ;
   float *dMcal       ;
   float *dMagSys     ;
-  float *Xm          ;
+  float *McalChiSq   ;
   int   *nFitPhotom  ;
   int   *flags       ;
@@ -143,8 +148,9 @@
 
   // create intermediate storage arrays
-  ALLOCATE (Mcal        ,         float,          Nimage_mags);
+  ALLOCATE (McalPSF     ,         float,          Nimage_mags);
+  ALLOCATE (McalAPER    ,         float,          Nimage_mags);
   ALLOCATE (dMcal       ,         float,          Nimage_mags);
   ALLOCATE (dMagSys     ,         float,          Nimage_mags);
-  ALLOCATE (Xm          ,         float,          Nimage_mags);
+  ALLOCATE (McalChiSq   ,         float,          Nimage_mags);
   ALLOCATE (nFitPhotom  ,           int,          Nimage_mags);
   ALLOCATE (flags       ,           int,          Nimage_mags);
@@ -154,8 +160,9 @@
   // assign the storage arrays
   for (i = 0; i < Nimage_mags; i++) {
-    Mcal       [i]   = image_mags[i].Mcal       ;
+    McalPSF    [i]   = image_mags[i].McalPSF    ;
+    McalAPER   [i]   = image_mags[i].McalAPER   ;
     dMcal      [i]   = image_mags[i].dMcal      ;
     dMagSys    [i]   = image_mags[i].dMagSys    ;
-    Xm         [i]   = image_mags[i].Xm         ;
+    McalChiSq  [i]   = image_mags[i].McalChiSq  ;
     nFitPhotom [i]   = image_mags[i].nFitPhotom ;
     flags      [i]   = image_mags[i].flags      ;
@@ -165,8 +172,9 @@
 
   // add the columns to the output array
-  gfits_set_bintable_column (&theader, &ftable, "MCAL",           Mcal       ,         Nimage_mags);
+  gfits_set_bintable_column (&theader, &ftable, "MCAL_PSF",       McalPSF    ,         Nimage_mags);
+  gfits_set_bintable_column (&theader, &ftable, "MCAL_APER",      McalAPER   ,         Nimage_mags);
   gfits_set_bintable_column (&theader, &ftable, "MCAL_ERR",       dMcal      ,         Nimage_mags);
   gfits_set_bintable_column (&theader, &ftable, "MCAL_SYSERR",    dMagSys    ,         Nimage_mags);
-  gfits_set_bintable_column (&theader, &ftable, "CHISQ",          Xm         ,         Nimage_mags);
+  gfits_set_bintable_column (&theader, &ftable, "MCAL_CHISQ",     McalChiSq  ,         Nimage_mags);
   gfits_set_bintable_column (&theader, &ftable, "NFIT",           nFitPhotom ,         Nimage_mags);
   gfits_set_bintable_column (&theader, &ftable, "FLAGS",          flags      ,         Nimage_mags);
@@ -174,8 +182,9 @@
   gfits_set_bintable_column (&theader, &ftable, "ID",             imageID    ,         Nimage_mags);
 
-  free (Mcal       );
+  free (McalPSF    );
+  free (McalAPER   );
   free (dMcal      );
   free (dMagSys    );
-  free (Xm         );
+  free (McalChiSq  );
   free (nFitPhotom );
   free (flags      );
Index: branches/eam_branches/ohana.20170822/src/relphot/src/ImageOps.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/ImageOps.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/ImageOps.c	(revision 40212)
@@ -143,5 +143,6 @@
     image[i].photom_map_id = input[i].photom_map_id;
     image[i].flags         = input[i].flags        ;
-    image[i].Mcal          = input[i].Mcal         ;
+    image[i].McalPSF       = input[i].McalPSF      ;
+    image[i].McalAPER      = input[i].McalAPER     ;
     image[i].dMcal         = input[i].dMcal        ;
     image[i].tzero         = input[i].tzero        ;
@@ -179,5 +180,6 @@
     subset[i].photom_map_id = image[i].photom_map_id;
     subset[i].flags         = image[i].flags        ;
-    subset[i].Mcal          = image[i].Mcal         ;
+    subset[i].McalPSF       = image[i].McalPSF      ;
+    subset[i].McalAPER      = image[i].McalAPER     ;
     subset[i].dMcal         = image[i].dMcal        ;
     subset[i].tzero         = image[i].tzero        ;
@@ -443,5 +445,5 @@
 
   if (image[i].flags & IMAGE_BAD) return (NAN);  
-  value = image[i].Mcal;
+  value = image[i].McalPSF;
 
   // to do this, I need to pass in the catalog and flatcorr pointers
@@ -470,5 +472,5 @@
 
   if (image[i].flags & IMAGE_BAD) return (NAN);  
-  value = image[i].Mcal;
+  value = image[i].McalPSF;
 
   // to do this, I need to pass in the catalog and flatcorr pointers
@@ -483,5 +485,4 @@
 }
 
-// returns image.Mcal - ff(x,y)
 short getUbercalDist (off_t meas, int cat) {
 
@@ -499,5 +500,4 @@
 }
 
-// returns image.Mcal - ff(x,y)
 float getCenterOffset (off_t meas, int cat, Measure *measure, unsigned int *myID) {
 
@@ -519,5 +519,4 @@
 }
 
-// returns image.Mcal - ff(x,y)
 int MatchImageName (off_t meas, int cat, char *name) {
 
@@ -542,5 +541,4 @@
 }
 
-// returns image.Mcal - ff(x,y)
 int MatchImageSkycellID (off_t meas, int cat, int myTessID, int myProjectionID, int mySkycellID) {
 
@@ -563,5 +561,4 @@
 }
 
-// returns image.Mcal - ff(x,y)
 int FindImageSkycellID (off_t meas, int cat, int *myTessID, int *myProjectionID, int *mySkycellID) {
 
@@ -703,5 +700,12 @@
 	  continue;
       }
-      Mrel  = getMrel  (catalog, m, c);
+
+      // 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
+      // Aperture-like magnitues.  (We have an option to use the kron magnitudes or the
+      // other apertures here).  I basically need to do this analysis separately for each
+      // magnitude type
+
+      Mrel  = getMrel  (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP);
       if (isnan(Mrel)) {
 	  Nrel ++;
@@ -774,8 +778,9 @@
     liststats_irls (refStars, Nref, &stats);
 # endif
-    image[i].Mcal       = stats.mean;
+    image[i].McalPSF    = stats.mean;
+    image[i].McalAPER   = stats.mean;
     image[i].dMcal      = stats.error;
     image[i].nFitPhotom = Nref;
-    image[i].Xm         = 100.0*log10(stats.chisq);
+    image[i].McalChiSq  = stats.chisq;
     Ncalibrated ++;
 
@@ -787,13 +792,13 @@
 
     if ((image[i].imageID == TEST_IMAGE1) || (image[i].imageID == TEST_IMAGE2)) {
-      fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].Mcal, image[i].dMcal);
+      fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].McalPSF, image[i].dMcal);
     }
 
     if (!mark && VERBOSE_IMAGE) {
-      fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].Mcal, image[i].dMcal);
+      fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].McalPSF, image[i].dMcal);
     }
 
     if (PLOTSTUFF) {
-      fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].Mcal, image[i].dMcal);
+      fprintf (stderr, "Mcal for : %s : %7.4f %7.4f\n", image[i].name, image[i].McalPSF, image[i].dMcal);
       plot_setMcal (refStars->flxlist, Nref, &stats, CLOUD_TOLERANCE);
     }
@@ -803,6 +808,6 @@
     image[i].dMagSys = stats.sigma;
 
-    if (image[i].Mcal < -CLOUD_TOLERANCE) {
-      image[i].Mcal = 0.0;
+    if (image[i].McalPSF < -CLOUD_TOLERANCE) {
+      image[i].McalPSF = 0.0;
     }
 
@@ -848,5 +853,5 @@
     if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue;
 
-    mlist[N] = image[i].Mcal;
+    mlist[N] = image[i].McalPSF;
     slist[N] = image[i].dMcal;
     dlist[N] = 1;
@@ -873,5 +878,5 @@
     mark = FALSE;
     image[i].flags &= ~ID_IMAGE_PHOTOM_POOR;
-    mark = (image[i].dMcal > MaxScatter) || (fabs(image[i].Mcal - MedOffset) > MaxOffset);
+    mark = (image[i].dMcal > MaxScatter) || (fabs(image[i].McalPSF - MedOffset) > MaxOffset);
     if (mark) { 
       Nmark ++;
@@ -961,11 +966,11 @@
     if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue;
 
-    Mlist[Nplot] = image[i].Mcal;
+    Mlist[Nplot] = image[i].McalPSF;
     dlist[Nplot] = image[i].dMcal;
     xlist[Nplot] = image[i].secz;
     minAirmass = MIN (image[i].secz, minAirmass);
     maxAirmass = MAX (image[i].secz, maxAirmass);
-    minMcal = MIN (image[i].Mcal, minMcal);
-    maxMcal = MAX (image[i].Mcal, maxMcal);
+    minMcal = MIN (image[i].McalPSF, minMcal);
+    maxMcal = MAX (image[i].McalPSF, maxMcal);
     mindMcal = MIN (image[i].dMcal, mindMcal);
     maxdMcal = MAX (image[i].dMcal, maxdMcal);
@@ -1092,5 +1097,5 @@
     if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue;
 
-    list[n] = pow (10.0, 0.01*image[i].Xm);
+    list[n] = image[i].McalChiSq;
     dlist[n] = 1;
     n++;
@@ -1125,5 +1130,5 @@
     if (FREEZE_IMAGES && isGPC1chip(image[i].photcode)) continue;
 
-    list[n] = image[i].Mcal;
+    list[n] = image[i].McalPSF;
     dlist[n] = 1;
     n++;
Index: branches/eam_branches/ohana.20170822/src/relphot/src/ImageSubset.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/ImageSubset.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/ImageSubset.c	(revision 40212)
@@ -63,5 +63,6 @@
   char type[16];
 
-  GET_COLUMN (Mcal,    	 "MCAL",         float);
+  GET_COLUMN (McalPSF, 	 "MCAL_PSF",     float);
+  GET_COLUMN (McalAPER,  "MCAL_APER",    float);
   GET_COLUMN (dMcal,   	 "MCAL_ERR",     float);
   GET_COLUMN (imageID, 	 "IMAGE_ID",     int);
@@ -79,5 +80,6 @@
   ALLOCATE (image, ImageSubset, Nrow);
   for (i = 0; i < Nrow; i++) {
-    image[i].Mcal          = Mcal[i];
+    image[i].McalPSF       = McalPSF[i];
+    image[i].McalAPER      = McalAPER[i];
     image[i].dMcal         = dMcal[i];
     image[i].imageID       = imageID[i];
@@ -93,5 +95,6 @@
   fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow);
 
-  free (Mcal);
+  free (McalPSF);
+  free (McalAPER);
   free (dMcal);
   free (imageID);
@@ -151,5 +154,5 @@
   gfits_create_table (&theader, &ftable);
 
-  float *Mcal, *dMcal;
+  float *McalPSF, *McalAPER, *dMcal;
   unsigned int *imageID, *map, *flags, *tzero;
   int *tessID, *projID, *skycellID;
@@ -158,5 +161,6 @@
 
   // create intermediate storage arrays
-  ALLOCATE (Mcal,      float, 	       Nimage);
+  ALLOCATE (McalPSF,   float, 	       Nimage);
+  ALLOCATE (McalAPER,  float, 	       Nimage);
   ALLOCATE (dMcal,     float, 	       Nimage);
   ALLOCATE (imageID,   unsigned int,   Nimage);
@@ -172,5 +176,6 @@
   // assign the storage arrays
   for (i = 0; i < Nimage; i++) {
-    Mcal[i]      = image[i].Mcal;
+    McalPSF[i]   = image[i].McalPSF;
+    McalAPER[i]  = image[i].McalAPER;
     dMcal[i]     = image[i].dMcal;
     imageID[i]   = image[i].imageID;
@@ -186,5 +191,6 @@
 
   // add the columns to the output array
-  gfits_set_bintable_column (&theader, &ftable, "MCAL",         Mcal,      Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "MCAL_PSF",     McalPSF,   Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "MCAL_APER",    McalAPER,  Nimage);
   gfits_set_bintable_column (&theader, &ftable, "MCAL_ERR",     dMcal,     Nimage);
   gfits_set_bintable_column (&theader, &ftable, "IMAGE_ID",     imageID,   Nimage);
@@ -198,5 +204,6 @@
   gfits_set_bintable_column (&theader, &ftable, "UBERCAL_DIST", ucdist,    Nimage);
 
-  free (Mcal);
+  free (McalPSF);
+  free (McalAPER);
   free (dMcal);
   free (imageID);
Index: branches/eam_branches/ohana.20170822/src/relphot/src/MosaicOps.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/MosaicOps.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/MosaicOps.c	(revision 40212)
@@ -111,13 +111,14 @@
     
     /* a new mosaic, define ranges -- preserve the original values incase this image is not used */
-    mosaic[Nmosaic].start  = start;
-    mosaic[Nmosaic].stop   = stop;
-    mosaic[Nmosaic].Mcal   = 0.0; // note : mosaic stores only offsets relative to the original image values
-    mosaic[Nmosaic].dMcal  = 0.0; // note : at the end, mosaic.Mcal is added back to the input images
-    mosaic[Nmosaic].dMsys  = 0.0;
-    mosaic[Nmosaic].Xm = 0.0;
-    mosaic[Nmosaic].flags  = image[i].flags;
-    mosaic[Nmosaic].secz   = image[i].secz;
-    mosaic[Nmosaic].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode);
+    mosaic[Nmosaic].start     = start;
+    mosaic[Nmosaic].stop      = stop;
+    mosaic[Nmosaic].McalPSF   = 0.0; // note : at the end, mosaic.Mcal is added back to the input images
+    mosaic[Nmosaic].McalAPER  = 0.0; // note : mosaic stores only offsets relative to the original image values
+    mosaic[Nmosaic].dMcal     = 0.0; // note : at the end, mosaic.Mcal is added back to the input images
+    mosaic[Nmosaic].dMsys     = 0.0;
+    mosaic[Nmosaic].McalChiSq = 0.0;// NAN or 0.0?
+    mosaic[Nmosaic].flags     = image[i].flags;
+    mosaic[Nmosaic].secz      = image[i].secz;
+    mosaic[Nmosaic].photcode  = GetPhotcodeEquivCodebyCode (image[i].photcode);
 
     // XXX do we need to do something about flag consistency across a mosaic?
@@ -208,14 +209,15 @@
   for (i = 0; i < Nmosaic; i++) {
     /* a new mosaic, define ranges */
-    mosaic[i].start    = startTimesMosaic[i];
-    mosaic[i].stop     = 0;
-    mosaic[i].Mcal     = 0.0;
-    mosaic[i].dMcal    = 0.0;
-    mosaic[i].dMsys    = 0.0;
-    mosaic[i].Xm       = 0.0;
-    mosaic[i].flags    = 0;
-    mosaic[i].secz     = NAN;
-    mosaic[i].photcode = 0;
-    mosaic[i].skipCal  = FALSE;
+    mosaic[i].start     = startTimesMosaic[i];
+    mosaic[i].stop      = 0;
+    mosaic[i].McalPSF   = 0.0; // note : at the end, mosaic.Mcal is added back to the input images
+    mosaic[i].McalAPER  = 0.0; // note : mosaic stores only offsets relative to the original image values
+    mosaic[i].dMcal     = 0.0; // note : at the end, mosaic.Mcal is added back to the input images
+    mosaic[i].dMsys     = 0.0;
+    mosaic[i].McalChiSq = 0.0;// NAN or 0.0?
+    mosaic[i].flags     = 0;
+    mosaic[i].secz      = NAN;
+    mosaic[i].photcode  = 0;
+    mosaic[i].skipCal   = FALSE;
     
     memset (&mosaic[i].coords, 0, sizeof(Coords));
@@ -294,12 +296,15 @@
       abort();
     }
-    mosaic[j].stop     = stop;
-    mosaic[j].Mcal     = 0.0;
-    mosaic[j].dMcal    = 0.0;
-    mosaic[j].Xm       = 0.0;
-    mosaic[j].dMsys    = subset[i].flags;
-    mosaic[j].flags    = subset[i].flags;
-    mosaic[j].secz     = subset[i].secz;
-    mosaic[j].photcode = GetPhotcodeEquivCodebyCode (subset[i].photcode);
+    mosaic[j].stop      = stop;
+
+    mosaic[j].McalPSF   = 0.0;
+    mosaic[j].McalAPER  = 0.0;
+    mosaic[j].dMcal     = 0.0;
+    mosaic[j].McalChiSq = 0.0;
+
+    mosaic[j].dMsys     = subset[i].flags;
+    mosaic[j].flags     = subset[i].flags;
+    mosaic[j].secz      = subset[i].secz;
+    mosaic[j].photcode  = GetPhotcodeEquivCodebyCode (subset[i].photcode);
   }
 
@@ -377,14 +382,15 @@
   // init the mosaic array values
   for (i = 0; i < Nmosaic; i++) {
-    mosaic[i].start    = startTimesMosaic[i];
-    mosaic[i].stop     = 0;
-    mosaic[i].Mcal     = 0.0;
-    mosaic[i].dMcal    = 0.0;
-    mosaic[i].dMsys    = 0.0;
-    mosaic[i].Xm       = 0.0;
-    mosaic[i].flags    = 0;
-    mosaic[i].secz     = NAN;
-    mosaic[i].photcode = 0;
-    mosaic[i].skipCal  = FALSE;
+    mosaic[i].start     = startTimesMosaic[i];
+    mosaic[i].stop      = 0;
+    mosaic[i].McalPSF   = 0.0; // note : at the end, mosaic.Mcal is added back to the input images
+    mosaic[i].McalAPER  = 0.0; // note : mosaic stores only offsets relative to the original image values
+    mosaic[i].dMcal     = 0.0; // note : at the end, mosaic.Mcal is added back to the input images
+    mosaic[i].dMsys     = 0.0;
+    mosaic[i].McalChiSq = 0.0;// NAN or 0.0?
+    mosaic[i].flags     = 0;
+    mosaic[i].secz      = NAN;
+    mosaic[i].photcode  = 0;
+    mosaic[i].skipCal   = FALSE;
     
     memset (&mosaic[i].coords, 0, sizeof(Coords));
@@ -438,11 +444,12 @@
     }
     mosaic[j].stop     = stop;
-    mosaic[j].Mcal     = 0.0;
-    mosaic[j].dMcal    = 0.0;
-    mosaic[j].Xm       = 0.0;
-    mosaic[j].dMsys    = image[i].flags;
-    mosaic[j].flags    = image[i].flags;
-    mosaic[j].secz     = image[i].secz;
-    mosaic[j].photcode = GetPhotcodeEquivCodebyCode (image[i].photcode);
+    mosaic[j].McalPSF   = 0.0;
+    mosaic[j].McalAPER  = 0.0;
+    mosaic[j].dMcal     = 0.0;
+    mosaic[j].McalChiSq = 0.0;
+    mosaic[j].dMsys     = image[i].flags;
+    mosaic[j].flags     = image[i].flags;
+    mosaic[j].secz      = image[i].secz;
+    mosaic[j].photcode  = GetPhotcodeEquivCodebyCode (image[i].photcode);
   }
   MARKTIME("assign images to mosaic: %f sec\n", dtime);
@@ -594,7 +601,9 @@
     mosaic[i].coords.cdelt2 = 1.0 / 3600.0;
 
-    mosaic[i].Mcal   = 0.0;
-    mosaic[i].dMcal  = 0.0;
-    mosaic[i].Xm     = 0.0;
+    mosaic[i].McalPSF   = 0.0; 
+    mosaic[i].McalAPER  = 0.0; 
+    mosaic[i].dMcal     = 0.0; 
+    mosaic[i].dMsys     = 0.0;
+    mosaic[i].McalChiSq = 0.0; 
   }
   return;
@@ -612,5 +621,5 @@
   double dS, dX, dY;
   double R, D, Rmin, Rmax, Dmin, Dmax;
-  double Mcal, dMcal, Xm;
+  double McalPSF, McalAPER, dMcal, McalChiSq;
 
   fprintf (stderr, "*** moving Mcal from image.Mcal to mosaic.Mcal ***\n");
@@ -621,5 +630,5 @@
     Dmax = Rmax = -360.0;
     dS = 0.0;
-    Mcal = dMcal = Xm = 0;
+    McalPSF = McalAPER = dMcal = McalChiSq = 0;
     for (j = 0; j < MosaicN_Image[i]; j++) {
       m = MosaicToImage[i][j];
@@ -678,11 +687,13 @@
       // if it helps, note that ubercal uses a single zp per exposure, so the mean of those values is the same as the value
 
-      Mcal  += image[m].Mcal;
-      dMcal += image[m].dMcal;
-      Xm    += image[m].Xm;
-
-      image[m].Mcal   = 0.0;
-      image[m].dMcal  = NAN;
-      image[m].Xm     = NAN_S_SHORT;
+      McalPSF   += image[m].McalPSF;
+      McalAPER  += image[m].McalAPER;
+      dMcal     += image[m].dMcal;
+      McalChiSq += image[m].McalChiSq;
+
+      image[m].McalPSF   = 0.0;
+      image[m].McalAPER  = 0.0;
+      image[m].dMcal     = NAN;
+      image[m].McalChiSq = NAN;
     }
     dS /= MosaicN_Image[i];
@@ -696,7 +707,8 @@
     RD_to_XY (&dX, &dY, Rmax, Dmax, &mosaic[i].coords);
 
-    mosaic[i].Mcal   = Mcal / MosaicN_Image[i];
-    mosaic[i].dMcal  = dMcal / MosaicN_Image[i];
-    mosaic[i].Xm     = Xm / MosaicN_Image[i];
+    mosaic[i].McalPSF   = McalPSF / MosaicN_Image[i];
+    mosaic[i].McalAPER  = McalAPER / MosaicN_Image[i];
+    mosaic[i].dMcal     = dMcal / MosaicN_Image[i];
+    mosaic[i].McalChiSq = McalChiSq / MosaicN_Image[i];
   }
   if (!USE_GRID) return;
@@ -724,14 +736,16 @@
     for (j = 0; j < MosaicN_Image[i]; j++) {
       im = MosaicToImage[i][j];
-      image[im].Mcal += mosaic[i].Mcal;
-      image[im].dMcal = mosaic[i].dMcal;
-      image[im].Xm = mosaic[i].Xm;
+      image[im].McalPSF    += mosaic[i].McalPSF;
+      image[im].McalAPER   += mosaic[i].McalAPER;
+      image[im].dMcal       = mosaic[i].dMcal;
+      image[im].McalChiSq   = mosaic[i].McalChiSq;
       image[im].ubercalDist = mosaic[i].ubercalDist;
-      image[im].dMagSys = mosaic[i].dMsys;
-      image[im].nFitPhotom = mosaic[i].nFitPhotom;
-      image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_FEW);
-      image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_POOR);
-    }
-    mosaic[i].Mcal = 0.0;
+      image[im].dMagSys     = mosaic[i].dMsys;
+      image[im].nFitPhotom  = mosaic[i].nFitPhotom;
+      image[im].flags 	   |= (mosaic[i].flags & ID_IMAGE_PHOTOM_FEW);
+      image[im].flags 	   |= (mosaic[i].flags & ID_IMAGE_PHOTOM_POOR);
+    }
+    mosaic[i].McalPSF  = 0.0;
+    mosaic[i].McalAPER = 0.0;
   }      
 }
@@ -886,5 +900,5 @@
 
   if (mosaic[i].flags & IMAGE_BAD) return (NAN);  
-  value = mosaic[i].Mcal;
+  value = mosaic[i].McalPSF;
   return (value);
 }
@@ -1130,8 +1144,9 @@
     off_t c = MosaicToCatalog[Nmos][j];
       
+    // NOTE : we are only using Mcal == McalPSF in this function; we set McalAPER to McalPSF
     if (fout) {
       Mcal  = getMcal  (m, c, flatcorr, catalog);
       Mgrid = getMgrid (m, c);
-      Mrel  = getMrel  (catalog, m, c);
+      Mrel  = getMrel  (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP);
       Mflat = getMflat (m, c, flatcorr, catalog);
 
@@ -1160,5 +1175,5 @@
       continue;
     }
-    Mrel  = getMrel  (catalog, m, c);
+    Mrel  = getMrel  (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP);
     if (isnan(Mrel)) {
       info->Nrel ++;
@@ -1226,8 +1241,10 @@
   if (VERBOSE2 && info->PoorImages) fprintf (stderr, "Mmos: %f %f %d %d\n", stats.mean, stats.sigma, stats.Nmeas, N);
 
-  myMosaic[0].Mcal  = stats.mean;
-  myMosaic[0].dMcal = stats.error;
+  // for now, I have no reason to measure these separately for camera-level images
+  myMosaic[0].McalPSF    = stats.mean;
+  myMosaic[0].McalAPER   = stats.mean;
+  myMosaic[0].dMcal      = stats.error;
+  myMosaic[0].McalChiSq  = stats.chisq;
   myMosaic[0].nFitPhotom = N;
-  myMosaic[0].Xm    = 100.0*log10(stats.chisq);
 
   if (testImage) {
@@ -1244,10 +1261,10 @@
   myMosaic[0].dMsys = stats.sigma;
 
-  if (myMosaic[0].Mcal < -CLOUD_TOLERANCE) {
-    myMosaic[0].Mcal = 0.0;
+  if (myMosaic[0].McalPSF < -CLOUD_TOLERANCE) {
+    myMosaic[0].McalPSF = 0.0;
   }
 
   if (testImage) {
-    fprintf (stderr, "%f %f  :  %f\n", myMosaic[0].Mcal, myMosaic[0].dMsys, pow (10.0, 0.01*myMosaic[0].Xm));
+    fprintf (stderr, "%f %f  :  %f\n", myMosaic[0].McalPSF, myMosaic[0].dMsys, myMosaic[0].McalChiSq);
   }
 
@@ -1427,15 +1444,15 @@
     imageOffset[i] = 0.0;
 
-    if (VERBOSE2 && (fabs(mosaic[i].Mcal) < CLOUD_TOLERANCE)) {
-      fprintf (stderr, "cloud-free: %s : %f\n", image[MosaicToImage[i][0]].name, mosaic[i].Mcal);
+    if (VERBOSE2 && (fabs(mosaic[i].McalPSF) < CLOUD_TOLERANCE)) {
+      fprintf (stderr, "cloud-free: %s : %f\n", image[MosaicToImage[i][0]].name, mosaic[i].McalPSF);
     } 
-    if (VERBOSE2 && (mosaic[i].Mcal < -CLOUD_TOLERANCE)) {
-      imageOffset[i] = -mosaic[i].Mcal; 
-      // NOTE the negative sign: down below, we are going to add in the negative of Mcal
+    if (VERBOSE2 && (mosaic[i].McalPSF < -CLOUD_TOLERANCE)) {
+      imageOffset[i] = -mosaic[i].McalPSF; 
+      // NOTE the negative sign: down below, we are going to add in the negative of McalPSF
       // to this image, and the propagated mean values for other images
-      fprintf (stderr, "anti-clouds: %s : %f\n", image[MosaicToImage[i][0]].name, mosaic[i].Mcal);
+      fprintf (stderr, "anti-clouds: %s : %f\n", image[MosaicToImage[i][0]].name, mosaic[i].McalPSF);
     } 
-    if (VERBOSE2 && (mosaic[i].Mcal > CLOUD_TOLERANCE)) {
-      fprintf (stderr, "cloudy    : %s : %f\n", image[MosaicToImage[i][0]].name, mosaic[i].Mcal);
+    if (VERBOSE2 && (mosaic[i].McalPSF > CLOUD_TOLERANCE)) {
+      fprintf (stderr, "cloudy    : %s : %f\n", image[MosaicToImage[i][0]].name, mosaic[i].McalPSF);
     } 
   }
@@ -1540,5 +1557,5 @@
     }
 
-    // a negative cloud image (cloud: Mcal > 0; anti-clouds: Mcal < 0; imageOffset = -Mcal)
+    // a negative cloud image (cloud: McalPSF > 0; anti-clouds: McalPSF < 0; imageOffset = -McalPSF)
     if (imageOffset[i] > 0.0) continue;
 
@@ -1564,5 +1581,5 @@
   // find the images / mosaics with negative clouds and save their offset
   for (i = 0; i < Nmosaic; i++) {
-    mosaic[i].Mcal += imageOffset[i];
+    mosaic[i].McalPSF += imageOffset[i];
   }
 
@@ -1605,5 +1622,5 @@
     if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue;
 
-    list[n] = mosaic[i].Mcal;
+    list[n] = mosaic[i].McalPSF;
     dlist[n] = 1;
     n++;
@@ -1681,5 +1698,5 @@
       Mgrid = getMgrid (m, c);
       if (isnan(Mgrid)) continue;
-      Mrel = getMrel  (catalog, m, c);
+      Mrel = getMrel  (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP);
       if (isnan(Mrel)) continue;
       N++;
@@ -1719,5 +1736,5 @@
     if (KEEP_UBERCAL && (mosaic[i].flags & ID_IMAGE_PHOTOM_UBERCAL)) continue;
 
-    list[n]  = pow (10.0, 0.01*mosaic[i].Xm);
+    list[n]  = mosaic[i].McalChiSq;
     dlist[n] = 1;
     n++;
@@ -1751,5 +1768,5 @@
     if (mosaic[i].flags & IMAGE_BAD) continue;
     if (mosaic[i].skipCal) continue;
-    mlist[N] = mosaic[i].Mcal;
+    mlist[N] = mosaic[i].McalPSF;
     slist[N] = mosaic[i].dMcal;
     dlist[N] = 1;
@@ -1781,5 +1798,5 @@
       Nscatter ++;
     }
-    if (fabs(mosaic[i].Mcal - MedOffset) > MaxOffset) {
+    if (fabs(mosaic[i].McalPSF - MedOffset) > MaxOffset) {
       mark = TRUE;
       Noffset ++;
@@ -1858,5 +1875,5 @@
 
   for (i = 0; i < Nmosaic; i++) {
-    Mlist[i] = mosaic[i].Mcal;
+    Mlist[i] = mosaic[i].McalPSF;
     dlist[i] = mosaic[i].dMcal;
     xlist[i] = mosaic[i].secz;
Index: branches/eam_branches/ohana.20170822/src/relphot/src/StarOps.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/StarOps.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/StarOps.c	(revision 40212)
@@ -34,22 +34,66 @@
 }  
 
-float getMrel (Catalog *catalog, off_t meas, int cat) {
-
-  int Nsec, Nsecfilt, photcode;
-  int ave;
-  float value;
-
-  ave = catalog[cat].measureT[meas].averef;
-  photcode = catalog[cat].measureT[meas].photcode;
+// 
+float getMrel (Catalog *catalog, off_t meas, int cat, dvoMagClassType class, dvoMagSourceType source) {
+
+  int ave = catalog[cat].measureT[meas].averef;
+  int photcode = catalog[cat].measureT[meas].photcode;
 
   int ecode = GetPhotcodeEquivCodebyCode (photcode);
-  Nsec = GetPhotcodeNsec(ecode);
-  Nsecfilt = GetPhotcodeNsecfilt ();
+  int Nsec = GetPhotcodeNsec(ecode);
+  int Nsecfilt = GetPhotcodeNsecfilt ();
+
+  int entry = Nsecfilt*ave+Nsec;
+
+  SecFilt *secfilt = &catalog[cat].secfilt[entry];
 
   // is this star OK?
-  if (catalog[cat].secfilt[Nsecfilt*ave+Nsec].flags & STAR_BAD) return (NAN);  
- 
-  value = catalog[cat].secfilt[Nsecfilt*ave+Nsec].M;
-  return (value);
+  if (secfilt->flags & STAR_BAD) return (NAN);  
+
+  switch (class) {
+    case MAG_CLASS_PSF:
+      switch (source) {
+	case MAG_SRC_CHP:
+	  return secfilt->MpsfChp;
+	case MAG_SRC_WRP:
+	  return secfilt->MpsfWrp;
+	case MAG_SRC_STK:
+	  return secfilt->MpsfStk;
+	default:
+	  return NAN;
+      }
+      break;
+    case MAG_CLASS_KRON:
+      switch (source) {
+	case MAG_SRC_CHP:
+	  return secfilt->MkronChp;
+	case MAG_SRC_WRP:
+	  return secfilt->MkronWrp;
+	case MAG_SRC_STK:
+	  return secfilt->MkronStk;
+	default:
+	  return NAN;
+      }
+      break;
+    case MAG_CLASS_APER:
+      switch (source) {
+	case MAG_SRC_CHP:
+	  return secfilt->MapChp;
+	case MAG_SRC_WRP:
+	  return secfilt->MapWrp;
+	case MAG_SRC_STK:
+	  return secfilt->MapStk;
+	default:
+	  return NAN;
+      }
+      break;
+    case MAG_CLASS_NONE:
+    case MAG_CLASS_DEV: // DeVaucouleur Model (only for galphot)
+    case MAG_CLASS_EXP: // Exponential Model (only for galphot)
+    case MAG_CLASS_SER: // Sersic Model (only for galphot)
+      return NAN;
+      break;
+  }
+  return NAN; // should not be able to reach here
 }
 
@@ -513,5 +557,5 @@
   if (VERBOSE) fprintf (stderr, "marking poor stars\n");
 
-  /* find Xm median -> ChiSq lim must be > median */
+  /* find Mchisq median -> ChiSq lim must be > median */
   for (i = Ntot = 0; i < Ncatalog; i++) {
     Ntot += catalog[i].Naverage; 
@@ -535,5 +579,5 @@
 	if (isnan(Mchisq)) continue;
 	xlist[Ntot] = Mchisq;
-	slist[Ntot] = catalog[i].secfilt[Nsecfilt*j+Nsec].dM;
+	slist[Ntot] = catalog[i].secfilt[Nsecfilt*j+Nsec].dMpsfChp;
 	dlist[Ntot] = 1;
 	Ntot ++;
@@ -551,5 +595,5 @@
     for (i = 0; i < Ncatalog; i++) {
       for (j = 0; j < catalog[i].Naverage; j++) {
-	dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dM;
+	dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dMpsfChp;
 	float Mchisq = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq;
 	mark = (dM > MaxScatter) || (isnan(Mchisq)) || (Mchisq > MaxChisq);
@@ -865,5 +909,5 @@
       if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue;  
 
-      dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dM;
+      dM = catalog[i].secfilt[Nsecfilt*j+Nsec].dMpsfChp;
       if (isnan(dM)) continue;
       list[n] = dM;
@@ -906,5 +950,5 @@
       for (j = 0; j < catalog[i].Naverage; j++) {
 	if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue;  
-	dMrel = catalog[i].secfilt[Nsecfilt*j+Nsec].dM;
+	dMrel = catalog[i].secfilt[Nsecfilt*j+Nsec].dMpsfChp;
 	bin = dMrel / 0.00025;
 	bin = MAX (0, MIN (NBIN-1, bin));
@@ -946,5 +990,5 @@
       for (j = 0; j < catalog[i].Naverage; j++) {
 	if (catalog[i].secfilt[Nsecfilt*j+Nsec].flags & STAR_BAD) continue;
-	xlist[N] = catalog[i].secfilt[Nsecfilt*j+Nsec].M;
+	xlist[N] = catalog[i].secfilt[Nsecfilt*j+Nsec].MpsfChp;
 	value    = catalog[i].secfilt[Nsecfilt*j+Nsec].Mchisq;
 	if (isnan((double)(value))) continue;
Index: branches/eam_branches/ohana.20170822/src/relphot/src/plot_scatter.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/plot_scatter.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/plot_scatter.c	(revision 40212)
@@ -47,5 +47,5 @@
 		if (isnan(Mgrid)) continue;
 
-		Mrel = catalog[i].secfilt[Nsecfilt*j+Nsec].M;
+		Mrel = catalog[i].secfilt[Nsecfilt*j+Nsec].MpsfChp;
 		if (isnan(Mrel)) continue;
 
Index: branches/eam_branches/ohana.20170822/src/relphot/src/relphot_synthphot_catalog.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/relphot_synthphot_catalog.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/relphot_synthphot_catalog.c	(revision 40212)
@@ -92,8 +92,8 @@
       float *value = (float *) zpts->matrix[Nsec].buffer;
       float ZP = !isnan(value[Npix]) ? value[Npix] : 0.0;
-      secfilt[Nsec].M  	 = measure[measSYN[i]].M + ZP;
-      secfilt[Nsec].dM 	 = 0.6;
-      secfilt[Nsec].Mchisq = NAN;
-      secfilt[Nsec].flags |= ID_SECF_USE_SYNTH;
+      secfilt[Nsec].MpsfChp  = measure[measSYN[i]].M + ZP;
+      secfilt[Nsec].dMpsfChp = 0.6;
+      secfilt[Nsec].Mchisq   = NAN;
+      secfilt[Nsec].flags   |= ID_SECF_USE_SYNTH;
     }
   }
Index: branches/eam_branches/ohana.20170822/src/relphot/src/select_images.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/select_images.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/select_images.c	(revision 40212)
@@ -259,7 +259,8 @@
       if (RESET_ZEROPTS) {
 	if (!KEEP_UBERCAL || !(image[nimage].flags & ID_IMAGE_PHOTOM_UBERCAL)) {
-	  image[nimage].Mcal = 0.0;
-	  image[nimage].dMcal = NAN;
-	  image[nimage].flags &= ~ID_IMAGE_PHOTOM_UBERCAL;
+	  image[nimage].McalPSF  = 0.0;
+	  image[nimage].McalAPER = 0.0;
+	  image[nimage].dMcal    = NAN;
+	  image[nimage].flags   &= ~ID_IMAGE_PHOTOM_UBERCAL;
 	}
       }
Index: branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c	(revision 40212)
@@ -377,8 +377,8 @@
 	}
       }
-      secfilt[Nsec].M      = Mpsf + ZP;
-      secfilt[Nsec].dM     = 0.6;
-      secfilt[Nsec].Mchisq = 0.0;
-      secfilt[Nsec].flags |= ID_SECF_USE_SYNTH;
+      secfilt[Nsec].MpsfChp  = Mpsf + ZP;
+      secfilt[Nsec].dMpsfChp = 0.6;
+      secfilt[Nsec].Mchisq   = 0.0;
+      secfilt[Nsec].flags   |= ID_SECF_USE_SYNTH;
       continue;
     } 
@@ -390,7 +390,7 @@
       secfilt[Nsec].flags |= ID_OBJ_FEW;
     } else {
-      secfilt[Nsec].M  	 = psfstats->mean;
-      secfilt[Nsec].dM 	 = psfstats->error;
-      secfilt[Nsec].Mchisq = (psfstats->Nmeas > 1) ? psfstats->chisq : NAN;
+      secfilt[Nsec].MpsfChp  = psfstats->mean;
+      secfilt[Nsec].dMpsfChp = psfstats->error;
+      secfilt[Nsec].Mchisq   = (psfstats->Nmeas > 1) ? psfstats->chisq : NAN;
     }
     int minRankPSF = (Nranking > 0) ? results->psfData[Nsec].ranking[0] : 10;
@@ -410,8 +410,8 @@
 
       if (Nranking) {
-	secfilt[Nsec].Mstdev = psfstats->sigma;
-	secfilt[Nsec].Nused  = psfstats->Nmeas;
-	secfilt[Nsec].Mmax   = psfstats->max;
-	secfilt[Nsec].Mmin   = psfstats->min;
+	secfilt[Nsec].sMpsfChp = psfstats->sigma;
+	secfilt[Nsec].Nused    = psfstats->Nmeas;
+	secfilt[Nsec].Mmax     = psfstats->max;
+	secfilt[Nsec].Mmin     = psfstats->min;
       }
       secfilt[Nsec].psfQfMax     = results->psfQfMax[Nsec];
@@ -424,7 +424,7 @@
       Nranking = MAG_STATS_BY_RANKING (&results->aperData[Nsec], apstats);
       if (Nranking) {
-	secfilt[Nsec].Map     = apstats->mean; 
-	secfilt[Nsec].dMap    = apstats->error; 
-	secfilt[Nsec].sMap    = apstats->sigma; 
+	secfilt[Nsec].MapChp  = apstats->mean; 
+	secfilt[Nsec].dMapChp = apstats->error; 
+	secfilt[Nsec].sMapChp = apstats->sigma; 
 	secfilt[Nsec].NusedAp = Nranking;
       }
@@ -435,7 +435,7 @@
       Nranking = MAG_STATS_BY_RANKING (&results->kronData[Nsec], kronstats);
       if (Nranking) {
-	secfilt[Nsec].Mkron     = kronstats->mean; 
-	secfilt[Nsec].dMkron    = kronstats->error; 
-	secfilt[Nsec].sMkron    = kronstats->sigma; 
+	secfilt[Nsec].MkronChp  = kronstats->mean; 
+	secfilt[Nsec].dMkronChp = kronstats->error; 
+	secfilt[Nsec].sMkronChp = kronstats->sigma; 
 	secfilt[Nsec].NusedKron = Nranking;
       }
Index: branches/eam_branches/ohana.20170822/src/relphot/src/setMrelFinal.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/setMrelFinal.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/setMrelFinal.c	(revision 40212)
@@ -105,5 +105,5 @@
   ALLOCATE (catalog[0].measureRank, char, catalog[0].Nmeasure);
   setMeasureRank (catalog);
-  setMrelOutput (catalog, 1, flatcorr); // sets the values secfilt.M = <measure.M + measure.Mflat - image.Mcal>
+  setMrelOutput (catalog, 1, flatcorr); // sets the values secfilt.MpsfChp = <measure.M + measure.Mflat - image.Mcal>
   setMcalOutput (catalog, 1, flatcorr); // sets measure.Mcal = image.Mcal
 
Index: branches/eam_branches/ohana.20170822/src/relphot/src/share_image_mags.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/share_image_mags.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/share_image_mags.c	(revision 40212)
@@ -74,8 +74,9 @@
       continue;
     }
-    images[seq].Mcal  	    = image_mags[i].Mcal;
+    images[seq].McalPSF     = image_mags[i].McalPSF;
+    images[seq].McalAPER    = image_mags[i].McalAPER;
     images[seq].dMcal  	    = image_mags[i].dMcal;
     images[seq].dMagSys	    = image_mags[i].dMagSys;
-    images[seq].Xm  	    = image_mags[i].Xm;
+    images[seq].McalChiSq   = image_mags[i].McalChiSq;
     images[seq].nFitPhotom  = image_mags[i].nFitPhotom;
     images[seq].flags 	    = image_mags[i].flags;
@@ -91,8 +92,9 @@
 int set_image_mags (ImageMag *image_mags, Image *image) {
 
-  image_mags->Mcal  	  = image->Mcal;
+  image_mags->McalPSF  	  = image->McalPSF;
+  image_mags->McalAPER 	  = image->McalAPER;
   image_mags->dMcal  	  = image->dMcal;
   image_mags->dMagSys	  = image->dMagSys;
-  image_mags->Xm  	  = image->Xm;
+  image_mags->McalChiSq	  = image->McalChiSq;
   image_mags->nFitPhotom  = image->nFitPhotom;
   image_mags->flags 	  = image->flags;
Index: branches/eam_branches/ohana.20170822/src/relphot/src/share_mean_mags.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/share_mean_mags.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/share_mean_mags.c	(revision 40212)
@@ -111,5 +111,5 @@
     if (Nsec < 0) continue;
 
-    catalog[catSeq].secfilt[objSeq*Nsecfilt + Nsec].M = meanmags[i].M;
+    catalog[catSeq].secfilt[objSeq*Nsecfilt + Nsec].MpsfChp = meanmags[i].M;
   }
   free (meanmags);
@@ -122,6 +122,6 @@
 int set_mean_mags (MeanMag *meanmags, AverageTiny *average, SecFilt *secfilt, int Nsec) {
 
-  meanmags->M  = secfilt->M;
-  meanmags->dM = secfilt->dM;
+  meanmags->M  = secfilt->MpsfChp;
+  meanmags->dM = secfilt->dMpsfChp;
   meanmags->Mchisq = secfilt->Mchisq;
   meanmags->Nsec = Nsec; // key to secfilt entry
Index: branches/eam_branches/ohana.20170822/src/relphot/src/synthetic_mags.c
===================================================================
--- branches/eam_branches/ohana.20170822/src/relphot/src/synthetic_mags.c	(revision 40122)
+++ branches/eam_branches/ohana.20170822/src/relphot/src/synthetic_mags.c	(revision 40212)
@@ -37,6 +37,6 @@
   // (r - i > 0.5) : w = r + 0.268 - 0.435 (r-i) - 0.078(r-i)^2
 
-  float Mr = secfilt[NSr].M;
-  float Mi = secfilt[NSi].M;
+  float Mr = secfilt[NSr].MpsfChp;
+  float Mi = secfilt[NSi].MpsfChp;
 
   if (!isfinite(Mr)) return FALSE;
