Index: trunk/psModules/src/objects/pmSourceIO.c
===================================================================
--- trunk/psModules/src/objects/pmSourceIO.c	(revision 10920)
+++ trunk/psModules/src/objects/pmSourceIO.c	(revision 11229)
@@ -3,6 +3,6 @@
  *  @author EAM, IfA
  *
- *  @version $Revision: 1.16 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-01-05 20:19:23 $
+ *  @version $Revision: 1.17 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-01-22 01:13:00 $
  *
  *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
@@ -396,15 +396,11 @@
 bool pmCellReadObjects (pmCell *cell, const pmFPAview *view, pmFPAfile *file, pmConfig *config)
 {
-    // determine the number of readouts:
-    switch (file->type) {
-    case PM_FPA_FILE_CMP: {
-            pmReadout *readout;
-            readout = pmReadoutAlloc (cell);
-            psFree (readout);
-            break;
-        }
-    default:
-        psAbort ("pmSourceIO", "n readouts is not yet defined\n");
-    }
+    // multiple readout mode is not yet defined for CMP or CMF files
+    // if they have not been allocated, allocate a single readout
+    if (!cell->readouts || !cell->readouts->n) {
+        pmReadout *readout = pmReadoutAlloc (cell);
+        psFree (readout);
+    }
+
     for (int i = 0; i < cell->readouts->n; i++) {
         pmReadout *readout = cell->readouts->data[i];
@@ -477,6 +473,17 @@
         }
 
-        char *dataname = pmFPAfileNameFromRule (file->extrule, file, view);
-        psFitsMoveExtName (file->fits, dataname);
+        // we need to find the corresponding table EXTNAME.
+        // first check the header
+        char *dataname = psMetadataLookupStr (NULL, hdu->header, "EXTDATA");
+        psMemIncrRefCounter (dataname); // so free below is safe
+        if (!dataname) {
+            // if it is not defined in the header, try the value in the filerule
+            dataname = pmFPAfileNameFromRule (file->extrule, file, view);
+            if (!dataname)
+                psAbort ("pmSourceIO", "cannot determine data EXTNAME");
+        }
+        if (!psFitsMoveExtName (file->fits, dataname)) {
+            psAbort ("pmSourceIO", "cannot find data extension %s in %s", dataname, file->filename);
+        }
         sources = pmSourcesReadCMF (file->fits, hdu->header);
         psFree (dataname);
