Index: branches/alma/external/atnf/PKSIO/PKSreader.cc
===================================================================
--- branches/alma/external/atnf/PKSIO/PKSreader.cc	(revision 1453)
+++ branches/alma/external/atnf/PKSIO/PKSreader.cc	(revision 1757)
@@ -2,29 +2,32 @@
 //# PKSreader.cc: Class to read Parkes multibeam data.
 //#---------------------------------------------------------------------------
-//# Copyright (C) 2000-2006
-//# Associated Universities, Inc. Washington DC, USA.
-//#
-//# This library is free software; you can redistribute it and/or modify it
-//# under the terms of the GNU Library General Public License as published by
-//# the Free Software Foundation; either version 2 of the License, or (at your
-//# option) any later version.
-//#
-//# This library is distributed in the hope that it will be useful, but WITHOUT
+//# livedata - processing pipeline for single-dish, multibeam spectral data.
+//# Copyright (C) 2000-2009, Australia Telescope National Facility, CSIRO
+//#
+//# This file is part of livedata.
+//#
+//# livedata is free software: you can redistribute it and/or modify it under
+//# the terms of the GNU General Public License as published by the Free
+//# Software Foundation, either version 3 of the License, or (at your option)
+//# any later version.
+//#
+//# livedata is distributed in the hope that it will be useful, but WITHOUT
 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-//# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
-//# License for more details.
-//#
-//# You should have received a copy of the GNU Library General Public License
-//# along with this library; if not, write to the Free Software Foundation,
-//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
-//#
-//# Correspondence concerning AIPS++ should be addressed as follows:
-//#        Internet email: aips2-request@nrao.edu.
-//#        Postal address: AIPS++ Project Office
-//#                        National Radio Astronomy Observatory
-//#                        520 Edgemont Road
-//#                        Charlottesville, VA 22903-2475 USA
-//#
-//# $Id$
+//# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+//# more details.
+//#
+//# You should have received a copy of the GNU General Public License along
+//# with livedata.  If not, see <http://www.gnu.org/licenses/>.
+//#
+//# Correspondence concerning livedata may be directed to:
+//#        Internet email: mcalabre@atnf.csiro.au
+//#        Postal address: Dr. Mark Calabretta
+//#                        Australia Telescope National Facility, CSIRO
+//#                        PO Box 76
+//#                        Epping NSW 1710
+//#                        AUSTRALIA
+//#
+//# http://www.atnf.csiro.au/computing/software/livedata.html
+//# $Id: PKSreader.cc,v 19.13 2009-09-29 07:33:39 cal103 Exp $
 //#---------------------------------------------------------------------------
 //# Original: 2000/08/23, Mark Calabretta, ATNF
@@ -41,5 +44,4 @@
 #include <casa/OS/File.h>
 
-
 //--------------------------------------------------------------- getPKSreader
 
@@ -50,12 +52,5 @@
         const Int retry,
         const Int interpolate,
-        String &format,
-        Vector<Bool> &beams,
-        Vector<Bool> &IFs,
-        Vector<uInt> &nChan,
-        Vector<uInt> &nPol,
-        Vector<Bool> &haveXPol,
-        Bool   &haveBase,
-        Bool   &haveSpectra)
+        String &format)
 {
   // Check accessibility of the input.
@@ -63,29 +58,36 @@
   if (!inFile.exists()) {
     format = "DATASET NOT FOUND";
-    return 0;
+    return 0x0;
   }
 
   if (!inFile.isReadable()) {
     format = "DATASET UNREADABLE";
-    return 0;
+    return 0x0;
   }
 
   // Determine the type of input.
-  PKSreader *reader = 0;
+  PKSreader *reader = 0x0;
   if (inFile.isRegular()) {
     // Is it MBFITS or SDFITS?
-    RegularFileIO file(name);
-    char buf[32];
-    file.read(30, buf, False);
-    buf[30] = '\0';
-    if (String(buf) == "SIMPLE  =                    T") {
-      // Looks like SDFITS.
+    if (strstr(name.chars(), ".sdfits")) {
+      // Looks like SDFITS, possibly gzip'd.
       format = "SDFITS";
       reader = new PKSFITSreader("SDFITS");
 
     } else {
-      // Assume it's MBFITS.
-      format = "MBFITS";
-      reader = new PKSFITSreader("MBFITS", retry, interpolate);
+      RegularFileIO file(name);
+      char buf[32];
+      file.read(30, buf, False);
+      buf[30] = '\0';
+      if (String(buf) == "SIMPLE  =                    T") {
+        // Looks like SDFITS.
+        format = "SDFITS";
+        reader = new PKSFITSreader("SDFITS");
+
+       } else {
+         // Assume it's MBFITS.
+         format = "MBFITS";
+         reader = new PKSFITSreader("MBFITS", retry, interpolate);
+       }
     }
 
@@ -104,20 +106,67 @@
     format = "UNRECOGNIZED INPUT FORMAT";
   }
-
+  return reader;
+}
+
+//--------------------------------------------------------------- getPKSreader
+
+// Search a list of directories for a Parkes Multibeam dataset and return an
+
+PKSreader* getPKSreader(
+        const String name,
+        const Vector<String> directories,
+        const Int retry,
+        const Int interpolate,
+        Int    &iDir,
+        String &format)
+{
+  PKSreader *reader = 0x0;
+
+  iDir = -1;
+  Int nDir = directories.nelements();
+  for (Int i = 0; i < nDir; i++) {
+    String inName = directories(i) + "/" + name;
+    reader = getPKSreader(inName, retry, interpolate, format);
+    if (reader) {
+      iDir = i;
+      break;
+    }
+  }
+
+  return reader;
+}
+
+//--------------------------------------------------------------- getPKSreader
+
+// Open an appropriate PKSreader for a Parkes Multibeam dataset.
+
+PKSreader* getPKSreader(
+        const String name,
+        const String antenna,
+        const Int retry,
+        const Int interpolate,
+        String &format,
+        Vector<Bool> &beams,
+        Vector<Bool> &IFs,
+        Vector<uInt> &nChan,
+        Vector<uInt> &nPol,
+        Vector<Bool> &haveXPol,
+        Bool   &haveBase,
+        Bool   &haveSpectra)
+{
+  PKSreader *reader = getPKSreader(name, retry, interpolate, format);
 
   // Try to open it.
   if (reader) {
-    if (reader->open(name, beams, IFs, nChan, nPol, haveXPol, haveBase,
-                     haveSpectra)) {
+    if (reader->open(name, antenna, beams, IFs, nChan, nPol, haveXPol, 
+                     haveBase, haveSpectra)) {
       format += " OPEN ERROR";
       delete reader;
-    } else {
-      return reader;
-    }
-  }
-
-  return 0;
-}
-
+      reader = 0x0;
+    }
+  }
+
+  return reader;
+}
 
 //--------------------------------------------------------------- getPKSreader
@@ -125,7 +174,7 @@
 // Search a list of directories for a Parkes Multibeam dataset and return an
 // appropriate PKSreader for it.
-
-PKSreader* getPKSreader(
-        const String name,
+PKSreader* getPKSreader(
+        const String name,
+        const String antenna,
         const Vector<String> directories,
         const Int retry,
@@ -141,16 +190,17 @@
         Bool   &haveSpectra)
 {
-  Int nDir = directories.nelements();
-  for (iDir = 0; iDir < nDir; iDir++) {
-    String inName = directories(iDir) + "/" + name;
-    PKSreader *reader = getPKSreader(inName, retry, interpolate, format,
-                                     beams, IFs, nChan, nPol, haveXPol,
-                                     haveBase, haveSpectra);
-    if (reader != 0) {
-      return reader;
-    }
-  }
-
-  iDir = -1;
-  return 0;
-}
+  PKSreader *reader = getPKSreader(name, directories, retry, interpolate,
+                                   iDir, format);
+
+  // Try to open it.
+  if (reader) {
+    if (reader->open(name, antenna, beams, IFs, nChan, nPol, haveXPol, 
+                     haveBase, haveSpectra)) {
+      format += " OPEN ERROR";
+      delete reader;
+      reader = 0x0;
+    }
+  }
+
+  return reader;
+}
