Index: trunk/psphot/src/psphotMagnitudes.c
===================================================================
--- trunk/psphot/src/psphotMagnitudes.c	(revision 10138)
+++ trunk/psphot/src/psphotMagnitudes.c	(revision 10185)
@@ -4,5 +4,5 @@
 		      psMetadata *recipe,
 		      pmPSF *psf,
-		      const pmConfig *config)
+		      pmReadout *background)
 {
     bool status = false;
@@ -13,25 +13,18 @@
     pmSourceMagnitudesInit (recipe);
 
+    // XXX require (assert) that we have a background model, or 
+    // allow it to be missing, setting local sky to 0.0?
+
     // 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);
-	}
-    }
+    assert(background != NULL);
+    assert(background->analysis != NULL);
+    int DX = psMetadataLookupS32(&status, background->analysis, "XBIN");
+    assert (status == true);
+    int DY = psMetadataLookupS32(&status, background->analysis, "YBIN");
+    assert (status == true);
+    int dx = psMetadataLookupS32(&status, background->analysis, "x0");
+    assert (status == true);
+    int dy = psMetadataLookupS32(&status, background->analysis, "y0");
+    assert (status == true);
 
     bool IGNORE_GROWTH = psMetadataLookupBool (&status, recipe, "IGNORE_GROWTH");
@@ -47,16 +40,9 @@
 	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();
-	    }
+	source->sky = psImageUnbinPixel(source->peak->x, source->peak->y, background->image, DX, DY, dx, dy);
+	if (isnan(source->sky) && false) {
+	  psError(PSPHOT_ERR_SKY, false, "Setting pmSource.sky");
+	  psErrorStackPrint(NULL, " ");
+	  psErrorClear();
 	}
     }	
