Index: trunk/ppImage/src/ppImageLoop.c
===================================================================
--- trunk/ppImage/src/ppImageLoop.c	(revision 6396)
+++ trunk/ppImage/src/ppImageLoop.c	(revision 6747)
@@ -1,8 +1,5 @@
 #include <stdio.h>
 #include "pslib.h"
-#include "pmFPA.h"
-#include "pmFPARead.h"
-#include "pmChipMosaic.h"
-#include "pmFPAWrite.h"
+#include "psmodules.h"
 #include "ppImageDetrend.h"
 #include "ppImage.h"
@@ -13,12 +10,9 @@
 // Read the entire FPA
 void readFPA(ppFile *file,              // File to read
-             ppConfig *config           // Configuration, containing the DB handle
+             pmConfig *config           // Configuration, containing the DB handle
     )
 {
     if (file->fpa && file->fits) {
-        if (! pmFPARead(file->fpa, file->fits, file->phu, config->database)) {
-            psErrorStackPrint(stderr, "Unable to populate camera from input FITS file\n");
-            exit(EXIT_FAILURE);
-        }
+        pmFPARead(file->fpa, file->fits, config->database);
     }
 }
@@ -26,22 +20,30 @@
 // Read a specified chip only
 void readChip(ppFile *file,             // File to read
-              ppConfig *config,         // Configuration
+              pmConfig *config,         // Configuration
               int chipNum               // Chip number to read
     )
 {
-    pmFPASelectChip(file->fpa, chipNum);
-    readFPA(file, config);
+    pmFPA *fpa = file->fpa;             // The FPA
+    if (fpa && file->fits) {
+        pmChip *chip = fpa->chips->data[chipNum]; // The chip
+        pmChipRead(chip, file->fits, config->database);
+    }
 }
 
 
-void readCell(ppFile *file, ppConfig *config, int chipNum, int cellNum)
+void readCell(ppFile *file, pmConfig *config, int chipNum, int cellNum)
 {
-    pmChip *chip = file->fpa->chips->data[chipNum];
-    pmChipSelectCell(chip, cellNum);
-    readFPA(file, config);
+    pmFPA *fpa = file->fpa;             // The FPA
+    if (fpa && file->fits) {
+        pmChip *chip = fpa->chips->data[chipNum]; // The chip
+        if (chip) {
+            pmCell *cell = chip->cells->data[cellNum]; // The cell
+            pmCellRead(cell, file->fits, config->database);
+        }
+    }
 }
 
 
-bool ppImageLoop(ppImageData *data, ppImageOptions *options, ppConfig *config)
+bool ppImageLoop(ppImageData *data, ppImageOptions *options, pmConfig *config)
 {
     ppImageDetrend detrend;
@@ -108,8 +110,7 @@
         }
 
+#if 0
         int numMosaicked = pmChipMosaic(inputChip, 1, 1); // Number of cells mosaicked together
         psLogMsg(__func__, PS_LOG_INFO, "%d cells mosaicked.\n", numMosaicked);
-
-        // XXX EAM: Photometry goes here!
 
         // XXX A kludge to get the write to behave w.r.t. the concepts --- we've changed the camera format, so
@@ -117,6 +118,13 @@
         const psMetadata *camera = data->input->fpa->camera;
         data->input->fpa->camera = NULL;
-        pmFPAWrite(data->output, data->input->fpa, config->database);
+#endif
+
+        // XXX Photometry goes here!
+
+        pmChipWrite(inputChip, data->output, config->database);
+
+#if 0
         data->input->fpa->camera = camera;
+#endif
 
         // Now I can blow away the mosaic so I can then read more.
