Index: trunk/psastro/src/psastroConvert.c
===================================================================
--- trunk/psastro/src/psastroConvert.c	(revision 38040)
+++ trunk/psastro/src/psastroConvert.c	(revision 39926)
@@ -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?
