Index: /branches/rel10_ifa/psModules/src/astrom/Makefile.am
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/Makefile.am	(revision 6719)
+++ /branches/rel10_ifa/psModules/src/astrom/Makefile.am	(revision 6720)
@@ -6,4 +6,5 @@
 	pmFPA.c \
 	pmFPAConstruct.c \
+	pmFPACopy.c \
 	pmFPAMaskWeight.c \
 	pmFPARead.c \
@@ -28,4 +29,5 @@
 	pmFPA.h \
 	pmFPAConstruct.h \
+	pmFPACopy.h \
 	pmFPAMaskWeight.h \
 	pmFPARead.h \
Index: /branches/rel10_ifa/psModules/src/astrom/pmFPACopy.c
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmFPACopy.c	(revision 6719)
+++ /branches/rel10_ifa/psModules/src/astrom/pmFPACopy.c	(revision 6720)
@@ -3,7 +3,12 @@
 
 #include "pslib.h"
+#include "psImageFlip.h"
+#include "psRegionIsBad.h"
+
 #include "pmFPA.h"
 #include "pmFPAUtils.h"
 #include "pmHDU.h"
+#include "pmHDUUtils.h"
+#include "pmFPACopy.h"
 
 #define MAX(x,y) ((x) > (y) ? (x) : (y))
@@ -53,6 +58,6 @@
 static bool cellList(psList *targets,   // The list of target cells
                      psList *sources,   // The list of source cells
-                     const pmCell *targetCell, // The target cell
-                     const pmCell *sourceCell // The source cell
+                     pmCell *targetCell, // The target cell
+                     pmCell *sourceCell // The source cell
                     )
 {
@@ -94,5 +99,5 @@
     }
 
-    return list;
+    return true;
 }
 
@@ -226,5 +231,6 @@
         psRegion *trimsec = psMetadataLookupPtr(&mdok, target->concepts, "CELL.TRIMSEC"); // Trim section
         if (!mdok || !trimsec) {
-            psLogMsg(PS_ERR_IO, true, "CELL.TRIMSEC has not been initialised in target cell --- ignored.\n");
+            psLogMsg(__func__, PS_LOG_WARN, "CELL.TRIMSEC has not been initialised in target cell --- "
+                     "ignored.\n");
             continue;
         }
@@ -239,5 +245,5 @@
         pmReadout *readout = source->readouts->data[0]; // The first source readout, as representative
         psImage *image = readout->image;// The proper image
-        *trimsec = sectionForImage(position, bias, readdir);
+        *trimsec = sectionForImage(&position, image, readdir);
     }
 
@@ -258,6 +264,6 @@
 
 // Generate an HDU with the pixels
-static bool generateHDU(pmCell *target  // The target cell
-                        const pmCell *source // The source cell
+static bool generateHDU(pmCell *target,  // The target cell
+                        pmCell *source // The source cell
                        )
 {
@@ -266,5 +272,5 @@
     psList *targetCells = psListAlloc(NULL); // List of target cells below the target HDU
     psList *sourceCells = psListAlloc(NULL); // List of source cells below the target HDU
-    if (! cellList(targetCells, sources, target, source)) {
+    if (! cellList(targetCells, sourceCells, target, source)) {
         psError(PS_ERR_IO, true, "Unable to find cells to generate HDU!\n");
         return false;
@@ -288,5 +294,5 @@
 
         }
-        psFree(cellsIter);
+        psFree(iter);
     }
 
@@ -327,5 +333,5 @@
         UPDATE_CASE(PS_TYPE_F32, F32);
         UPDATE_CASE(PS_TYPE_F64, F64);
-        UPDATE_CASE(PS_DATA_STR, V);
+        UPDATE_CASE(PS_DATA_STRING, V);
     default:
         psLogMsg(__func__, PS_LOG_WARN, "Unsupported type (%x) for concept %s --- ignored.\n",
@@ -416,5 +422,5 @@
         pmCell *targetCell = targetCells->data[i]; // The target cell
         const char *cellName = psMetadataLookupStr(NULL, targetCell->concepts, "CELL.NAME"); // Name of cell
-        int cellNum = pmFPAFindCell(source, cellName); // Number of cell with that name
+        int cellNum = pmChipFindCell(source, cellName); // Number of cell with that name
         if (cellNum >= 0) {
             pmCell *sourceCell = sourceCells->data[cellNum]; // The source cell
@@ -447,5 +453,5 @@
     pmHDU *hdu = pmHDUFromCell(target); // The target HDU; we need to fix this up
     if (! hdu->images) {
-        generateHDU(cell);
+        generateHDU(target, source);
     }
 
@@ -496,5 +502,5 @@
         while ((biassec = psListGetAndIncrement(biassecsIter))) {
             if (psRegionIsBad(*biassec)) {
-                psString *biassecString = psRegionToString(biassec); // String for bias section
+                psString biassecString = psRegionToString(*biassec); // String for bias section
                 psLogMsg(__func__, PS_LOG_WARN, "Bias section (%s) isn't set --- ignored.\n", biassecString);
                 psFree(biassecString);
Index: /branches/rel10_ifa/psModules/src/astrom/pmFPACopy.h
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmFPACopy.h	(revision 6720)
+++ /branches/rel10_ifa/psModules/src/astrom/pmFPACopy.h	(revision 6720)
@@ -0,0 +1,14 @@
+#ifndef PM_FPA_COPY_H
+#define PM_FPA_COPY_H
+
+int pmFPACopy(pmFPA *target,            // The target FPA
+              pmFPA *source             // The source FPA, to be copied
+             );
+int pmChipCopy(pmChip *target,          // The target chip
+               pmChip *source           // The source chip, to be copied
+              );
+int pmCellCopy(pmCell *target,          // The target cell
+               pmCell *source           // The source cell, to be copied
+              );
+
+#endif
Index: /branches/rel10_ifa/psModules/src/astrom/pmFPARead.c
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmFPARead.c	(revision 6719)
+++ /branches/rel10_ifa/psModules/src/astrom/pmFPARead.c	(revision 6720)
@@ -6,4 +6,6 @@
 #include "pmFPA.h"
 #include "pmFPARead.h"
+#include "pmHDU.h"
+#include "pmHDUUtils.h"
 #include "pmConcepts.h"
 #include "psRegionIsBad.h"
