Index: /branches/eam_branches/ohana.20170822/src/addstar/src/FilterStars.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/FilterStars.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/FilterStars.c	(revision 40212)
@@ -73,5 +73,5 @@
     outcat->measure[N].airmass = airmass (image[0].secz, outcat->average[N].R, outcat->average[N].D, image[0].sidtime, image[0].latitude);
     outcat->measure[N].az      = azimuth (15.0*image[0].sidtime - outcat->average[N].R, outcat->average[N].D, image[0].latitude);
-    outcat->measure[N].Mcal    = image[0].Mcal;
+    outcat->measure[N].Mcal    = image[0].McalPSF;
     outcat->measure[N].t       = image[0].tzero + 1e-4*outcat->measure[N].Yccd*image[0].trate;  /* trate is in 0.1 msec / row */
     outcat->measure[N].dt      = MTIME;
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/LoadDataPMM.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/LoadDataPMM.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/LoadDataPMM.c	(revision 40212)
@@ -234,12 +234,14 @@
     // altaz (&alt, &az, 15.0*image[0].sidtime - image[0].coords.crval1, image[0].coords.crval2, Latitude);
 
+    // secz is in units of airmass
     image[0].trate = 0.0;
     image[0].secz = 1.0;
     image[0].ccdnum = 0;
 
-    // secz is in units milli-airmass
-    image[0].Mcal = 0.0;
-    image[0].Xm   = NAN_S_SHORT;
-    image[0].flags = 0;
+    image[0].McalPSF   = 0.0;
+    image[0].McalAPER  = 0.0;
+    image[0].McalChiSq = NAN;
+    image[0].dMcal     = NAN;
+    image[0].flags     = 0;
 
     image[0].nstar = 0;
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/ReadImageHeader.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/ReadImageHeader.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/ReadImageHeader.c	(revision 40212)
@@ -265,9 +265,9 @@
   }
 
-  /* secz is in units milli-airmass */
-  image[0].Mcal = ZERO_POINT_OFFSET;
-  image[0].dMcal = ZERO_POINT_ERROR;
-  image[0].Xm   = NAN_S_SHORT;
-  image[0].flags = 0;
+  image[0].McalPSF   = ZERO_POINT_OFFSET;
+  image[0].McalAPER  = ZERO_POINT_OFFSET;
+  image[0].dMcal     = ZERO_POINT_ERROR;
+  image[0].McalChiSq = NAN;
+  image[0].flags     = 0;
 
   /* find expected number of stars */
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/ReadSDSSHeader.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/ReadSDSSHeader.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/ReadSDSSHeader.c	(revision 40212)
@@ -47,6 +47,8 @@
 
   // secz is in units milli-airmass
-  image[0].Mcal = 0.0;
-  image[0].Xm   = NAN_S_SHORT;
+  image[0].McalPSF   = 0.0;
+  image[0].McalAPER  = 0.0;
+  image[0].McalChiSq = NAN;
+  image[0].dMcal     = NAN;
   image[0].code = 0;
   memset (image[0].dummy, 0, sizeof(image[0].dummy));
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/ReadStarsSDSS.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/ReadStarsSDSS.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/ReadStarsSDSS.c	(revision 40212)
@@ -258,12 +258,14 @@
     altaz (&alt, &az, 15.0*images[N].sidtime - images[N].coords.crval1, images[N].coords.crval2, Latitude);
 
+    // secz is in units of airmass
     images[N].trate = clockRate * 1e-4;
     images[N].secz = catalog->measure[0].airmass;
     images[N].ccdnum = camcol;
 
-    // secz is in units milli-airmass
-    images[N].Mcal = 0.0;
-    images[N].Xm   = NAN_S_SHORT;
-    images[N].flags = 0;
+    images[N].McalPSF   = 0.0;
+    images[N].McalAPER  = 0.0;
+    images[N].McalChiSq = NAN;
+    images[N].dMcal     = NAN;
+    images[N].flags     = 0;
 
     images[N].nstar = Nstars;
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/ReadStarsUKIRT.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/ReadStarsUKIRT.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/ReadStarsUKIRT.c	(revision 40212)
@@ -251,7 +251,9 @@
 
     // secz is in units milli-airmass
-    images[N].Mcal = Mcal;
-    images[N].Xm   = NAN_S_SHORT;
-    images[N].flags = 0;
+    images[N].McalPSF   = Mcal;
+    images[N].McalAPER  = Mcal;
+    images[N].McalChiSq = NAN;
+    images[N].dMcal     = NAN;
+    images[N].flags     = 0;
 
     images[N].nstar = Nstars;
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/calibrate.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/calibrate.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/calibrate.c	(revision 40212)
@@ -74,6 +74,6 @@
   /* check if this reference code is an average magnitude */
   if (Nsec != -1) {
-    CalM0 = secfilt[Nsec].M;
-    dCalM = secfilt[Nsec].dM;
+    CalM0 = secfilt[Nsec].MpsfChp;
+    dCalM = secfilt[Nsec].dMpsfChp;
     found0 = TRUE;
   }
@@ -82,5 +82,5 @@
   Nsec  = GetPhotcodeNsec (CalC1);
   if (Nsec != -1) {
-    CalM1 = secfilt[Nsec].M;
+    CalM1 = secfilt[Nsec].MpsfChp;
     found1 = TRUE;
   }
@@ -89,5 +89,5 @@
   Nsec  = GetPhotcodeNsec (CalC2);
   if (Nsec != -1) {
-    CalM2 = secfilt[Nsec].M;
+    CalM2 = secfilt[Nsec].MpsfChp;
     found2 = TRUE;
   }
@@ -151,6 +151,7 @@
   if (MaxN == -1) {
     fprintf (stderr, "no clean stars\n");
-    image[0].Mcal = 10.000;
-    image[0].dMcal = 10.000;
+    image[0].McalPSF  = 10.000;
+    image[0].McalAPER = 10.000;
+    image[0].dMcal    = 10.000;
     return;
   }
@@ -187,6 +188,7 @@
   if (Nkeep < 5) {
     fprintf (stderr, "too few stars\n");
-    image[0].Mcal = 10.000;
-    image[0].dMcal = 10.000;
+    image[0].McalPSF  = 10.000;
+    image[0].McalAPER = 10.000;
+    image[0].dMcal    = 10.000;
     return;
   }
@@ -225,11 +227,13 @@
     fprintf (stdout, "ZERO_POINT_NSTARS    =    %4.0f\n", N);
     // fprintf (stderr, "N: %.0f, mean: %f, wt mean: %f, stdev: %f, precision: %f\n", N, M1, Mw, M2, M2 / sqrt (N));
-    image[0].Mcal = M1;
-    image[0].dMcal = M2 / sqrt (N);
+    image[0].McalPSF    = M1;
+    image[0].McalAPER   = M1;
+    image[0].dMcal      = M2 / sqrt (N);
     image[0].nFitPhotom = N;
   } else {
     fprintf (stderr, "too few stars\n");
-    image[0].Mcal = 10.000;
-    image[0].dMcal = 10.000;
+    image[0].McalPSF    = 10.000;
+    image[0].McalAPER   = 10.000;
+    image[0].dMcal      = 10.000;
     image[0].nFitPhotom = 0;
   }
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/fakeimage.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/fakeimage.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/fakeimage.c	(revision 40212)
@@ -110,6 +110,8 @@
     image[i+1].ccdnum = 0xff;
 
-    image[i+1].Mcal  = 0.0;
-    image[i+1].Xm    = NAN_S_SHORT;
+    image[i+1].McalPSF   = 0.0;
+    image[i+1].McalAPER  = 0.0;
+    image[i+1].McalChiSq = NAN;
+    image[i+1].dMcal     = NAN;
     image[i+1].flags = 0;
 
@@ -165,7 +167,11 @@
   image[0].secz = 1.0;
   image[0].ccdnum = 0xff;
-  image[0].Mcal = 0.0;
-  image[0].Xm   = NAN_S_SHORT;
+
+  image[0].McalPSF   = 0.0;
+  image[0].McalAPER  = 0.0;
+  image[0].McalChiSq = NAN;
+  image[0].dMcal     = NAN;
   image[0].flags = 0;
+
   image[0].nstar = 0;
 
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/find_matches.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/find_matches.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/find_matches.c	(revision 40212)
@@ -212,6 +212,6 @@
 	/* in UPDATE mode, this value is not saved; use relphot to recalculate */
 	if (Nsec > -1) { 
-	  if (isnan(tgtcat[0].secfilt[n*Nsecfilt+Nsec].M)) {
-	    tgtcat[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
+	  if (isnan(tgtcat[0].secfilt[n*Nsecfilt+Nsec].MpsfChp)) {
+	    tgtcat[0].secfilt[n*Nsecfilt+Nsec].MpsfChp = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
 	  }
 	}
@@ -305,5 +305,5 @@
       /* in UPDATE mode, this value is not saved; use relphot to recalculate */
       if (Nsec > -1) { 
-	tgtcat[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
+	tgtcat[0].secfilt[Nave*Nsecfilt+Nsec].MpsfChp = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
       }
 
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/find_matches_closest.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/find_matches_closest.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/find_matches_closest.c	(revision 40212)
@@ -248,6 +248,6 @@
       /* in UPDATE mode, this value is not saved; use relphot to recalculate */
       if (Nsec > -1) { 
-	if (isnan(tgtcat[0].secfilt[n*Nsecfilt+Nsec].M)) {
-	  tgtcat[0].secfilt[n*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
+	if (isnan(tgtcat[0].secfilt[n*Nsecfilt+Nsec].MpsfChp)) {
+	  tgtcat[0].secfilt[n*Nsecfilt+Nsec].MpsfChp = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
 	}
       }
@@ -352,5 +352,5 @@
       /* in UPDATE mode, this value is not saved; use relphot to recalculate */
       if (Nsec > -1) { 
-	tgtcat[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
+	tgtcat[0].secfilt[Nave*Nsecfilt+Nsec].MpsfChp = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
       }
 
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/find_matches_gaia.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/find_matches_gaia.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/find_matches_gaia.c	(revision 40212)
@@ -267,5 +267,5 @@
     /* in UPDATE mode, this value is not saved; use relphot to recalculate */
     if (Nsec > -1) { 
-      tgtcat[0].secfilt[Nave*Nsecfilt+Nsec].M = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
+      tgtcat[0].secfilt[Nave*Nsecfilt+Nsec].MpsfChp = PhotCat (&tgtcat[0].measure[Nmeas], MAG_CLASS_PSF);
     }
 
Index: /branches/eam_branches/ohana.20170822/src/addstar/src/loadsupercos_plates.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/addstar/src/loadsupercos_plates.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/addstar/src/loadsupercos_plates.c	(revision 40212)
@@ -72,7 +72,8 @@
     image[Nimage].apmifit = 0.0;
     image[Nimage].dapmifit = 0.0;
-    image[Nimage].Mcal = 0.0;
-    image[Nimage].dMcal = 0.0;
-    image[Nimage].Xm = 0.0;
+    image[Nimage].McalPSF   = 0.0;
+    image[Nimage].McalAPER  = 0.0;
+    image[Nimage].McalChiSq = 0.0;
+    image[Nimage].dMcal     = 0.0;
 
     char photname[128];
Index: /branches/eam_branches/ohana.20170822/src/checkastro/src/BrightCatalog.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/checkastro/src/BrightCatalog.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/checkastro/src/BrightCatalog.c	(revision 40212)
@@ -270,12 +270,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].M_20  = M_20[i];
-      secfilt[i].M_80  = M_80[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].M_20     = M_20[i];
+      secfilt[i].M_80     = M_80[i];
     }
     fprintf (stderr, "loaded data for %lld averages\n", (long long) Nrow);
@@ -652,12 +652,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  ;
-      M_20  [i]       = secfilt[i].M_20   ;
-      M_80  [i]       = secfilt[i].M_80   ;
+      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   ;
+      M_20  [i]       = secfilt[i].M_20    ;
+      M_80  [i]       = secfilt[i].M_80    ;
     }
 
Index: /branches/eam_branches/ohana.20170822/src/delstar/src/gimages.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/delstar/src/gimages.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/delstar/src/gimages.c	(revision 40212)
@@ -88,6 +88,7 @@
 
   /* secz is in units milli-airmass */
-  image[0].Mcal = ALPHA*(image[0].secz - 1.000);
-  image[0].Xm   = NAN_S_SHORT;
+  image[0].McalPSF   = ALPHA*(image[0].secz - 1.000);
+  image[0].McalAPER  = ALPHA*(image[0].secz - 1.000);
+  image[0].McalChiSq = NAN_S_SHORT;
 
   free (header.buffer);
Index: /branches/eam_branches/ohana.20170822/src/dvomerge/src/merge_catalogs_old.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/dvomerge/src/merge_catalogs_old.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/dvomerge/src/merge_catalogs_old.c	(revision 40212)
@@ -367,6 +367,6 @@
       // secfilt tables of input and output are the same
       for (k = 0; k < NsecfiltIn; k++) {
-        if ( isfinite(output[0].secfilt[n*NsecfiltIn+k].M)) continue;
-        if (!isfinite( input[0].secfilt[N*NsecfiltIn+k].M)) continue;
+        if ( isfinite(output[0].secfilt[n*NsecfiltIn+k].MpsfChp)) continue;
+        if (!isfinite( input[0].secfilt[N*NsecfiltIn+k].MpsfChp)) continue;
         output[0].secfilt[n*NsecfiltIn+k] = input[0].secfilt[N*NsecfiltIn+k];
       }
@@ -378,6 +378,6 @@
         int outputIndex = n * NsecfiltOut + secfiltMap[k];
         
-        if ( isfinite(output[0].secfilt[outputIndex].M)) continue;
-        if (!isfinite( input[0].secfilt[N*NsecfiltIn+k].M)) continue;
+        if ( isfinite(output[0].secfilt[outputIndex].MpsfChp)) continue;
+        if (!isfinite( input[0].secfilt[N*NsecfiltIn+k].MpsfChp)) continue;
         output[0].secfilt[outputIndex] = input[0].secfilt[N*NsecfiltIn+k];
       }
@@ -489,5 +489,5 @@
       }
     
-      if (isfinite(input[0].secfilt[N*NsecfiltIn+j].M)) {
+      if (isfinite(input[0].secfilt[N*NsecfiltIn+j].MpsfChp)) {
 	output[0].secfilt[outputIndex] = input[0].secfilt[N*NsecfiltIn+j];
       }
Index: /branches/eam_branches/ohana.20170822/src/dvopsps/src/insert_objects_dvopsps_catalog.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/dvopsps/src/insert_objects_dvopsps_catalog.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/dvopsps/src/insert_objects_dvopsps_catalog.c	(revision 40212)
@@ -372,8 +372,8 @@
     float meanPSFMagMin = NAN;
     float meanPSFMagMax = NAN;
-    if (isfinite(secfilt->dM) && isfinite(secfilt->M)) {
-      meanPSFMag    = secfilt->M;
-      meanPSFMagErr = secfilt->dM;
-      meanPSFMagStd = secfilt->Mstdev;
+    if (isfinite(secfilt->dMpsfChp) && isfinite(secfilt->MpsfChp)) {
+      meanPSFMag    = secfilt->MpsfChp;
+      meanPSFMagErr = secfilt->dMpsfChp;
+      meanPSFMagStd = secfilt->sMpsfChp;
       meanPSFMagMin = secfilt->Mmin;
       meanPSFMagMax = secfilt->Mmax;
@@ -383,8 +383,8 @@
     float meanKronMagErr = NAN;
     float meanKronMagStd = NAN;
-    if (isfinite(secfilt->dMkron) && isfinite(secfilt->Mkron) && (secfilt->dMkron < 0.333)) {
-      meanKronMag    = secfilt->Mkron;
-      meanKronMagErr = secfilt->dMkron;
-      meanKronMagStd = secfilt->sMkron;
+    if (isfinite(secfilt->dMkronChp) && isfinite(secfilt->MkronChp) && (secfilt->dMkronChp < 0.333)) {
+      meanKronMag    = secfilt->MkronChp;
+      meanKronMagErr = secfilt->dMkronChp;
+      meanKronMagStd = secfilt->sMkronChp;
     }
 
@@ -392,8 +392,8 @@
     float meanApMagErr = NAN;
     float meanApMagStd = NAN;
-    if (isfinite(secfilt->dMap) && isfinite(secfilt->Map)) {
-      meanApMag    = secfilt->Map;
-      meanApMagErr = secfilt->dMap;
-      meanApMagStd = secfilt->sMap;
+    if (isfinite(secfilt->dMapChp) && isfinite(secfilt->MapChp)) {
+      meanApMag    = secfilt->MapChp;
+      meanApMagErr = secfilt->dMapChp;
+      meanApMagStd = secfilt->sMapChp;
     }
 
Index: /branches/eam_branches/ohana.20170822/src/fakeastro/src/insert_fakestar.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/fakeastro/src/insert_fakestar.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/fakeastro/src/insert_fakestar.c	(revision 40212)
@@ -93,9 +93,9 @@
 
     // I need a photcode for r-band
-    catalog[0].secfilt[Nave*Nsecfilt+0].M = m_g;
-    catalog[0].secfilt[Nave*Nsecfilt+1].M = m_r;
-    catalog[0].secfilt[Nave*Nsecfilt+2].M = m_i;
-    catalog[0].secfilt[Nave*Nsecfilt+3].M = m_z;
-    catalog[0].secfilt[Nave*Nsecfilt+4].M = m_y;
+    catalog[0].secfilt[Nave*Nsecfilt+0].MpsfChp = m_g;
+    catalog[0].secfilt[Nave*Nsecfilt+1].MpsfChp = m_r;
+    catalog[0].secfilt[Nave*Nsecfilt+2].MpsfChp = m_i;
+    catalog[0].secfilt[Nave*Nsecfilt+3].MpsfChp = m_z;
+    catalog[0].secfilt[Nave*Nsecfilt+4].MpsfChp = m_y;
 
     catalog[0].starpar[Nstarpar]        = stars[i].starpar;
Index: /branches/eam_branches/ohana.20170822/src/fakeastro/src/load_template_images.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/fakeastro/src/load_template_images.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/fakeastro/src/load_template_images.c	(revision 40212)
@@ -61,5 +61,6 @@
 
     refimage[Nrefimage].secz     = childImage->secz;
-    refimage[Nrefimage].Mcal     = childImage->Mcal;
+    refimage[Nrefimage].McalPSF  = childImage->McalPSF;
+    refimage[Nrefimage].McalAPER = childImage->McalAPER;
     refimage[Nrefimage].dMcal    = childImage->dMcal;
     refimage[Nrefimage].exptime  = childImage->exptime;
Index: /branches/eam_branches/ohana.20170822/src/fakeastro/src/make_2mass_measures.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/fakeastro/src/make_2mass_measures.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/fakeastro/src/make_2mass_measures.c	(revision 40212)
@@ -44,16 +44,16 @@
 
     // make a crude JHK color for now:
-    double J_PS1 = secfilt[i*Nsecfilt + Nsec].M - 1.0; // make all stars have y-J = 1.0
+    double J_PS1 = secfilt[i*Nsecfilt + Nsec].MpsfChp - 1.0; // make all stars have y-J = 1.0
     if (J_PS1 > MAX_MAG_2MASS) continue; // only generate 2MASS detections for objects with J_PS1 < 16.0
 
-    if (isnan(secfilt[i*Nsecfilt + Nsec].M)) {
+    if (isnan(secfilt[i*Nsecfilt + Nsec].MpsfChp)) {
       // look for a non-NAN secfilt mag and just use that (it is not super important)
       int ns;
       for (ns = 0; ns < Nsecfilt; ns++) {
-	if (!isnan(secfilt[i*Nsecfilt + ns].M)) break;
+	if (!isnan(secfilt[i*Nsecfilt + ns].MpsfChp)) break;
       }
       if (ns == Nsecfilt) continue; // no non-nan
 
-      J_PS1 = secfilt[i*Nsecfilt + ns].M; // pretend secfilt.M = J
+      J_PS1 = secfilt[i*Nsecfilt + ns].MpsfChp; // pretend secfilt.MpsfChp = J
       if (J_PS1 > MAX_MAG_2MASS) continue; // only generate 2MASS detections for objects with J_PS1 < 16.0
     }
Index: /branches/eam_branches/ohana.20170822/src/fakeastro/src/make_fake_stars_catalog.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/fakeastro/src/make_fake_stars_catalog.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/fakeastro/src/make_fake_stars_catalog.c	(revision 40212)
@@ -42,6 +42,6 @@
 
   // XXX put in airmass?
-  float ZP  = SCALE*code->C - image->Mcal + Mtime;
-  float ZPo = 25.0 - image->Mcal + Mtime;
+  float ZP  = SCALE*code->C - image->McalPSF + Mtime;
+  float ZPo = 25.0 - image->McalPSF + Mtime;
   // float ZP = code[0].K*(measure[0].airmass - 1.000) + SCALE*code[0].C - measure[0].Mcal;
   
@@ -79,5 +79,5 @@
     // float Minst = Msky - SCALE*code->C - measure[0].dt
 
-    double Minst = secfilt[i*Nsecfilt + Nsec].M  - ZP;
+    double Minst = secfilt[i*Nsecfilt + Nsec].MpsfChp - ZP;
     double Counts = pow(10.0, -0.4*Minst);
     double SkyCts = sky[Nsec];
@@ -175,5 +175,5 @@
 
     stars[Nstars].measure.az      = azimuth (15.0*image->sidtime - stars[Nstars].average.R, stars[Nstars].average.D, image->latitude);
-    stars[Nstars].measure.Mcal    = image->Mcal;
+    stars[Nstars].measure.Mcal    = image->McalPSF;
     stars[Nstars].measure.t       = image->tzero + 1e-4*stars[Nstars].measure.Yccd*image->trate;  // trate is in 0.1 msec / row 
     stars[Nstars].measure.dt      = Mtime;
Index: /branches/eam_branches/ohana.20170822/src/fakeastro/src/make_gaia_measures.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/fakeastro/src/make_gaia_measures.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/fakeastro/src/make_gaia_measures.c	(revision 40212)
@@ -42,16 +42,16 @@
 
     // make a crude G-i color for now:
-    double G_PS1 = secfilt[i*Nsecfilt + Nsec].M; // make all stars have G-i = 1.0
+    double G_PS1 = secfilt[i*Nsecfilt + Nsec].MpsfChp; // make all stars have G-i = 1.0
     if (G_PS1 > MAX_MAG_GAIA) continue; // only generate GAIA detections for objects with G_PS1 < 21.0
 
-    if (isnan(secfilt[i*Nsecfilt + Nsec].M)) {
+    if (isnan(secfilt[i*Nsecfilt + Nsec].MpsfChp)) {
       // look for a non-NAN secfilt mag and just use that (it is not super important)
       int ns;
       for (ns = 0; ns < Nsecfilt; ns++) {
-	if (!isnan(secfilt[i*Nsecfilt + ns].M)) break;
+	if (!isnan(secfilt[i*Nsecfilt + ns].MpsfChp)) break;
       }
       if (ns == Nsecfilt) continue; // no non-nan
 
-      G_PS1 = secfilt[i*Nsecfilt + ns].M; // pretend secfilt.M = G
+      G_PS1 = secfilt[i*Nsecfilt + ns].MpsfChp; // pretend secfilt.M = G
       if (G_PS1 > MAX_MAG_GAIA) continue; // only generate GAIA detections for objects with G_PS1 < 21.0
     }
Index: /branches/eam_branches/ohana.20170822/src/getstar/src/ReadImageHeader.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/getstar/src/ReadImageHeader.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/getstar/src/ReadImageHeader.c	(revision 40212)
@@ -127,6 +127,7 @@
 
   /* secz is in units milli-airmass */
-  image[0].Mcal = 0.0;
-  image[0].Xm   = NAN_S_SHORT;
+  image[0].McalPSF   = 0.0;
+  image[0].McalAPER  = 0.0;
+  image[0].McalChiSq = NAN;
   image[0].flags = 0;
 
Index: /branches/eam_branches/ohana.20170822/src/getstar/src/select_by_region.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/getstar/src/select_by_region.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/getstar/src/select_by_region.c	(revision 40212)
@@ -78,5 +78,5 @@
         }
       } else {
-        mag = catalog[0].secfilt[i*Nsecfilt + Nsec].M;
+        mag = catalog[0].secfilt[i*Nsecfilt + Nsec].MpsfChp;
       }
       if (isnan(mag)) continue;
@@ -131,5 +131,5 @@
         }
       } else {
-        mag = catalog[0].secfilt[i*Nsecfilt + Nsec].M;
+        mag = catalog[0].secfilt[i*Nsecfilt + Nsec].MpsfChp;
       }
       if (isnan(mag) || (mag > MagLimitValue)) continue;
Index: /branches/eam_branches/ohana.20170822/src/getstar/src/write_getstar_ps1_dev_0.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/getstar/src/write_getstar_ps1_dev_0.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/getstar/src/write_getstar_ps1_dev_0.c	(revision 40212)
@@ -55,5 +55,5 @@
     // find primary magnitude
     if (Nsec_c0 != -1) {
-      output[i].mag = secfilt[i*Nsecfilt + Nsec_c0].M;
+      output[i].mag = secfilt[i*Nsecfilt + Nsec_c0].MpsfChp;
     } else {
       output[i].mag = NAN;
@@ -69,5 +69,5 @@
     // find color term 1
     if (Nsec_c1 != -1) {
-      output[i].c1 = secfilt[i*Nsecfilt + Nsec_c1].M;
+      output[i].c1 = secfilt[i*Nsecfilt + Nsec_c1].MpsfChp;
     } else {
       output[i].c1 = NAN;
@@ -83,5 +83,5 @@
     // find color term 2
     if (Nsec_c2 != -1) {
-      output[i].c2 = secfilt[i*Nsecfilt + Nsec_c2].M;
+      output[i].c2 = secfilt[i*Nsecfilt + Nsec_c2].MpsfChp;
     } else {
       output[i].c2 = NAN;
Index: /branches/eam_branches/ohana.20170822/src/getstar/src/write_getstar_ps1_dev_1.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/getstar/src/write_getstar_ps1_dev_1.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/getstar/src/write_getstar_ps1_dev_1.c	(revision 40212)
@@ -58,5 +58,5 @@
     // find primary magnitude
     if (Nsec_c0 != -1) {
-      output[i].mag = secfilt[i*Nsecfilt + Nsec_c0].M;
+      output[i].mag = secfilt[i*Nsecfilt + Nsec_c0].MpsfChp;
     } else {
       output[i].mag = NAN;
@@ -72,5 +72,5 @@
     // find color term 1
     if (Nsec_c1 != -1) {
-      output[i].c1 = secfilt[i*Nsecfilt + Nsec_c1].M;
+      output[i].c1 = secfilt[i*Nsecfilt + Nsec_c1].MpsfChp;
     } else {
       output[i].c1 = NAN;
@@ -86,5 +86,5 @@
     // find color term 2
     if (Nsec_c2 != -1) {
-      output[i].c2 = secfilt[i*Nsecfilt + Nsec_c2].M;
+      output[i].c2 = secfilt[i*Nsecfilt + Nsec_c2].MpsfChp;
     } else {
       output[i].c2 = NAN;
Index: /branches/eam_branches/ohana.20170822/src/getstar/src/write_getstar_ps1_dev_2.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/getstar/src/write_getstar_ps1_dev_2.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/getstar/src/write_getstar_ps1_dev_2.c	(revision 40212)
@@ -64,5 +64,5 @@
     // find primary magnitude
     if (Nsec_c0 != -1) {
-      output[i].mag = secfilt[i*Nsecfilt + Nsec_c0].M;
+      output[i].mag = secfilt[i*Nsecfilt + Nsec_c0].MpsfChp;
     } else {
       output[i].mag = NAN;
@@ -78,5 +78,5 @@
     // find color term 1
     if (Nsec_c1 != -1) {
-      output[i].c1 = secfilt[i*Nsecfilt + Nsec_c1].M;
+      output[i].c1 = secfilt[i*Nsecfilt + Nsec_c1].MpsfChp;
     } else {
       output[i].c1 = NAN;
@@ -92,5 +92,5 @@
     // find color term 2
     if (Nsec_c2 != -1) {
-      output[i].c2 = secfilt[i*Nsecfilt + Nsec_c2].M;
+      output[i].c2 = secfilt[i*Nsecfilt + Nsec_c2].MpsfChp;
     } else {
       output[i].c2 = NAN;
Index: /branches/eam_branches/ohana.20170822/src/imregister/imphot/dumpfits.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/imregister/imphot/dumpfits.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/imregister/imphot/dumpfits.c	(revision 40212)
@@ -114,5 +114,5 @@
     startstr = ohana_sec_to_date (subset[0].tzero);
     filtstr  = GetPhotcodeNamebyCode (subset[0].photcode);
-    zp       = subset[0].Mcal;
+    zp       = subset[0].McalPSF;
     dzp      = subset[0].dMcal;
     XY_to_RD (&ra, &dec, 0.0, 0.0, &subset[0].coords);
Index: /branches/eam_branches/ohana.20170822/src/imregister/imphot/output.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/imregister/imphot/output.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/imregister/imphot/output.c	(revision 40212)
@@ -37,5 +37,5 @@
       
     fprintf (stdout, "%s %s %s  %7.4f %7.4f  %7.4f %5d %02x\n", image[i].name, photstr, timestr, 
-	     image[i].Mcal, image[i].dMcal, image[i].secz, image[i].nstar, image[i].flags); 
+	     image[i].McalPSF, image[i].dMcal, image[i].secz, image[i].nstar, image[i].flags); 
     free (timestr);
   }
Index: /branches/eam_branches/ohana.20170822/src/kapa2/src/DrawObjects.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/kapa2/src/DrawObjects.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/kapa2/src/DrawObjects.c	(revision 40212)
@@ -97,20 +97,26 @@
   switch (object[0].style) {
     case KAPA_PLOT_CONNECT: 
+      // fprintf (stderr, "plot KAPA_PLOT_CONNECT: \n");
       DrawConnect (graphic, graph, object);
       break;
     case KAPA_PLOT_HISTOGRAM:
+      // fprintf (stderr, "plot KAPA_PLOT_HISTOGRAM:\n");
       DrawHistogram (graphic, graph, object);
       break;
     case KAPA_PLOT_BARS_SOLID:
+      // fprintf (stderr, "plot KAPA_PLOT_BARS_SOLID:\n");
       DrawBars (graphic, graph, object, KAPA_PLOT_BARS_SOLID);
       break;
     case KAPA_PLOT_BARS_OUTLINE:
+      // fprintf (stderr, "plot KAPA_PLOT_BARS_OUTLINE:\n");
       DrawBars (graphic, graph, object, KAPA_PLOT_BARS_OUTLINE);
       break;
     case KAPA_PLOT_BARS_OUTFILL:
+      // fprintf (stderr, "plot KAPA_PLOT_BARS_OUTFILL:\n");
       DrawBars (graphic, graph, object, KAPA_PLOT_BARS_OUTFILL);
       break;
     case KAPA_PLOT_POINTS:
     default:
+      // fprintf (stderr, "plot KAPA_PLOT_POINTS:\n");
       DrawPoints (graphic, graph, object);
       break;
Index: /branches/eam_branches/ohana.20170822/src/libautocode/def/secfilt.d
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libautocode/def/secfilt.d	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libautocode/def/secfilt.d	(revision 40212)
@@ -5,13 +5,18 @@
 DESCRIPTION  DVO SecFilt : Secondary Filter Data 
 
+## 2017.11.22 : To clarify the parallel structures, I am explicitly renaming M,Map,Mkron to MpsfChp, MapChp, MkronChp
+
 ## *** this section is for per-exposure mean values *** (unlabled values are implicitly PSF values)
-FIELD  M,             MAG,             float,      average mag in this band,              mags
-FIELD  dM,            MAG_ERR,         float,      formal error on average mag,           mags
-FIELD  Map,           MAG_AP,          float,      average mag in this band,              mags
-FIELD  dMap,          MAG_AP_ERR,      float,      formal error on average mag,           mags
-FIELD  sMap,          MAG_AP_STDEV,    float,      standard deviation of ap mags,         mags
-FIELD  Mkron,         MAG_KRON,        float,      ave kron mag in this band,             mags
-FIELD  dMkron,        MAG_KRON_ERR,    float,      formal error on average kron mag,      mags
-FIELD  sMkron,        MAG_KRON_STDEV,  float,      standard deviation of kron mags,       mags
+FIELD  MpsfChp,       MAG,             float,      average mag in this band,              mags
+FIELD  dMpsfChp,      MAG_ERR,         float,      formal error on average mag,           mags
+FIELD  sMpsfChp,      MAG_STDEV,       float,      standard deviation of measurements,    mags
+
+FIELD  MapChp,        MAG_AP,          float,      average mag in this band,              mags
+FIELD  dMapChp,       MAG_AP_ERR,      float,      formal error on average mag,           mags
+FIELD  sMapChp,       MAG_AP_STDEV,    float,      standard deviation of ap mags,         mags
+
+FIELD   MkronChp,     MAG_KRON,        float,      ave kron mag in this band,             mags
+FIELD  dMkronChp,     MAG_KRON_ERR,    float,      formal error on average kron mag,      mags
+FIELD  sMkronChp,     MAG_KRON_STDEV,  float,      standard deviation of kron mags,       mags
 
 # XXX I could add these fields to secfilt or calculate in dvopsps?
@@ -20,5 +25,4 @@
 
 # these statistics are PSF-specific      
-FIELD  Mstdev,        MAG_STDEV,       float,      standard deviation of measurements,    mags
 FIELD  Mmin,          MAG_MIN,         float,      minimum accepted mag,                  mags
 FIELD  Mmax,          MAG_MAX,         float,      maximum accepted mag,                  mags
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_catalog.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_catalog.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_catalog.c	(revision 40212)
@@ -235,17 +235,17 @@
 
   if (mode & SECFILT_RESET_CHIP) {
-    secfilt->M           = NAN;
-    secfilt->dM          = NAN;
-    secfilt->Map         = NAN;
-    secfilt->dMap        = NAN;
-    secfilt->sMap        = NAN;
-    secfilt->Mkron       = NAN;
-    secfilt->dMkron      = NAN;
-    secfilt->sMkron      = NAN;
+    secfilt->MpsfChp     = NAN;
+    secfilt->dMpsfChp    = NAN;
+    secfilt->sMpsfChp    = NAN;
+    secfilt->MapChp      = NAN;
+    secfilt->dMapChp     = NAN;
+    secfilt->sMapChp     = NAN;
+    secfilt->MkronChp    = NAN;
+    secfilt->dMkronChp   = NAN;
+    secfilt->sMkronChp   = NAN;
 
     secfilt->psfQfMax     = NAN;
     secfilt->psfQfPerfMax = NAN;
 
-    secfilt->Mstdev      = NAN;
     secfilt->Mmin        = NAN;
     secfilt->Mmax        = NAN;
@@ -923,12 +923,12 @@
     for (in = out = i = 0; i < catalog[0].Naverage; i++) {
       for (j = 0; j < catalog[0].Nsecfilt; j++, in++, out++) {
-	outsec[out].M  	   = insec[in].M;
-	outsec[out].dM 	   = insec[in].dM;
-	outsec[out].Mchisq = insec[in].Mchisq;
+	outsec[out].MpsfChp  = insec[in].MpsfChp;
+	outsec[out].dMpsfChp = insec[in].dMpsfChp;
+	outsec[out].Mchisq   = insec[in].Mchisq;
       }
       for (j = 0; j < Nextra; j++, out++) {
-	outsec[out].M  	   = NAN;
-	outsec[out].dM 	   = NAN;
-	outsec[out].Mchisq = NAN;
+	outsec[out].MpsfChp  = NAN;
+	outsec[out].dMpsfChp = NAN;
+	outsec[out].Mchisq   = NAN;
       }
     }
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_DEV_1.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_DEV_1.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_DEV_1.c	(revision 40212)
@@ -182,6 +182,7 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].MpsfChp     = in[i].M;      
+    out[i].dMpsfChp    = in[i].dM;      
+
     out[i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
     out[i].Ncode = in[i].Ncode;
@@ -199,6 +200,7 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+
     out[i].Xm    = 100.0*log10(in[i].Mchisq);     
     out[i].Ncode = in[i].Ncode;
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_DEV_2.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_DEV_2.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_DEV_2.c	(revision 40212)
@@ -177,6 +177,7 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].MpsfChp     = in[i].M;      
+    out[i].dMpsfChp    = in[i].dM;      
+
     out[i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
     out[i].Ncode = in[i].Ncode;
@@ -194,6 +195,7 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+
     out[i].Xm    = 100.0*log10(in[i].Mchisq);     
     out[i].Ncode = in[i].Ncode;
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_REF.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_REF.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_REF.c	(revision 40212)
@@ -114,6 +114,6 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].MpsfChp     = in[i].M;      
+    out[i].dMpsfChp    = in[i].dM;      
  }
   return (out);
@@ -128,6 +128,6 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
   }
   return (out);
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_SIM.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_SIM.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_SIM.c	(revision 40212)
@@ -199,6 +199,7 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M             = in[i].M;      
-    out[i].dM            = in[i].dM;      
+    out[i].MpsfChp     = in[i].M;      
+    out[i].dMpsfChp    = in[i].dM;      
+
     out[i].Ncode         = in[i].Ncode;
     out[i].Nused         = in[i].Nused;
@@ -217,6 +218,7 @@
   for (i = 0; i < Nvalues; i++) {
 
-    out[i].M             = in[i].M;      
-    out[i].dM            = in[i].dM;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+
     out[i].Ncode         = in[i].Ncode;
     out[i].Nused         = in[i].Nused;
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V1.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V1.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V1.c	(revision 40212)
@@ -197,6 +197,7 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].MpsfChp     = in[i].M;      
+    out[i].dMpsfChp    = in[i].dM;      
+
     out[i].Mchisq= in[i].Mchisq;     
     out[i].Ncode = in[i].Ncode;
@@ -216,6 +217,7 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+
     out[i].Mchisq= in[i].Mchisq;     
     out[i].Ncode = in[i].Ncode;
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V2.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V2.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V2.c	(revision 40212)
@@ -206,6 +206,7 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].MpsfChp     = in[i].M;      
+    out[i].dMpsfChp    = in[i].dM;      
+
     out[i].Mchisq= in[i].Mchisq;     
     out[i].flags = in[i].flags;     
@@ -226,6 +227,7 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+
     out[i].Mchisq= in[i].Mchisq;     
     out[i].flags = in[i].flags;     
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V3.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V3.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V3.c	(revision 40212)
@@ -210,7 +210,9 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M           = in[i].M;      
-    out[i].Map         = in[i].Map;      
-    out[i].dM          = in[i].dM;      
+    out[i].MpsfChp     = in[i].M;      
+    out[i].sMpsfChp    = in[i].Mstdev;      
+    out[i].dMpsfChp    = in[i].dM;      
+    out[i].MapChp      = in[i].Map;      
+
     out[i].Mchisq      = in[i].Mchisq;     
     out[i].flags       = in[i].flags;     
@@ -219,5 +221,4 @@
     out[i].Mmin        = in[i].M_20*0.001;      
     out[i].Mmax        = in[i].M_80*0.001;      
-    out[i].Mstdev      = in[i].Mstdev;      
     out[i].ubercalDist = in[i].ubercalDist;      
  }
@@ -233,7 +234,9 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M           = in[i].M;      
-    out[i].Map         = in[i].Map;      
-    out[i].dM          = in[i].dM;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+    out[i].Mstdev        = in[i].sMpsfChp;      
+    out[i].Map           = in[i].MapChp;      
+
     out[i].Mchisq      = in[i].Mchisq;     
     out[i].flags       = in[i].flags;     
@@ -242,5 +245,4 @@
     out[i].M_20        = in[i].Mmin*1000.0;      
     out[i].M_80        = in[i].Mmax*1000.0;      
-    out[i].Mstdev      = in[i].Mstdev;      
     out[i].ubercalDist = in[i].ubercalDist;      
   }
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V4.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V4.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V4.c	(revision 40212)
@@ -234,9 +234,10 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M             = in[i].M;      
-    out[i].Map           = in[i].Map;      
-    out[i].Mkron         = in[i].Mkron;      
-    out[i].dMkron        = in[i].dMkron;      
-    out[i].dM            = in[i].dM;      
+    out[i].MpsfChp       = in[i].M;      
+    out[i].sMpsfChp      = in[i].Mstdev;      
+    out[i].dMpsfChp      = in[i].dM;      
+    out[i].MapChp        = in[i].Map;      
+    out[i].MkronChp      = in[i].Mkron;      
+
     out[i].Mchisq        = in[i].Mchisq;     
     out[i].FpsfStk       = in[i].FluxPSF;
@@ -249,5 +250,4 @@
     out[i].Mmin          = in[i].M_20*0.001;      
     out[i].Mmax          = in[i].M_80*0.001;      
-    out[i].Mstdev        = in[i].Mstdev;      
     out[i].ubercalDist   = in[i].ubercalDist;      
     out[i].stackPrmryOff = in[i].stackPrmryOff;      
@@ -265,9 +265,10 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M           	 = in[i].M;      
-    out[i].Map         	 = in[i].Map;      
-    out[i].Mkron       	 = in[i].Mkron;      
-    out[i].dMkron      	 = in[i].dMkron;      
-    out[i].dM          	 = in[i].dM;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+    out[i].Mstdev        = in[i].sMpsfChp;      
+    out[i].Map           = in[i].MapChp;      
+    out[i].Mkron         = in[i].MkronChp;      
+
     out[i].Mchisq        = in[i].Mchisq;
     out[i].FluxPSF     	 = in[i].FpsfStk;
@@ -280,5 +281,4 @@
     out[i].M_20        	 = in[i].Mmin*1000.0;      
     out[i].M_80        	 = in[i].Mmax*1000.0;      
-    out[i].Mstdev      	 = in[i].Mstdev;      
     out[i].ubercalDist 	 = in[i].ubercalDist;      
     out[i].stackPrmryOff = in[i].stackPrmryOff;      
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V5.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V5.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V5.c	(revision 40212)
@@ -311,17 +311,17 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M             = in[i].M;      
-    out[i].dM            = in[i].dM;      
-    out[i].Map           = in[i].Map;      
-    out[i].dMap          = in[i].dMap;      
-    out[i].sMap          = in[i].sMap;      
-    out[i].Mkron         = in[i].Mkron;      
-    out[i].dMkron        = in[i].dMkron;      
-    out[i].sMkron        = in[i].sMkron;      
+    out[i].MpsfChp       = in[i].M;      
+    out[i].sMpsfChp      = in[i].Mstdev;      
+    out[i].dMpsfChp      = in[i].dM;      
+    out[i].MapChp        = in[i].Map;      
+    out[i].dMapChp       = in[i].dMap;      
+    out[i].sMapChp       = in[i].sMap;      
+    out[i].MkronChp      = in[i].Mkron;      
+    out[i].dMkronChp     = in[i].dMkron;      
+    out[i].sMkronChp     = in[i].sMkron;      
 
     out[i].psfQfMax      = in[i].psfQfMax;      
     out[i].psfQfPerfMax  = in[i].psfQfPerfMax;      
 
-    out[i].Mstdev        = in[i].Mstdev;      
     out[i].Mmin          = in[i].Mmin;      
     out[i].Mmax          = in[i].Mmax;      
@@ -389,17 +389,17 @@
   for (i = 0; i < Nvalues; i++) {
 
-    out[i].M             = in[i].M;      
-    out[i].dM            = in[i].dM;      
-    out[i].Map           = in[i].Map;      
-    out[i].dMap          = in[i].dMap;      
-    out[i].sMap          = in[i].sMap;      
-    out[i].Mkron         = in[i].Mkron;      
-    out[i].dMkron        = in[i].dMkron;      
-    out[i].sMkron        = in[i].sMkron;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+    out[i].Mstdev        = in[i].sMpsfChp;      
+    out[i].Map           = in[i].MapChp;      
+    out[i].dMap          = in[i].dMapChp;      
+    out[i].sMap          = in[i].sMapChp;      
+    out[i].Mkron         = in[i].MkronChp;      
+    out[i].dMkron        = in[i].dMkronChp;      
+    out[i].sMkron        = in[i].sMkronChp;      
 
     out[i].psfQfMax      = in[i].psfQfMax;      
     out[i].psfQfPerfMax  = in[i].psfQfPerfMax;      
 
-    out[i].Mstdev        = in[i].Mstdev;      
     out[i].Mmin          = in[i].Mmin;      
     out[i].Mmax          = in[i].Mmax;      
@@ -1500,13 +1500,14 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M             = in[i].M;      
-    out[i].dM            = in[i].dM;      
-    out[i].Map           = in[i].Map;      
-    out[i].dMap          = in[i].dMap;      
-    out[i].sMap          = in[i].sMap;      
-    out[i].Mkron         = in[i].Mkron;      
-    out[i].dMkron        = in[i].dMkron;      
-
-    out[i].Mstdev        = in[i].Mstdev;      
+    out[i].MpsfChp       = in[i].M;      
+    out[i].dMpsfChp      = in[i].dM;      
+    out[i].sMpsfChp      = in[i].Mstdev;      
+    out[i].MapChp        = in[i].Map;      
+    out[i].dMapChp       = in[i].dMap;      
+    out[i].sMapChp       = in[i].sMap;      
+    out[i].MkronChp      = in[i].Mkron;      
+    out[i].dMkronChp     = in[i].dMkron;      
+    out[i].sMkronChp     = in[i].sMkron;      
+
     out[i].Mmin          = in[i].Mmin;      
     out[i].Mmax          = in[i].Mmax;      
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V5_LOAD.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V5_LOAD.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V5_LOAD.c	(revision 40212)
@@ -221,5 +221,5 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M             = in[i].M;      
+    out[i].MpsfChp       = in[i].M;      
     out[i].Ncode         = in[i].Ncode;
     out[i].Nused         = in[i].Nused;
@@ -237,5 +237,5 @@
   for (i = 0; i < Nvalues; i++) {
 
-    out[i].M             = in[i].M;      
+    out[i].M             = in[i].MpsfChp;      
     out[i].Ncode         = in[i].Ncode;
     out[i].Nused         = in[i].Nused;
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V6.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V6.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_PS1_V6.c	(revision 40212)
@@ -311,17 +311,17 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M             = in[i].M;      
-    out[i].dM            = in[i].dM;      
-    out[i].Map           = in[i].Map;      
-    out[i].dMap          = in[i].dMap;      
-    out[i].sMap          = in[i].sMap;      
-    out[i].Mkron         = in[i].Mkron;      
-    out[i].dMkron        = in[i].dMkron;      
-    out[i].sMkron        = in[i].sMkron;      
+    out[i].MpsfChp       = in[i].M;      
+    out[i].sMpsfChp      = in[i].Mstdev;      
+    out[i].dMpsfChp      = in[i].dM;      
+    out[i].MapChp        = in[i].Map;      
+    out[i].dMapChp       = in[i].dMap;      
+    out[i].sMapChp       = in[i].sMap;      
+    out[i].MkronChp      = in[i].Mkron;      
+    out[i].dMkronChp     = in[i].dMkron;      
+    out[i].sMkronChp     = in[i].sMkron;      
 
     out[i].psfQfMax      = in[i].psfQfMax;      
     out[i].psfQfPerfMax  = in[i].psfQfPerfMax;      
 
-    out[i].Mstdev        = in[i].Mstdev;      
     out[i].Mmin          = in[i].Mmin;      
     out[i].Mmax          = in[i].Mmax;      
@@ -389,17 +389,17 @@
   for (i = 0; i < Nvalues; i++) {
 
-    out[i].M             = in[i].M;      
-    out[i].dM            = in[i].dM;      
-    out[i].Map           = in[i].Map;      
-    out[i].dMap          = in[i].dMap;      
-    out[i].sMap          = in[i].sMap;      
-    out[i].Mkron         = in[i].Mkron;      
-    out[i].dMkron        = in[i].dMkron;      
-    out[i].sMkron        = in[i].sMkron;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+    out[i].Mstdev        = in[i].sMpsfChp;      
+    out[i].Map           = in[i].MapChp;      
+    out[i].dMap          = in[i].dMapChp;      
+    out[i].sMap          = in[i].sMapChp;      
+    out[i].Mkron         = in[i].MkronChp;      
+    out[i].dMkron        = in[i].dMkronChp;      
+    out[i].sMkron        = in[i].sMkronChp;      
 
     out[i].psfQfMax      = in[i].psfQfMax;      
     out[i].psfQfPerfMax  = in[i].psfQfPerfMax;      
 
-    out[i].Mstdev        = in[i].Mstdev;      
     out[i].Mmin          = in[i].Mmin;      
     out[i].Mmax          = in[i].Mmax;      
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_elixir.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_elixir.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_elixir.c	(revision 40212)
@@ -109,6 +109,6 @@
 
     // changed for PANSTARRS_DEV_0 (moved from Average to Measure)
-    primary[0][i].M     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M  * 0.001;      
-    primary[0][i].dM    = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM * 0.001;      
+    primary[0][i].MpsfChp  = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M  * 0.001;      
+    primary[0][i].dMpsfChp = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM * 0.001;      
     primary[0][i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
 
@@ -142,6 +142,6 @@
 
     // changed for PANSTARRS_DEV_0 (moved from Average to Measure)
-    out[i].M       = isnan(primary[i].M)  ? NAN_S_SHORT : primary[i].M   * 1000.0;
-    out[i].dM      = isnan(primary[i].dM) ? NAN_S_SHORT : primary[i].dM  * 1000.0;
+    out[i].M       = isnan(primary[i].MpsfChp)  ? NAN_S_SHORT : primary[i].MpsfChp   * 1000.0;
+    out[i].dM      = isnan(primary[i].dMpsfChp) ? NAN_S_SHORT : primary[i].dMpsfChp  * 1000.0;
     out[i].Xm      = 100.0*log10(primary[i].Mchisq);     
 
@@ -172,6 +172,6 @@
 
     // added or changed for PANSTARRS_DEV_0
-    out[i].M     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M   * 0.001;
-    out[i].dM    = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM  * 0.001;
+    out[i].MpsfChp     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M   * 0.001;
+    out[i].dMpsfChp    = (in[i].dM == NAN_S_SHORT) ? NAN : in[i].dM  * 0.001;
   }
   return (out);
@@ -190,6 +190,6 @@
 
     // added or changed for PANSTARRS_DEV_0
-    out[i].M     = isnan(in[i].M)  ? NAN_S_SHORT : in[i].M   * 1000.0;
-    out[i].dM    = isnan(in[i].dM) ? NAN_S_SHORT : in[i].dM  * 1000.0;
+    out[i].M     = isnan(in[i].MpsfChp)  ? NAN_S_SHORT : in[i].MpsfChp   * 1000.0;
+    out[i].dM    = isnan(in[i].dMpsfChp) ? NAN_S_SHORT : in[i].dMpsfChp  * 1000.0;
   }
   return (out);
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_loneos.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_loneos.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_loneos.c	(revision 40212)
@@ -89,6 +89,6 @@
 
     // changed for PANSTARRS_DEV_0 (moved from Average to Measure)
-    primary[0][i].M     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M  * 0.001;      
-    primary[0][i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
+    primary[0][i].MpsfChp = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M  * 0.001;      
+    primary[0][i].Mchisq  = pow (10.0, 0.01*in[i].Xm);     
 
     // added for PANSTARRS_DEV_0
@@ -123,5 +123,5 @@
 
     // changed for PANSTARRS_DEV_0 (moved from Average to Measure)
-    out[i].M       = isnan(primary[i].M)  ? NAN_S_SHORT : primary[i].M   * 1000.0;
+    out[i].M       = isnan(primary[i].MpsfChp)  ? NAN_S_SHORT : primary[i].MpsfChp   * 1000.0;
     out[i].Xm      = 100.0*log10(primary[i].Mchisq);     
 
@@ -152,5 +152,5 @@
 
     // added or changed for PANSTARRS_DEV_0
-    out[i].M     = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M * 0.001;
+    out[i].MpsfChp = (in[i].M  == NAN_S_SHORT) ? NAN : in[i].M * 0.001;
   }
   return (out);
@@ -169,5 +169,5 @@
 
     // added or changed for PANSTARRS_DEV_0
-    out[i].M    = isnan(in[i].M)  ? NAN_S_SHORT : in[i].M * 1000.0;
+    out[i].M    = isnan(in[i].MpsfChp)  ? NAN_S_SHORT : in[i].MpsfChp * 1000.0;
   }
   return (out);
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_panstarrs_DEV_0.c	(revision 40212)
@@ -188,6 +188,7 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].MpsfChp     = in[i].M;      
+    out[i].dMpsfChp    = in[i].dM;      
+
     out[i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
     out[i].Ncode = in[i].Ncode;
@@ -206,6 +207,7 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+
     out[i].Xm    = 100.0*log10(in[i].Mchisq);     
     out[i].Ncode = in[i].Ncode;
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_convert_panstarrs_DEV_1.c	(revision 40212)
@@ -188,6 +188,7 @@
     dvo_secfilt_init (&out[i], SECFILT_RESET_ALL);
 
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].MpsfChp     = in[i].M;      
+    out[i].dMpsfChp    = in[i].dM;      
+
     out[i].Mchisq= pow (10.0, 0.01*in[i].Xm);     
     out[i].Ncode = in[i].Ncode;
@@ -206,6 +207,7 @@
 
   for (i = 0; i < Nvalues; i++) {
-    out[i].M     = in[i].M;      
-    out[i].dM    = in[i].dM;      
+    out[i].M             = in[i].MpsfChp;      
+    out[i].dM            = in[i].dMpsfChp;      
+
     out[i].Xm    = 100.0*log10(in[i].Mchisq);     
     out[i].Ncode = in[i].Ncode;
Index: /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_photcode_ops.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_photcode_ops.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/libdvo/src/dvo_photcode_ops.c	(revision 40212)
@@ -479,11 +479,11 @@
       switch (class) {
 	case MAG_CLASS_PSF:
-	  Mave = secfilt[Ns].M;
+	  Mave = secfilt[Ns].MpsfChp;
 	  break;
 	case MAG_CLASS_KRON:
-	  Mave = secfilt[Ns].Mkron;
+	  Mave = secfilt[Ns].MkronChp;
 	  break;
 	case MAG_CLASS_APER:
-	  Mave = secfilt[Ns].Map;
+	  Mave = secfilt[Ns].MapChp;
 	  break;
 	default:
@@ -592,11 +592,11 @@
       switch (class) {
 	case MAG_CLASS_PSF:
-	  dMave = secfilt[Ns].dM;
+	  dMave = secfilt[Ns].dMpsfChp;
 	  break;
 	case MAG_CLASS_KRON:
-	  dMave = secfilt[Ns].dMkron;
+	  dMave = secfilt[Ns].dMkronChp;
 	  break;
 	case MAG_CLASS_APER:
-	  dMave = secfilt[Ns].dMap;
+	  dMave = secfilt[Ns].dMapChp;
 	  break;
 	default:
@@ -677,6 +677,6 @@
     Ns2 = photcodes[0].hashNsec[code[0].c2];
   
-    m1 = (Ns1 == -1) ? NAN : secfilt[Ns1].M;
-    m2 = (Ns2 == -1) ? NAN : secfilt[Ns2].M;
+    m1 = (Ns1 == -1) ? NAN : secfilt[Ns1].MpsfChp;
+    m2 = (Ns2 == -1) ? NAN : secfilt[Ns2].MpsfChp;
     mc = (isnan(m1) || isnan(m2)) ? NAN : (m1 - m2);
     return (mc);
@@ -694,5 +694,5 @@
   } else {
     Ns = photcodes[0].hashNsec[color[0].code];
-    m1 = (Ns == -1) ? NAN : secfilt[Ns].M;
+    m1 = (Ns == -1) ? NAN : secfilt[Ns].MpsfChp;
   }	
 
@@ -708,5 +708,5 @@
   } else {
     Ns = photcodes[0].hashNsec[color[0].code];
-    m2 = (Ns == -1) ? NAN : secfilt[Ns].M;
+    m2 = (Ns == -1) ? NAN : secfilt[Ns].MpsfChp;
   }	
   mc = (isnan(m1) || isnan(m2)) ? NAN : (m1 - m2);
@@ -727,11 +727,11 @@
       switch (class) {
 	case MAG_CLASS_PSF:
-	  Mstdev = secfilt[Ns].Mstdev;
+	  Mstdev = secfilt[Ns].sMpsfChp;
 	  break;
 	case MAG_CLASS_KRON:
-	  Mstdev = secfilt[Ns].sMkron;
+	  Mstdev = secfilt[Ns].sMkronChp;
 	  break;
 	case MAG_CLASS_APER:
-	  Mstdev = secfilt[Ns].sMap;
+	  Mstdev = secfilt[Ns].sMapChp;
 	  break;
 	default:
@@ -1040,5 +1040,5 @@
   } else {
     Ns = photcodes[0].hashNsec[code[0].code];
-    M1 = (Ns == -1) ? NAN : secfilt[Ns].M;
+    M1 = (Ns == -1) ? NAN : secfilt[Ns].MpsfChp;
   }	
 
@@ -1056,5 +1056,5 @@
   } else {
     Ns = photcodes[0].hashNsec[code[0].code];
-    M2 = (Ns == -1) ? NAN : secfilt[Ns].M;
+    M2 = (Ns == -1) ? NAN : secfilt[Ns].MpsfChp;
   }	
   
@@ -1289,11 +1289,11 @@
       switch (class) {
 	case MAG_CLASS_PSF:
-	  Fave = MagToFlux(secfilt[Ns].M - 8.9);
+	  Fave = MagToFlux(secfilt[Ns].MpsfChp - 8.9);
 	  break;
 	case MAG_CLASS_KRON:
-	  Fave = MagToFlux(secfilt[Ns].Mkron - 8.9);
+	  Fave = MagToFlux(secfilt[Ns].MkronChp - 8.9);
 	  break;
 	case MAG_CLASS_APER:
-	  Fave = MagToFlux(secfilt[Ns].Map - 8.9);
+	  Fave = MagToFlux(secfilt[Ns].MapChp - 8.9);
 	  break;
 	default:
@@ -1350,11 +1350,11 @@
       switch (class) {
 	case MAG_CLASS_PSF:
-	  dFave = secfilt[Ns].dM * MagToFlux(secfilt[Ns].M - 8.9);
+	  dFave = secfilt[Ns].dMpsfChp * MagToFlux(secfilt[Ns].MpsfChp - 8.9);
 	  break;
 	case MAG_CLASS_KRON:
-	  dFave = secfilt[Ns].dMkron * MagToFlux(secfilt[Ns].Mkron - 8.9);
+	  dFave = secfilt[Ns].dMkronChp * MagToFlux(secfilt[Ns].MkronChp - 8.9);
 	  break;
 	case MAG_CLASS_APER:
-	  dFave = secfilt[Ns].dMap * MagToFlux(secfilt[Ns].Map - 8.9);
+	  dFave = secfilt[Ns].dMapChp * MagToFlux(secfilt[Ns].MapChp - 8.9);
 	  break;
 	default:
@@ -1840,11 +1840,11 @@
       switch (class) {
 	case MAG_CLASS_PSF:
-	  Mave = secfilt[Ns].M;
+	  Mave = secfilt[Ns].MpsfChp;
 	  break;
 	case MAG_CLASS_KRON:
-	  Mave = secfilt[Ns].Mkron;
+	  Mave = secfilt[Ns].MkronChp;
 	  break;
 	case MAG_CLASS_APER:
-	  Mave = secfilt[Ns].Map;
+	  Mave = secfilt[Ns].MapChp;
 	  break;
 	default:
@@ -1927,6 +1927,6 @@
     Ns2 = photcodes[0].hashNsec[code[0].c2];
   
-    m1 = (Ns1 == -1) ? NAN : secfilt[Ns1].M;
-    m2 = (Ns2 == -1) ? NAN : secfilt[Ns2].M;
+    m1 = (Ns1 == -1) ? NAN : secfilt[Ns1].MpsfChp;
+    m2 = (Ns2 == -1) ? NAN : secfilt[Ns2].MpsfChp;
     mc = (isnan(m1) || isnan(m2)) ? NAN : (m1 - m2);
     return (mc);
@@ -1944,5 +1944,5 @@
   } else {
     Ns = photcodes[0].hashNsec[color[0].code];
-    m1 = (Ns == -1) ? NAN : secfilt[Ns].M;
+    m1 = (Ns == -1) ? NAN : secfilt[Ns].MpsfChp;
   }	
 
@@ -1958,5 +1958,5 @@
   } else {
     Ns = photcodes[0].hashNsec[color[0].code];
-    m2 = (Ns == -1) ? NAN : secfilt[Ns].M;
+    m2 = (Ns == -1) ? NAN : secfilt[Ns].MpsfChp;
   }	
   mc = (isnan(m1) || isnan(m2)) ? NAN : (m1 - m2);
@@ -1973,5 +1973,5 @@
 
   Ns = photcodes[0].hashNsec[code[0].code];
-  dM  = (Ns == -1) ? NAN : secfilt[Ns].dM;
+  dM  = (Ns == -1) ? NAN : secfilt[Ns].dMpsfChp;
   return (dM);
 }
@@ -2010,5 +2010,5 @@
   } else {
     Ns = photcodes[0].hashNsec[code[0].code];
-    M1 = (Ns == -1) ? NAN : secfilt[Ns].M;
+    M1 = (Ns == -1) ? NAN : secfilt[Ns].MpsfChp;
   }	
 
@@ -2026,5 +2026,5 @@
   } else {
     Ns = photcodes[0].hashNsec[code[0].code];
-    M2 = (Ns == -1) ? NAN : secfilt[Ns].M;
+    M2 = (Ns == -1) ? NAN : secfilt[Ns].MpsfChp;
   }	
   
Index: /branches/eam_branches/ohana.20170822/src/opihi/dvo/gimages.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/opihi/dvo/gimages.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/opihi/dvo/gimages.c	(revision 40212)
@@ -214,9 +214,9 @@
     if (PixelCoords) {
       gprint (GP_LOG, "%3d %5d %s %6.1f %6.1f %20s %5d %2d %4.2f %6.3f %5.3f %5.3f %4x %7d\n", 
-	      Nfound, (int) i, image[i].name, X, Y, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal, image[i].exptime, image[i].flags, image[i].imageID);
+	      Nfound, (int) i, image[i].name, X, Y, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].McalPSF, image[i].dMcal, image[i].exptime, image[i].flags, image[i].imageID);
     } else {
       XY_to_RD (&ra, &dec, 0.5*image[i].NX, 0.5*image[i].NY, &image[i].coords);
       gprint (GP_LOG, "%3d %5d %s %8.4f %8.4f %20s %5d %2d %4.2f %6.3f %5.3f %5.3f %4x %7d\n", 
-	      Nfound, (int) i, image[i].name, ra, dec, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal, image[i].exptime, image[i].flags, image[i].imageID);
+	      Nfound, (int) i, image[i].name, ra, dec, date, image[i].nstar, image[i].photcode, image[i].secz, image[i].McalPSF, image[i].dMcal, image[i].exptime, image[i].flags, image[i].imageID);
     }
     sprintf (name, "IMAGEx:%d", Nfound);
Index: /branches/eam_branches/ohana.20170822/src/opihi/dvo/gstar.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/opihi/dvo/gstar.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/opihi/dvo/gstar.c	(revision 40212)
@@ -960,5 +960,5 @@
 	print_double (NAN);
       } else {
-	print_double_exp (secfilt[seq].Mstdev);
+	print_double_exp (secfilt[seq].sMpsfChp);
       }
       break;
@@ -1023,5 +1023,5 @@
 	print_double (NAN);
       } else {
-	print_double (secfilt[seq].M);
+	print_double (secfilt[seq].MpsfChp);
       }
       break;
@@ -1031,5 +1031,5 @@
 	print_double (NAN);
       } else {
-	print_double (secfilt[seq].dM);
+	print_double (secfilt[seq].dMpsfChp);
       }
       break;
@@ -1039,5 +1039,5 @@
 	print_double (NAN);
       } else {
-	print_double (secfilt[seq].Map);
+	print_double (secfilt[seq].MapChp);
       }
       break;
@@ -1047,5 +1047,5 @@
 	print_double (NAN);
       } else {
-	print_double (secfilt[seq].dMap);
+	print_double (secfilt[seq].dMapChp);
       }
       break;
@@ -1055,5 +1055,5 @@
 	print_double (NAN);
       } else {
-	print_double_exp (secfilt[seq].sMap);
+	print_double_exp (secfilt[seq].sMapChp);
       }
       break;
@@ -1063,5 +1063,5 @@
 	print_double (NAN);
       } else {
-	print_double_exp (secfilt[seq].dMap);
+	print_double_exp (secfilt[seq].dMapChp);
       }
       break;
@@ -1071,5 +1071,5 @@
 	print_double (NAN);
       } else {
-	print_double (secfilt[seq].Mkron);
+	print_double (secfilt[seq].MkronChp);
       }
       break;
@@ -1079,5 +1079,5 @@
 	print_double (NAN);
       } else {
-	print_double (secfilt[seq].dMkron);
+	print_double (secfilt[seq].dMkronChp);
       }
       break;
@@ -1087,5 +1087,5 @@
 	print_double (NAN);
       } else {
-	print_double_exp (secfilt[seq].sMkron);
+	print_double_exp (secfilt[seq].sMkronChp);
       }
       break;
@@ -1095,5 +1095,5 @@
 	print_double (NAN);
       } else {
-	print_double_exp (secfilt[seq].dMkron);
+	print_double_exp (secfilt[seq].dMkronChp);
       }
       break;
Index: /branches/eam_branches/ohana.20170822/src/opihi/dvo/imlist.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/opihi/dvo/imlist.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/opihi/dvo/imlist.c	(revision 40212)
@@ -141,5 +141,5 @@
     if (VERBOSE) {
       gprint (GP_LOG, "%3lld %s %8lld %8.4f %8.4f %f %5d %2d %4.2f %5.3f %5.3f", 
-			 (long long) i, image[i].name, (long long) image[i].imageID, r, d, t, image[i].nstar, image[i].photcode, image[i].secz, image[i].Mcal, image[i].dMcal);
+			 (long long) i, image[i].name, (long long) image[i].imageID, r, d, t, image[i].nstar, image[i].photcode, image[i].secz, image[i].McalPSF, image[i].dMcal);
 
       if (showUR) {
Index: /branches/eam_branches/ohana.20170822/src/opihi/dvo/imphot.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/opihi/dvo/imphot.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/opihi/dvo/imphot.c	(revision 40212)
@@ -64,5 +64,5 @@
       for (x = 0; x < 100; x+=1.0, p++) {
 	// *p = applyMcal (&image[subset[0]], (fx*x), (fy*y));
-	*p = image[subset[0]].Mcal;
+	*p = image[subset[0]].McalPSF;
       }
     }
@@ -71,5 +71,5 @@
   for (j = 0; j < Nsubset; j++) {
     i = subset[j];
-    gprint (GP_ERR, "%s: %f\n", image[i].name, image[i].Mcal);
+    gprint (GP_ERR, "%s: %f\n", image[i].name, image[i].McalPSF);
 
 // XXX old code when we had the option of a 2D zero point model
@@ -77,18 +77,18 @@
     switch (image[i].order) {
     case 0:
-      gprint (GP_ERR, "%s: %d - %f\n", image[i].name, image[i].order, image[i].Mcal);
+      gprint (GP_ERR, "%s: %d - %f\n", image[i].name, image[i].order, image[i].McalPSF);
       break;
     case 1:
-      gprint (GP_ERR, "%s: %d - %f, %d %d\n", image[i].name, image[i].order, image[i].Mcal, image[i].Mx, image[i].My);
+      gprint (GP_ERR, "%s: %d - %f, %d %d\n", image[i].name, image[i].order, image[i].McalPSF, image[i].Mx, image[i].My);
       break;
     case 2:
-      gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d\n", image[i].name, image[i].order, image[i].Mcal, image[i].Mx, image[i].My, image[i].Mxx, image[i].Mxy, image[i].Myy);
+      gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d\n", image[i].name, image[i].order, image[i].McalPSF, image[i].Mx, image[i].My, image[i].Mxx, image[i].Mxy, image[i].Myy);
       break;
     case 3:
-      gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d, %d %d %d %d\n", image[i].name, image[i].order, image[i].Mcal, image[i].Mx, image[i].My, 
+      gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d, %d %d %d %d\n", image[i].name, image[i].order, image[i].McalPSF, image[i].Mx, image[i].My, 
 	       image[i].Mxx, image[i].Mxy, image[i].Myy, image[i].Mxxx, image[i].Mxxy, image[i].Mxyy, image[i].Myyy);
       break;
     case 4:
-      gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d, %d %d %d %d, %d %d %d %d %d\n", image[i].name, image[i].order, image[i].Mcal, image[i].Mx, image[i].My, 
+      gprint (GP_ERR, "%s: %d - %f, %d %d, %d %d %d, %d %d %d %d, %d %d %d %d %d\n", image[i].name, image[i].order, image[i].McalPSF, image[i].Mx, image[i].My, 
 	       image[i].Mxx, image[i].Mxy, image[i].Myy, image[i].Mxxx, image[i].Mxxy, image[i].Mxyy, image[i].Myyy,
 	       image[i].Mxxxx, image[i].Mxxxy, image[i].Mxxyy, image[i].Mxyyy, image[i].Myyyy);
Index: /branches/eam_branches/ohana.20170822/src/opihi/dvo/imstats.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/opihi/dvo/imstats.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/opihi/dvo/imstats.c	(revision 40212)
@@ -41,5 +41,5 @@
     Xvec.elements.Flt[i] = image[i].secz;
     if (Mcal) 
-      Yvec.elements.Flt[i] = image[i].Mcal;
+      Yvec.elements.Flt[i] = image[i].McalPSF;
     else 
       Yvec.elements.Flt[i] = image[i].dMcal;
@@ -47,5 +47,5 @@
     gprint (GP_ERR, "%d %8.4f %8.4f %10d %6d  %5.3f %6.3f %6.3f\n", 
 	     i, r, d, image[i].tzero, image[i].nstar, Xvec.elements.Flt[i], 
-	     image[i].Mcal, image[i].dMcal);
+	     image[i].McalPSF, image[i].dMcal);
   } 
   if (AutoLimits) SetLimits (&Xvec, &Yvec, &graphmode);
Index: /branches/eam_branches/ohana.20170822/src/opihi/dvo/objectcoverage.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/opihi/dvo/objectcoverage.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/opihi/dvo/objectcoverage.c	(revision 40212)
@@ -203,5 +203,5 @@
 	if (catalog.secfilt[j*Nsecfilt+Nsec].Ncode < 2) { continue; }
 
-	invalid = ((catalog.secfilt[j*Nsecfilt + Nsec].M < 1.0) || (isnan(catalog.secfilt[j*Nsecfilt + Nsec].M)));
+	invalid = ((catalog.secfilt[j*Nsecfilt + Nsec].MpsfChp < 1.0) || (isnan(catalog.secfilt[j*Nsecfilt + Nsec].MpsfChp)));
 	if (invalid) continue;
 	
Index: /branches/eam_branches/ohana.20170822/src/opihi/dvo/paverage.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/opihi/dvo/paverage.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/opihi/dvo/paverage.c	(revision 40212)
@@ -125,5 +125,5 @@
       while (average[i].R > Rmax) average[i].R -= 360.0;
 
-      mag = secfilt[i*Nsecfilt+Nsec].M;
+      mag = secfilt[i*Nsecfilt+Nsec].MpsfChp;
       Zvec[Npts] = MIN (1.0, MAX (0.01, (mag - Mz) / Mr));
       if (LimExclude && (Zvec[Npts] > 0.99)) continue;
Index: /branches/eam_branches/ohana.20170822/src/opihi/dvo/skycoverage.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/opihi/dvo/skycoverage.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/opihi/dvo/skycoverage.c	(revision 40212)
@@ -330,8 +330,8 @@
 	      break;
 	    case MIN_MCAL:
-	      V[ys*Nx + xs] = MIN(V[ys*Nx + xs], image[i].Mcal);
+	      V[ys*Nx + xs] = MIN(V[ys*Nx + xs], image[i].McalPSF);
 	      break;
 	    case MAX_MCAL:
-	      V[ys*Nx + xs] = MAX(V[ys*Nx + xs], image[i].Mcal);
+	      V[ys*Nx + xs] = MAX(V[ys*Nx + xs], image[i].McalPSF);
 	      break;
 	    case MIN_TIME: {
Index: /branches/eam_branches/ohana.20170822/src/opihi/lib.shell/evaluate_stack.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/opihi/lib.shell/evaluate_stack.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/opihi/lib.shell/evaluate_stack.c	(revision 40212)
@@ -188,4 +188,8 @@
 	  snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s\n", stack[i-1].name, stack[i-2].name);
 	  push_error (line);
+	  if (strchr(stack[i-1].name, ':') || strchr(stack[i-2].name, ':')) {
+	    snprintf (line, 512, "syntax error: invalid operand for binary operation: %s or %s\n(Note that the : in a trinary operation must be protected by spaces)\n", stack[i-1].name, stack[i-2].name);
+	    push_error (line);
+	  }
 	  clear_stack (&tmp_stack);
 	  return (FALSE);
Index: /branches/eam_branches/ohana.20170822/src/photdbc/src/get_mags.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/photdbc/src/get_mags.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/photdbc/src/get_mags.c	(revision 40212)
@@ -20,7 +20,7 @@
     Nlist = MAX (Nlist, catalog[0].average[i].Nm);
     for (j = 0; j < Nsecfilt; j++) {
-      catalog[0].secfilt[i*Nsecfilt+j].M  = NAN;
-      catalog[0].secfilt[i*Nsecfilt+j].dM = NAN;
-      catalog[0].secfilt[i*Nsecfilt+j].Mchisq = NAN;
+      catalog[0].secfilt[i*Nsecfilt+j].MpsfChp  = NAN;
+      catalog[0].secfilt[i*Nsecfilt+j].dMpsfChp = NAN;
+      catalog[0].secfilt[i*Nsecfilt+j].Mchisq   = NAN;
     }
   }
@@ -52,7 +52,7 @@
       if (N < 1) continue;
     
-      Mval = (Nsec == -1) ? &catalog[0].average[i].M : &catalog[0].secfilt[i*Nsecfilt+Nsec].M;
+      Mval = (Nsec == -1) ? &catalog[0].average[i].M : &catalog[0].secfilt[i*Nsecfilt+Nsec].MpsfChp;
       *Mval = stats.mean;
-      Mval = (Nsec == -1) ? &catalog[0].average[i].dM : &catalog[0].secfilt[i*Nsecfilt+Nsec].dM;
+      Mval = (Nsec == -1) ? &catalog[0].average[i].dM : &catalog[0].secfilt[i*Nsecfilt+Nsec].dMpsfChp;
       *Mval = stats.sigma;
       Mval = (Nsec == -1) ? &catalog[0].average[i].Mchisq : &catalog[0].secfilt[i*Nsecfilt+Nsec].Mchisq;
Index: /branches/eam_branches/ohana.20170822/src/photdbc/src/join_stars.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/photdbc/src/join_stars.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/photdbc/src/join_stars.c	(revision 40212)
@@ -87,5 +87,5 @@
 
     // require base star to meet certain conditions:
-    if (isnan(secfilt[Ni*Nsecfilt + baseNsec].M)) {
+    if (isnan(secfilt[Ni*Nsecfilt + baseNsec].MpsfChp)) {
       i++;
       continue;
Index: /branches/eam_branches/ohana.20170822/src/photdbc/src/make_subcatalog.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/photdbc/src/make_subcatalog.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/photdbc/src/make_subcatalog.c	(revision 40212)
@@ -63,5 +63,5 @@
       keep = FALSE;
       for (j = 0; !keep && (j < Nsecfilt); j++) {
-	if (catalog[0].secfilt[Nsecfilt*i+j].dM < AVE_SIGMA_LIM) {
+	if (catalog[0].secfilt[Nsecfilt*i+j].dMpsfChp < AVE_SIGMA_LIM) {
 	  keep = TRUE;
 	}
Index: /branches/eam_branches/ohana.20170822/src/relastro/include/relastro.h
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relastro/include/relastro.h	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/relastro/include/relastro.h	(revision 40212)
@@ -215,7 +215,8 @@
   unsigned int stop;
   off_t myImage;
-  float Mcal;
+  float McalPSF;
+  float McalAPER;
   float dMcal;
-  short Xm;
+  float McalChiSq;
   float secz;
   char flags;
Index: /branches/eam_branches/ohana.20170822/src/relastro/src/BrightCatalog.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relastro/src/BrightCatalog.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/relastro/src/BrightCatalog.c	(revision 40212)
@@ -285,12 +285,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);
@@ -694,12 +694,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/relastro/src/ImageOps.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relastro/src/ImageOps.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/relastro/src/ImageOps.c	(revision 40212)
@@ -431,5 +431,5 @@
   /**** dMcal vs airmass ****/
   for (i = 0; i < Nimage; i++) {
-    Mlist[i] = image[i].Mcal;
+    Mlist[i] = image[i].McalPSF;
     dlist[i] = image[i].dMcal;
     xlist[i] = image[i].secz;
@@ -819,8 +819,8 @@
 
     if ((DCR_BLUE_NSEC_POS >= 0) && (DCR_BLUE_NSEC_NEG >= -1)) {
-      ref[i].ColorBlue = catalog[c].secfilt[n*Nsecfilt + DCR_BLUE_NSEC_POS].M - catalog[c].secfilt[n*Nsecfilt + DCR_BLUE_NSEC_NEG].M;
+      ref[i].ColorBlue = catalog[c].secfilt[n*Nsecfilt + DCR_BLUE_NSEC_POS].MpsfChp - catalog[c].secfilt[n*Nsecfilt + DCR_BLUE_NSEC_NEG].MpsfChp;
     }
     if ((DCR_RED_NSEC_POS >= 0) && (DCR_RED_NSEC_NEG >= -1)) {
-      ref[i].ColorRed = catalog[c].secfilt[n*Nsecfilt + DCR_RED_NSEC_POS].M - catalog[c].secfilt[n*Nsecfilt + DCR_RED_NSEC_NEG].M;
+      ref[i].ColorRed = catalog[c].secfilt[n*Nsecfilt + DCR_RED_NSEC_POS].MpsfChp - catalog[c].secfilt[n*Nsecfilt + DCR_RED_NSEC_NEG].MpsfChp;
     }
 
Index: /branches/eam_branches/ohana.20170822/src/relastro/src/MosaicOps.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relastro/src/MosaicOps.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/relastro/src/MosaicOps.c	(revision 40212)
@@ -97,13 +97,14 @@
 
     /* a new mosaic, define ranges */
-    mosaic[Nmosaic].start   = start;
-    mosaic[Nmosaic].stop    = stop;
-    mosaic[Nmosaic].Mcal    = 0.0;
-    mosaic[Nmosaic].dMcal   = 0.0;
-    mosaic[Nmosaic].Xm      = 0.0;
-    mosaic[Nmosaic].flags   = image[i].flags;
-    mosaic[Nmosaic].secz    = image[i].secz;
-    mosaic[Nmosaic].coords  = image[i].coords;
-    mosaic[Nmosaic].myImage = i;
+    mosaic[Nmosaic].start     = start;
+    mosaic[Nmosaic].stop      = stop;
+    mosaic[Nmosaic].McalPSF   = 0.0;
+    mosaic[Nmosaic].McalAPER  = 0.0;
+    mosaic[Nmosaic].dMcal     = 0.0;
+    mosaic[Nmosaic].McalChiSq = 0.0;
+    mosaic[Nmosaic].flags     = image[i].flags;
+    mosaic[Nmosaic].secz      = image[i].secz;
+    mosaic[Nmosaic].coords    = image[i].coords;
+    mosaic[Nmosaic].myImage   = i;
 
     // init the mosaic_own_images array data
Index: /branches/eam_branches/ohana.20170822/src/relphot/include/relphot.h
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relphot/include/relphot.h	(revision 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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 40211)
+++ /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;
Index: /branches/eam_branches/ohana.20170822/src/uniphot/include/setphot.h
===================================================================
--- /branches/eam_branches/ohana.20170822/src/uniphot/include/setphot.h	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/uniphot/include/setphot.h	(revision 40212)
@@ -11,5 +11,6 @@
 
 typedef struct {
-  float Mcal;
+  float McalPSF;
+  float McalAPER;
   float dMcal;
   unsigned int imageID;
Index: /branches/eam_branches/ohana.20170822/src/uniphot/src/ImageSubset.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/uniphot/src/ImageSubset.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/uniphot/src/ImageSubset.c	(revision 40212)
@@ -56,9 +56,10 @@
   char type[16];
 
-  GET_COLUMN (Mcal,    "MCAL",       float);
-  GET_COLUMN (dMcal,   "MCAL_ERR",   float);
-  GET_COLUMN (imageID, "IMAGE_ID",   int);
-  GET_COLUMN (map,     "PHOTOM_MAP", int);
-  GET_COLUMN (flags,   "FLAGS",      int);
+  GET_COLUMN (McalPSF,  "MCAL_PSF",   float);
+  GET_COLUMN (McalAPER, "MCAL_APER",  float);
+  GET_COLUMN (dMcal,    "MCAL_ERR",   float);
+  GET_COLUMN (imageID,  "IMAGE_ID",   int);
+  GET_COLUMN (map,      "PHOTOM_MAP", int);
+  GET_COLUMN (flags,    "FLAGS",      int);
 
   // XXX free the fits table data here 
@@ -69,10 +70,12 @@
     image[i].photom_map_id = map[i];
     image[i].flags         = flags[i];
-    image[i].Mcal          = Mcal[i];
+    image[i].McalPSF       = McalPSF[i];
+    image[i].McalAPER      = McalAPER[i];
     image[i].dMcal         = dMcal[i];
   }
   fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow);
 
-  free (Mcal);
+  free (McalPSF);
+  free (McalAPER);
   free (dMcal);
   free (imageID);
@@ -108,31 +111,32 @@
   gfits_create_table (&theader, &ftable);
 
-  float *Mcal, *dMcal;
-  unsigned int *imageID, *map, *flags;
-
   // create intermediate storage arrays
-  ALLOCATE (Mcal,    float, 	   Nimage);
-  ALLOCATE (dMcal,   float, 	   Nimage);
-  ALLOCATE (imageID, unsigned int, Nimage);
-  ALLOCATE (map,     unsigned int, Nimage);
-  ALLOCATE (flags,   unsigned int, Nimage);
+  ALLOCATE_PTR (McalPSF,  float,        Nimage);
+  ALLOCATE_PTR (McalAPER, float,        Nimage);
+  ALLOCATE_PTR (dMcal,    float,        Nimage);
+  ALLOCATE_PTR (imageID,  unsigned int, Nimage);
+  ALLOCATE_PTR (map,      unsigned int, Nimage);
+  ALLOCATE_PTR (flags,    unsigned int, Nimage);
 
   // assign the storage arrays
   for (i = 0; i < Nimage; i++) {
-    imageID[i] = image[i].imageID;
-    map[i]     = image[i].photom_map_id;
-    flags[i]   = image[i].flags;
-    Mcal[i]    = image[i].Mcal;
-    dMcal[i]   = image[i].dMcal;
+    imageID[i]  =  image[i].imageID;
+    map[i]      =  image[i].photom_map_id;
+    flags[i]    =  image[i].flags;
+    McalPSF[i]  =  image[i].McalPSF;
+    McalAPER[i] =  image[i].McalAPER;
+    dMcal[i]    =  image[i].dMcal;
   }
 
   // add the columns to the output array
-  gfits_set_bintable_column (&theader, &ftable, "MCAL",       Mcal,    Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "MCAL_ERR",   dMcal,   Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "IMAGE_ID",   imageID, Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "PHOTOM_MAP", map,     Nimage);
-  gfits_set_bintable_column (&theader, &ftable, "FLAGS",      flags,   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);
+  gfits_set_bintable_column (&theader, &ftable, "PHOTOM_MAP", map,      Nimage);
+  gfits_set_bintable_column (&theader, &ftable, "FLAGS",      flags,    Nimage);
 
-  free (Mcal);
+  free (McalPSF);
+  free (McalAPER);
   free (dMcal);
   free (imageID);
@@ -174,5 +178,6 @@
     image[i].photom_map_id = subset[i].photom_map_id;
     image[i].flags         = subset[i].flags        ;
-    image[i].Mcal          = subset[i].Mcal         ;
+    image[i].McalPSF       = subset[i].McalPSF      ;
+    image[i].McalAPER      = subset[i].McalAPER     ;
     image[i].dMcal         = subset[i].dMcal        ;
   }
Index: /branches/eam_branches/ohana.20170822/src/uniphot/src/dumpresult.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/uniphot/src/dumpresult.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/uniphot/src/dumpresult.c	(revision 40212)
@@ -2,5 +2,5 @@
 
 void dumpresult () {
-  short Mcal, Mgrp, Mset;
+  float Mcal, Mgrp, Mset;
   FILE *f;
   char outfile[64];
@@ -13,5 +13,5 @@
       if (sgroup[i].image[j][0].code & IMAGE_BAD) continue;
       tgrp = (Group *) sgroup[i].imlink[j][0].tgroup;
-      Mcal = sgroup[i].image[j][0].Mcal;
+      Mcal = sgroup[i].image[j][0].McalPSF;
       Mset = sgroup[i].M;
       Mgrp = tgrp[0].M;
Index: /branches/eam_branches/ohana.20170822/src/uniphot/src/fit_groups.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/uniphot/src/fit_groups.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/uniphot/src/fit_groups.c	(revision 40212)
@@ -18,5 +18,5 @@
       if (tgroup[i].image[j][0].flags & IMAGE_BAD) continue;
       sgroup = (Group *) tgroup[i].imlink[j][0].sgroup;
-      Mcal = tgroup[i].image[j][0].Mcal;
+      Mcal = tgroup[i].image[j][0].McalPSF;
       Mgrp = sgroup[0].M;
       mlist[Nlist] = (Mcal - Mgrp);
@@ -58,5 +58,5 @@
       if (sgroup[i].image[j][0].flags & IMAGE_BAD) continue;
       tgroup = (Group *) sgroup[i].imlink[j][0].tgroup;
-      Mcal = sgroup[i].image[j][0].Mcal;
+      Mcal = sgroup[i].image[j][0].McalPSF;
       Mgrp = tgroup[0].M;
       mlist[Nlist] = (Mcal - Mgrp);
Index: /branches/eam_branches/ohana.20170822/src/uniphot/src/match_zpts_to_images.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/uniphot/src/match_zpts_to_images.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/uniphot/src/match_zpts_to_images.c	(revision 40212)
@@ -41,7 +41,8 @@
   if (RESET) {
     for (i = 0; i < Nimage; i++) {
-      image[i].Mcal = 0.0;
-      image[i].dMcal = NAN;
-      image[i].flags &= ~ID_IMAGE_PHOTOM_NOCAL; // clear the NOCAL flag
+      image[i].McalPSF  = 0.0;
+      image[i].McalAPER = 0.0;
+      image[i].dMcal    = NAN;
+      image[i].flags   &= ~ID_IMAGE_PHOTOM_NOCAL; // clear the NOCAL flag
       if (UBERCAL) {
 	image[i].flags &= ~ID_IMAGE_PHOTOM_UBERCAL; // clear the UBERCAL flag
@@ -107,8 +108,10 @@
     // UBERCAL includes 2.5log(exptime) + K*airmass in the zero point
     if (UBERCAL) {
-      image[Ni].Mcal = SCALE*code[0].C - zpts[Nz].zpt + 2.5*log10(image[Ni].exptime) + code[0].K*(image[Ni].secz - 1.000);
-      myAssert (isfinite(image[Ni].Mcal), "oops, ubercal made a nan image");
+      image[Ni].McalPSF  = SCALE*code[0].C - zpts[Nz].zpt + 2.5*log10(image[Ni].exptime) + code[0].K*(image[Ni].secz - 1.000);
+      image[Ni].McalAPER = SCALE*code[0].C - zpts[Nz].zpt + 2.5*log10(image[Ni].exptime) + code[0].K*(image[Ni].secz - 1.000);
+      myAssert (isfinite(image[Ni].McalPSF), "oops, ubercal made a nan image");
     } else {
-      image[Ni].Mcal = SCALE*code[0].C - zpts[Nz].zpt;
+      image[Ni].McalPSF  = SCALE*code[0].C - zpts[Nz].zpt;
+      image[Ni].McalAPER = SCALE*code[0].C - zpts[Nz].zpt;
     }
 
@@ -116,5 +119,6 @@
     float offset = apply_zpt_offset (code[0].equiv);
     assert (isfinite(offset));
-    image[Ni].Mcal += offset;
+    image[Ni].McalPSF  += offset;
+    image[Ni].McalAPER += offset;
 
     image[Ni].dMcal = zpts[Nz].zpt_err;
Index: /branches/eam_branches/ohana.20170822/src/uniphot/src/update_catalog_setastrom.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/uniphot/src/update_catalog_setastrom.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/uniphot/src/update_catalog_setastrom.c	(revision 40212)
@@ -153,6 +153,6 @@
 	case 101:
 	case 102: {
-	  float gmag = secfilt[Nsec_g].M;
-	  float imag = secfilt[Nsec_i].M;
+	  float gmag = secfilt[Nsec_g].MpsfChp;
+	  float imag = secfilt[Nsec_i].MpsfChp;
 	  dColor = average->refColorBlue - (gmag - imag);
 	  break;
@@ -160,6 +160,6 @@
 	case 103:
 	case 104: {
-	  float zmag = secfilt[Nsec_z].M;
-	  float ymag = secfilt[Nsec_y].M;
+	  float zmag = secfilt[Nsec_z].MpsfChp;
+	  float ymag = secfilt[Nsec_y].MpsfChp;
 	  dColor = average->refColorRed - (zmag - ymag);
 	  break;
Index: /branches/eam_branches/ohana.20170822/src/uniphot/src/update_catalog_setphot.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/uniphot/src/update_catalog_setphot.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/uniphot/src/update_catalog_setphot.c	(revision 40212)
@@ -39,5 +39,5 @@
     if (id < 0) continue;
 
-    float Mcal = image[id].Mcal;
+    float Mcal  = image[id].McalPSF;
     float dMcal = image[id].dMcal;
     float Mflat = 0.0;
Index: /branches/eam_branches/ohana.20170822/src/uniphot/src/update_catalog_uniphot.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/uniphot/src/update_catalog_uniphot.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/uniphot/src/update_catalog_uniphot.c	(revision 40212)
@@ -14,6 +14,6 @@
   for (i = 0; i < catalog[0].Naverage; i++) {
     
-    if (!isnan(catalog[0].secfilt[i*Nsecfilt+Nsec].M)) {
-      catalog[0].secfilt[i*Nsecfilt+Nsec].M += sgroup[0].M;
+    if (!isnan(catalog[0].secfilt[i*Nsecfilt+Nsec].MpsfChp)) {
+      catalog[0].secfilt[i*Nsecfilt+Nsec].MpsfChp += sgroup[0].M;
     }
 
Index: /branches/eam_branches/ohana.20170822/src/uniphot/src/update_dvo_uniphot.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/uniphot/src/update_dvo_uniphot.c	(revision 40211)
+++ /branches/eam_branches/ohana.20170822/src/uniphot/src/update_dvo_uniphot.c	(revision 40212)
@@ -37,5 +37,6 @@
   for (i = 0; i < Nsgroup; i++) {
     for (j = 0; j < sgroup[i].Nimage; j++) {
-      sgroup[i].image[j][0].Mcal -= sgroup[i].M;
+      sgroup[i].image[j][0].McalPSF  -= sgroup[i].M;
+      sgroup[i].image[j][0].McalAPER -= sgroup[i].M;
     }
   }
