Index: branches/czw_branch/20160809/psastro/src/psastro.h
===================================================================
--- branches/czw_branch/20160809/psastro/src/psastro.h	(revision 39651)
+++ branches/czw_branch/20160809/psastro/src/psastro.h	(revision 39653)
@@ -70,5 +70,5 @@
 bool              psastroCorrectKH (pmConfig *config, pmFPAview *view, pmReadout *readout, psMetadata *recipe, psArray *inStars);
 
-psArray          *pmSourceToAstromObj (psArray *sources);
+psArray          *pmSourceToAstromObj (psArray *sources, float MagOffset);
 bool              psastroAstromGuess (int *nStars, pmConfig *config);
 bool              psastroAstromGuessCheck (pmConfig *config);
Index: branches/czw_branch/20160809/psastro/src/psastroChipAstrom.c
===================================================================
--- branches/czw_branch/20160809/psastro/src/psastroChipAstrom.c	(revision 39651)
+++ branches/czw_branch/20160809/psastro/src/psastroChipAstrom.c	(revision 39653)
@@ -85,9 +85,9 @@
 		  for (int nn = 0; nn < refstars->n; nn++) {
 		    pmAstromObj *ref = refstars->data[nn];
-		    fprintf (outfile, "%lf %lf  %lf %lf  %lf %lf  %lf %lf\n", 
+		    fprintf (outfile, "%lf %lf  %lf %lf  %lf %lf  %lf %lf : %f %f\n", 
 			     ref->sky->r*PS_DEG_RAD, ref->sky->d*PS_DEG_RAD,
 			     ref->TP->x, ref->TP->y, 
 			     ref->FP->x, ref->FP->y, 
-			     ref->chip->x, ref->chip->y);
+			     ref->chip->x, ref->chip->y, ref->Mag, ref->magCal);
 		  }
 		  fclose (outfile);
@@ -101,9 +101,9 @@
 		  for (int nn = 0; nn < gridrawstars->n; nn++) {
 		    pmAstromObj *ref = gridrawstars->data[nn];
-		    fprintf (outfile, "%lf %lf  %lf %lf  %lf %lf  %lf %lf\n", 
+		    fprintf (outfile, "%lf %lf  %lf %lf  %lf %lf  %lf %lf : %f %f\n", 
 			     ref->sky->r*PS_DEG_RAD, ref->sky->d*PS_DEG_RAD,
 			     ref->TP->x, ref->TP->y, 
 			     ref->FP->x, ref->FP->y, 
-			     ref->chip->x, ref->chip->y);
+			     ref->chip->x, ref->chip->y, ref->Mag, ref->magCal);
 		  }
 		  fclose (outfile);
Index: branches/czw_branch/20160809/psastro/src/psastroConvert.c
===================================================================
--- branches/czw_branch/20160809/psastro/src/psastroConvert.c	(revision 39651)
+++ branches/czw_branch/20160809/psastro/src/psastroConvert.c	(revision 39653)
@@ -51,4 +51,29 @@
     bool status;
 
+    // XXX I want to make this optional
+    float MagOffset = 0.0;
+    if (1) {
+      // select the input data sources
+      pmFPAfile *input = psMetadataLookupPtr (NULL, config->files, "PSASTRO.INPUT");
+      if (!input) {
+	psError(PSASTRO_ERR_CONFIG, true, "failed to find PSASTRO.INPUT\n");
+	return false;
+      }
+      pmFPA *fpa = input->fpa;
+
+      float zeropt, exptime;
+
+      // really error-out here?  or just skip?
+      if (!psastroZeroPointFromRecipe (&zeropt, &exptime, NULL, fpa, recipe)) {
+        psLogMsg ("psastro", PS_LOG_INFO, "failed to load zeropt data from recipe");
+	zeropt = 0.0;
+	exptime = 1.0;
+      }
+
+      // recipe values are given in instrumental magnitudes
+      // use the zero point and exposure time to convert to apparent mags: M_ap = M_inst + C_0 + 2.5*log(exptime)
+      MagOffset = zeropt + 2.5*log10(exptime);
+    }
+
     // PSPHOT.SOURCES carries the pmSource objects (from psphot analysis or loaded externally)
     pmDetections *detections = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.DETECTIONS");
@@ -59,5 +84,5 @@
 
     // convert the pmSource objects into pmAstromObj objects (drop !STAR and SATSTAR?)
-    psArray *inStars = pmSourceToAstromObj (sources);
+    psArray *inStars = pmSourceToAstromObj (sources, MagOffset);
 
     // apply Koppenhoefer correction if needed
@@ -175,5 +200,5 @@
 
 // select a magnitude range?
-psArray *pmSourceToAstromObj (psArray *sources) {
+psArray *pmSourceToAstromObj (psArray *sources, float MagOffset) {
 
     psArray *objects = psArrayAllocEmpty (sources->n);
@@ -211,4 +236,5 @@
         obj->dMag = source->psfMagErr;
         obj->SBinst = source->psfMag + 5.0*log10(axes.major);
+        obj->magCal = obj->Mag + MagOffset;
 
         // XXX do we have the information giving the readout and cell offset?
Index: branches/czw_branch/20160809/psastro/src/psastroLoadRefstars.c
===================================================================
--- branches/czw_branch/20160809/psastro/src/psastroLoadRefstars.c	(revision 39651)
+++ branches/czw_branch/20160809/psastro/src/psastroLoadRefstars.c	(revision 39653)
@@ -265,4 +265,5 @@
             ref->Color    = 0.0;
         }
+	ref->magCal   = ref->Mag;
 
         // XXX VERY temporary hack to avoid M31 bulge
@@ -306,4 +307,5 @@
             ref->Color = 0.0;
         }
+	ref->magCal   = ref->Mag;
 
         // XXX VERY temporary hack to avoid M31 bulge
