Index: /trunk/ppImage/src/ppImage.c
===================================================================
--- /trunk/ppImage/src/ppImage.c	(revision 10214)
+++ /trunk/ppImage/src/ppImage.c	(revision 10215)
@@ -17,5 +17,5 @@
     pmConfig *config = ppImageArguments(argc, argv);
     if (config == NULL) {
-        psErrorStackPrint(stderr, " ");
+        psErrorStackPrint(stderr, "Unable to parse command-line arguments.");
         exit(1);
     }
@@ -25,5 +25,5 @@
     ppImageOptions *options = ppImageParseCamera(config);
     if (options == NULL) {
-        psErrorStackPrint(stderr, " ");
+        psErrorStackPrint(stderr, "Unable to parse camera.");
         exit(1);
     }
@@ -31,12 +31,13 @@
     // Image Arithmetic Loop
     if (!ppImageLoop(config, options)) {
-        psErrorStackPrint(stderr, " ");
+        psErrorStackPrint(stderr, "Unable to loop over input");
         exit(1);
     }
 
-    psLogMsg ("ppImage", 3, "complete ppImage run: %f sec\n", psTimerMark (TIMERNAME));
+    psLogMsg ("ppImage", 3, "Complete ppImage run: %f sec\n", psTimerMark(TIMERNAME));
 
     // Cleaning up
     ppImageCleanup(config, options);
+
     return EXIT_SUCCESS;
 }
Index: unk/ppImage/src/ppImageDetrendFlat.c
===================================================================
--- /trunk/ppImage/src/ppImageDetrendFlat.c	(revision 10214)
+++ 	(revision )
@@ -1,27 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include "pslib.h"
-#include "psmodules.h"
-#include "ppImage.h"
-
-// why does this use the flat pmReadout?
-
-bool ppDetrendFlat (pmReadout *inputReadout, pmReadout *flat, ppOptions *options) {
-
-    psLogMsg("phase2", PS_LOG_INFO, "Performing flat field.\n");
-
-
-
-#ifndef PRODUCTION
-    psImage *dummyImage = psImageAlloc(inputReadout->image->numCols,
-                                       inputReadout->image->numRows,
-                                       PS_TYPE_U8);
-    pmReadout *dummyMask = pmReadoutAlloc(NULL);
-    dummyMask->image = dummyImage;
-    (void)pmFlatField(inputReadout, dummyMask, flatReadout);
-    psFree(dummyMask);
-    psFree(dummyImage);
-#endif
Index: /trunk/ppImage/src/ppImageDetrendFringe.h
===================================================================
--- /trunk/ppImage/src/ppImageDetrendFringe.h	(revision 10214)
+++ /trunk/ppImage/src/ppImageDetrendFringe.h	(revision 10215)
@@ -6,4 +6,5 @@
 #include "ppImageOptions.h"
 
+// Measure fringes
 bool ppImageDetrendFringeMeasure(pmReadout *readout, // Readout to measure
                                  pmCell *fringe, // Fringe cell (each readout is a different component)
@@ -11,4 +12,5 @@
     );
 
+// Solve the fringe system
 bool ppImageDetrendFringeSolve(pmChip *scienceChip, // Chip with science
                                const pmChip *refChip, // Chip with reference fringes
@@ -16,5 +18,5 @@
     );
 
-
+// Generate fringe frame
 psImage *ppImageDetrendFringeGenerate(pmCell *science, // Science cell
                                       pmCell *fringes // Fringe cell, one readout per fringe component
Index: unk/ppImage/src/ppImageDetrendMask.c
===================================================================
--- /trunk/ppImage/src/ppImageDetrendMask.c	(revision 10214)
+++ 	(revision )
@@ -1,43 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ppImage.h"
-
-# define MASK_MODE (PM_MASK_TRAP | PM_MASK_BADCOL | PM_MASK_SAT)
-
-// XXX pass 'concepts' not 'cell' to this function?
-
-bool ppImageDetrendMask(pmReadout *input, pmReadout *mask) {
-
-    psImage *image = NULL;
-
-    float saturation = psMetadataLookupF32(NULL, input->parent->concepts, "CELL.SATURATION");
-
-    // Need to change this later to grow the mask by the size of the convolution kernel
-    // XXX does this function respect the mask / image cell region information?
-    // XXX should probably take pmRegion *mask
-
-    if (mask->image->type.type != PS_TYPE_MASK) {
-        image = psImageCopy (NULL, mask->image, PS_TYPE_MASK);
-    } else {
-        image = psMemIncrRefCounter (mask->image);
-    }
-
-    pmMaskBadPixels(input, image, MASK_MODE, saturation, PM_MASK_TRAP, 0);
-    psFree (image);
-
-    return true;
-}
-
-
-// XXX the translation here should not be needed
-// the mask should (but is not) be read in using the mask read functions
-// by identifying the image type as a mask (in pmFPAfile).
-// currently, pmFPAfileReadImage converts the image to F32
-
-
-// XXX this function needs to use pmReadoutGenerateMask to construct the initial mask
-// then the pixels will correspond and pmMaskBadPixels can be correctly applied.
-// this function should not have to lookup the value of CELL.SATURATION, nor should it have to
-// apply it.
Index: unk/ppImage/src/ppImageDetrendPedestal.c
===================================================================
--- /trunk/ppImage/src/ppImageDetrendPedestal.c	(revision 10214)
+++ 	(revision )
@@ -1,81 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include "pslib.h"
-#include "psmodules.h"
-#include "ppImage.h"
-
-// XXX check on image overlaps, as well as image sizes
-// XXX what constraints do we put on the detrend images?
-// XXX this function is much easier if we can assume all detrend images
-//     should have the same size and represent the same pixels...
-
-pmReadout *ppDetrendPedestal (pmReadout *pedestal, pmCell *input, pmReadout *bias, pmReadout *dark, float darkTime, ppOptions *options) {
-
-#ifdef PRODUCTION
-    static float lastExptime = 0.0;
-    bool reusePedestal = true;
-
-    if (options->doDark) {
-        // Dark time for input image
-        float inputTime = psMetadataLookupF32(NULL, input->concepts, "CELL.DARKTIME");
-        if (inputTime <= 0) {
-            psErrorStackPrint(stderr, "DARKTIME for input image (%f) is non-positive.\n",
-                              inputTime);
-            exit(EXIT_FAILURE);
-        }
-
-        if (inputTime != lastExptime) {
-            // this will create a new pedestal if the input one is NULL
-            // XXX EAM : this function had darkTime * inputTime, which is wrong, yes?
-            if (pedestal == NULL) {
-                pedestal = pmReadoutAlloc (NULL);
-            }
-            pedestal->col0    = dark->col0;
-            pedestal->row0    = dark->row0;
-            pedestal->colBins = dark->colBins;
-            pedestal->rowBins = dark->rowBins;
-
-            pedestal->image   = (psImage *) psBinaryOp(pedestal->image, dark->image, "*", psScalarAlloc(inputTime / darkTime, PS_TYPE_F32));
-            reusePedestal = false;
-            lastExptime = inputTime
-        }
-    }
-
-    // no bias image, return dark pedestal or NULL
-    if (!options->doBias) {
-        return pedestal;
-    }
-
-    // no dark image, return bias pedestal, or reuse
-    if (!options->doDark) {
-        if (!pedestal) {
-            pedestal = psMemIncrRefCounter(bias);
-        }
-        return pedestal;
-    }
-
-    if (reusePedestal) {
-        return pedestal;
-    }
-
-    if (bias->image->numRows != dark->image->numRows ||
-        bias->image->numCols != dark->image->numCols) {
-        psError(PS_ERR_IO, true, "Bias and dark images have different dimensions: %dx%d vs %dx%d\n",
-                bias->image->numCols, bias->image->numRows,
-                dark->image->numCols, dark->image->numRows);
-        exit(EXIT_FAILURE);
-    }
-
-    psBinaryOp(pedestal->image, pedestal->image, "+", bias->image);
-    return pedestal;
-#else
-    return NULL;
-#endif
-}
-
-// creates a new pedestal image for this readout
-// if the current exptime is the same as the last exptime,
-// reuses the supplied pedestal
Index: /trunk/ppImage/src/ppImageParseCamera.c
===================================================================
--- /trunk/ppImage/src/ppImageParseCamera.c	(revision 10214)
+++ /trunk/ppImage/src/ppImageParseCamera.c	(revision 10215)
@@ -16,4 +16,20 @@
         return NULL;
     }
+
+#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
 
     // add recipe options supplied on command line
Index: unk/ppImage/src/ppImageParseDetrend.c
===================================================================
--- /trunk/ppImage/src/ppImageParseDetrend.c	(revision 10214)
+++ 	(revision )
@@ -1,85 +1,0 @@
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include "ppImage.h"
-
-// identify all needed detrend and other I/O files
-// create the pmFPAfiles for the active I/O files
-
-bool ppImageParseDetrend(ppImageOptions *options, pmConfig *config)
-{
-
-    bool status;
-
-    // some of the output files are associated with the input fpa
-    pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PPIMAGE.INPUT");
-
-    // the following are defined from the argument list, if given,
-    // otherwise they revert to the config information
-
-    if (options->doBias) {
-        bool status = false;
-        pmFPAfileFromArgs (&status, config, "PPIMAGE.BIAS", "BIAS");
-        pmFPAfileFromConf (&status, config, "PPIMAGE.BIAS", input->fpa);
-        if (!status) psAbort ("ppImageParseDetrend", "can't find a bias image source");
-    }
-
-    if (options->doDark) {
-        bool status = false;
-        pmFPAfileFromArgs (&status, config, "PPIMAGE.DARK", "DARK");
-        pmFPAfileFromConf (&status, config, "PPIMAGE.DARK", input->fpa);
-        if (!status) psAbort ("ppImageParseDetrend", "can't find a dark image source");
-    }
-
-    if (options->doMask) {
-        bool status = false;
-        pmFPAfileFromArgs (&status, config, "PPIMAGE.MASK", "MASK");
-        pmFPAfileFromConf (&status, config, "PPIMAGE.MASK", input->fpa);
-        if (!status) psAbort ("ppImageParseDetrend", "can't find a mask image source");
-    }
-
-    if (options->doShutter) {
-        bool status = false;
-        pmFPAfileFromArgs (&status, config, "PPIMAGE.SHUTTER", "SHUTTER");
-        pmFPAfileFromConf (&status, config, "PPIMAGE.SHUTTER", input->fpa);
-        if (!status) psAbort ("ppImageParseDetrend", "can't find a shutter image source");
-    }
-
-    if (options->doFlat) {
-        bool status = false;
-        pmFPAfileFromArgs (&status, config, "PPIMAGE.FLAT", "FLAT");
-        pmFPAfileFromConf (&status, config, "PPIMAGE.FLAT", input->fpa);
-        if (!status) psAbort ("ppImageParseDetrend", "can't find a flat image source");
-    }
-
-    if (options->doFringe) {
-        bool status = false;
-        pmFPAfileFromArgs (&status, config, "PPIMAGE.FRINGE", "FRINGE");
-        pmFPAfileFromConf (&status, config, "PPIMAGE.FRINGE", input->fpa);
-        if (!status) psAbort ("ppImageParseDetrend", "can't find a fringe image source");
-    }
-
-    // the following files are output targets
-    // XXX which of these are required?
-    pmFPAfileDefine (config->files, config->camera, input->fpa, "PPIMAGE.OUTPUT");
-
-    // XXX do these need to construct a new fpa?
-    if (options->doBin1) {
-        pmFPAfile *file = pmFPAfileFromFPA (config, input->fpa, options->xBin1, options->yBin1, "PPIMAGE.BIN1");
-        pmFPAfileDefine (config->files, config->camera, file->fpa, "PPIMAGE.JPEG1");
-    }
-    if (options->doBin2) {
-        pmFPAfile *file = pmFPAfileFromFPA (config, input->fpa, options->xBin2, options->yBin2, "PPIMAGE.BIN2");
-        pmFPAfileDefine (config->files, config->camera, file->fpa, "PPIMAGE.JPEG2");
-    }
-
-
-    // ppImage is supplied with an output name, which may be used by multiple
-    // output files to construct the output names.  supply this value to the
-    // files which are write types.
-    char *output = psMetadataLookupPtr(&status, config->arguments, "OUTPUT");
-    pmFPAfileAddFileNames (config->files, "OUTPUT", output, PM_FPA_MODE_WRITE);
-
-    return true;
-}
