Index: /trunk/psphot/Makefile
===================================================================
--- /trunk/psphot/Makefile	(revision 6055)
+++ /trunk/psphot/Makefile	(revision 6056)
@@ -56,5 +56,4 @@
 $(SRC)/psSparse.$(ARCH).o           \
 $(SRC)/psPolynomialUtils.$(ARCH).o  \
-$(SRC)/psImageData.$(ARCH).o        \
 $(SRC)/psModulesUtils.$(ARCH).o	    \
 $(SRC)/pmSourceContour.$(ARCH).o    \
@@ -66,4 +65,8 @@
 $(SRC)/psBicube.$(ARCH).o           \
 $(SRC)/psphotTestArguments.$(ARCH).o
+
+OLD = \
+$(SRC)/psImageData.$(ARCH).o        
+
 
 psphot: $(BIN)/psphot.$(ARCH)
Index: /trunk/psphot/src/psphot.c
===================================================================
--- /trunk/psphot/src/psphot.c	(revision 6055)
+++ /trunk/psphot/src/psphot.c	(revision 6056)
@@ -5,5 +5,6 @@
 
     psMetadata  *config  = NULL;
-    eamReadout  *imdata  = NULL;
+    psMetadata  *header  = NULL;
+    pmReadout   *readout  = NULL;
     psArray     *sources = NULL;
     psArray     *peaks   = NULL;
@@ -18,21 +19,21 @@
 
     // load input data (config and images (signal, noise, mask)
-    imdata = psphotSetup (config);
+    readout = psphotSetup (config, &header);
 
     // run a single-model test if desired
-    psphotModelTest (imdata, config);
+    psphotModelTest (readout, config);
 
     // measure image stats for initial guess 
-    sky = psphotImageStats (imdata, config);
+    sky = psphotImageStats (readout, config);
 
     // generate a background model (currently, 2D polynomial)
     // XXX this should be available to be re-added to the original image
-    psphotImageBackground (imdata, config, sky);
+    psphotImageBackground (readout, config, sky);
 
     // find the peaks in the image
-    peaks = psphotFindPeaks (imdata, config, sky);
+    peaks = psphotFindPeaks (readout, config, sky);
 
     // construct sources and measure basic stats
-    sources = psphotSourceStats (imdata, config, peaks);
+    sources = psphotSourceStats (readout, config, peaks);
 
     // classify sources based on moments, brightness
@@ -49,33 +50,33 @@
     switch (FITMODE) {
       case 0:
-	psphotEnsemblePSF (imdata, config, sources, psf, sky);
+	psphotEnsemblePSF (readout, config, sources, psf, sky);
 	break;
 
       case 1:
-	psphotEnsemblePSF (imdata, config, sources, psf, sky);
-	psphotFullFit (imdata, config, sources, psf, sky);
+	psphotEnsemblePSF (readout, config, sources, psf, sky);
+	psphotFullFit (readout, config, sources, psf, sky);
 	psphotReplaceUnfit (sources);
-	psphotApResid (imdata, sources, config, psf);
+	psphotApResid (readout, sources, config, psf);
 	break;
 
       case 2:
-	psphotEnsemblePSF (imdata, config, sources, psf, sky);
-	psphotBlendFit (imdata, config, sources, psf, sky);
+	psphotEnsemblePSF (readout, config, sources, psf, sky);
+	psphotBlendFit (readout, config, sources, psf, sky);
 	psphotReplaceUnfit (sources);
-	psphotApResid (imdata, sources, config, psf);
+	psphotApResid (readout, sources, config, psf);
 	break;
 
       case 3:
-	psphotApplyPSF (imdata, config, sources, psf, sky);
+	psphotApplyPSF (readout, config, sources, psf, sky);
 	break;
 
       case 4:
-	psphotApplyPSF (imdata, config, sources, psf, sky);
-	psphotFitExtended (imdata, config, sources, sky);
+	psphotApplyPSF (readout, config, sources, psf, sky);
+	psphotFitExtended (readout, config, sources, sky);
 	break;
     }
 
     // write out data in appropriate format
-    psphotOutput (imdata, config, sources, psf, sky);
+    psphotOutput (readout, header, config, sources, psf, sky);
     psLogMsg ("psphot", 3, "wrote output: %f sec\n", psTimerMark ("psphot"));
     psLogMsg ("psphot", 3, "complete psphot run: %f sec\n", psTimerMark ("complete"));
Index: /trunk/psphot/src/psphot.h
===================================================================
--- /trunk/psphot/src/psphot.h	(revision 6055)
+++ /trunk/psphot/src/psphot.h	(revision 6056)
@@ -14,32 +14,25 @@
 # define psMemCopy(A)(psMemIncrRefCounter((A)))
 
-typedef struct {
-    psImage *image;
-    psImage *mask;
-    psImage *weight;
-    psMetadata *header;
-} eamReadout;
-
 // top-level psphot functions
 psMetadata     *psphotArguments (int *argc, char **argv);
-eamReadout     *psphotSetup (psMetadata *config);
-bool            psphotModelTest (eamReadout *imdata, psMetadata *config);
-psStats        *psphotImageStats (eamReadout *imdata, psMetadata *config);
-psPolynomial2D *psphotImageBackground (eamReadout *imdata, psMetadata *config, psStats *sky);
-psArray        *psphotFindPeaks (eamReadout *imdata, psMetadata *config, psStats *sky);
-psArray        *psphotSourceStats (eamReadout *imdata, psMetadata *config, psArray *allpeaks);
+pmReadout      *psphotSetup (psMetadata *config, psMetadata **header);
+bool            psphotModelTest (pmReadout *readout, psMetadata *config);
+psStats        *psphotImageStats (pmReadout *readout, psMetadata *config);
+psPolynomial2D *psphotImageBackground (pmReadout *readout, psMetadata *config, psStats *sky);
+psArray        *psphotFindPeaks (pmReadout *readout, psMetadata *config, psStats *sky);
+psArray        *psphotSourceStats (pmReadout *readout, psMetadata *config, psArray *allpeaks);
 bool            psphotRoughClass (psArray *sources, psMetadata *config);
 bool            psphotBasicDeblend (psArray *sources, psMetadata *config, psStats *sky);
 pmPSF          *psphotChoosePSF (psMetadata *config, psArray *sources, psStats *sky);
-void            psphotOutput (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
+void            psphotOutput (pmReadout *readout, psMetadata *header, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
 
 // optional object analysis steps
-bool 	        psphotEnsemblePSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
-bool            psphotFullFit (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
-bool            psphotBlendFit (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
+bool 	        psphotEnsemblePSF (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
+bool            psphotFullFit (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
+bool            psphotBlendFit (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
 bool            psphotReplaceUnfit (psArray *sources);
-bool            psphotApplyPSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
-bool            psphotFitExtended (eamReadout *imdata, psMetadata *config, psArray *sources, psStats *skyStats);
-bool            psphotApResid (eamReadout *imdata, psArray *sources, psMetadata *config, pmPSF *psf);
+bool            psphotApplyPSF (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky);
+bool            psphotFitExtended (pmReadout *readout, psMetadata *config, psArray *sources, psStats *skyStats);
+bool            psphotApResid (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf);
 
 // basic support functions
@@ -51,21 +44,21 @@
 int 	        psphotSortBySN (const void **a, const void **b);
 int 	        psphotSortByY (const void **a, const void **b);
-bool            psphotGrowthCurve (eamReadout *imdata, pmPSF *psf);
+bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf);
 void            psphotTestArguments (int *argc, char **argv);
 
 // functions to set the correct source pixels
 bool 		psphotInitRadiusPSF (psMetadata *config, psStats *sky, pmModelType type);
-bool 		psphotCheckRadiusPSF (eamReadout *imdata, pmSource *source, pmModel *model);
+bool 		psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model);
 bool 		psphotInitRadiusEXT (psMetadata *config, psStats *sky, pmModelType type);
-bool 		psphotCheckRadiusEXT (eamReadout *imdata, pmSource *source, pmModel *model);
-bool 	        psphotDefinePixels (pmSource *mySource, const eamReadout *imdata, psF32 x, psF32 y, psF32 Radius);
-bool 	        psphotRedefinePixels (pmSource *mySource, const eamReadout *imdata, psF32 x, psF32 y, psF32 Radius);
+bool 		psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model);
+bool 	        psphotDefinePixels (pmSource *mySource, const pmReadout *readout, psF32 x, psF32 y, psF32 Radius);
+bool 	        psphotRedefinePixels (pmSource *mySource, const pmReadout *readout, psF32 x, psF32 y, psF32 Radius);
 
 // output functions
-bool 	     	pmSourcesWriteText (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);
-bool 	     	pmSourcesWriteOBJ  (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);
-bool 	     	pmSourcesWriteCMP  (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);
-bool 	     	pmSourcesWriteCMF  (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);
-bool 	     	pmSourcesWriteSX   (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);
+bool 	     	pmSourcesWriteText (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);
+bool 	     	pmSourcesWriteOBJ  (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);
+bool 	     	pmSourcesWriteCMP  (pmReadout *readout, psMetadata *header, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);
+bool 	     	pmSourcesWriteCMF  (pmReadout *readout, psMetadata *header, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);
+bool 	     	pmSourcesWriteSX   (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky);
 
 bool 	     	pmModelWritePSFs (psArray *sources, psMetadata *config, char *filename, pmPSF *psf);
@@ -96,12 +89,9 @@
 bool 		psphotInitLimitsPSF (psMetadata *config);
 bool		psphotInitLimitsEXT (psMetadata *config, psStats *sky);
-bool		psphotFitBlend (eamReadout *imdata, pmSource *source);
-bool		psphotFitBlob (eamReadout *imdata, pmSource *source, psArray *sources);
-bool		psphotFitPSF (eamReadout *imdata, pmSource *source);
-pmModel	       *psphotFitEXT (eamReadout *imdata, pmSource *source);
-psArray	       *psphotFitDBL (eamReadout *imdata, pmSource *source);
-
-// eamReadout functions
-eamReadout     *eamReadoutAlloc (psImage *image, psImage *noise, psImage *mask, psMetadata *header);
+bool		psphotFitBlend (pmReadout *readout, pmSource *source);
+bool		psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources);
+bool		psphotFitPSF (pmReadout *readout, pmSource *source);
+pmModel	       *psphotFitEXT (pmReadout *readout, pmSource *source);
+psArray	       *psphotFitDBL (pmReadout *readout, pmSource *source);
 
 // bicubic interpolation
Index: /trunk/psphot/src/psphotApResid.c
===================================================================
--- /trunk/psphot/src/psphotApResid.c	(revision 6055)
+++ /trunk/psphot/src/psphotApResid.c	(revision 6056)
@@ -2,5 +2,5 @@
 
 // measure the aperture residual statistics
-bool psphotApResid (eamReadout *imdata, psArray *sources, psMetadata *config, pmPSF *psf) { 
+bool psphotApResid (pmReadout *readout, psArray *sources, psMetadata *config, pmPSF *psf) { 
 
     int Npsf;
@@ -14,5 +14,5 @@
     float REF_RADIUS = psMetadataLookupF32 (&status, config, "PSF_REF_RADIUS");
     psf->growth = pmGrowthCurveAlloc (3.0, REF_RADIUS, 0.1);
-    psphotGrowthCurve (imdata, psf);
+    psphotGrowthCurve (readout, psf);
     
     psVector *mask    = psVectorAlloc (300, PS_TYPE_U8);
Index: /trunk/psphot/src/psphotApplyPSF.c
===================================================================
--- /trunk/psphot/src/psphotApplyPSF.c	(revision 6055)
+++ /trunk/psphot/src/psphotApplyPSF.c	(revision 6056)
@@ -2,5 +2,5 @@
 
 // fit psf model to all objects 
-bool psphotApplyPSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) 
+bool psphotApplyPSF (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) 
 { 
     float x;
@@ -34,5 +34,5 @@
 
 	// sets the model radius (via source->model) and adjusts pixels as needed
-	psphotCheckRadiusPSF (imdata, source, model);
+	psphotCheckRadiusPSF (readout, source, model);
 
 	x = model->params->data.F32[2];
Index: /trunk/psphot/src/psphotBlendFit.c
===================================================================
--- /trunk/psphot/src/psphotBlendFit.c	(revision 6055)
+++ /trunk/psphot/src/psphotBlendFit.c	(revision 6056)
@@ -2,5 +2,5 @@
 
 // XXX I don't like this name
-bool psphotBlendFit (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) { 
+bool psphotBlendFit (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) { 
 
     psTimerStart ("psphot");
@@ -30,6 +30,6 @@
 	psTrace ("psphot.blend", 5, "trying source at %f, %f\n", source->moments->x, source->moments->y);
 
-	if (psphotFitBlend (imdata, source)) continue;
-	if (psphotFitBlob (imdata, source, sources)) continue;
+	if (psphotFitBlend (readout, source)) continue;
+	if (psphotFitBlob (readout, source, sources)) continue;
 
 	psTrace ("psphot.blend", 5, "failed fits\n");
Index: /trunk/psphot/src/psphotDefinePixels.c
===================================================================
--- /trunk/psphot/src/psphotDefinePixels.c	(revision 6055)
+++ /trunk/psphot/src/psphotDefinePixels.c	(revision 6056)
@@ -2,5 +2,5 @@
 
 bool psphotDefinePixels(pmSource *mySource, 
-			const eamReadout *imdata,
+			const pmReadout *readout,
 			psF32 x, 
 			psF32 y,
@@ -11,9 +11,9 @@
     // Grab a subimage of the original image of size (2 * outerRadius).
     srcRegion = psRegionForSquare (x, y, Radius);
-    srcRegion = psRegionForImage (imdata->image, srcRegion);
+    srcRegion = psRegionForImage (readout->image, srcRegion);
 
-    mySource->pixels = psImageSubset(imdata->image, srcRegion);
-    mySource->weight = psImageSubset(imdata->weight, srcRegion);
-    mySource->mask   = psImageSubset(imdata->mask,  srcRegion);
+    mySource->pixels = psImageSubset(readout->image, srcRegion);
+    mySource->weight = psImageSubset(readout->weight, srcRegion);
+    mySource->mask   = psImageSubset(readout->mask,  srcRegion);
     mySource->region = srcRegion;
 
@@ -22,5 +22,5 @@
 
 bool psphotRedefinePixels(pmSource *mySource, 
-			  const eamReadout *imdata,
+			  const pmReadout *readout,
 			  psF32 x, 
 			  psF32 y,
@@ -34,5 +34,5 @@
     // check to see if new region is completely contained within old region
     newRegion = psRegionForSquare (x, y, Radius);
-    newRegion = psRegionForImage (imdata->image, newRegion);
+    newRegion = psRegionForImage (readout->image, newRegion);
 
     extend = false;
@@ -53,7 +53,7 @@
 	psFree (mySource->mask);
 
-	mySource->pixels = psImageSubset(imdata->image,  newRegion);
-	mySource->weight = psImageSubset(imdata->weight, newRegion);
-	mySource->mask   = psImageSubset(imdata->mask,   newRegion);
+	mySource->pixels = psImageSubset(readout->image,  newRegion);
+	mySource->weight = psImageSubset(readout->weight, newRegion);
+	mySource->mask   = psImageSubset(readout->mask,   newRegion);
 	mySource->region = newRegion;
     }
Index: /trunk/psphot/src/psphotEnsemblePSF.c
===================================================================
--- /trunk/psphot/src/psphotEnsemblePSF.c	(revision 6055)
+++ /trunk/psphot/src/psphotEnsemblePSF.c	(revision 6056)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-bool psphotEnsemblePSF (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) { 
+bool psphotEnsemblePSF (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) { 
 
     bool  status;
@@ -103,5 +103,5 @@
 
 	// if needed, ask for more object pixels
-	psphotRedefinePixels (inSource, imdata, x, y, model->radius);
+	psphotRedefinePixels (inSource, readout, x, y, model->radius);
 
 	// make temporary copies of the image pixels and mask
Index: /trunk/psphot/src/psphotFindPeaks.c
===================================================================
--- /trunk/psphot/src/psphotFindPeaks.c	(revision 6055)
+++ /trunk/psphot/src/psphotFindPeaks.c	(revision 6056)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-psArray *psphotFindPeaks (eamReadout *imdata, psMetadata *config, psStats *sky) {
+psArray *psphotFindPeaks (pmReadout *readout, psMetadata *config, psStats *sky) {
 
     bool  status = false;
@@ -15,5 +15,5 @@
     NSIGMA = psMetadataLookupF32 (&status, config, "PEAKS_SMOOTH_NSIGMA");
 
-    psImage *smooth = psImageCopy (NULL, imdata->image, PS_TYPE_F32);
+    psImage *smooth = psImageCopy (NULL, readout->image, PS_TYPE_F32);
     psImageSmooth (smooth, SIGMA, NSIGMA);
     psLogMsg ("psphot", 4, "smooth: %f sec\n", psTimerMark ("psphot"));
Index: /trunk/psphot/src/psphotFitGalaxies.c
===================================================================
--- /trunk/psphot/src/psphotFitGalaxies.c	(revision 6055)
+++ /trunk/psphot/src/psphotFitGalaxies.c	(revision 6056)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-bool psphotFitExtended (eamReadout *imdata, psMetadata *config, psArray *sources, psStats *skyStats)
+bool psphotFitExtended (pmReadout *readout, psMetadata *config, psArray *sources, psStats *skyStats)
 { 
     bool  status;
@@ -43,5 +43,5 @@
 
 	// sets the model radius (via source->model) and adjusts pixels as needed
-	psphotCheckRadiusEXT (imdata, source, model);
+	psphotCheckRadiusEXT (readout, source, model);
 
 	// fit EXT (not PSF) model (set/unset the pixel mask)
Index: /trunk/psphot/src/psphotFullFit.c
===================================================================
--- /trunk/psphot/src/psphotFullFit.c	(revision 6055)
+++ /trunk/psphot/src/psphotFullFit.c	(revision 6056)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-bool psphotFullFit (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) 
+bool psphotFullFit (pmReadout *readout, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) 
 { 
     bool  status;
@@ -46,5 +46,5 @@
 	source->mode &= ~PM_SOURCE_SUBTRACTED;
 
-	psphotCheckRadiusPSF (imdata, source, modelPSF);
+	psphotCheckRadiusPSF (readout, source, modelPSF);
 
 	x = modelPSF->params->data.F32[2];
@@ -95,5 +95,5 @@
 	pmModel *modelEXT = source->modelEXT;
 
-	psphotCheckRadiusEXT (imdata, source, modelEXT);
+	psphotCheckRadiusEXT (readout, source, modelEXT);
 
 	x = modelEXT->params->data.F32[2];
Index: /trunk/psphot/src/psphotGrowthCurve.c
===================================================================
--- /trunk/psphot/src/psphotGrowthCurve.c	(revision 6055)
+++ /trunk/psphot/src/psphotGrowthCurve.c	(revision 6056)
@@ -5,5 +5,5 @@
 //     the 'center' option
 
-bool psphotGrowthCurve (eamReadout *imdata, pmPSF *psf) { 
+bool psphotGrowthCurve (pmReadout *readout, pmPSF *psf) { 
 
     // bool status;
@@ -16,6 +16,6 @@
 
     // use this image region
-    xc = 0.5*imdata->image->numCols;
-    yc = 0.5*imdata->image->numRows;
+    xc = 0.5*readout->image->numCols;
+    yc = 0.5*readout->image->numRows;
     dx = psf->growth->maxRadius + 1;
     dy = psf->growth->maxRadius + 1;
@@ -33,5 +33,5 @@
     // generate working image for this source
     psRegion region = {xc - dx, xc + dx, yc - dy, yc + dy};
-    psImage *view = psImageSubset (imdata->image, region);
+    psImage *view = psImageSubset (readout->image, region);
     psImage *image = psImageCopy (NULL, view, PS_TYPE_F32);
     psImage *mask = psImageCopy (NULL, view, PS_TYPE_U8);
Index: /trunk/psphot/src/psphotImageBackground.c
===================================================================
--- /trunk/psphot/src/psphotImageBackground.c	(revision 6055)
+++ /trunk/psphot/src/psphotImageBackground.c	(revision 6056)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-psPolynomial2D *psphotImageBackground (eamReadout *imdata, psMetadata *config, psStats *sky) 
+psPolynomial2D *psphotImageBackground (pmReadout *readout, psMetadata *config, psStats *sky) 
 { 
 
@@ -7,6 +7,6 @@
     psTimerStart ("psphot");
 
-    psImage *image = imdata->image;
-    psImage *mask  = imdata->mask;
+    psImage *image = readout->image;
+    psImage *mask  = readout->mask;
 
     bool      status  = false;
Index: /trunk/psphot/src/psphotImageStats.c
===================================================================
--- /trunk/psphot/src/psphotImageStats.c	(revision 6055)
+++ /trunk/psphot/src/psphotImageStats.c	(revision 6056)
@@ -1,10 +1,10 @@
 # include "psphot.h"
 
-psStats *psphotImageStats (eamReadout *imdata, psMetadata *config) 
+psStats *psphotImageStats (pmReadout *readout, psMetadata *config) 
 { 
     psStats *stats = NULL;
     psStats *sky   = NULL;
 
-    psImage *image = imdata->image;
+    psImage *image = readout->image;
 
     // get image stats on a subset of the image (random 1e5 pts)
Index: /trunk/psphot/src/psphotModelTest.c
===================================================================
--- /trunk/psphot/src/psphotModelTest.c	(revision 6055)
+++ /trunk/psphot/src/psphotModelTest.c	(revision 6056)
@@ -2,5 +2,5 @@
 # include "psEllipse.h"
 
-bool psphotModelTest (eamReadout *imdata, psMetadata *config) {
+bool psphotModelTest (pmReadout *readout, psMetadata *config) {
 
     bool status;
@@ -75,5 +75,5 @@
     pmSource *source = pmSourceAlloc();
     source->peak = pmPeakAlloc (xObj, yObj, 0, 0);
-    psphotDefinePixels (source, imdata, xObj, yObj, OUTER);
+    psphotDefinePixels (source, readout, xObj, yObj, OUTER);
 
     // find the local sky
Index: /trunk/psphot/src/psphotOutput.c
===================================================================
--- /trunk/psphot/src/psphotOutput.c	(revision 6055)
+++ /trunk/psphot/src/psphotOutput.c	(revision 6056)
@@ -2,5 +2,5 @@
 
 // output functions: we have several fixed modes (sx, obj, cmp)
-void psphotOutput (eamReadout *imdata, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) {
+void psphotOutput (pmReadout *readout, psMetadata *header, psMetadata *config, psArray *sources, pmPSF *psf, psStats *sky) {
 
     bool status;
@@ -13,6 +13,6 @@
     char *psfFile    = psMetadataLookupPtr (&status, config, "PSF_OUTPUT_FILE");
 
-    if (residImage != NULL) psphotSaveImage (imdata->header, imdata->image, residImage);
-    psphotSamplePSFs (config, psf, imdata->image);
+    if (residImage != NULL) psphotSaveImage (header, readout->image, residImage);
+    psphotSamplePSFs (config, psf, readout->image);
 
     if (psfFile != NULL) {
@@ -30,21 +30,21 @@
     }
     if (!strcasecmp (outputMode, "OBJ")) {
-	pmSourcesWriteOBJ (imdata, config, outputFile, sources, psf, sky);
+	pmSourcesWriteOBJ (readout, config, outputFile, sources, psf, sky);
 	return;
     }
     if (!strcasecmp (outputMode, "SX")) {
-	pmSourcesWriteSX (imdata, config, outputFile, sources, psf, sky);
+	pmSourcesWriteSX (readout, config, outputFile, sources, psf, sky);
 	return;
     }
     if (!strcasecmp (outputMode, "CMP")) {
-	pmSourcesWriteCMP (imdata, config, outputFile, sources, psf, sky);
+	pmSourcesWriteCMP (readout, header, config, outputFile, sources, psf, sky);
 	return;
     }
     if (!strcasecmp (outputMode, "CMF")) {
-	pmSourcesWriteCMF (imdata, config, outputFile, sources, psf, sky);
+	pmSourcesWriteCMF (readout, header, config, outputFile, sources, psf, sky);
 	return;
     }
     if (!strcasecmp (outputMode, "TEXT")) {
-	pmSourcesWriteText (imdata, config, outputFile, sources, psf, sky);
+	pmSourcesWriteText (readout, config, outputFile, sources, psf, sky);
 	return;
     }
@@ -54,5 +54,5 @@
 
 // dophot-style output list with fixed line width
-bool pmSourcesWriteOBJ (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
+bool pmSourcesWriteOBJ (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
 
     int type;
@@ -106,5 +106,5 @@
 
 // elixir-mode / sextractor-style output list with fixed line width
-bool pmSourcesWriteSX (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
+bool pmSourcesWriteSX (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
 
     pmModel *model;
@@ -157,5 +157,5 @@
 
 // elixir-style pseudo FITS table (header + ascii list)
-bool pmSourcesWriteCMP (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
+bool pmSourcesWriteCMP (pmReadout *readout, psMetadata *header, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
 
     int i, type;
@@ -172,6 +172,6 @@
 
     // write necessary information to output header
-    psphotUpdateHeader (imdata->header, config);
-    psMetadataAdd (imdata->header, PS_LIST_TAIL, "NSTARS",   PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", sources->n);
+    psphotUpdateHeader (header, config);
+    psMetadataAdd (header, PS_LIST_TAIL, "NSTARS",   PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", sources->n);
 
     // create file, write-out header
@@ -179,10 +179,10 @@
 
     // set NAXIS to 0 : CFITSIO requires isolated header to have NAXIS = 0
-    mdi = psMetadataLookup (imdata->header, "NAXIS");
+    mdi = psMetadataLookup (header, "NAXIS");
     mdi->data.S32 = 0;
     mdi->type = PS_DATA_S32;
 
-    // psMetadataAdd (imdata->header, PS_LIST_HEAD, "NAXIS", PS_DATA_S32 | PS_META_REPLACE, "", 0);
-    psFitsWriteHeader (imdata->header, fits);
+    // psMetadataAdd (header, PS_LIST_HEAD, "NAXIS", PS_DATA_S32 | PS_META_REPLACE, "", 0);
+    psFitsWriteHeader (header, fits);
     psFitsClose (fits);
 
@@ -232,5 +232,5 @@
 // this format consists of a header derived from the image header
 // followed by a zero-size matrix, followed by the table data
-bool pmSourcesWriteCMF (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
+bool pmSourcesWriteCMF (pmReadout *readout, psMetadata *header, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *skyStats) {
 
     psArray *table;
@@ -249,5 +249,5 @@
 
     // write necessary information to output header
-    psphotUpdateHeader (imdata->header, config);
+    psphotUpdateHeader (header, config);
 
     table = psArrayAlloc (sources->n);
@@ -286,9 +286,9 @@
 
     // write the correct number of sources in the header
-    psMetadataAdd (imdata->header, PS_LIST_TAIL, "NSTARS", PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", table->n);
-    psMetadataAdd (imdata->header, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true);
+    psMetadataAdd (header, PS_LIST_TAIL, "NSTARS", PS_DATA_S32 | PS_META_REPLACE, "NUMBER OF STARS", table->n);
+    psMetadataAdd (header, PS_LIST_TAIL, "EXTEND", PS_DATA_BOOL | PS_META_REPLACE, "this file has extensions", true);
 
     // set NAXIS to 0 (we don't write out the data array)
-    mdi = psMetadataLookup (imdata->header, "NAXIS");
+    mdi = psMetadataLookup (header, "NAXIS");
     mdi->data.S32 = 0;
     mdi->type = PS_DATA_S32;
@@ -300,5 +300,5 @@
     // write out the header and table
     psFits *fits = psFitsOpen (filename, "w");
-    psFitsWriteHeader (imdata->header, fits);
+    psFitsWriteHeader (header, fits);
     psFitsWriteTable (fits, theader, table);
     psFitsClose (fits);
@@ -309,5 +309,5 @@
 /***** Text Output Methods *****/
 
-bool pmSourcesWriteText (eamReadout *imdata, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky) {
+bool pmSourcesWriteText (pmReadout *readout, psMetadata *config, char *filename, psArray *sources, pmPSF *psf, psStats *sky) {
 
     char *name = (char *) psAlloc (strlen(filename) + 10);
Index: /trunk/psphot/src/psphotRadiusChecks.c
===================================================================
--- /trunk/psphot/src/psphotRadiusChecks.c	(revision 6055)
+++ /trunk/psphot/src/psphotRadiusChecks.c	(revision 6056)
@@ -20,5 +20,5 @@
 }
 
-bool psphotCheckRadiusPSF (eamReadout *imdata, pmSource *source, pmModel *model) {
+bool psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model) {
 
     // set the fit radius based on the object flux limit and the model
@@ -31,5 +31,5 @@
     }
 
-    bool status = psphotRedefinePixels (source, imdata, model->params->data.F32[2], model->params->data.F32[3], model->radius);
+    bool status = psphotRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius);
     return status;
 }
@@ -54,5 +54,5 @@
 }
 
-bool psphotCheckRadiusEXT (eamReadout *imdata, pmSource *source, pmModel *model) {
+bool psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model) {
 
     // set the fit radius based on the object flux limit and the model
@@ -61,5 +61,5 @@
 
     // redefine the pixels if needed
-    bool status = psphotRedefinePixels (source, imdata, model->params->data.F32[2], model->params->data.F32[3], model->radius);
+    bool status = psphotRedefinePixels (source, readout, model->params->data.F32[2], model->params->data.F32[3], model->radius);
     return status;
 }
Index: /trunk/psphot/src/psphotSetup.c
===================================================================
--- /trunk/psphot/src/psphotSetup.c	(revision 6055)
+++ /trunk/psphot/src/psphotSetup.c	(revision 6056)
@@ -7,7 +7,7 @@
 // load or construct the weight 
 
-eamReadout *psphotSetup (psMetadata *config) 
+pmReadout *psphotSetup (psMetadata *config, psMetadata **header) 
 {
-    psMetadata *header = NULL;
+    psMetadata *myHeader;
     psImage *image = NULL;
     psImage *weight = NULL;
@@ -23,7 +23,7 @@
     // setup header template, specify COMMENT and HISTORY as MULTI
     // XXX EAM - shouldn't this be part of the basic FITS concept?
-    header = psMetadataAlloc ();
-    psMetadataAdd (header, PS_LIST_HEAD, "COMMENT", PS_DATA_METADATA_MULTI, "folder for comment", NULL);
-    psMetadataAdd (header, PS_LIST_HEAD, "HISTORY", PS_DATA_METADATA_MULTI, "folder for history", NULL);
+    myHeader = psMetadataAlloc ();
+    psMetadataAdd (myHeader, PS_LIST_HEAD, "COMMENT", PS_DATA_METADATA_MULTI, "folder for comment", NULL);
+    psMetadataAdd (myHeader, PS_LIST_HEAD, "HISTORY", PS_DATA_METADATA_MULTI, "folder for history", NULL);
 
     // read header and image data from INPUT 
@@ -31,5 +31,5 @@
     if (!status) psAbort ("psphot", "input image not specified");
     psFits *file = psFitsOpen (input, "r");
-    header = psFitsReadHeader (header, file);
+    myHeader = psFitsReadHeader (myHeader, file);
     psImage *tmpimage = psFitsReadImage (NULL, file, region, 0);
     image = psImageCopy (NULL, tmpimage, PS_TYPE_F32);
@@ -40,6 +40,6 @@
 
     // grab these values from the approrpiate location (image header if necessary)
-    float RDNOISE  = pmConfigLookupF32 (&status, config, header, "RDNOISE");
-    float GAIN     = pmConfigLookupF32 (&status, config, header, "GAIN");
+    float RDNOISE  = pmConfigLookupF32 (&status, config, myHeader, "RDNOISE");
+    float GAIN     = pmConfigLookupF32 (&status, config, myHeader, "GAIN");
     psMetadataAdd (config, PS_LIST_TAIL, "RDNOISE", PS_DATA_F32 | PS_META_REPLACE, "read noise value used", RDNOISE);
     psMetadataAdd (config, PS_LIST_TAIL, "GAIN",    PS_DATA_F32 | PS_META_REPLACE, "gain value used", GAIN);
@@ -108,5 +108,10 @@
 
     // return image data
-    eamReadout *imdata = eamReadoutAlloc(image, weight, mask, header);
-    return (imdata);
+    pmReadout *readout = pmReadoutAlloc(NULL);
+    readout->image = image;
+    readout->weight = weight;
+    readout->mask = mask;
+
+    *header = myHeader;
+    return (readout);
 }
Index: /trunk/psphot/src/psphotSourceFits.c
===================================================================
--- /trunk/psphot/src/psphotSourceFits.c	(revision 6055)
+++ /trunk/psphot/src/psphotSourceFits.c	(revision 6056)
@@ -4,5 +4,5 @@
 // given a source with an existing modelPSF, attempt a full PSF fit, subtract if successful
 
-bool psphotFitPSF (eamReadout *imdata, pmSource *source) { 
+bool psphotFitPSF (pmReadout *readout, pmSource *source) { 
 
     float x, y;
@@ -12,5 +12,5 @@
 
     // extend source radius as needed
-    psphotCheckRadiusPSF (imdata, source, PSF);
+    psphotCheckRadiusPSF (readout, source, PSF);
 
     x = PSF->params->data.F32[2];
@@ -61,5 +61,5 @@
 }
 
-bool psphotFitBlob (eamReadout *imdata, pmSource *source, psArray *sources) { 
+bool psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources) { 
 
     bool okEXT, okDBL;
@@ -79,9 +79,9 @@
     pmSource *tmpSrc = pmSourceAlloc ();
 
-    pmModel *EXT = psphotFitEXT (imdata, source);
+    pmModel *EXT = psphotFitEXT (readout, source);
     okEXT = psphotEvalEXT (tmpSrc, EXT);
     chiEXT = EXT->chisq / EXT->nDOF;
 
-    psArray *DBL = psphotFitDBL (imdata, source);
+    psArray *DBL = psphotFitDBL (readout, source);
     okDBL  = psphotEvalDBL (tmpSrc, DBL->data[0]);
     okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]);
@@ -129,5 +129,5 @@
 
 // fit a double PSF source to an extended blob
-psArray *psphotFitDBL (eamReadout *imdata, pmSource *source) { 
+psArray *psphotFitDBL (pmReadout *readout, pmSource *source) { 
 
     float x, y, dx, dy;
@@ -149,5 +149,5 @@
     // save the PSF model from the Ensemble fit
     PSF = source->modelPSF;
-    psphotCheckRadiusPSF (imdata, source, PSF);
+    psphotCheckRadiusPSF (readout, source, PSF);
 
     modelSet = psArrayAlloc (2);
@@ -176,5 +176,5 @@
 }
 
-pmModel *psphotFitEXT (eamReadout *imdata, pmSource *source) { 
+pmModel *psphotFitEXT (pmReadout *readout, pmSource *source) { 
 
     float x, y;
@@ -183,5 +183,5 @@
     pmModel *EXT = pmSourceModelGuess (source, modelTypeEXT); 
 
-    psphotCheckRadiusEXT (imdata, source, EXT);
+    psphotCheckRadiusEXT (readout, source, EXT);
 
     x = EXT->params->data.F32[2];
@@ -196,5 +196,5 @@
 }
 
-bool psphotFitBlend (eamReadout *imdata, pmSource *source) { 
+bool psphotFitBlend (pmReadout *readout, pmSource *source) { 
 
     float x, y, dR;
@@ -202,5 +202,5 @@
     // if this source is not a possible blend, just fit as PSF
     if ((source->blends == NULL) || (source->mode & PM_SOURCE_SATSTAR)) {
-	bool status = psphotFitPSF (imdata, source);
+	bool status = psphotFitPSF (readout, source);
 	return status;
     }
@@ -212,5 +212,5 @@
 
     // extend source radius as needed
-    psphotCheckRadiusPSF (imdata, source, PSF);
+    psphotCheckRadiusPSF (readout, source, PSF);
 
     x = PSF->params->data.F32[2];
Index: /trunk/psphot/src/psphotSourceStats.c
===================================================================
--- /trunk/psphot/src/psphotSourceStats.c	(revision 6055)
+++ /trunk/psphot/src/psphotSourceStats.c	(revision 6056)
@@ -1,5 +1,5 @@
 # include "psphot.h"
 
-psArray *psphotSourceStats (eamReadout *imdata, psMetadata *config, psArray *peaks) 
+psArray *psphotSourceStats (pmReadout *readout, psMetadata *config, psArray *peaks) 
 {
     bool     status  = false;
@@ -25,5 +25,5 @@
 	// allocate image, weight, mask arrays for each peak (square of radius OUTER)
 	// XXX EAM : this has 12 leaks (v.5)
-	psphotDefinePixels (source, imdata, source->peak->x, source->peak->y, OUTER);
+	psphotDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
 
 	// measure a local sky value
