Index: trunk/ppImage/src/ppImageParseCamera.c
===================================================================
--- trunk/ppImage/src/ppImageParseCamera.c	(revision 6260)
+++ trunk/ppImage/src/ppImageParseCamera.c	(revision 6747)
@@ -1,10 +1,8 @@
 #include <stdio.h>
 #include "pslib.h"
-#include "pmFPA.h"
-#include "pmFPAConstruct.h"
-#include "pmConfig.h"
+#include "psmodules.h"
 #include "ppImage.h"
 
-bool ppImageParseCamera(ppImageData *data, ppConfig *config)
+bool ppImageParseCamera(ppImageData *data, pmConfig *config)
 {
     // Initialise the containers where the files will go
@@ -22,5 +20,5 @@
     data->input->fits = psFitsOpen(data->input->filename, "r"); // File handle for FITS file
     if (! data->input->fits) {
-        // There's no point in continuing if we can't open the input
+        // We can't open the input
         psErrorStackPrint(stderr, "Can't open input image: %s\n", data->input->filename);
         exit(EXIT_FAILURE);
@@ -29,6 +27,7 @@
 
     // Get camera configuration from header if not already defined
+    psMetadata *cameraFormat = NULL;    // Camera format description
     if (! config->camera) {
-        config->camera = pmConfigCameraFromHeader(config->site, data->input->phu);
+        cameraFormat = pmConfigCameraFormatFromHeader(config, data->input->phu);
         if (! config->camera) {
              // There's no point in continuing if we can't recognise what we've got
@@ -36,6 +35,6 @@
             exit(EXIT_FAILURE);
         }
-   } else if (! pmConfigValidateCamera(config->camera, data->input->phu)) {
-       // There's no point in continuing if what we've got doesn't match what we've been told
+    } else if (! pmConfigValidateCameraFormat(config->camera, data->input->phu)) {
+        // What we've got doesn't match what we've been told
         psError(PS_ERR_IO, true, "%s does not seem to be from the specified camera.\n",
                 data->input->filename);
@@ -43,18 +42,15 @@
     }
 
-    // Determine the correct recipe to use
-    if (! config->recipe && !(config->recipe = pmConfigRecipeFromCamera(config->camera, RECIPE))) {
-        // There's no point in continuing if we can't work out what recipe to use
-        psErrorStackPrint(stderr, "Can't find recipe configuration!\n");
-        exit(EXIT_FAILURE);
-    }
+    // Construct cameras in preparation for reading
+    data->input->fpa  = pmFPAConstruct(config->camera);
+    data->input->view = pmFPAAddSource(data->input->fpa, data->input->phu, cameraFormat);
 
-    // Construct cameras in preparation for reading
-    data->input->fpa   = pmFPAConstruct(config->camera);
-    data->mask->fpa    = pmFPAConstruct(config->camera);
-    data->bias->fpa    = pmFPAConstruct(config->camera);
-    data->dark->fpa    = pmFPAConstruct(config->camera);
-    data->flat->fpa    = pmFPAConstruct(config->camera);
-    data->fringe->fpa  = pmFPAConstruct(config->camera);
+    ppFileOpen(data->mask, "-mask", config, config->camera, cameraFormat);
+    ppFileOpen(data->bias, "-bias", config, config->camera, cameraFormat);
+    ppFileOpen(data->dark, "-dark", config, config->camera, cameraFormat);
+    ppFileOpen(data->flat, "-flat", config, config->camera, cameraFormat);
+    ppFileOpen(data->fringe, "-fringe", config, config->camera, cameraFormat);
+
+    psFree(cameraFormat);
 
     // Open output file
@@ -66,19 +62,5 @@
     }
 
-    // XXX EAM : extend this to allow an array of selected chips by name
-    // Chip selection: if we are using a single chip, select it for each FPA
-    int chipNum = psMetadataLookupS32(NULL, config->arguments, "-chip"); // Chip number to work on
-    if (chipNum >= 0) {
-        if (! pmFPASelectChip(data->input->fpa, chipNum)) {
-            psErrorStackPrint(stderr, "Chip number %d doesn't exist in camera.\n", chipNum);
-            exit(EXIT_FAILURE);
-        }
-        psLogMsg("ppImage", PS_LOG_INFO, "Operating only on chip %d\n", chipNum);
-    }
     return true;
 }
 
-// XXX EAM : I dropped the pre-open of the output files; replace with a stats test of output permissions
-
-// XXX : for split data (data spread across multiple files), this step is only operating on a component
-//       of the FPA.  the other components should be set to 'invalid' in this case?
