Index: trunk/psphot/src/psphotParseCamera.c
===================================================================
--- trunk/psphot/src/psphotParseCamera.c	(revision 12792)
+++ 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)
