Index: trunk/psModules/src/camera/pmFPAfileFitsIO.c
===================================================================
--- trunk/psModules/src/camera/pmFPAfileFitsIO.c	(revision 11801)
+++ trunk/psModules/src/camera/pmFPAfileFitsIO.c	(revision 11864)
@@ -28,6 +28,20 @@
     }
 
-    // Need to change format
-    pmFPA *fpa = pmFPAConstruct(file->camera);
+    // May need to change format
+    pmFPALevel level = pmFPAviewLevel(view); // Level for the view
+    if (level == PM_FPA_LEVEL_NONE || level == PM_FPA_LEVEL_READOUT) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
+                "This function shouldn't be called at the readout (or unknown) level.");
+        return NULL;
+    }
+
+    // Does the HDU of interest conform to the desired format?
+    pmHDU *hdu = pmFPAviewThisHDU(view, file->fpa); // The HDU of interest
+    if (hdu && hdu->format == file->format) {
+        // No work required
+        return psMemIncrRefCounter(file->fpa);
+    }
+
+    // Otherwise, we have to generate a copy with the correct format
 
     pmFPAview *phuView = pmFPAviewAlloc(0); // View corresponding to the PHU
@@ -35,16 +49,16 @@
     pmFPALevel phuLevel = pmFPAPHULevel(file->format); // Level for the PHU
     switch (phuLevel) {
-    case PM_FPA_LEVEL_FPA:
+      case PM_FPA_LEVEL_FPA:
         phuView->chip = -1;
         // Flow through
-    case PM_FPA_LEVEL_CHIP:
+      case PM_FPA_LEVEL_CHIP:
         phuView->cell = -1;
         // Flow through
-    case PM_FPA_LEVEL_CELL:
+      case PM_FPA_LEVEL_CELL:
         phuView->readout = -1;
         break;
-    case PM_FPA_LEVEL_READOUT:
-    case PM_FPA_LEVEL_NONE:
-    default:
+      case PM_FPA_LEVEL_READOUT:
+      case PM_FPA_LEVEL_NONE:
+      default:
         psAbort("Should never get here: bad phu level.\n");
     }
@@ -57,7 +71,8 @@
     const char *fpaname = psMetadataLookupStr(&mdok, nameSource->concepts, "FPA.NAME"); // Name of FPA
 
-    if (!pmFPAAddSourceFromView(fpa, fpaname, phuView, file->format)) {
+    pmFPA *copy = pmFPAConstruct(file->camera);  // FPA to return
+    if (!pmFPAAddSourceFromView(copy, fpaname, phuView, file->format)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to insert HDU into FPA for writing.\n");
-        psFree(fpa);
+        psFree(copy);
         psFree(phuView);
         return false;
@@ -65,36 +80,37 @@
     psFree(phuView);
 
-
-    switch (phuLevel) {
-    case PM_FPA_LEVEL_FPA:
-        if (!pmFPACopy(fpa, file->fpa)) {
+    switch (level) {
+      case PM_FPA_LEVEL_FPA:
+        if (!pmFPACopy(copy, file->fpa)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to copy FPA for format conversion.\n");
             return NULL;
         }
-        return fpa;
-    case PM_FPA_LEVEL_CHIP: {
-            pmChip *chip = pmFPAviewThisChip(view, fpa); // Chip of interest
-            pmChip *srcChip = pmFPAviewThisChip(view, file->fpa); // Source chip
-            if (!pmChipCopy(chip, srcChip)) {
-                psError(PS_ERR_UNKNOWN, false, "Unable to copy chip for format conversion.\n");
-                return false;
-            }
-            return fpa;
-        }
-    case PM_FPA_LEVEL_CELL: {
-            pmCell *cell = pmFPAviewThisCell(view, fpa); // Cell of interest
-            pmCell *srcCell = pmFPAviewThisCell(view, file->fpa); // Source cell
-            if (!pmCellCopy(cell, srcCell)) {
-                psError(PS_ERR_UNKNOWN, false, "Unable to copy cell for format conversion.\n");
-                return false;
-            }
-            return fpa;
-        }
-    case PM_FPA_LEVEL_READOUT:
-    case PM_FPA_LEVEL_NONE:
-    default:
+        return copy;
+      case PM_FPA_LEVEL_CHIP: {
+          pmChip *chip = pmFPAviewThisChip(view, copy); // Chip of interest
+          pmChip *srcChip = pmFPAviewThisChip(view, file->fpa); // Source chip
+          if (!pmChipCopy(chip, srcChip)) {
+              psError(PS_ERR_UNKNOWN, false, "Unable to copy chip for format conversion.\n");
+              return false;
+          }
+          return copy;
+      }
+      case PM_FPA_LEVEL_CELL: {
+          pmCell *cell = pmFPAviewThisCell(view, copy); // Cell of interest
+          pmCell *srcCell = pmFPAviewThisCell(view, file->fpa); // Source cell
+          if (!pmCellCopy(cell, srcCell)) {
+              psError(PS_ERR_UNKNOWN, false, "Unable to copy cell for format conversion.\n");
+              return false;
+          }
+          return copy;
+      }
+      case PM_FPA_LEVEL_READOUT:
+      case PM_FPA_LEVEL_NONE:
+      default:
         psAbort("Should never get here: bad phu level.\n");
     }
+
     return NULL;
+
 }
 
