Index: /trunk/src/SDContainer.cc
===================================================================
--- /trunk/src/SDContainer.cc	(revision 20)
+++ /trunk/src/SDContainer.cc	(revision 30)
@@ -173,2 +173,101 @@
   }
 }
+
+Array<Float> SDContainer::getSpectrum(uInt whichBeam, uInt whichIF) const
+{
+  Matrix<Float> spectra(nChan_, nPol_);
+
+  // Beam.
+  ArrayAccessor<Float, Axis<0> > i0(spectrum_);
+  i0.reset(i0.begin(whichBeam));
+
+  // IF.
+  ArrayAccessor<Float, Axis<1> > i1(i0);
+  i1.reset(i1.begin(whichIF));
+
+  // Polarization.
+  ArrayAccessor<Float, Axis<2> > i2(i1);
+  ArrayAccessor<Float, Axis<1> > o1(spectra);
+
+  while (i2 != i2.end()) {
+    // Channel.
+    ArrayAccessor<Float, Axis<3> > i3(i2);
+    ArrayAccessor<Float, Axis<0> > o0(o1);
+
+    while (i3 != i3.end()) {
+      *o0 = *i3;
+
+      i3++;
+      o0++;
+    }
+
+    i2++;
+    o1++;
+  }
+
+  return spectra;
+}
+
+Array<uChar> SDContainer::getFlags(uInt whichBeam, uInt whichIF) const
+{
+  Matrix<uChar> flagtra(nChan_, nPol_);
+
+  // Beam.
+  ArrayAccessor<uChar, Axis<0> > i0(flags_);
+  i0.reset(i0.begin(whichBeam));
+
+  // IF.
+  ArrayAccessor<uChar, Axis<1> > i1(i0);
+  i1.reset(i1.begin(whichIF));
+
+  // Polarization.
+  ArrayAccessor<uChar, Axis<2> > i2(i1);
+  ArrayAccessor<uChar, Axis<1> > o1(flagtra);
+
+  while (i2 != i2.end()) {
+    // Channel.
+    ArrayAccessor<uChar, Axis<3> > i3(i2);
+    ArrayAccessor<uChar, Axis<0> > o0(o1);
+
+    while (i3 != i3.end()) {
+      *o0 = *i3;
+
+      i3++;
+      o0++;
+    }
+
+    i2++;
+    o1++;
+  }
+
+  return flagtra;
+}
+
+Array<Float> SDContainer::getTsys(uInt whichBeam, uInt whichIF) const
+{
+  Vector<Float> tsys(nPol_);
+
+  // Beam.
+  ArrayAccessor<Float, Axis<0> > i0(tsys_);
+  i0.reset(i0.begin(whichBeam));
+
+  // IF.
+  ArrayAccessor<Float, Axis<1> > i1(i0);
+  i1.reset(i1.begin(whichIF));
+
+  // Channel.
+  ArrayAccessor<Float, Axis<3> > i3(i1);
+
+  // Polarization.
+  ArrayAccessor<Float, Axis<2> > i2(i3);
+  ArrayAccessor<Float, Axis<0> > o0(tsys);
+
+  while (i2 != i2.end()) {
+    *o0 = *i2;
+
+    i2++;
+    o0++;
+  }
+
+  return tsys;
+}
Index: /trunk/src/SDContainer.h
===================================================================
--- /trunk/src/SDContainer.h	(revision 20)
+++ /trunk/src/SDContainer.h	(revision 30)
@@ -109,9 +109,13 @@
   const Array<uChar>& getFlags() const { return flags_; }
   const Array<Float>& getTsys() const { return tsys_; }
+  
+  Array<Float> getSpectrum(uInt whichBeam, uInt whichIF) const;
+  Array<uChar> getFlags(uInt whichBeam, uInt whichIF) const;
+  Array<Float> getTsys(uInt whichBeam, uInt whichIF) const;
 
   Double timestamp;
   String sourcename;
   Double interval;
-  uInt scanid;
+  Int scanid;
   
 private:
Index: /trunk/src/SDMemTable.cc
===================================================================
--- /trunk/src/SDMemTable.cc	(revision 20)
+++ /trunk/src/SDMemTable.cc	(revision 30)
@@ -65,7 +65,6 @@
   beamSel_(0),
   polSel_(0) {
-  name_ = String(name);
-  Table tab(name_);
-  table_ = tab.copyToMemoryTable(name_);
+  Table tab("dummy");
+  table_ = tab.copyToMemoryTable("dummy");
 }
 
@@ -75,5 +74,4 @@
   this->polSel_= other.polSel_;
   this->chanMask_ = other.chanMask_;
-  this->name_ = String("dummy");
   this->table_ = other.table_.copyToMemoryTable(String("dummy"));
   // clear all rows()
@@ -91,10 +89,9 @@
   beamSel_(0),
   polSel_(0) {
-  name_ = String("SDMemTable");
   String exprs = String("select * from $1 where SCANID == ")
     +String::toString(scanID);
   cerr << exprs << endl;
   Table t = tableCommand(exprs,tab);
-  table_ = t.copyToMemoryTable(name_);
+  table_ = t.copyToMemoryTable("dummy");
 }
 
@@ -119,10 +116,6 @@
   // Now create a new table from the description.
 
-  SetupNewTable aNewTab(name_, td, Table::New);
+  SetupNewTable aNewTab("dummy", td, Table::New);
   table_ = Table(aNewTab, Table::Memory, 0);  
-}
-
-std::string SDMemTable::name() const {
-  return name_;
 }
 
@@ -206,5 +199,5 @@
   return mask;
 }
-std::vector<float> SDMemTable::getSpectrum(Int whichRow) const {
+std::vector<float> SDMemTable::getSpectrum(Int whichRow) {
 
   std::vector<float> spectrum;
@@ -222,4 +215,55 @@
   }
   return spectrum;
+}
+void SDMemTable::getSpectrum(Vector<Float>& spectrum, Int whichRow=0) {
+  ROArrayColumn<Float> spec(table_, "SPECTRA");
+  Array<Float> arr;
+  spec.get(whichRow, arr);
+  spectrum.resize(arr.shape()(3));
+  ArrayAccessor<Float, Axis<0> > aa0(arr);
+  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
+  ArrayAccessor<Float, Axis<1> > aa1(aa0);
+  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
+  ArrayAccessor<Float, Axis<2> > aa2(aa1);
+  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
+
+  ArrayAccessor<Float, Axis<0> > va(spectrum);
+  for (ArrayAccessor<Float, Axis<3> > i(aa2); i != i.end(); ++i) {
+    (*va) = (*i);
+    va++;
+  }
+}
+
+void SDMemTable::getMask(Vector<Bool>& mask, Int whichRow=0) const {
+  ROArrayColumn<uChar> spec(table_, "FLAGTRA");
+  Array<uChar> arr;
+  spec.get(whichRow, arr);
+  mask.resize(arr.shape()(3));
+
+  ArrayAccessor<uChar, Axis<0> > aa0(arr);
+  aa0.reset(aa0.begin(uInt(beamSel_)));//go to beam
+  ArrayAccessor<uChar, Axis<1> > aa1(aa0);
+  aa1.reset(aa1.begin(uInt(IFSel_)));// go to IF
+  ArrayAccessor<uChar, Axis<2> > aa2(aa1);
+  aa2.reset(aa2.begin(uInt(polSel_)));// go to pol
+
+  Bool useUserMask = ( chanMask_.size() == arr.shape()(3) );
+  
+  ArrayAccessor<Bool, Axis<0> > va(mask);
+  std::vector<bool> tmp;
+  tmp = chanMask_; // WHY the fxxx do I have to make a copy here. The
+		   // iterator should work on chanMask_??
+  std::vector<bool>::iterator miter;
+  miter = tmp.begin();
+
+  for (ArrayAccessor<uChar, Axis<3> > i(aa2); i != i.end(); ++i) {
+    bool out =!static_cast<bool>(*i);
+    if (useUserMask) {
+      out = out && (*miter);
+      miter++;
+    }
+    (*va) = out;
+    va++;
+  }  
 }
 
@@ -303,4 +347,29 @@
 }
 
+SDContainer SDMemTable::getSDContainer(uInt whichRow) const {
+  ROScalarColumn<Double> mjd(table_, "TIME");
+  ROScalarColumn<String> srcn(table_, "SRCNAME");
+  ROArrayColumn<Float> spec(table_, "SPECTRA");
+  ROArrayColumn<uChar> flags(table_, "FLAGTRA");
+  ROArrayColumn<Float> ts(table_, "TSYS");
+  ROScalarColumn<Int> scan(table_, "SCANID");
+  ROScalarColumn<Double> integr(table_, "INTERVAL");
+
+  SDContainer sdc(nBeam(),nIF(),nPol(),nChan());
+  mjd.get(whichRow, sdc.timestamp);
+  srcn.get(whichRow, sdc.sourcename);
+  integr.get(whichRow, sdc.interval);
+  scan.get(whichRow, sdc.scanid);
+  Array<Float> spectrum;
+  Array<Float> tsys;
+  Array<uChar> flagtrum;
+  spec.get(whichRow, spectrum);
+  sdc.putSpectrum(spectrum);
+  flags.get(whichRow, flagtrum);
+  sdc.putFlags(flagtrum);
+  ts.get(whichRow, tsys);
+  sdc.putTsys(tsys);
+  return sdc;
+}
 bool SDMemTable::putSDHeader(const SDHeader& sdh) {
   table_.lock();
@@ -322,6 +391,24 @@
   cerr << "Table Header set" << endl;
   return true;
-}
-
+}\
+
+SDHeader SDMemTable::getSDHeader() const {
+  SDHeader sdh;
+  table_.keywordSet().get("nBeam",sdh.nbeam);
+  table_.keywordSet().get("nIF",sdh.nif);
+  table_.keywordSet().get("nPol",sdh.npol);
+  table_.keywordSet().get("nChan",sdh.nchan);
+  table_.keywordSet().get("Observer", sdh.observer);
+  table_.keywordSet().get("Project", sdh.project);
+  table_.keywordSet().get("Obstype", sdh.obstype);
+  table_.keywordSet().get("AntennaName", sdh.antennaname);
+  table_.keywordSet().get("AntennaPosition", sdh.antennaposition);
+  table_.keywordSet().get("Equinox", sdh.equinox);
+  table_.keywordSet().get("FreqRefFrame", sdh.freqref);
+  table_.keywordSet().get("FreqRefVal", sdh.reffreq);
+  table_.keywordSet().get("Bandwidth", sdh.bandwidth);
+  table_.keywordSet().get("UTC", sdh.utc);
+  return sdh;
+}
 void SDMemTable::makePersistent(const std::string& filename) {
   table_.deepCopy(filename,Table::New);
@@ -376,5 +463,4 @@
   return n;
 }
-
 /*
 void SDMemTable::maskChannels(const std::vector<Int>& whichChans ) {
Index: /trunk/src/SDMemTable.h
===================================================================
--- /trunk/src/SDMemTable.h	(revision 20)
+++ /trunk/src/SDMemTable.h	(revision 30)
@@ -69,12 +69,20 @@
   virtual bool putSDHeader(const SDHeader& sdh);
   virtual bool putSDFreqTable(const SDFrequencyTable& sdft) {;}
+
+  //get the dat wrapped up in a meta container
+  virtual SDContainer getSDContainer(uInt whichRow=0) const;
+  virtual SDHeader getSDHeader() const;
   
   // get spectrum,mask and tsys for the given row, at the selected
-  // cursor
-  virtual std::vector<float> getSpectrum(Int whichRow) const;
+  // cursor - all as stl vectors
+  virtual std::vector<float> getSpectrum(Int whichRow);
   virtual std::vector<bool> getMask(Int whichRow) const;
+
   virtual Float getTsys(Int whichRow) const;
+  // get all as aips++ Vectors
+  virtual void getSpectrum(Vector<Float>& spectrum, Int whichRow=0);
+  virtual void getMask(Vector<Bool>& mask,Int whichRow=0) const;
 
-  // get info fro current row
+  // get info for current row
   virtual Double getTime(Int whichRow) const ;
   virtual std::string getSourceName(Int whichRow) const;
@@ -95,7 +103,4 @@
   virtual void summary() const;
   
-  // the (irrelevant) name 
-  std::string name() const;
-
   // write to disk as aips++ table
   void makePersistent(const std::string& filename);
@@ -104,5 +109,5 @@
   SDMemTable getScan(Int scanID);
 
-  const TableRecord& getHeader() const {;}
+  const TableRecord& getHeader() const {return table_.keywordSet();}
   // get a handle to the "raw" aips++ table
   const Table& table() { return table_; }
@@ -114,4 +119,7 @@
   Int nChan() const;
 
+  // return the number of rows (integrations) in the table
+  Int nRows() const { return table_.nrow(); }
+
   // return a row as a Masked array, internally converting uChar flags
   // to bool mask
@@ -120,5 +128,5 @@
 
 private:
-  // set up tabel structure
+  // set up table structure
   void setup();
   // the current cursor into the array
Index: /trunk/src/SDMemTableWrapper.h
===================================================================
--- /trunk/src/SDMemTableWrapper.h	(revision 20)
+++ /trunk/src/SDMemTableWrapper.h	(revision 30)
@@ -97,5 +97,4 @@
   CountedPtr<SDMemTable> getCP() const {return table_;}
   void summary() { table_->summary(); }
-  std::string name() { return table_->name(); }
   
 private:
@@ -125,6 +124,11 @@
   SDMemTableWrapper multiply(const SDMemTableWrapper& in,
 			     Float factor) {
-    return SDMemTableWrapper(SDMath::multiply(in.getCP(),factor));
+    return SDMemTableWrapper(SDMath::multiply(in.getCP(),factor));    
   }
+  /*
+  std::vector<float> baseline(const SDMemTableWrapper& in, const std::string& fitexpr) {
+    return SDMath::baseline(in.getCP(), fitexpr);
+  }
+  */
 };
 
Index: /trunk/src/SDReader.cc
===================================================================
--- /trunk/src/SDReader.cc	(revision 20)
+++ /trunk/src/SDReader.cc	(revision 30)
@@ -77,10 +77,6 @@
     return;
   }
+
   nBeam_ = beams.nelements();
-  //cout << "Reading " + format + " format from " + inName << endl;
-  //cout << "nChannels = " << nChan_ << ", " << "nPol = " << nPol_ << endl
-  //     << "nIF = " << nIF_ << endl 
-  //     << "nBeams = " << nBeam_ << endl;
-  
   // Get basic parameters.
   header_ = SDHeader();
@@ -89,5 +85,4 @@
   header_.nbeam = nBeam_;
 
-  //cerr << " getting header ..." << endl;
   Int status = reader_->getHeader(header_.observer, header_.project, 
 				  header_.antennaname, header_.antennaposition,
@@ -135,11 +130,8 @@
   Complex         xCalFctr;
   Vector<Complex> xPol;
-  mjd = 0;
   uInt n = seq.size();
-  //cerr <<  header_.nif << ", " << header_.nbeam << endl;
+
   uInt stepsize = header_.nif*header_.nbeam;
   cerr << "SDReader stepsize = " << stepsize << endl;
-  uInt scanid = 0;
-  String prevName = "_noname_";// temporary until scanid is present
   uInt seqi = 0;
   //SDFrequencyTable sdft();
Index: /trunk/src/SDWriter.cc
===================================================================
--- /trunk/src/SDWriter.cc	(revision 30)
+++ /trunk/src/SDWriter.cc	(revision 30)
@@ -0,0 +1,194 @@
+//#---------------------------------------------------------------------------
+//# SDWriter.cc: ASAP class to write out single dish spectra.
+//#---------------------------------------------------------------------------
+//# Copyright (C) 2004
+//# Mark Calabretta, ATNF
+//#
+//# This program 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 2 of the License, or (at your option)
+//# any later version.
+//#
+//# This program 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 General
+//# Public License for more details.
+//#
+//# You should have received a copy of the GNU General Public License along
+//# with this program; if not, write to the Free Software Foundation, Inc.,
+//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
+//#
+//# Correspondence concerning this software should be addressed as follows:
+//#        Internet email: Malte.Marquarding@csiro.au
+//#        Postal address: Malte Marquarding,
+//#                        Australia Telescope National Facility,
+//#                        P.O. Box 76,
+//#                        Epping, NSW, 2121,
+//#                        AUSTRALIA
+//#
+//# $Id$
+//#---------------------------------------------------------------------------
+
+#include <string>
+
+#include <aips/aips.h>
+#include <aips/Arrays.h>
+#include <aips/Mathematics/Complex.h>
+#include <aips/Utilities/CountedPtr.h>
+
+#include <atnf/PKSIO/PKSMS2writer.h>
+#include <atnf/PKSIO/PKSSDwriter.h>
+
+#include <SDMemTable.h>
+#include <SDWriter.h>
+
+
+using namespace atnf_sd;
+
+//--------------------------------------------------------- SDWriter::SDWriter
+
+// Default constructor.
+
+SDWriter::SDWriter(
+        const string &format = "SDFITS")
+{
+  cFormat = format;
+
+  if (cFormat == "MS2") {
+    cWriter = new PKSMS2writer();
+  } else {
+    cWriter = new PKSSDwriter();
+  }
+}
+
+//-------------------------------------------------------- SDWriter::~SDWriter
+
+// Destructor.
+
+SDWriter::~SDWriter()
+{
+  // Nothing.
+}
+
+//-------------------------------------------------------- SDWriter::setFormat
+
+// Reset the output format.
+
+Int SDWriter::setFormat(
+        const string &format = "SDFITS")
+{
+  if (format != cFormat) {
+    delete cWriter;
+
+    cFormat = format;
+    if (cFormat == "MS2") {
+      cWriter = new PKSMS2writer();
+    } else {
+      cWriter = new PKSSDwriter();
+    }
+  }
+
+  return 0;
+}
+
+//------------------------------------------------------------ SDWriter::write
+
+// Write an SDMemTable to file in the desired format, closing the file when
+// finished.
+
+Int SDWriter::write(
+        const CountedPtr<SDMemTable> table,
+        const string &filename)
+{
+  // Extract the header from the table.
+  SDHeader hdr = table->getSDHeader();
+  Int nPol  = hdr.npol;
+  Int nChan = hdr.nchan;
+
+  // Create the output file and write static data.
+  Int status;
+  if (status = cWriter->create(filename, hdr.observer, hdr.project,
+                               hdr.antennaname, hdr.antennaposition,
+                               hdr.obstype, hdr.equinox, hdr.freqref,
+                               nChan, nPol, False, False)) {
+    cerr << "Failed to create output file." << endl;
+    return 1;
+  }
+
+  Int scanNo = -1;
+  Int cycleNo;
+  Double mjd0 = 0.0;
+
+  Int count = 0;
+  for (Int iRow = 0; iRow < table->nRows(); iRow++) {
+    // Extract the next integration from the table.
+    SDContainer sd = table->getSDContainer(iRow);
+    if (sd.scanid != scanNo) {
+      scanNo = sd.scanid;
+      mjd0 = sd.timestamp;
+      cycleNo = 1;
+    } else if (fabs(sd.timestamp-mjd0) > sd.interval) {
+      cycleNo++;
+    }
+
+    // Write it out beam by beam.
+    for (Int iBeam = 0; iBeam < hdr.nbeam; iBeam++) {
+
+      // Write it out IF by IF.
+      for (Int iIF = 0; iIF < hdr.nif; iIF++) {
+        // None of these are stored in SDMemTable by SDReader.
+        String          fieldName = "";
+        Vector<Double>  srcDir(2, 0.0);
+        Vector<Double>  srcPM(2, 0.0);
+        Double          srcVel = 0.0;
+        Double          freqInc = 0.0;
+        Vector<Float>   tcal(2, 0.0f);
+        String          tcalTime = "";
+        Float           azimuth = 0.0f;
+        Float           elevation = 0.0f;
+        Float           parAngle = 0.0f;
+        Float           focusAxi = 0.0f;
+        Float           focusTan = 0.0f;
+        Float           focusRot = 0.0f;
+        Float           temperature = 0.0f;
+        Float           pressure = 0.0f;
+        Float           humidity = 0.0f;
+        Float           windSpeed = 0.0f;
+        Float           windAz = 0.0f;
+        Int             refBeam = 0;
+        Vector<Double>  direction(2, 0.0);
+        Vector<Double>  scanRate(2, 0.0);
+        Vector<Float>   sigma(nPol, 0.0f);
+        Vector<Float>   calFctr(nPol, 0.0f);
+        Matrix<Float>   baseLin(nPol,2, 0.0f);
+        Matrix<Float>   baseSub(nPol,9, 0.0f);
+        Complex         xCalFctr;
+        Vector<Complex> xPol;
+
+        if (status = cWriter->write(sd.scanid, cycleNo, sd.timestamp,
+                                    sd.interval, fieldName, sd.sourcename,
+                                    srcDir, srcPM, srcVel, iIF+1, hdr.reffreq,
+                                    hdr.bandwidth, freqInc, tcal, tcalTime,
+                                    azimuth, elevation, parAngle,
+                                    focusAxi, focusTan, focusRot, temperature,
+                                    pressure, humidity, windSpeed, windAz,
+                                    refBeam, iBeam+1, direction, scanRate,
+                                    sd.getTsys(iBeam, iIF),
+                                    sigma, calFctr, baseLin, baseSub,
+                                    sd.getSpectrum(iBeam, iIF),
+                                    sd.getFlags(iBeam, iIF),
+                                    xCalFctr, xPol)) {
+          cerr << "Error writing output file." << endl;
+          return 1;
+        }
+
+        count++;
+      }
+    }
+  }
+
+  cout << "SDWriter: wrote " << count << " rows to " << filename << endl;
+  cWriter->close();
+
+  return 0;
+}
Index: /trunk/src/SDWriter.h
===================================================================
--- /trunk/src/SDWriter.h	(revision 30)
+++ /trunk/src/SDWriter.h	(revision 30)
@@ -0,0 +1,71 @@
+//#---------------------------------------------------------------------------
+//# SDWriter.h: ASAP class to write out single dish spectra.
+//#---------------------------------------------------------------------------
+//# Copyright (C) 2004
+//# Mark Calabretta, ATNF
+//#
+//# This program 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 2 of the License, or (at your option)
+//# any later version.
+//#
+//# This program 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 General
+//# Public License for more details.
+//#
+//# You should have received a copy of the GNU General Public License along
+//# with this program; if not, write to the Free Software Foundation, Inc.,
+//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
+//#
+//# Correspondence concerning this software should be addressed as follows:
+//#        Internet email: Malte.Marquarding@csiro.au
+//#        Postal address: Malte Marquarding,
+//#                        Australia Telescope National Facility,
+//#                        P.O. Box 76,
+//#                        Epping, NSW, 2121,
+//#                        AUSTRALIA
+//#
+//# $Id$
+//#---------------------------------------------------------------------------
+#ifndef _SDWRITER_H_
+#define _SDWRITER_H_
+
+#include <string>
+
+#include <aips/aips.h>
+#include <aips/Utilities/CountedPtr.h>
+
+#include <SDMemTable.h>
+#include <SDMemTableWrapper.h>
+
+class PKSwriter;
+
+namespace atnf_sd {
+
+class SDWriter {
+public:
+  SDWriter(const string &format = "SDFITS");
+  ~SDWriter();
+
+  Int setFormat(const string &format = "SDFITS");
+  Int write(const CountedPtr<SDMemTable> table,
+            const string &filename);
+
+private:
+  string     cFormat;
+  PKSwriter *cWriter;
+};
+
+
+class SDWriterWrapper : public SDWriter {
+public:
+  SDWriterWrapper(const string &format = "SDFITS") : SDWriter(format) {;}
+
+  Int write(const SDMemTableWrapper &table, const string &filename) {
+    return SDWriter::write(table.getCP(), filename);
+  }
+};
+
+} // namespace atnf_sd
+#endif
Index: /trunk/src/python_SD.cc
===================================================================
--- /trunk/src/python_SD.cc	(revision 20)
+++ /trunk/src/python_SD.cc	(revision 30)
@@ -27,5 +27,5 @@
 //#                        AUSTRALIA
 //#
-//# $Id:
+//# $Id$
 //#---------------------------------------------------------------------------
 #include <string>
@@ -41,4 +41,5 @@
   atnf_sd::python::python_SDMemTable();
   atnf_sd::python::python_SDReader();
+  atnf_sd::python::python_SDWriter();
   atnf_sd::python::python_SDMath();
 
Index: /trunk/src/python_SD.h
===================================================================
--- /trunk/src/python_SD.h	(revision 20)
+++ /trunk/src/python_SD.h	(revision 30)
@@ -27,5 +27,5 @@
 //#                        AUSTRALIA
 //#
-//# $Id:
+//# $Id$
 //#---------------------------------------------------------------------------
 #ifndef _PYTHON_SD_H_
@@ -37,4 +37,5 @@
 void python_SDMemTable();
 void python_SDReader();
+void python_SDWriter();
 void python_SDMath();
 
Index: /trunk/src/python_SDMemTable.cc
===================================================================
--- /trunk/src/python_SDMemTable.cc	(revision 20)
+++ /trunk/src/python_SDMemTable.cc	(revision 30)
@@ -46,6 +46,8 @@
     .def( init < SDMemTableWrapper, int > () )
     .def("getscan", &SDMemTableWrapper::getScan)
-    .def("getspectrum", &SDMemTableWrapper::getSpectrum)
-    .def("getmask", &SDMemTableWrapper::getMask)
+    .def("getspectrum", &SDMemTableWrapper::getSpectrum,
+	 (boost::python::arg("whichRow")=0) )
+    .def("getmask", &SDMemTableWrapper::getMask,
+	 (boost::python::arg("whichRow")=0) )
     .def("gettsys", &SDMemTableWrapper::getTsys)
     .def("getsourcename", &SDMemTableWrapper::getSourceName)
@@ -66,5 +68,4 @@
     .def("makepersistent",  &SDMemTableWrapper::makePersistent)
     .def("summary",  &SDMemTableWrapper::summary)
-    .def("name",  &SDMemTableWrapper::name)
   ;
 };
Index: /trunk/src/python_SDWriter.cc
===================================================================
--- /trunk/src/python_SDWriter.cc	(revision 30)
+++ /trunk/src/python_SDWriter.cc	(revision 30)
@@ -0,0 +1,51 @@
+//#---------------------------------------------------------------------------
+//# python_SDWriter.cc: Python binding to C++ SDWriter class.
+//#---------------------------------------------------------------------------
+//# Copyright (C) 2004
+//# Mark Calabretta, ATNF
+//#
+//# This program 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 2 of the License, or (at your option)
+//# any later version.
+//#
+//# This program 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 General
+//# Public License for more details.
+//#
+//# You should have received a copy of the GNU General Public License along
+//# with this program; if not, write to the Free Software Foundation, Inc.,
+//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
+//#
+//# Correspondence concerning this software should be addressed as follows:
+//#        Internet email: Malte.Marquarding@csiro.au
+//#        Postal address: Malte Marquarding,
+//#                        Australia Telescope National Facility,
+//#                        P.O. Box 76,
+//#                        Epping, NSW, 2121,
+//#                        AUSTRALIA
+//#
+//# $Id$
+//#---------------------------------------------------------------------------
+#include <boost/python.hpp>
+
+#include "SDWriter.h"
+
+using namespace boost::python;
+
+namespace atnf_sd {
+namespace python  {
+
+void python_SDWriter() {
+  class_<SDWriterWrapper>("sdwriter")
+    .def(init <> ())
+    .def(init <string> ())
+    .def("setformat", &SDWriterWrapper::setFormat,
+        (boost::python::arg("format")="SDFITS"))
+    .def("write",     &SDWriterWrapper::write);
+  ;
+};
+
+} // namespace python
+} // namespace atnf_sd
