Index: trunk/psModules/src/camera/pmFPACopy.c
===================================================================
--- trunk/psModules/src/camera/pmFPACopy.c	(revision 9588)
+++ trunk/psModules/src/camera/pmFPACopy.c	(revision 9589)
@@ -22,5 +22,5 @@
 // Bin a region down by specified factors in x and y
 static void binRegion(psRegion *region, // Region to be binned
-                      int xBin, int yBin// Binning in x and y
+                      int xBin, int yBin // Binning in x and y
                      )
 {
@@ -38,5 +38,5 @@
 
 // Find the blank (image-less) PHU, given a cell.
-static pmHDU *findBlankPHU(const pmCell *cell// The cell for which to find the PHU
+static pmHDU *findBlankPHU(const pmCell *cell // The cell for which to find the PHU
                           )
 {
@@ -63,6 +63,8 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
+// Common engine for pmCellCopy and pmCellCopyStructure
+// Does the actual splitting/splicing that's required to copy an FPA to a different representation.
 static bool cellCopy(pmCell *target,     // The target cell
-                     pmCell *source,     // The source cell, to be copied
+                     const pmCell *source, // The source cell, to be copied
                      bool pixels,        // Copy the pixels?
                      int xBin, int yBin  // (Relative) binning factors in x and y
@@ -249,5 +251,6 @@
         psTrace("psModules.camera", 3, "CELL.X0: Before: %d After: %d\n", xZero,
                 xZero - (readout->image->numCols - 1) * xParity * xBin);
-        psTrace("psModules.camera", 9, "(xParity: %d xBin: %d numCols: %d)\n", xParity, xBin, readout->image->numCols);
+        psTrace("psModules.camera", 9, "(xParity: %d xBin: %d numCols: %d)\n",
+                xParity, xBin, readout->image->numCols);
         xZero -= (readout->image->numCols - 1) * xParity * xBin; // Change the parity on the X0 position
         psMetadataItem *newItem = psMetadataLookup(target->concepts, "CELL.X0"); // CELL.X0 from target
@@ -261,5 +264,6 @@
         psTrace("psModules.camera", 3, "CELL.Y0: Before: %d After: %d\n", yZero,
                 yZero - (readout->image->numRows - 1) * yParity * yBin);
-        psTrace("psModules.camera", 9, "(yParity: %d yBin: %d numRows: %d)\n", yParity, yBin, readout->image->numRows);
+        psTrace("psModules.camera", 9, "(yParity: %d yBin: %d numRows: %d)\n",
+                yParity, yBin, readout->image->numRows);
         yZero -= (readout->image->numRows - 1) * yParity * yBin; // Change the parity on the Y0 position
         psMetadataItem *newItem = psMetadataLookup(target->concepts, "CELL.Y0"); // CELL.Y0 from target
@@ -294,6 +298,8 @@
 }
 
+// Common engine for pmChipCopy and pmChipCopyStructure
+// Iterate on the components
 static bool chipCopy(pmChip *target,          // The target chip
-                     pmChip *source,          // The source chip, to be copied
+                     const pmChip *source, // The source chip, to be copied
                      bool pixels,             // Copy the pixels?
                      int xBin, int yBin       // (Relative) binning factors in x and y
@@ -308,5 +314,6 @@
     psArray *sourceCells = source->cells; // The source cells
     if (targetCells->n != sourceCells->n) {
-        psError(PS_ERR_IO, true, "Number of source cells (%ld) differs from the number of target cells (%ld)\n",
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "Number of source cells (%ld) differs from the number of target cells (%ld)\n",
                 sourceCells->n, targetCells->n);
         return false;
@@ -331,8 +338,10 @@
 }
 
-static bool fpaCopy(pmFPA *target,            // The target FPA
-                    pmFPA *source,            // The source FPA, to be copied
-                    bool pixels,              // Copy the pixels?
-                    int xBin, int yBin        // (Relative) binning factors in x and y
+// Common engine for pmFPACopy and pmFPACopyStructure.
+// Iterate on the components
+static bool fpaCopy(pmFPA *target,      // The target FPA
+                    const pmFPA *source, // The source FPA, to be copied
+                    bool pixels,        // Copy the pixels?
+                    int xBin, int yBin  // (Relative) binning factors in x and y
                    )
 {
@@ -345,5 +354,6 @@
     psArray *sourceChips = source->chips; // The source chips
     if (targetChips->n != sourceChips->n) {
-        psError(PS_ERR_IO, true, "Number of source chips (%ld) differs from the number of target chips (%ld)\n",
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "Number of source chips (%ld) differs from the number of target chips (%ld)\n",
                 sourceChips->n, targetChips->n);
         return false;
@@ -371,7 +381,5 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-bool pmFPACopy(pmFPA *target,            // The target FPA
-               pmFPA *source             // The source FPA, to be copied
-              )
+bool pmFPACopy(pmFPA *target, const pmFPA *source)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
@@ -380,7 +388,5 @@
 }
 
-bool pmChipCopy(pmChip *target,          // The target chip
-                pmChip *source           // The source chip, to be copied
-               )
+bool pmChipCopy(pmChip *target, const pmChip *source)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
@@ -389,7 +395,5 @@
 }
 
-bool pmCellCopy(pmCell *target,          // The target cell
-                pmCell *source           // The source cell, to be copied
-               )
+bool pmCellCopy(pmCell *target, const pmCell *source)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
@@ -399,8 +403,5 @@
 
 
-bool pmFPACopyStructure(pmFPA *target,   // The target FPA
-                        pmFPA *source,   // The source FPA, to be copied
-                        int xBin, int yBin // Binning factors in x and y
-                       )
+bool pmFPACopyStructure(pmFPA *target, const pmFPA *source, int xBin, int yBin)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
@@ -411,8 +412,5 @@
 }
 
-bool pmChipCopyStructure(pmChip *target, // The target chip
-                         pmChip *source, // The source chip, to be copied
-                         int xBin, int yBin // Binning factors in x and y
-                        )
+bool pmChipCopyStructure(pmChip *target, const pmChip *source, int xBin, int yBin)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
@@ -423,8 +421,5 @@
 }
 
-bool pmCellCopyStructure(pmCell *target, // The target cell
-                         pmCell *source, // The source cell, to be copied
-                         int xBin, int yBin // Binning factors in x and y
-                        )
+bool pmCellCopyStructure(pmCell *target, const pmCell *source, int xBin, int yBin)
 {
     PS_ASSERT_PTR_NON_NULL(target, false);
Index: trunk/psModules/src/camera/pmFPACopy.h
===================================================================
--- trunk/psModules/src/camera/pmFPACopy.h	(revision 9588)
+++ trunk/psModules/src/camera/pmFPACopy.h	(revision 9589)
@@ -1,28 +1,75 @@
+/// @file pmFPACopy.h
+///
+/// @brief Functions to copy FPA components.
+///
+/// @ingroup Camera
+///
+/// @author Paul Price, IfA
+///
+/// @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
+/// @date $Date: 2006-10-17 01:16:17 $
+///
+/// Copyright 2005-2006 Institute for Astronomy, University of Hawaii
+///
+
 #ifndef PM_FPA_COPY_H
 #define PM_FPA_COPY_H
 
-// Copy the FPA components, including the pixels
-bool pmFPACopy(pmFPA *target,            // The target FPA
-               pmFPA *source             // The source FPA, to be copied
+/// Copy an FPA and components, including the pixels, to a different representation of the same camera
+///
+/// This function is useful for converting between different representations of the same camera.  For example,
+/// between Megacam "RAW" (one amp per extension) and Megacam "SPLICED" formats (two amps = 1 chip per
+/// extension, spliced together).  Components are spliced together as necessary.
+bool pmFPACopy(pmFPA *target,           ///< The target FPA
+               const pmFPA *source      ///< The source FPA, to be copied
               );
-bool pmChipCopy(pmChip *target,          // The target chip
-                pmChip *source           // The source chip, to be copied
-               );
-bool pmCellCopy(pmCell *target,          // The target cell
-                pmCell *source           // The source cell, to be copied
+
+/// Copy a chip and components, including the pixels, to a different representation of the same camera
+///
+/// This function is useful for converting between different representations of the same camera.  For example,
+/// between Megacam "RAW" (one amp per extension) and Megacam "SPLICED" formats (two amps = 1 chip per
+/// extension, spliced together).  Components are spliced together as necessary.
+bool pmChipCopy(pmChip *target,         ///< The target chip
+                const pmChip *source    ///< The source chip, to be copied
                );
 
-// Versions that copy the structure and not the pixels; they also allow binning
-bool pmFPACopyStructure(pmFPA *target,   // The target FPA
-                        pmFPA *source,   // The source FPA, to be copied
-                        int xBin, int yBin     // Binning factors in x and y
+/// Copy a cell and components, including the pixels, to a different representation of the same camera
+///
+/// This function is useful for converting between different representations of the same camera.  For example,
+/// between Megacam "RAW" (one amp per extension) and Megacam "SPLICED" formats (two amps = 1 chip per
+/// extension, spliced together).  Components are spliced together as necessary.
+bool pmCellCopy(pmCell *target,         ///< The target cell
+                const pmCell *source    ///< The source cell, to be copied
+               );
+
+
+/// Copy an FPA, but not the pixels, to a different representation of the same camera
+///
+/// This function the same as pmFPACopy, except that the pixels are not copied (though images of sufficient
+/// size are allocated in the target).  Changes the CELL.XBIN and CELL.YBIN according to the provided binning
+/// factors.
+bool pmFPACopyStructure(pmFPA *target,   ///< The target FPA
+                        const pmFPA *source, ///< The source FPA, to be copied
+                        int xBin, int yBin ///< Binning factors in x and y
                        );
-bool pmChipCopyStructure(pmChip *target, // The target chip
-                         pmChip *source, // The source chip, to be copied
-                         int xBin, int yBin   // Binning factors in x and y
+
+/// Copy a chip, but not the pixels, to a different representation of the same camera
+///
+/// This function the same as pmChipCopy, except that the pixels are not copied (though images of sufficient
+/// size are allocated in the target).  Changes the CELL.XBIN and CELL.YBIN according to the provided binning
+/// factors.
+bool pmChipCopyStructure(pmChip *target, ///< The target chip
+                         const pmChip *source, ///< The source chip, to be copied
+                         int xBin, int yBin ///< Binning factors in x and y
                         );
-bool pmCellCopyStructure(pmCell *target, // The target cell
-                         pmCell *source, // The source cell, to be copied
-                         int xBin, int yBin // Binning factors in x and y
+
+/// Copy a cell, but not the pixels, to a different representation of the same camera
+///
+/// This function the same as pmCellCopy, except that the pixels are not copied (though images of sufficient
+/// size are allocated in the target).  Changes the CELL.XBIN and CELL.YBIN according to the provided binning
+/// factors.
+bool pmCellCopyStructure(pmCell *target, ///< The target cell
+                         const pmCell *source, ///< The source cell, to be copied
+                         int xBin, int yBin ///< Binning factors in x and y
                         );
 
