Index: trunk/src/MSWriter.cpp
===================================================================
--- trunk/src/MSWriter.cpp	(revision 2291)
+++ trunk/src/MSWriter.cpp	(revision 2293)
@@ -1819,49 +1819,4 @@
 }
   
-// void MSWriter::fillAntenna() 
-// {
-// //   double startSec = mathutil::gettimeofday_sec() ;
-// //   os_ << "start MSWriter::fillAntenna() startSec=" << startSec << LogIO::POST ;
-
-//   // only 1 row
-//   mstable_->antenna().addRow( 1, True ) ;
-//   MSAntennaColumns msAntCols( mstable_->antenna() ) ;
-
-//   String hAntennaName = header_.antennaname ;
-//   String::size_type pos = hAntennaName.find( "//" ) ;
-//   String antennaName ;
-//   String stationName ;
-//   if ( pos != String::npos ) {
-//     hAntennaName = hAntennaName.substr( pos+2 ) ;
-//   }
-//   pos = hAntennaName.find( "@" ) ;
-//   if ( pos != String::npos ) {
-//     antennaName = hAntennaName.substr( 0, pos ) ;
-//     stationName = hAntennaName.substr( pos+1 ) ;
-//   }
-//   else {
-//     antennaName = hAntennaName ;
-//     stationName = hAntennaName ;
-//   }
-// //   os_ << "antennaName = " << antennaName << LogIO::POST ;
-// //   os_ << "stationName = " << stationName << LogIO::POST ;
-  
-//   msAntCols.name().put( 0, antennaName ) ;
-//   msAntCols.station().put( 0, stationName ) ;
-
-// //   os_ << "antennaPosition = " << header_.antennaposition << LogIO::POST ;
-  
-//   msAntCols.position().put( 0, header_.antennaposition ) ;
-
-//   // MOUNT is set to "ALT-AZ"
-//   msAntCols.mount().put( 0, "ALT-AZ" ) ;
-
-//   Double diameter = getDishDiameter( antennaName ) ;
-//   msAntCols.dishDiameterQuant().put( 0, Quantity( diameter, "m" ) ) ;
-
-// //   double endSec = mathutil::gettimeofday_sec() ;
-// //   os_ << "end MSWriter::fillAntenna() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
-// }
-
 void MSWriter::fillProcessor() 
 {
@@ -2291,447 +2246,4 @@
 }
 
-void MSWriter::addFeed( Int id ) 
-{
-//   double startSec = mathutil::gettimeofday_sec() ;
-//   os_ << "start MSWriter::addFeed() startSec=" << startSec << LogIO::POST ;
-
-  // add row
-  MSFeed msFeed = mstable_->feed() ;
-  msFeed.addRow( 1, True ) ;
-  Int nrow = msFeed.nrow() ;
-  Int numReceptors = 2 ;
-  Vector<String> polType( numReceptors ) ;
-  Matrix<Double> beamOffset( 2, numReceptors ) ;
-  beamOffset = 0.0 ;
-  Vector<Double> receptorAngle( numReceptors, 0.0 ) ;
-  if ( polType_ == "linear" ) {
-    polType[0] = "X" ;
-    polType[1] = "Y" ;
-  }
-  else if ( polType_ == "circular" ) {
-    polType[0] = "R" ;
-    polType[1] = "L" ;
-  }
-  else {
-    polType[0] = "X" ;
-    polType[1] = "Y" ;
-  }
-  Matrix<Complex> polResponse( numReceptors, numReceptors, 0.0 ) ;
-  for ( Int i = 0 ; i < numReceptors ; i++ )
-    polResponse( i, i ) = 0.0 ;
-
-  MSFeedColumns msFeedCols( mstable_->feed() ) ;
-
-  msFeedCols.feedId().put( nrow-1, id ) ;
-  msFeedCols.antennaId().put( nrow-1, 0 ) ;
-  msFeedCols.numReceptors().put( nrow-1, numReceptors ) ;
-  msFeedCols.polarizationType().put( nrow-1, polType ) ;
-  msFeedCols.beamOffset().put( nrow-1, beamOffset ) ;
-  msFeedCols.receptorAngle().put( nrow-1, receptorAngle ) ;
-  msFeedCols.polResponse().put( nrow-1, polResponse ) ;
-
-//   double endSec = mathutil::gettimeofday_sec() ;
-//   os_ << "end MSWriter::addFeed() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
-}
-
-void MSWriter::addSpectralWindow( Int spwid, Int freqid ) 
-{
-//   double startSec = mathutil::gettimeofday_sec() ;
-//   os_ << "start MSWriter::addSpectralWindow() startSec=" << startSec << LogIO::POST ;
-  
-  // add row
-  MSSpectralWindow msSpw = mstable_->spectralWindow() ;
-  while( (Int)msSpw.nrow() <= spwid ) {
-    msSpw.addRow( 1, True ) ;
-  }
-  
-  MSSpWindowColumns msSpwCols( msSpw ) ;
-
-  STFrequencies stf = table_->frequencies() ;
-
-  // MEAS_FREQ_REF
-  msSpwCols.measFreqRef().put( spwid, stf.getFrame( True ) ) ;
-
-  Double refpix ;
-  Double refval ;
-  Double inc ;
-  stf.getEntry( refpix, refval, inc, (uInt)freqid ) ;
-
-  // NUM_CHAN
-  //Int nchan = (Int)(refpix * 2) + 1 ;
-  //if ( nchan == 0 )
-  //nchan = 1 ;
-  Int nchan = table_->nchan( spwid ) ;
-  msSpwCols.numChan().put( spwid, nchan ) ;
-
-  // TOTAL_BANDWIDTH
-  Double bw = nchan * abs( inc ) ;
-  msSpwCols.totalBandwidth().put( spwid, bw ) ;
-
-  // REF_FREQUENCY
-  Double refFreq = refval - refpix * inc ;
-  msSpwCols.refFrequency().put( spwid, refFreq ) ;
-
-  // NET_SIDEBAND
-  // tentative: USB->0, LSB->1
-  Int netSideband = 0 ;
-  if ( inc < 0 ) 
-    netSideband = 1 ;
-  msSpwCols.netSideband().put( spwid, netSideband ) ;
-
-  // RESOLUTION, CHAN_WIDTH, EFFECTIVE_BW
-  Vector<Double> sharedDoubleArr( nchan, abs(inc) ) ;
-  msSpwCols.resolution().put( spwid, sharedDoubleArr ) ;
-  msSpwCols.chanWidth().put( spwid, sharedDoubleArr ) ;
-  msSpwCols.effectiveBW().put( spwid, sharedDoubleArr ) ;
-
-  // CHAN_FREQ
-  indgen( sharedDoubleArr, refFreq, inc ) ;
-  msSpwCols.chanFreq().put( spwid, sharedDoubleArr ) ;
-
-//   double endSec = mathutil::gettimeofday_sec() ;
-//   os_ << "end MSWriter::addSpectralWindow() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
-}
-
-void MSWriter::addField( Int fid, String fieldname, String srcname, Double t, Vector<Double> rate ) 
-{
-//   double startSec = mathutil::gettimeofday_sec() ;
-//   os_ << "start MSWriter::addField() startSec=" << startSec << LogIO::POST ;
- 
-  MSField msField = mstable_->field() ;
-  while( (Int)msField.nrow() <= fid ) {
-    msField.addRow( 1, True ) ;
-  }
-  MSFieldColumns msFieldCols( msField ) ;
-
-  // Access to SOURCE table
-  MSSource msSrc = mstable_->source() ;
-
-  // fill target row
-  msFieldCols.name().put( fid, fieldname ) ;
-  msFieldCols.time().put( fid, t ) ;
-  Int numPoly = 0 ;
-  if ( anyNE( rate, 0.0 ) ) 
-    numPoly = 1 ;
-  msFieldCols.numPoly().put( fid, numPoly ) ;
-  MSSourceIndex msSrcIdx( msSrc ) ;
-  Int srcId = -1 ;
-  Vector<Int> srcIdArr = msSrcIdx.matchSourceName( srcname ) ;
-  if ( srcIdArr.size() != 0 ) {
-    srcId = srcIdArr[0] ;
-    MSSource msSrcSel = msSrc( msSrc.col("SOURCE_ID") == srcId, 1 ) ;
-    ROMSSourceColumns msSrcCols( msSrcSel ) ;
-    Vector<Double> srcDir = msSrcCols.direction()( 0 ) ;
-    Matrix<Double> srcDirA( IPosition( 2, 2, 1+numPoly ) ) ;
-//     os_ << "srcDirA = " << srcDirA << LogIO::POST ;
-//     os_ << "sliced srcDirA = " << srcDirA.column( 0 ) << LogIO::POST ;
-    srcDirA.column( 0 ) = srcDir ;
-//     os_ << "srcDirA = " << srcDirA << LogIO::POST ;
-    if ( numPoly != 0 ) 
-      srcDirA.column( 1 ) = rate ;
-    msFieldCols.phaseDir().put( fid, srcDirA ) ;
-    msFieldCols.referenceDir().put( fid, srcDirA ) ;
-    msFieldCols.delayDir().put( fid, srcDirA ) ;
-  }
-  msFieldCols.sourceId().put( fid, srcId ) ;
-
-//   double endSec = mathutil::gettimeofday_sec() ;
-//   os_ << "end MSWriter::addField() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
-}
-
-void MSWriter::addPointing( String &name, Double &me, Double &interval, Matrix<Double> &dir ) 
-{
-//   double startSec = mathutil::gettimeofday_sec() ;
-//   os_ << "start MSWriter::addPointing() startSec=" << startSec << LogIO::POST ;
-  
-  // access to POINTING subtable
-  MSPointing msp = mstable_->pointing() ;
-  uInt nrow = msp.nrow() ;
-
-  // add row
-  msp.addRow( 1, True ) ;
-
-  // fill row
-  TableRow row( msp ) ;
-  TableRecord &rec = row.record() ;
-  RecordFieldPtr<Int> antennaRF( rec, "ANTENNA_ID" ) ;
-  *antennaRF = 0 ;
-  RecordFieldPtr<Int> numpolyRF( rec, "NUM_POLY" ) ;
-  *numpolyRF = dir.ncolumn() - 1 ;
-  RecordFieldPtr<Double> timeRF( rec, "TIME" ) ;
-  *timeRF = me ;
-  RecordFieldPtr<Double> toriginRF( rec, "TIME_ORIGIN" ) ;
-  *toriginRF = me ;
-  RecordFieldPtr<Double> intervalRF( rec, "INTERVAL" ) ;
-  *intervalRF = interval ;
-  RecordFieldPtr<String> nameRF( rec, "NAME" ) ;
-  *nameRF = name ;
-  RecordFieldPtr<Bool> trackRF( rec, "TRACKING" ) ;
-  *trackRF = True ;
-  RecordFieldPtr< Array<Double> > dirRF( rec, "DIRECTION" ) ;
-  *dirRF = dir ;
-  RecordFieldPtr< Array<Double> > targetRF( rec, "TARGET" ) ;
-  *targetRF = dir ;
-  row.put( nrow ) ;
-
-//   double endSec = mathutil::gettimeofday_sec() ;
-//   os_ << "end MSWriter::addPointing() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
-}
-
-Int MSWriter::addPolarization( Vector<Int> polnos ) 
-{
-//   double startSec = mathutil::gettimeofday_sec() ;
-//   os_ << "start MSWriter::addPolarization() startSec=" << startSec << LogIO::POST ;
-
-//   os_ << "polnos = " << polnos << LogIO::POST ;
-  MSPolarization msPol = mstable_->polarization() ;
-  uInt nrow = msPol.nrow() ;
-
-//   // only 1 POLARIZATION row for 1 scantable
-//   if ( nrow > 0 )
-//     return 0 ;
-  
-  Vector<Int> corrType = toCorrType( polnos ) ;
-  
-  ROArrayColumn<Int> corrtCol( msPol, "CORR_TYPE" ) ;
-  //Matrix<Int> corrTypeArr = corrtCol.getColumn() ;
-  Int polid = -1 ;
-  for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
-    Vector<Int> corrTypeArr = corrtCol( irow ) ;
-    if ( corrType.nelements() == corrTypeArr.nelements() 
-         && allEQ( corrType, corrTypeArr ) ) {
-      polid = irow ;
-      break ;
-    }
-  }
-
-  if ( polid == -1 ) {
-    MSPolarizationColumns msPolCols( msPol ) ;
-
-    // add row
-    msPol.addRow( 1, True ) ;
-    polid = (Int)nrow ;
-
-    // CORR_TYPE
-    msPolCols.corrType().put( nrow, corrType ) ;
-
-    // NUM_CORR
-    uInt npol = corrType.size() ;
-    msPolCols.numCorr().put( nrow, npol ) ;
-
-    // CORR_PRODUCT
-    Matrix<Int> corrProd( 2, npol, -1 ) ;
-    if ( npol == 1 ) {
-      corrProd = 0 ;
-    }
-    else if ( npol == 2 ) {
-      corrProd.column( 0 ) = 0 ;
-      corrProd.column( 1 ) = 1 ;
-    }
-    else {
-      corrProd.column( 0 ) = 0 ;
-      corrProd.column( 3 ) = 1 ;
-      corrProd( 0,1 ) = 0 ;
-      corrProd( 1,1 ) = 1 ;
-      corrProd( 0,2 ) = 1 ;
-      corrProd( 1,2 ) = 0 ;
-    }
-    msPolCols.corrProduct().put( nrow, corrProd ) ;    
-  }
-
-//   double endSec = mathutil::gettimeofday_sec() ;
-//   os_ << "end MSWriter::addPolarization() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
-
-  return polid ;
-} 
-
-Int MSWriter::addDataDescription( Int polid, Int spwid ) 
-{
-//   double startSec = mathutil::gettimeofday_sec() ;
-//   os_ << "start MSWriter::addDataDescription() startSec=" << startSec << LogIO::POST ;
-
-  MSDataDescription msDataDesc = mstable_->dataDescription() ;
-  uInt nrow = msDataDesc.nrow() ;
-
-  // only 1 POLARIZATION_ID for 1 scantable
-  Int ddid = -1 ;
-  ROScalarColumn<Int> spwCol( msDataDesc, "SPECTRAL_WINDOW_ID" ) ;
-  Vector<Int> spwIds = spwCol.getColumn() ;
-  //ROScalarColumn<Int> polCol( msDataDesc, "POLARIZATION_ID" ) ;
-  //Vector<Int> polIds = polCol.getColumn() ;
-  for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
-    //if ( spwid == spwIds[irow] && polid == polIds[irow] ) {
-    if ( spwid == spwIds[irow] ) {
-      ddid = irow ;
-      break ;
-    }
-  }
-//   os_ << "ddid = " << ddid << LogIO::POST ;
-  
-
-  if ( ddid == -1 ) {
-    msDataDesc.addRow( 1, True ) ;
-    MSDataDescColumns msDataDescCols( msDataDesc ) ;
-    msDataDescCols.polarizationId().put( nrow, polid ) ;
-    msDataDescCols.spectralWindowId().put( nrow, spwid ) ;
-    ddid = (Int)nrow ;
-  }
-
-//   double endSec = mathutil::gettimeofday_sec() ;
-//   os_ << "end MSWriter::addDataDescription() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
-
-  return ddid ;
-}
-
-Int MSWriter::addState( Int st, Int &subscan ) 
-{
-//   double startSec = mathutil::gettimeofday_sec() ;
-//   os_ << "start MSWriter::addState() startSec=" << startSec << LogIO::POST ;
-
-  // access to STATE subtable
-  MSState msState = mstable_->state() ;
-  uInt nrow = msState.nrow() ;
-
-  String obsMode ;
-  Bool isSignal ;
-  Double tnoise ;
-  Double tload ;
-  queryType( st, obsMode, isSignal, tnoise, tload ) ;
-//   os_ << "obsMode = " << obsMode << " isSignal = " << isSignal << LogIO::POST ;
-
-  Int idx = -1 ;
-  ROScalarColumn<String> obsModeCol( msState, "OBS_MODE" ) ;
-  ROScalarColumn<Int> subscanCol( msState, "SUB_SCAN" ) ;
-  for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
-    if ( obsModeCol(irow) == obsMode 
-         //&& sigCol(irow) == isSignal 
-         //&& refCol(irow) != isSignal
-         && subscanCol(irow) == subscan ) {
-      idx = irow ;
-      break ;
-    }
-  }
-  if ( idx == -1 ) {
-    msState.addRow( 1, True ) ;
-    TableRow row( msState ) ;
-    TableRecord &rec = row.record() ;
-    RecordFieldPtr<String> obsmodeRF( rec, "OBS_MODE" ) ;
-    *obsmodeRF = obsMode ;
-    RecordFieldPtr<Bool> sigRF( rec, "SIG" ) ;
-    *sigRF = isSignal ;
-    RecordFieldPtr<Bool> refRF( rec, "REF" ) ;
-    *refRF = !isSignal ;
-    RecordFieldPtr<Int> subscanRF( rec, "SUB_SCAN" ) ;
-    *subscanRF = subscan ;
-    RecordFieldPtr<Double> noiseRF( rec, "CAL" ) ;
-    *noiseRF = tnoise ;
-    RecordFieldPtr<Double> loadRF( rec, "LOAD" ) ;
-    *loadRF = tload ;
-    row.put( nrow ) ;
-    idx = nrow ;
-  }
-  subscan++ ;
-
-//   double endSec = mathutil::gettimeofday_sec() ;
-//   os_ << "end MSWriter::addState() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
-
-  return idx ;
-}
-
-Vector<Int> MSWriter::toCorrType( Vector<Int> polnos ) 
-{
-//   double startSec = mathutil::gettimeofday_sec() ;
-//   os_ << "start MSWriter::toCorrType() startSec=" << startSec << LogIO::POST ;
-
-  uInt npol = polnos.size() ;
-  Vector<Int> corrType( npol, Stokes::Undefined ) ;
-  
-  if ( npol == 4 ) {
-    if ( polType_ == "linear" ) {
-      for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
-        if ( polnos[ipol] == 0 )
-          corrType[ipol] = Stokes::XX ;
-        else if ( polnos[ipol] == 1 )
-          corrType[ipol] = Stokes::XY ;
-        else if ( polnos[ipol] == 2 ) 
-          corrType[ipol] = Stokes::YX ;
-        else if ( polnos[ipol] == 3 ) 
-          corrType[ipol] = Stokes::YY ;
-      }
-    }
-    else if ( polType_ == "circular" ) {
-      for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
-        if ( polnos[ipol] == 0 )
-          corrType[ipol] = Stokes::RR ;
-        else if ( polnos[ipol] == 1 )
-          corrType[ipol] = Stokes::RL ;
-        else if ( polnos[ipol] == 2 ) 
-          corrType[ipol] = Stokes::LR ;
-        else if ( polnos[ipol] == 3 ) 
-          corrType[ipol] = Stokes::LL ;
-      }
-    }
-    else if ( polType_ == "stokes" ) {
-      for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
-        if ( polnos[ipol] == 0 )
-          corrType[ipol] = Stokes::I ;
-        else if ( polnos[ipol] == 1 )
-          corrType[ipol] = Stokes::Q ;
-        else if ( polnos[ipol] == 2 ) 
-          corrType[ipol] = Stokes::U ;
-        else if ( polnos[ipol] == 3 ) 
-          corrType[ipol] = Stokes::V ;
-      }
-    }
-  }
-  else if ( npol == 2 ) {
-    if ( polType_ == "linear" ) {
-      for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
-        if ( polnos[ipol] == 0 )
-          corrType[ipol] = Stokes::XX ;
-        else if ( polnos[ipol] == 1 )
-          corrType[ipol] = Stokes::YY ;
-      }
-    }
-    else if ( polType_ == "circular" ) {
-      for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
-        if ( polnos[ipol] == 0 )
-          corrType[ipol] = Stokes::RR ;
-        else if ( polnos[ipol] == 1 ) 
-          corrType[ipol] = Stokes::LL ;
-      }
-    }
-    else if ( polType_ == "stokes" ) {
-      for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
-        if ( polnos[ipol] == 0 )
-          corrType[ipol] = Stokes::I ;
-        else if ( polnos[ipol] == 1 ) 
-          corrType[ipol] = Stokes::V ;
-      }
-    }
-    else if ( polType_ == "linpol" ) {
-      for ( uInt ipol = 0 ; ipol < npol ; ipol++ ) {
-        if ( polnos[ipol] == 1 )
-          corrType[ipol] = Stokes::Plinear ;
-        else if ( polnos[ipol] == 2 ) 
-          corrType[ipol] = Stokes::Pangle ;
-      }
-    }
-  }      
-  else if ( npol == 1 ) {
-    if ( polType_ == "linear" )
-      corrType[0] = Stokes::XX ;
-    else if ( polType_ == "circular" )
-      corrType[0] = Stokes::RR ;
-    else if ( polType_ == "stokes" ) 
-      corrType[0] = Stokes::I ;
-  }
-
-//   double endSec = mathutil::gettimeofday_sec() ;
-//   os_ << "end MSWriter::toCorrType() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
-
-  return corrType ;
-}
-
 void MSWriter::getValidTimeRange( Double &me, Double &interval, Table &tab ) 
 {
@@ -2780,299 +2292,3 @@
 }
 
-//void MSWriter::queryType( Int type, String &stype, Bool &b )
-void MSWriter::queryType( Int type, String &stype, Bool &b, Double &t, Double &l )
-{
-//   double startSec = mathutil::gettimeofday_sec() ;
-//   os_ << "start MSWriter::queryType() startSec=" << startSec << LogIO::POST ;
-
-  // 2011/03/14 TN
-  // OBS_MODE string of MS created by importasdm task is slightly 
-  // (but critically) changed.
-  // 2011/05/20 TN
-  // OBS_MODE string of MS created by importasdm task is changed 
-  // again (separator is now "#" instead of "_"
-  String sep1="#" ;
-  String sep2="," ;
-  String target="OBSERVE_TARGET" ;
-  String atmcal="CALIBRATE_TEMPERATURE" ;
-  String onstr="ON_SOURCE" ;
-  String offstr="OFF_SOURCE" ;
-  String pswitch="POSITION_SWITCH" ;
-  String nod="NOD" ;
-  String fswitch="FREQUENCY_SWITCH" ;
-  String sigstr="SIG" ;
-  String refstr="REF" ;
-  String unspecified="UNSPECIFIED" ;
-  String ftlow="LOWER" ;
-  String fthigh="HIGHER" ;
-  switch ( type ) {
-  case SrcType::PSON:
-    //stype = "OBSERVE_TARGET_ON_SOURCE,POSITION_SWITCH" ;
-    stype = target+sep1+onstr+sep2+pswitch ;
-    b = True ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::PSOFF:
-    //stype = "OBSERVE_TARGET_OFF_SOURCE,POSITION_SWITCH" ;
-    stype = target+sep1+offstr+sep2+pswitch ;
-    b = False ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::NOD:
-    //stype = "OBSERVE_TARGET_ON_SOURCE,NOD" ;
-    stype = target+sep1+onstr+sep2+nod ;
-    b = True ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::FSON:
-    //stype = "OBSERVE_TARGET_ON_SOURCE,FREQUENCY_SWITCH_SIG" ;
-    stype = target+sep1+onstr+sep2+fswitch+sep1+sigstr ;
-    b = True ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::FSOFF:
-    //stype = "OBSERVE_TARGET_ON_SOURCE,FREQUENCY_SWITCH_REF" ;
-    stype = target+sep1+onstr+sep2+fswitch+sep1+refstr ;
-    b = False ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::SKY:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,UNSPECIFIED" ;
-    stype = atmcal+sep1+offstr+sep2+unspecified ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::HOT:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,UNSPECIFIED" ;
-    stype = atmcal+sep1+offstr+sep2+unspecified ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::WARM:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,UNSPECIFIED" ;
-    stype = atmcal+sep1+offstr+sep2+unspecified ;
-    t = 0.0 ;
-    b = False ;
-    l = 1.0 ;
-    break ;
-  case SrcType::COLD:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,UNSPECIFIED" ;
-    stype = atmcal+sep1+offstr+sep2+unspecified ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::PONCAL:
-    //stype = "CALIBRATE_TEMPERATURE_ON_SOURCE,POSITION_SWITCH" ;
-    stype = atmcal+sep1+onstr+sep2+pswitch ;
-    b = True ;
-    t = 1.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::POFFCAL:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,POSITION_SWITCH" ;
-    stype = atmcal+sep1+offstr+sep2+pswitch ;
-    b = False ;
-    t = 1.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::NODCAL:
-    //stype = "CALIBRATE_TEMPERATURE_ON_SOURCE,NOD" ;
-    stype = atmcal+sep1+onstr+sep2+nod ;
-    b = True ;
-    t = 1.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::FONCAL:
-    //stype = "CALIBRATE_TEMPERATURE_ON_SOURCE,FREQUENCY_SWITCH_SIG" ;
-    stype = atmcal+sep1+onstr+sep2+fswitch+sep1+sigstr ;
-    b = True ;
-    t = 1.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::FOFFCAL:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,FREQUENCY_SWITCH_REF" ;
-    stype = atmcal+sep1+offstr+sep2+fswitch+sep1+refstr ;
-    b = False ;
-    t = 1.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::FSLO:
-    //stype = "OBSERVE_TARGET_ON_SOURCE,FREQUENCY_SWITCH_LOWER" ;
-    stype = target+sep1+onstr+sep2+fswitch+sep1+ftlow ;
-    b = True ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::FLOOFF:
-    //stype = "OBSERVE_TARGET_OFF_SOURCE,FREQUENCY_SWITCH_LOWER" ;
-    stype = target+sep1+offstr+sep2+fswitch+sep1+ftlow ;
-    b = False ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::FLOSKY:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,FREQUENCY_SWITCH_LOWER" ;
-    stype = atmcal+sep1+offstr+sep2+fswitch+sep1+ftlow ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::FLOHOT:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,FREQUENCY_SWITCH_LOWER" ;
-    stype = atmcal+sep1+offstr+sep2+fswitch+sep1+ftlow ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::FLOWARM:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,FREQUENCY_SWITCH_LOWER" ;
-    stype = atmcal+sep1+offstr+sep2+fswitch+sep1+ftlow ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::FLOCOLD:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,FREQUENCY_SWITCH_LOWER" ;
-    stype = atmcal+sep1+offstr+sep2+fswitch+sep1+ftlow ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::FSHI:
-    //stype = "OBSERVE_TARGET_ON_SOURCE,FREQUENCY_SWITCH_HIGHER" ;
-    stype = target+sep1+onstr+sep2+fswitch+sep1+fthigh ;
-    b = True ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::FHIOFF:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,FREQUENCY_SWITCH_HIGHER" ;
-    stype = target+sep1+offstr+sep2+fswitch+sep1+fthigh ;
-    b = False ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::FHISKY:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,FREQUENCY_SWITCH_HIGHER" ;
-    stype = atmcal+sep1+offstr+sep2+fswitch+sep1+fthigh ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::FHIHOT:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,FREQUENCY_SWITCH_HIGHER" ;
-    stype = atmcal+sep1+offstr+sep2+fswitch+sep1+fthigh ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::FHIWARM:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,FREQUENCY_SWITCH_HIGHER" ;
-    stype = atmcal+sep1+offstr+sep2+fswitch+sep1+fthigh ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::FHICOLD:
-    //stype = "CALIBRATE_TEMPERATURE_OFF_SOURCE,FREQUENCY_SWITCH_HIGHER" ;
-    stype = atmcal+sep1+offstr+sep2+fswitch+sep1+fthigh ;
-    b = False ;
-    t = 0.0 ;
-    l = 1.0 ;
-    break ;
-  case SrcType::SIG:
-    //stype = "OBSERVE_TARGET_ON_SOURCE,UNSPECIFIED" ;
-    stype = target+sep1+onstr+sep2+unspecified ;
-    b = True ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  case SrcType::REF:
-    //stype = "OBSERVE_TARGET_ON_SOURCE,UNSPECIFIED" ;
-    stype = target+sep1+offstr+sep2+unspecified ;
-    b = False ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  default:
-    //stype = "UNSPECIFIED" ;
-    stype = unspecified ;
-    b = True ;
-    t = 0.0 ;
-    l = 0.0 ;
-    break ;
-  }
-
-//   double endSec = mathutil::gettimeofday_sec() ;
-//   os_ << "end MSWriter::queryType() endSec=" << endSec << " (" << endSec-startSec << "sec)" << LogIO::POST ;
 }
-
-Double MSWriter::getDishDiameter( String antname )
-{
-  Double diameter = 0.0 ;
-  
-  antname.upcase() ;
-
-  if ( antname.matches( Regex( "DV[0-9]+$" ) ) 
-       || antname.matches( Regex( "DA[0-9]+$" ) )
-       || antname.matches( Regex( "PM[0-9]+$" ) ) )
-    diameter = 12.0 ;
-  else if ( antname.matches( Regex( "CM[0-9]+$" ) ) )
-    diameter = 7.0 ;
-  else if ( antname.contains( "GBT" ) ) 
-    diameter = 104.9 ;
-  else if ( antname.contains( "MOPRA" ) )
-    diameter = 22.0 ;
-  else if ( antname.contains( "PKS" ) || antname.contains( "PARKS" ) )
-    diameter = 64.0 ;
-  else if ( antname.contains( "TIDBINBILLA" ) ) 
-    diameter = 70.0 ;
-  else if ( antname.contains( "CEDUNA" ) )
-    diameter = 30.0 ;
-  else if ( antname.contains( "HOBART" ) ) 
-    diameter = 26.0 ;
-  else if ( antname.contains( "APEX" ) ) 
-    diameter = 12.0 ;
-  else if ( antname.contains( "ASTE" ) ) 
-    diameter = 10.0 ;
-  else if ( antname.contains( "NRO" ) ) 
-    diameter = 45.0 ;
-  else 
-    diameter = 1.0 ;
-
-  return diameter ;
-}
-
-void MSWriter::infillSpectralWindow()
-{
-  MSSpectralWindow msSpw = mstable_->spectralWindow() ;
-  MSSpWindowColumns msSpwCols( msSpw ) ;
-  uInt nrow = msSpw.nrow() ;
-
-  ScalarColumn<Int> measFreqRefCol = msSpwCols.measFreqRef() ;
-  ArrayColumn<Double> chanFreqCol = msSpwCols.chanFreq() ;
-  ArrayColumn<Double> chanWidthCol = msSpwCols.chanWidth() ;
-  ArrayColumn<Double> effectiveBWCol = msSpwCols.effectiveBW() ;
-  ArrayColumn<Double> resolutionCol = msSpwCols.resolution() ;
-  Vector<Double> dummy( 1, 0.0 ) ;
-  for ( uInt irow = 0 ; irow < nrow ; irow++ ) {
-    if ( !(chanFreqCol.isDefined( irow )) ) {
-      measFreqRefCol.put( irow, 1 ) ;
-      chanFreqCol.put( irow, dummy ) ;
-      chanWidthCol.put( irow, dummy ) ;
-      effectiveBWCol.put( irow, dummy ) ;
-      resolutionCol.put( irow, dummy ) ;
-    }
-  }
-
-}
-
-}
