Index: /trunk/psphot/src/psphotMagnitudes.c
===================================================================
--- /trunk/psphot/src/psphotMagnitudes.c	(revision 10137)
+++ /trunk/psphot/src/psphotMagnitudes.c	(revision 10138)
@@ -1,6 +1,9 @@
 # include "psphot.h"
 
-bool psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf) {
-
+bool psphotMagnitudes(psArray *sources,
+		      psMetadata *recipe,
+		      pmPSF *psf,
+		      const pmConfig *config)
+{
     bool status = false;
     int Nap = 0;
@@ -9,4 +12,26 @@
 
     pmSourceMagnitudesInit (recipe);
+
+    // Get enough information to return sky level
+    assert (config != NULL);
+    const psImage *background = NULL;
+    int DX = 0, DY = 0, dx = 0, dy = 0;	// unpacked with PSPHOT.BACKMDL
+    {
+	const pmFPAfile *backgroundFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL");
+	if (backgroundFile != NULL) {
+	    assert (backgroundFile->readout != NULL);
+	    background = backgroundFile->readout->image;
+
+	    assert(backgroundFile->readout->analysis != NULL);
+	    DX = psMetadataLookupS32(&status, backgroundFile->readout->analysis, "XBIN");
+	    assert (status == true);
+	    DY = psMetadataLookupS32(&status, backgroundFile->readout->analysis, "YBIN");
+	    assert (status == true);
+	    dx = psMetadataLookupS32(&status, backgroundFile->readout->analysis, "x0");
+	    assert (status == true);
+	    dy = psMetadataLookupS32(&status, backgroundFile->readout->analysis, "y0");
+	    assert (status == true);
+	}
+    }
 
     bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH");
@@ -21,4 +46,18 @@
 	status = pmSourceMagnitudes (source, psf, photMode);
 	if (status) Nap ++;
+
+	source->sky = 0;
+#if 0
+	source->sky += source->moments->Sky;
+#endif
+
+        if (background != NULL) {
+	    source->sky += psImageUnbinPixel(source->peak->x, source->peak->y, background, DX, DY, dx, dy);
+	    if (isnan(source->sky) && false) {
+		psError(PSPHOT_ERR_SKY, false, "Setting pmSource.sky");
+		psErrorStackPrint(NULL, " ");
+		psErrorClear();
+	    }
+	}
     }	
 
Index: /trunk/psphot/src/psphotReadout.c
===================================================================
--- /trunk/psphot/src/psphotReadout.c	(revision 10137)
+++ /trunk/psphot/src/psphotReadout.c	(revision 10138)
@@ -111,5 +111,5 @@
 
     // calculate source magnitudes
-    psphotMagnitudes (sources, recipe, psf);
+    psphotMagnitudes(sources, recipe, psf, config);
 
     // replace background in residual image
