Index: trunk/ppImage/src/ppImageParseCamera.c
===================================================================
--- trunk/ppImage/src/ppImageParseCamera.c	(revision 12746)
+++ trunk/ppImage/src/ppImageParseCamera.c	(revision 12807)
@@ -5,5 +5,4 @@
 # include "ppImage.h"
 
-// XXX clean up error checks: return NULL, not psAbort
 ppImageOptions *ppImageParseCamera (pmConfig *config) {
 
@@ -17,19 +16,8 @@
     }
 
-#if 0
-    // the input image defines the camera, and all recipes and options the follow
-    pmFPAfile *inputMask = pmFPAfileDefineFromArgs (&status, config, "PPIMAGE.INPUT.MASK", "INPUT.MASK");
-    if (!status || !inputMask) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPIMAGE.INPUT.MASK");
-        return NULL;
-    }
-
-    // the input image defines the camera, and all recipes and options the follow
-    pmFPAfile *inputWeight = pmFPAfileDefineFromArgs (&status, config, "PPIMAGE.INPUT.WEIGHT", "INPUT.WEIGHT");
-    if (!status || !inputWeight) {
-        psError(PS_ERR_IO, false, "Failed to build FPA from PPIMAGE.INPUT.WEIGHT");
-        return NULL;
-    }
-#endif
+    // if MASK or WEIGHT was supplied on command line, bind files to 'input'
+    // the mask and weight will be mosaicked with the image
+    pmFPAfileBindFromArgs (NULL, input, config, "PPIMAGE.INPUT.MASK",   "MASK");
+    pmFPAfileBindFromArgs (NULL, input, config, "PPIMAGE.INPUT.WEIGHT", "WEIGHT");
 
     // add recipe options supplied on command line
@@ -189,4 +177,38 @@
         psFree(options);
         return NULL;
+    }
+
+    // For photometry, we operate on the chip-mosaicked image
+    if (options->doPhotom) {
+	pmFPAfile *psphotInput = pmFPAfileDefineInput (config, byChip->fpa, "PSPHOT.INPUT");
+	PS_ASSERT (psphotInput, false);
+	psphotInput->mode = PM_FPA_MODE_REFERENCE;
+
+	// define associated psphot input/output files
+	if (!psphotDefineFiles (config, psphotInput)) {
+	    psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psphot");
+	    return false;
+	}
+    }
+
+    // For photometry, we operate on the chip-mosaicked image
+    if (options->doAstromChip || options->doAstromMosaic) {
+	if (!options->doPhotom) {
+	    psError (PSASTRO_ERR_CONFIG, false, "photometry mode is not selected; it is required for astrometry");
+	    return false;
+	}
+
+	pmFPAfile *psphotOutput = psMetadataLookupPtr (&status, config->files, "PSPHOT.OUTPUT");
+	PS_ASSERT (psphotOutput, false);
+
+	pmFPAfile *psastroInput = pmFPAfileDefineInput (config, psphotOutput->fpa, "PSASTRO.INPUT");
+	PS_ASSERT (psastroInput, false);
+	psastroInput->mode = PM_FPA_MODE_REFERENCE;
+
+	// define associated psphot input/output files
+	if (!psastroDefineFiles (config, psastroInput)) {
+	    psError(PSPHOT_ERR_CONFIG, false, "Trouble defining the additional input/output files for psastro");
+	    return false;
+	}
     }
 
@@ -265,17 +287,17 @@
     }
 
-#if 0
-    // Get a look inside all the files.
-    psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); // Iterator
-    psMetadataItem *item;               // Item from iteration
-    fprintf(stderr, "Files:\n");
-    while ((item = psMetadataGetAndIncrement(filesIter))) {
-        pmFPAfile *file = item->data.V; // File of interest
-        fprintf(stderr, "%s: %p %p %p (%p) %p\n", file->name,
-                file->src, file->fpa,
-                file->camera, file->fpa->camera, file->format);
-    }
-    psFree(filesIter);
-#endif
+    if (psTraceGetLevel("ppImage.config") > 0) {
+	// Get a look inside all the files.
+	psMetadataIterator *filesIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, NULL); // Iterator
+	psMetadataItem *item;               // Item from iteration
+	fprintf(stderr, "Files:\n");
+	while ((item = psMetadataGetAndIncrement(filesIter))) {
+	    pmFPAfile *file = item->data.V; // File of interest
+	    fprintf(stderr, "%s: %p %p %p (%p) %p\n", file->name,
+		    file->src, file->fpa,
+		    file->camera, file->fpa->camera, file->format);
+	}
+	psFree(filesIter);
+    }
 
     return (options);
