Index: trunk/psphot/src/psphotImageStats.c
===================================================================
--- trunk/psphot/src/psphotImageStats.c	(revision 6056)
+++ trunk/psphot/src/psphotImageStats.c	(revision 6117)
@@ -39,13 +39,12 @@
     }
 
-    // we store these values in mean,stdev 
-    bool status = false;
-    float NOISE = psMetadataLookupF32 (&status, config, "RDNOISE");
-    float GAIN  = psMetadataLookupF32 (&status, config, "GAIN");
+    pmCell *cell = readout->parent;	// cell containing this readout;
+    float gain = psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN"); // Cell gain
+    float noise = psMetadataLookupF32(NULL, cell->concepts, "CELL.READNOISE"); // Cell read noise
 
     // convert instrumental background to poisson stats
     sky = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);
     sky->sampleMean   = stats->sampleMedian;
-    sky->sampleStdev  = sqrt(sky->sampleMean/GAIN + PS_SQR(NOISE));
+    sky->sampleStdev  = sqrt(sky->sampleMean/gain + PS_SQR(noise));
 
     psLogMsg ("psphot", 4, "background: %f +/- %f\n", sky->sampleMean, sky->sampleStdev);
