Index: trunk/psphot/src/psphotReadout.c
===================================================================
--- trunk/psphot/src/psphotReadout.c	(revision 6522)
+++ trunk/psphot/src/psphotReadout.c	(revision 6571)
@@ -2,40 +2,42 @@
 
 // XXX 2006.02.07 : no leaks!
-bool psphotReadout (pmReadout *readout, psMetadata *config) {
+// XXX change 'config' to 'recipe' eventually
+bool psphotReadout (pmConfig *config, pmFPAview *view) {
 
     psArray     *sources  = NULL;
     psArray     *peaks    = NULL;
-    psImage     *skymodel = NULL;
     pmPSF       *psf      = NULL;
     bool         status;
 
+    // find the currently selected readout
+    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, "PSPHOT");
+    pmFPA *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
+    pmReadout  *readout = pmFPAviewThisReadout (view, input);
+
     // generate a background model (median, smoothed image)
-    skymodel = psphotImageMedian (readout, config);
-
-    // optional output of background-subtracted image
-    psphot
+    psphotImageMedian (config, view);
 
     // find the peaks in the image
-    peaks = psphotFindPeaks (readout, config);
+    peaks = psphotFindPeaks (readout, recipe);
 
     // construct sources and measure basic stats
     // limit moments analysis by S/N?
-    sources = psphotSourceStats (readout, config, peaks);
+    sources = psphotSourceStats (readout, recipe, peaks);
 
     // classify sources based on moments, brightness
     // faint sources not classified?
-    psphotRoughClass (sources, config);
+    psphotRoughClass (sources, recipe);
 
     // mark blended peaks PS_SOURCE_BLEND
-    psphotBasicDeblend (sources, config);
+    psphotBasicDeblend (sources, recipe);
 
     // use bright stellar objects to measure PSF
-    psf = psphotChoosePSF (config, sources);
+    psf = psphotChoosePSF (sources, recipe);
 
     // linear PSF fit to peaks
-    psphotEnsemblePSF (readout, config, sources, psf, FALSE);
+    psphotEnsemblePSF (readout, sources, recipe, psf, FALSE);
 
     // non-linear PSF and EXT fit to brighter sources
-    psphotBlendFit (readout, config, sources, psf);
+    psphotBlendFit (readout, sources, recipe, psf);
 
     // replace fitted sources
@@ -46,13 +48,14 @@
 
     // linear PSF fit to remaining peaks
-    psphotEnsemblePSF (readout, config, sources, psf, TRUE);
+    psphotEnsemblePSF (readout, sources, recipe, psf, TRUE);
 
     // measure aperture photometry corrections
-    psphotApResid (readout, sources, config, psf);
+    psphotApResid (readout, sources, recipe, psf);
 
     // calculate source magnitudes
-    psphotMagnitudes (config, sources, psf);
+    psphotMagnitudes (sources, recipe, psf);
 
     // update the header with stats results
+    // XXX need to do this conditionally?
     psMetadata *header = pmReadoutGetHeader (readout);
     psphotUpdateHeader (header, config);
@@ -60,5 +63,5 @@
     // XXX make this an option?
     // replace background in residual image
-    psphotSkyReplace (readout, skymodel);
+    psphotSkyReplace (config, view);
 
     // need to do something with the sources, psf, and sky
@@ -67,5 +70,4 @@
     // XXX : replace? status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SKY.MEAN",  PS_DATA_F32,     "psphot sky mean", sky->sampleMean);
     // XXX : replace? status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SKY.SIGMA", PS_DATA_F32,     "psphot sky stdev", sky->sampleStdev);
-    // XXX : what should I do with the skymodel image?
 
     // free up the local copies of the data
@@ -73,5 +75,4 @@
     psFree (sources);
     psFree (peaks);
-    psFree (skymodel);
     return true;
 }
