Index: trunk/ppImage/src/ppTest.c
===================================================================
--- trunk/ppImage/src/ppTest.c	(revision 6566)
+++ trunk/ppImage/src/ppTest.c	(revision 6624)
@@ -3,6 +3,4 @@
 #include "pslib.h"
 #include "psmodules.h"
-
-#define RECIPE "PHASE2"
 
 int main(int argc, char *argv[])
@@ -12,5 +10,5 @@
 // ppImageConfig.c
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
-    pmConfig *config = pmConfigRead(&argc, argv, RECIPE);
+    pmConfig *config = pmConfigRead(&argc, argv);
     if (! config) {
         psErrorStackPrint(stderr, "Can't find site configuration!\n");
@@ -49,13 +47,13 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-    const char *filename = psMetadataLookupStr(NULL, config->arguments, "-input");
-    psLogMsg("ppImage", PS_LOG_INFO, "Opening input image: %s\n", filename);
-    psFits *fits = psFitsOpen(filename, "r"); // File handle for FITS file
-    if (! fits) {
+    const char *inName = psMetadataLookupStr(NULL, config->arguments, "-input");
+    psLogMsg("ppImage", PS_LOG_INFO, "Opening input image: %s\n", inName);
+    psFits *inFile = psFitsOpen(inName, "r"); // File handle for FITS file
+    if (! inFile) {
         // There's no point in continuing if we can't open the input
-        psErrorStackPrint(stderr, "Can't open input image: %s\n", filename);
+        psErrorStackPrint(stderr, "Can't open input image: %s\n", inName);
         exit(EXIT_FAILURE);
     }
-    psMetadata *phu = psFitsReadHeader(NULL, fits); // FITS primary header
+    psMetadata *phu = psFitsReadHeader(NULL, inFile); // FITS primary header
 
     psMetadata *cameraFormat = pmConfigCameraFormatFromHeader(config, phu);
@@ -69,7 +67,16 @@
     }
     // Determine the correct recipe to use
-    if (! config->recipe && !pmConfigRecipeFromCamera(config, RECIPE)) {
-        // There's no point in continuing if we can't work out what recipe to use
+    if (! config->recipes && !pmConfigReadRecipes(config)) {
+        // There's no point in continuing if we can't work out what recipes to use
         psErrorStackPrint(stderr, "Can't find recipe configuration!\n");
+        exit(EXIT_FAILURE);
+    }
+
+    const char *outName = psMetadataLookupStr(NULL, config->arguments, "-output");
+    psLogMsg("ppImage", PS_LOG_INFO, "Opening output image: %s\n", outName);
+    psFits *outFile = psFitsOpen(outName, "w");
+    if (!outFile) {
+        // There's no point in continuing if we can't open the output
+        psErrorStackPrint(stderr, "Can't open output image: %s\n", outName);
         exit(EXIT_FAILURE);
     }
@@ -83,13 +90,26 @@
 
     // Add in a source file
-    pmFPAAddSource(fpa, NULL, NULL, phu, cameraFormat);
+    pmFPAview *view = pmFPAAddSource(fpa, phu, cameraFormat);
+    printf("View chip: %d\n", view->chip);
+    printf("View cell: %d\n", view->cell);
 
     // Read the FPA
-//    pmFPARead(fpa, fits, NULL);
+    pmFPARead(fpa, inFile, NULL);
 
     // How'd we do?
-    pmFPAPrint(fpa, false);
+    pmFPAPrint(fpa, true);
+#if 1
+    pmChip *chip = fpa->chips->data[13];
+    psString chipName = psMetadataLookupStr(NULL, chip->concepts, "CHIP.NAME");
+    printf("CELL.NAME for chip 13: %s\n", chipName);
+    pmCell *cell = chip->cells->data[0];
+    psMetadataPrint(cell->concepts, 10);
+#endif
 
-    psFitsClose(fits);
+
+    pmFPAWrite(fpa, outFile, NULL);
+
+    psFitsClose(inFile);
+    psFitsClose(outFile);
     psFree(phu);
     psFree(cameraFormat);
