Index: /branches/rel10_ifa/psModules/src/astrom/pmHDU.c
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmHDU.c	(revision 6854)
+++ /branches/rel10_ifa/psModules/src/astrom/pmHDU.c	(revision 6855)
@@ -6,4 +6,36 @@
 #include "psAdditionals.h"
 
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// File-static (private) functions
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+
+// Move to the appropriate extension in FITS file for HDU
+static bool hduMove(pmHDU *hdu,         // HDU with extname
+                    psFits *fits        // FITS file in which to move
+                   )
+{
+    // Deal with the PHU case
+    if (strcasecmp(hdu->extname, "PHU") == 0 || hdu->phu) {
+        if (! psFitsMoveExtNum(fits, 0, false)) {
+            psError(PS_ERR_IO, false, "Unable to move to primary header!\n");
+            return false;
+        }
+        hdu->phu = true;
+        return true;
+    }
+
+    if (! psFitsMoveExtName(fits, hdu->extname)) {
+        psError(PS_ERR_IO, false, "Unable to move to extension %s\n", hdu->extname);
+        return false;
+    }
+    // Now, just in case for some reason the PHU has an extension name that we've moved to....
+    if (psFitsGetExtNum(fits) == 0) {
+        hdu->phu = true;
+    } else {
+        hdu->phu = false;
+    }
+
+    return true;
+}
 
 static void hduFree(pmHDU *hdu)
@@ -18,4 +50,8 @@
 }
 
+
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
+// Public functions
+//////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
 pmHDU *pmHDUAlloc(const char *extname   // Extension name
@@ -46,4 +82,28 @@
 }
 
+bool pmHDUReadHeader(pmHDU *hdu,        // HDU for which to read header
+                     psFits *fits       // FITS file from which to read
+                    )
+{
+    assert(hdu);
+    assert(fits);
+
+    // Move to the appropriate extension
+    psTrace(__func__, 5, "Moving to extension %s...\n", hdu->extname);
+    if (!hduMove(hdu, fits)) {
+        return false;
+    }
+
+    if (!hdu->header) {
+        psTrace(__func__, 5, "Reading the header...\n");
+        hdu->header = psFitsReadHeader(NULL, fits);
+        if (! hdu->header) {
+            psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", hdu->extname);
+            return false;
+        }
+    }
+
+    return true;
+}
 
 // Read the HDU
@@ -56,32 +116,7 @@
     assert(fits);
 
-    // Move to the appropriate extension
-    psTrace(__func__, 5, "Moving to extension %s...\n", hdu->extname);
-    if (strcasecmp(hdu->extname, "PHU") == 0) {
-        if (! psFitsMoveExtNum(fits, 0, false)) {
-            psError(PS_ERR_IO, false, "Unable to move to primary header!\n");
-            return false;
-        }
-        hdu->phu = true;
-    } else {
-        if (! psFitsMoveExtName(fits, hdu->extname)) {
-            psError(PS_ERR_IO, false, "Unable to move to extension %s\n", hdu->extname);
-        }
-        // Now, just in case for some reason the PHU has an extension name that we've moved to....
-        if (psFitsGetExtNum(fits) == 0) {
-            hdu->phu = true;
-        } else {
-            hdu->phu = false;
-        }
-    }
-
-    // Read the header
-    if (! hdu->header) {
-        psTrace(__func__, 5, "Reading the header...\n");
-        hdu->header = psFitsReadHeader(NULL, fits);
-        if (! hdu->header) {
-            psError(PS_ERR_IO, false, "Unable to read header for extension %s\n", hdu->extname);
-            return false;
-        }
+    // Read the header; includes the move
+    if (!pmHDUReadHeader(hdu, fits)) {
+        return false;
     }
 
Index: /branches/rel10_ifa/psModules/src/astrom/pmHDU.h
===================================================================
--- /branches/rel10_ifa/psModules/src/astrom/pmHDU.h	(revision 6854)
+++ /branches/rel10_ifa/psModules/src/astrom/pmHDU.h	(revision 6855)
@@ -20,4 +20,9 @@
 pmHDU *pmHDUAlloc(const char *extname);
 
+// Read the header
+bool pmHDUReadHeader(pmHDU *hdu,        // HDU for which to read header
+                     psFits *fits       // FITS file from which to read
+                    );
+
 // Read the HDU
 bool pmHDURead(pmHDU *hdu,              // HDU to read
