Index: /trunk/psphot/src/Makefile.am
===================================================================
--- /trunk/psphot/src/Makefile.am	(revision 12804)
+++ /trunk/psphot/src/Makefile.am	(revision 12805)
@@ -8,4 +8,5 @@
 psphot_LDFLAGS = $(PSLIB_LIBS) $(PSMODULE_LIBS) $(PSPHOT_LIBS)
 psphot_LDADD = libpsphot.la
+
 psphot_SOURCES = psphot.c	\
 	psphotArguments.c	\
@@ -20,4 +21,5 @@
 	psphotModelGroupInit.c	\
 	psphotMaskReadout.c	\
+	psphotDefineFiles.c	\
 	psphotReadout.c		\
 	psphotImageMedian.c	\
@@ -56,5 +58,4 @@
 	psphotAddNoise.c
 
-
 include_HEADERS = \
 	psphot.h \
@@ -62,5 +63,6 @@
 
 noinst_HEADERS = \
-	psphotInternal.h
+	psphotInternal.h \
+	psphotStandAlone.h
 
 clean-local:
Index: /trunk/psphot/src/psphot.c
===================================================================
--- /trunk/psphot/src/psphot.c	(revision 12804)
+++ /trunk/psphot/src/psphot.c	(revision 12805)
@@ -1,3 +1,3 @@
-# include "psphotInternal.h"
+# include "psphotStandAlone.h"
 
 static void usage (void) {
Index: /trunk/psphot/src/psphot.h
===================================================================
--- /trunk/psphot/src/psphot.h	(revision 12804)
+++ /trunk/psphot/src/psphot.h	(revision 12805)
@@ -1,12 +1,8 @@
-# ifdef HAVE_CONFIG_H
-# include <config.h>
-# endif
+/* This file defines the library functions available to external programs.  It must be included
+ * by programs which are compiled against psphot functions.
+ */
 
-#ifndef PS_PHOT_H
-#define PS_PHOT_H
-
-#include <stdio.h>
-#include <pslib.h>
-#include <psmodules.h>
+#ifndef PSPHOT_H
+#define PSPHOT_H
 
 #include "psphotErrorCodes.h"
@@ -14,11 +10,96 @@
 
 // top-level psphot functions
-const char *psphotCVSName(void);
-psString psphotVersion(void);
-psString psphotVersionLong(void);
+const char     *psphotCVSName(void);
+psString        psphotVersion(void);
+psString        psphotVersionLong(void);
 
 bool            psphotModelTest (pmReadout *readout, psMetadata *recipe);
 bool            psphotReadout (pmConfig *config, pmFPAview *view);
 bool            psphotReadoutCleanup (pmConfig *config, pmReadout *readout, psMetadata *recipe, pmPSF *psf, psArray *sources);
+bool            psphotDefineFiles (pmConfig *config, pmFPAfile *input);
+
+// XXX test functions
+bool            psphotTestPSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
+bool            pmPSFtestModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask);
+
+psArray        *psphotFakeSources ();
+
+// psphotReadout functions
+bool            psphotImageMedian (pmConfig *config, pmFPAview *view);
+psArray        *psphotFindPeaks (pmReadout *readout, psMetadata *recipe, int pass);
+psArray        *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *allpeaks);
+bool            psphotRoughClass (psArray *sources, psMetadata *recipe);
+bool            psphotBasicDeblend (psArray *sources, psMetadata *recipe);
+pmPSF          *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
+bool            psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf);
+bool            psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources);
+bool            psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
+bool            psphotGuessModels (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
+bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
+bool            psphotReplaceUnfit (psArray *sources);
+bool            psphotReplaceAll (psArray *sources);
+bool            psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
+bool            psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf, pmReadout *background);
+bool            psphotSkyReplace (pmConfig *config, pmFPAview *view);
+
+// basic support functions
+void            psphotModelGroupInit (void);
+int             psphotSortBySN (const void **a, const void **b);
+int             psphotSortByY (const void **a, const void **b);
+bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore);
+void            psphotTestArguments (int *argc, char **argv);
+bool            psphotMaskReadout (pmReadout *readout, psMetadata *recipe);
+void            psphotSourceFreePixels (psArray *sources);
+
+// functions to set the correct source pixels
+bool            psphotInitRadiusPSF (const psMetadata *recipe, const pmModelType type);
+bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model);
+bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR);
+bool            psphotInitRadiusEXT (psMetadata *recipe, pmModelType type);
+bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model);
+
+// output functions
+bool            psphotAddPhotcode (psMetadata *recipe, pmConfig *config, pmFPAview *view);
+bool            psphotDumpMoments (psMetadata *recipe, psArray *sources);
+psMetadata     *psphotDefineHeader (psMetadata *recipe);
+bool            psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
+int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
+bool            psphotDumpConfig (pmConfig *config);
+pmReadout      *psphotSelectBackground (pmConfig *config, pmFPAview *view);
+
+// PSF / DBL / EXT evaluation functions
+bool            psphotEvalPSF (pmSource *source, pmModel *model);
+bool            psphotEvalDBL (pmSource *source, pmModel *model);
+bool            psphotEvalEXT (pmSource *source, pmModel *model);
+
+//  functions to support the source fitting process
+bool            psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout);
+bool            psphotInitLimitsEXT (psMetadata *recipe);
+bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf);
+bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf);
+bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf);
+pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source);
+psArray        *psphotFitDBL (pmReadout *readout, pmSource *source);
+
+// functions to support simultaneous multi-source fitting
+bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode);
+
+// plotting functions (available if libkapa is installed)
+bool 		psphotPlotMoments (pmConfig *config, pmFPAview *view, psArray *sources);
+bool 		psphotPlotPSFModel (pmConfig *config, pmFPAview *view, psArray *sources);
+bool 		psphotFitInit ();
+bool 		psphotFitSummary ();
+bool 		psphotMergeSources (psArray *oldSources, psArray *newSources);
+bool 		psphotLoadExtSources (pmConfig *config, pmFPAview *view, psArray *sources);
+bool 		psphotSetHeaderNstars (psMetadata *recipe, psArray *sources);
+bool 		psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add);
+bool 		psphotRadialPlot (int *kapa, char *filename, pmSource *source);
+bool 		psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe);
+bool 		psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY);
+
+bool 		psphotAddWithTest (pmSource *source, bool useState);
+bool 		psphotSubWithTest (pmSource *source, bool useState);
+bool 		psphotSetState (pmSource *source, bool curState);
+bool 		psphotDeblendSatstars (psArray *sources, psMetadata *recipe);
 
 #endif
Index: /trunk/psphot/src/psphotArguments.c
===================================================================
--- /trunk/psphot/src/psphotArguments.c	(revision 12804)
+++ /trunk/psphot/src/psphotArguments.c	(revision 12805)
@@ -1,3 +1,3 @@
-# include "psphotInternal.h"
+# include "psphotStandAlone.h"
 
 pmConfig *psphotArguments(int argc, char **argv) {
Index: /trunk/psphot/src/psphotCleanup.c
===================================================================
--- /trunk/psphot/src/psphotCleanup.c	(revision 12804)
+++ /trunk/psphot/src/psphotCleanup.c	(revision 12805)
@@ -1,3 +1,3 @@
-# include "psphotInternal.h"
+# include "psphotStandAlone.h"
 
 void psphotCleanup (pmConfig *config) {
Index: /trunk/psphot/src/psphotDefineFiles.c
===================================================================
--- /trunk/psphot/src/psphotDefineFiles.c	(revision 12805)
+++ /trunk/psphot/src/psphotDefineFiles.c	(revision 12805)
@@ -0,0 +1,99 @@
+# include "psphotInternal.h"
+
+// XXX we need to be able to distinguish several cases:
+// 1) the particular output data was not requested
+// 2) the particular output data was requested but was not generated (skipped)
+// 3) the particular output data was requested but was not generated (for valid failure)
+// 4) the particular output data was requested but was not generated (surprising failure)
+
+// define the needed / desired I/O files
+bool psphotDefineFiles (pmConfig *config, pmFPAfile *input) {
+
+    bool status = false;
+
+    // select recipe options supplied on command line
+    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
+
+    // the output sources are carried on the input->fpa structures
+    if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT")) {
+	psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.OUTPUT");
+	return false;
+    }
+
+    // if we are choosing not to save the output detections, mark this file inactive so it will 
+    // not be written, but will keep the detections in memory for other functions (eg, astrometry)
+    if (!psMetadataLookupBool (NULL, recipe, "SAVE.OUTPUT")) {
+	pmFPAfileActivate (config->files, false, "PSPHOT.OUTPUT");
+    }
+
+    // optionally save the residual image 
+    if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) {
+	if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.RESID")) {
+	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.RESID");
+	    return false;
+	}
+    }
+    // optionally save the background model (small FITS image)
+    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) {
+	int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
+	int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
+	if (!pmFPAfileDefineFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL")) {
+	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL");
+	    return false;
+	}
+    }
+    // optionally save the full background image
+    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) {
+	if (!pmFPAfileDefineFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKGND")) {
+	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKGND");
+	    return false;
+	}
+    }
+    // optionally save the background-subtracted image
+    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) {
+	if (!pmFPAfileDefineFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKSUB")) {
+	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.");
+	    return false;
+	}
+    }
+    // optionally save the PSF Model
+    if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) {
+	if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.PSF.SAVE")) {
+	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.PSF.SAVE");
+	    return false;
+	}
+    }
+
+    // optionally save output plots
+    if (psMetadataLookupBool(NULL, recipe, "SAVE.PLOTS")) {
+	if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.MOMENTS")) {
+	    psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.MOMENTS");
+	}
+	if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.PSFMODEL")) {
+	    psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.PSFMODEL");
+	}
+    }
+
+    // XXX add in example PSF image thumbnails
+    // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE");
+
+    return true;
+}
+
+    // if we have requested PSPHOT.SRC, attempt to resolve it 
+    // this is a list of input sources, stored in a psphot output format file
+    // XXX this was disabled after the switch to CHIP-mosaicked images.  It needs to be tested
+    // before it is added back into the code.
+# if (0)    
+    if (psMetadataLookupPtr(NULL, config->arguments, "SRC")) { 
+	pmFPAfileDefineFromArgs (&status, config, "PSPHOT.SRC", "SRC");
+	if (!status) {
+	    psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.SRC");
+	    return status;
+	}
+    }
+    // optionally load the PSF Model and/or fixed stars
+    // XXX add this back in later
+    // pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSF");
+# endif
+
Index: /trunk/psphot/src/psphotImageLoop.c
===================================================================
--- /trunk/psphot/src/psphotImageLoop.c	(revision 12804)
+++ /trunk/psphot/src/psphotImageLoop.c	(revision 12805)
@@ -1,3 +1,3 @@
-# include "psphotInternal.h"
+# include "psphotStandAlone.h"
 
 bool psphotImageLoop (pmConfig *config) {
Index: /trunk/psphot/src/psphotInternal.h
===================================================================
--- /trunk/psphot/src/psphotInternal.h	(revision 12804)
+++ /trunk/psphot/src/psphotInternal.h	(revision 12805)
@@ -1,8 +1,10 @@
+/* this file is included by the internal, library functions. */
+
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
 
-#ifndef PS_PHOT_INTERNAL_H
-#define PS_PHOT_INTERNAL_H
+#ifndef PSPHOT_INTERNAL_H
+#define PSPHOT_INTERNAL_H
 
 #include <stdio.h>
@@ -11,100 +13,5 @@
 #include <pslib.h>
 #include <psmodules.h>
-
 #include "psphot.h"
 
-// Top level functions
-pmConfig       *psphotArguments (int argc, char **argv);
-bool            psphotParseCamera (pmConfig *config);
-bool            psphotImageLoop (pmConfig *config);
-bool            psphotMosaicChip(pmConfig *config, const pmFPAview *view, char *outFile, char *inFile);
-void            psphotCleanup (pmConfig *config);
-
-// XXX test functions
-bool psphotTestPSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
-bool pmPSFtestModel (psArray *sources, char *modelName, float RADIUS, bool poissonErrors, psPolynomial2D *psfTrendMask);
-
-psArray        *psphotFakeSources ();
-
-// psphotReadout functions
-bool            psphotImageMedian (pmConfig *config, pmFPAview *view);
-psArray        *psphotFindPeaks (pmReadout *readout, psMetadata *recipe, int pass);
-psArray        *psphotSourceStats (pmReadout *readout, psMetadata *recipe, psArray *allpeaks);
-bool            psphotRoughClass (psArray *sources, psMetadata *recipe);
-bool            psphotBasicDeblend (psArray *sources, psMetadata *recipe);
-pmPSF          *psphotChoosePSF (pmReadout *readout, psArray *sources, psMetadata *recipe);
-bool            psphotPSFstats (pmReadout *readout, psMetadata *recipe, pmPSF *psf);
-bool            psphotMomentsStats (pmReadout *readout, psMetadata *recipe, psArray *sources);
-bool            psphotEnsemblePSF (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf, bool final);
-bool            psphotGuessModels (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
-bool            psphotBlendFit (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
-bool            psphotReplaceUnfit (psArray *sources);
-bool            psphotReplaceAll (psArray *sources);
-bool            psphotApResid (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
-bool            psphotMagnitudes (psArray *sources, psMetadata *recipe, pmPSF *psf, pmReadout *background);
-bool            psphotSkyReplace (pmConfig *config, pmFPAview *view);
-
-// basic support functions
-void            psphotModelGroupInit (void);
-int             psphotSortBySN (const void **a, const void **b);
-int             psphotSortByY (const void **a, const void **b);
-bool            psphotGrowthCurve (pmReadout *readout, pmPSF *psf, bool ignore);
-void            psphotTestArguments (int *argc, char **argv);
-bool            psphotMaskReadout (pmReadout *readout, psMetadata *recipe);
-void            psphotSourceFreePixels (psArray *sources);
-
-// functions to set the correct source pixels
-bool            psphotInitRadiusPSF (const psMetadata *recipe, const pmModelType type);
-bool            psphotCheckRadiusPSF (pmReadout *readout, pmSource *source, pmModel *model);
-bool            psphotCheckRadiusPSFBlend (pmReadout *readout, pmSource *source, pmModel *model, float dR);
-bool            psphotInitRadiusEXT (psMetadata *recipe, pmModelType type);
-bool            psphotCheckRadiusEXT (pmReadout *readout, pmSource *source, pmModel *model);
-
-// output functions
-bool            psphotAddPhotcode (psMetadata *recipe, pmConfig *config, pmFPAview *view);
-bool            psphotDumpMoments (psMetadata *recipe, psArray *sources);
-psMetadata     *psphotDefineHeader (psMetadata *recipe);
-bool            psphotWeightBias (pmReadout *readout, psArray *sources, psMetadata *recipe, pmPSF *psf);
-int             psphotSaveImage (psMetadata *header, psImage *image, char *filename);
-bool psphotDumpConfig (pmConfig *config);
-pmReadout *psphotSelectBackground (pmConfig *config, pmFPAview *view);
-
-// PSF / DBL / EXT evaluation functions
-bool            psphotEvalPSF (pmSource *source, pmModel *model);
-bool            psphotEvalDBL (pmSource *source, pmModel *model);
-bool            psphotEvalEXT (pmSource *source, pmModel *model);
-
-//  functions to support the source fitting process
-bool            psphotInitLimitsPSF (psMetadata *recipe, pmReadout *readout);
-bool            psphotInitLimitsEXT (psMetadata *recipe);
-bool            psphotFitBlend (pmReadout *readout, pmSource *source, pmPSF *psf);
-bool            psphotFitBlob (pmReadout *readout, pmSource *source, psArray *sources, pmPSF *psf);
-bool            psphotFitPSF (pmReadout *readout, pmSource *source, pmPSF *psf);
-pmModel        *psphotFitEXT (pmReadout *readout, pmSource *source);
-psArray        *psphotFitDBL (pmReadout *readout, pmSource *source);
-
-// functions to support simultaneous multi-source fitting
-bool            psphotFitSet (pmSource *oneSrc, pmModel *oneModel, char *fitset, pmSourceFitMode mode);
-
-// plotting functions (available if libkapa is installed)
-bool psphotPlotMoments (pmConfig *config, pmFPAview *view, psArray *sources);
-bool psphotPlotPSFModel (pmConfig *config, pmFPAview *view, psArray *sources);
-
-bool psphotFitInit ();
-bool psphotFitSummary ();
-bool psphotMergeSources (psArray *oldSources, psArray *newSources);
-bool psphotLoadExtSources (pmConfig *config, pmFPAview *view, psArray *sources);
-psExit psphotGetExitStatus ();
-bool psphotSetHeaderNstars (psMetadata *recipe, psArray *sources);
-bool psphotAddNoise (pmReadout *readout, psArray *sources, psMetadata *recipe, bool add);
-bool psphotRadialPlot (int *kapa, char *filename, pmSource *source);
-bool psphotSourcePlots (pmReadout *readout, psArray *sources, psMetadata *recipe);
-bool psphotMosaicSubimage (psImage *outImage, pmSource *source, int Xo, int Yo, int DX, int DY);
-
-bool psphotAddWithTest (pmSource *source, bool useState);
-bool psphotSubWithTest (pmSource *source, bool useState);
-bool psphotSetState (pmSource *source, bool curState);
-bool psphotDeblendSatstars (psArray *sources, psMetadata *recipe);
-
-
 #endif
Index: /trunk/psphot/src/psphotParseCamera.c
===================================================================
--- /trunk/psphot/src/psphotParseCamera.c	(revision 12804)
+++ /trunk/psphot/src/psphotParseCamera.c	(revision 12805)
@@ -1,3 +1,3 @@
-# include "psphotInternal.h"
+# include "psphotStandAlone.h"
 
 // define the needed / desired I/O files
@@ -15,4 +15,9 @@
     load->dataLevel = PM_FPA_LEVEL_CHIP; // force load at the CHIP level
 
+    // if MASK or WEIGHT was supplied on command line, bind files to 'load'
+    // the mask and weight will be mosaicked with the image
+    pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.MASK",   "MASK");
+    pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.WEIGHT", "WEIGHT");
+
     // the psphot analysis is performed on chips
     pmFPAfile *input = pmFPAfileDefineChipMosaic(config, load->fpa, "PSPHOT.INPUT");
@@ -22,96 +27,9 @@
     }
 
-    // if we have requested PSPHOT.SRC, attempt to resolve it 
-    // this is a list of input sources, stored in a psphot output format file
-# if (0)    
-    if (psMetadataLookupPtr(NULL, config->arguments, "SRC")) { 
-	pmFPAfileDefineFromArgs (&status, config, "PSPHOT.SRC", "SRC");
-	if (!status) {
-	    psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.SRC");
-	    return status;
-	}
+    // define the additional input/output files associated with psphot 
+    if (!psphotDefineFiles (config, input)) {
+	psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files");
+	return false;
     }
-# endif
-
-    // select recipe options supplied on command line
-    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, PSPHOT_RECIPE);
-
-    // these values are used below to define the background subtraction images.
-
-    // if MASK or WEIGHT was supplied on command line, bind files to input fpa
-    // XXX these do not quite yet work: pmFPAAddSourceFromHeader is not appropriate
-    // the mask and weight will be mosaic'ed with the image
-    pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.MASK",   "MASK");
-    pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.WEIGHT", "WEIGHT");
-
-    // optionally load the PSF Model and/or fixed stars
-    // XXX bind this to the input or the load file?
-    // if the readout->analysis entries are copied, we can bind to the load file
-    // XXX add this back in later
-    // pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSF");
-
-    // XXX we need to be able to distinguish several cases:
-    // 1) the particular output data was not requested
-    // 2) the particular output data was requested but was not generated (skipped)
-    // 3) the particular output data was requested but was not generated (for valid failure)
-    // 4) the particular output data was requested but was not generated (surprising failure)
-
-    // the output sources are carried on the input->fpa structures
-    if (psMetadataLookupBool (NULL, recipe, "SAVE.OUTPUT")) {
-	if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT")) {
-	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.OUTPUT");
-	    return false;
-	}
-    }
-    // optionally save the residual image 
-    if (psMetadataLookupBool(NULL, recipe, "SAVE.RESID")) {
-	if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.RESID")) {
-	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL");
-	    return false;
-	}
-    }
-    // optionally save the background model (small FITS image)
-    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKMDL")) {
-	int DX = psMetadataLookupS32 (&status, recipe, "BACKGROUND.XBIN");
-	int DY = psMetadataLookupS32 (&status, recipe, "BACKGROUND.YBIN");
-	if (!pmFPAfileDefineFromFPA (config, input->fpa, DX, DY, "PSPHOT.BACKMDL")) {
-	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKMDL");
-	    return false;
-	}
-    }
-    // optionally save the full background image
-    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKGND")) {
-	if (!pmFPAfileDefineFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKGND")) {
-	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.BACKGND");
-	    return false;
-	}
-    }
-    // optionally save the background-subtracted image
-    if (psMetadataLookupBool(NULL, recipe, "SAVE.BACKSUB")) {
-	if (!pmFPAfileDefineFromFPA (config, input->fpa,  1,  1, "PSPHOT.BACKSUB")) {
-	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.");
-	    return false;
-	}
-    }
-    // optionally save the PSF Model
-    if (psMetadataLookupBool(NULL, recipe, "SAVE.PSF")) {
-	if (!pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.PSF.SAVE")) {
-	    psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for PSPHOT.PSF.SAVE");
-	    return false;
-	}
-    }
-
-    // optionally save output plots
-    if (psMetadataLookupBool(NULL, recipe, "SAVE.PLOTS")) {
-	if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.MOMENTS")) {
-	    psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.MOMENTS");
-	}
-	if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.PSFMODEL")) {
-	    psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.PSFMODEL");
-	}
-    }
-
-    // XXX add in example PSF image thumbnails
-    // pmFPAfileConstruct (config->files, format, config->camera, "PSPHOT.PSF_SAMPLE");
 
     // Chip selection: turn on only the chips specified (pass status to suppress missing-key log msg)
Index: /trunk/psphot/src/psphotStandAlone.h
===================================================================
--- /trunk/psphot/src/psphotStandAlone.h	(revision 12805)
+++ /trunk/psphot/src/psphotStandAlone.h	(revision 12805)
@@ -0,0 +1,21 @@
+# ifdef HAVE_CONFIG_H
+# include <config.h>
+# endif
+
+#ifndef PSPHOT_STAND_ALONE_H
+#define PSPHOT_STAND_ALONE_H
+
+#include <stdio.h>
+#include <pslib.h>
+#include <psmodules.h>
+#include "psphot.h"
+
+// Top level functions
+pmConfig       *psphotArguments (int argc, char **argv);
+bool            psphotParseCamera (pmConfig *config);
+bool            psphotImageLoop (pmConfig *config);
+bool            psphotMosaicChip(pmConfig *config, const pmFPAview *view, char *outFile, char *inFile);
+void            psphotCleanup (pmConfig *config);
+psExit          psphotGetExitStatus ();
+
+#endif
Index: /trunk/psphot/src/psphotVersion.c
===================================================================
--- /trunk/psphot/src/psphotVersion.c	(revision 12804)
+++ /trunk/psphot/src/psphotVersion.c	(revision 12805)
@@ -1,3 +1,3 @@
-#include "psphotInternal.h"
+# include "psphotInternal.h"
 
 # if (HAVE_KAPA)
