Changeset 2208


Ignore:
Timestamp:
07/06/11 16:52:38 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-1913

Ready for Test: No

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No

Module(s): Module Names change impacts.

Description: Describe your changes here...

Update of asdm2ASAP and related classes.

  • replaced LogIO with StreamLogSink
  • all log messages are written to logger via StreamLogSink
  • no output to stdout/stderr
  • commented out junk log
  • added time_sampling selection
  • supported wvr_corrected_data='both'
  • added logfile specification
  • added corr_mode selection


Location:
trunk/external-alma/asdm2ASAP
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/external-alma/asdm2ASAP/ASDMFiller.cc

    r2197 r2208  
    1212#include <casa/Arrays/Matrix.h>
    1313#include <casa/Quanta/MVTime.h>
     14#include <casa/Logging/LogMessage.h>
    1415
    1516#include "ASDMFiller.h"
     
    2223  : FillerBase( stable ),
    2324    antennaId_( -1 ),
    24     antennaName_( "" )
    25 {
    26   cout << "This is constructor of ASDMFiller" << endl ;
    27 
     25    antennaName_( "" ),
     26    className_("ASDMFiller")
     27{
    2828  reader_ = new ASDMReader() ;
    29 
    30   cout << "input filename is " << stable->table().tableName() << endl ;
    3129}
    3230
    3331ASDMFiller::~ASDMFiller()
    3432{
    35   cout << "This is destructor of ASDMFiller" << endl ;
     33  // nothing to do?
     34  logsink_ = 0 ;
     35}
     36
     37void ASDMFiller::setLogger( CountedPtr<LogSinkInterface> &logsink )
     38{
     39  logsink_ = logsink ;
     40  if ( !(reader_.null()) ) {
     41    reader_->setLogger( logsink ) ;
     42  }
    3643}
    3744
    3845bool ASDMFiller::open( const string &filename, const Record &rec )
    3946{
     47  String funcName = "open" ;
    4048  bool status = reader_->open( filename, rec ) ;
    4149
     
    4351  antennaName_ = reader_->getAntennaName() ;
    4452
    45   cout << "antennaId_ = " << antennaId_ << endl ;
    46   cout << "antennaName_ = " << antennaName_ << endl ;
     53  //logsink->postLocally( LogMessage("antennaId_ = "+String::toString(antennaId_),LogOrigin(className_,funcName,WHERE)) ) ;
     54  //logsink->postLocally( LogMessage("antennaName_ = "+antennaName_,LogOrigin(className_,funcName,WHERE)) ) ;
    4755
    4856  return status ;
     
    5159void ASDMFiller::fill()
    5260{
     61  String funcName = "fill" ;
     62
    5363  // header
    5464  fillHeader() ;
     
    6575  uInt numConfigDescId = configDescIdList.size() ;
    6676
    67   cout << "configDescIdList = " << configDescIdList << endl ;
     77  //logsink->postLocally( LogMessage("configDescIdList = "+String::toString(configDescIdList),LogOrigin(className_,funcName,WHERE)) ) ;
    6878
    6979  // get field list
     
    7181  uInt numFieldId = fieldIdList.size() ;
    7282
    73   cout << "fieldIdList = " << fieldIdList << endl ;
     83  //logsink->postLocally( LogMessage("fieldIdList = "+String::toString(fieldIdList),LogOrigin(className_,funcName,WHERE)) ) ;
    7484
    7585  // BEAMNO is always 0 since ALMA antenna is single beam
     
    8393
    8494  for ( uInt icon = 0 ; icon < numConfigDescId ; icon++ ) {
    85     //Vector<uInt> dataDescIdList = reader_->getDataDescIdList( configDescIdList[icon] ) ;
    86     //uInt numDataDescId = dataDescIdList.size() ;
    87     //Vector<uInt> switchCycleIdList = reader_->getSwitchCycleIdList( configDescIdList[icon] ) ;
    88     //Vector<uInt> feedIdList = reader_->getFeedIdList( configDescIdList[icon] ) ;
    89     //uInt numFeedId = feedIdList.size() ;
    9095    for ( unsigned int ifield = 0 ; ifield < numFieldId ; ifield++ ) {
    91       cout << "start configDescId " << configDescIdList[icon]
    92            << " fieldId " << fieldIdList[ifield] << endl ;
     96      //logsink_->postLocally( LogMessage("start configDescId "+String::toString(configDescIdList[icon])+" fieldId "+String::toString(fieldIdList[ifield]),LogOrigin(className_,funcName,WHERE)) ) ;
    9397
    9498      //Bool status = reader_->setMainRow( configDescIdList[icon], fieldIdList[ifield] ) ;
    9599      if ( !(reader_->setMainRow( configDescIdList[icon], fieldIdList[ifield] )) ) {
    96         cout << "skip configDescId " << configDescIdList[icon]
    97              << ", fieldId " << fieldIdList[ifield] << endl ;
     100        //logsink_->postLocally( LogMessage("skip configDescId "+String::toString(configDescIdList[icon])+" fieldId "+String::toString(fieldIdList[ifield]),LogOrigin(className_,funcName,WHERE)) ) ;
    98101        continue ;
    99102      }
     
    102105      uInt nrow = reader_->getNumMainRow() ;
    103106
    104       cout << "There are " << nrow << " rows in Main table." << endl ;
     107      //logsink_->postLocally( LogMessage("There are "+String::toString(nrow)+" rows in Main table corresponding to configDescId "+String::toString(configDescIdList[icon]+" fieldId "+String::toString(fieldIdList[ifield]),LogOrigin(className_,funcName,WHERE)) ) ;
    105108     
    106109      // CYCLENO
     
    112115        if ( !(reader_->setMainRow( irow )) ) {
    113116          // skip row since the row doesn't have valid configDescId
    114           cout << "skip " << irow << endl ;
     117          //logsink_->postLocally( LogMessage("skip "+String::toString(irow),LogOrigin(className_,funcName,WHERE)) ) ;
    115118          continue ;
    116119        }
     
    122125        // set data
    123126        if ( !(reader_->setData()) ) {
    124           // skip row since failed to retrieve data
    125           cout << "skip " << irow << endl ;
     127          // skip row since reader failed to retrieve data
     128          //logsink_->postLocally( LogMessage("skip "+String::toString(irow),LogOrigin(className_,funcName,WHRER)) ) ;
     129          continue ;
    126130        }
    127131
     
    235239            toJ2000( direction, az, el, mjd, antpos ) ;
    236240          }
    237           cout << "direction = " << direction << endl ;
     241          //logsink_->postLocally( LogMessage("direction = "+String::toString(direction),LogOrigin(className_,funcName,WHERE)) ) ;
    238242          setDirection( direction, (casa::Float)az, (casa::Float)el ) ;
    239243
    240244          // loop on polarization
    241245          vector<unsigned int> dataShape = reader_->getDataShape( idata ) ;
    242           for ( unsigned int i = 0 ; i < dataShape.size() ; i++ ) {
    243             if ( i == 0 )
    244               cout << "dataShape=[" << dataShape[i] << ", " ;
    245             else if ( i == dataShape.size()-1 )
    246               cout << dataShape[i] << "]" << endl ;
    247             else
    248               cout << dataShape[i] << ", " ;
    249           }
     246//           ostringstream oss ;
     247//           for ( unsigned int i = 0 ; i < dataShape.size() ; i++ ) {
     248//             if ( i == 0 )
     249//               oss << "dataShape=[" << dataShape[i] << ", " ;
     250//             else if ( i == dataShape.size()-1 )
     251//               oss << dataShape[i] << "]"  ;
     252//             else
     253//               oss << dataShape[i] << ", " ;
     254//           }
     255//           logsink_->postLocally( LogMessage(oss.str(),LogOrigin(className_,funcName,WHERE)) ) ;
     256                                     
    250257          //int numPol = reader_->getNumPol( idata ) ;
    251258          unsigned int numPol = dataShape[0] ;
    252259          unsigned int numChan = dataShape[1] ;
    253260
    254           cout << "numPol = " << numPol << endl ;
     261          //logsink_->postLocally( LogMessage("numPol = "+String::toString(numPol),LogOrigin(className_,funcName,WHERE)) ) ;
    255262
    256263          // OPACITY
     
    295302    }
    296303  }
    297 
    298   cout << "filled" << endl ;
    299304
    300305  return ;
     
    481486                               Vector<casa::Double> antpos )
    482487{
     488  String funcName = "toJ2000" ;
     489
    483490  Vector<casa::Double> azel( 2 ) ;
    484491  azel[0] = az ;
     
    491498  MPosition mp( MVPosition( qantpos ),
    492499                MPosition::ITRF ) ;
    493   mp.print( cout ) ;
     500//   mp.print( os_.output() ) ;
    494501  MeasFrame mf( me, mp ) ;
    495502  MDirection::Convert toj2000( MDirection::AZELGEO,
    496   //MDirection::Convert toj2000( MDirection::AZEL,
    497   //MDirection::Convert toj2000( MDirection::AZELSW,
    498   //MDirection::Convert toj2000( MDirection::AZELSWGEO,
    499   //MDirection::Convert toj2000( MDirection::AZELNE,
    500   //MDirection::Convert toj2000( MDirection::AZELNEGEO,
    501503                               MDirection::Ref( MDirection::J2000, mf ) ) ;
    502504  dir = toj2000( azel ).getAngle( "rad" ).getValue() ;
    503   cout << "dir = " << dir << endl ;
    504 }
    505 
     505  //logsink->postLocally( LogMessage("dir = "+String::toString(dir),LogOrigin(className_,funcName,WHERE)) ) ;
     506}
     507
  • trunk/external-alma/asdm2ASAP/ASDMFiller.h

    r2197 r2208  
    33
    44#include <string>
     5
     6#include <casa/Logging/LogSinkInterface.h>
    57
    68#include <FillerBase.h>
     
    2527  // get reader object
    2628  casa::CountedPtr<ASDMReader> getReader() { return reader_ ; } ;
     29
     30  // set logger
     31  void setLogger( casa::CountedPtr<casa::LogSinkInterface> &logsink ) ;
    2732
    2833private:
     
    7580  casa::Record ifrec_ ;
    7681
     82  casa::CountedPtr<casa::LogSinkInterface> logsink_ ;
     83
     84  casa::String className_ ;
     85
    7786} ;
    7887#endif // ASAP_ASDM_FILLER_H
  • trunk/external-alma/asdm2ASAP/ASDMReader.cc

    r2197 r2208  
    88#include <measures/Measures/MeasFrame.h>
    99#include <measures/Measures/MeasConvert.h>
     10#include <casa/Logging/LogMessage.h>
    1011
    1112#include "ASDMReader.h"
     
    1920// sec to day
    2021double s2d = 1.0 / 86400.0 ;
    21 
    2222
    2323ASDMReader::ASDMReader()
     
    2828    antennaName_( "" ),
    2929    row_(-1),
    30     apc_(AP_CORRECTED)
    31 {
    32   cout << "This is constructor of ASDMReader" << endl ;
    33 
     30    apc_(AP_CORRECTED),
     31    className_("ASDMReader")
     32{
    3433  configDescIdList_.resize(0) ;
    3534  feedIdList_.resize(0) ;
     
    3736  mainRow_.resize(0) ;
    3837  ifno_.clear() ;
    39 
     38  corrMode_.reset() ;
     39  timeSampling_.reset() ;
    4040}
    4141
    4242ASDMReader::~ASDMReader()
    4343{
    44   cout << "This is destructor of ASDMReader" << endl ;
     44  close() ;
     45  logsink_ = 0 ;
    4546}
    4647
    4748bool ASDMReader::open( const string &filename, const casa::Record &rec )
    4849{
     50  String funcName = "open" ;
     51
     52  // return value
     53  bool status = true ;
     54
     55  // set default
     56  timeSampling_.reset() ;
     57  corrMode_.reset() ;
     58  apc_ = AP_CORRECTED ;
     59
    4960  // parsing ASDM options
    5061  if ( rec.isDefined( "asdm" ) ) {
    5162    casa::Record asdmrec = rec.asRecord( "asdm" ) ;
     63
     64    // antenna
    5265    if ( asdmrec.isDefined( "antenna" ) ) {
    5366      if ( asdmrec.type( asdmrec.fieldNumber( "antenna" ) ) == casa::TpInt ) {
     
    6174      antennaId_ = 0 ;
    6275    }
     76
     77    // ATM phase correction
    6378    if ( asdmrec.isDefined( "apc" ) ) {
    6479      if ( asdmrec.asBool( "apc" ) )
     
    6782        apc_ = AP_UNCORRECTED ;
    6883    }
    69     asdmrec.print( cout ) ;
     84
     85    // time sampling
     86    String timeSampling = "all" ; // take all time sampling by default
     87    if ( asdmrec.isDefined( "sampling" ) ) {
     88      timeSampling = asdmrec.asString( "sampling" ) ;
     89    }
     90    if ( timeSampling == "all" ) {
     91      timeSampling_.set( INTEGRATION ) ;
     92      timeSampling_.set( SUBINTEGRATION ) ;
     93    }
     94    else if ( timeSampling == "integration" ) {
     95      timeSampling_.set( INTEGRATION ) ;
     96    }
     97    else if ( timeSampling == "subintegration" ) {
     98      timeSampling_.set( SUBINTEGRATION ) ;
     99    }
     100    else {
     101      //throw AipsError( "Unrecognized option for sampling" ) ;
     102      logsink_->postLocally( LogMessage( "Unrecognized option for time sampling: "+String::toString(timeSampling), LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ;
     103      status = false ;
     104    }     
     105
     106    // input correlation mode
     107    if ( asdmrec.isDefined( "corr" ) ) {
     108      string corrMode = string( asdmrec.asString( "corr" ) ) ;
     109      //logsink_->postLocally( LogMessage("corrMode = "+String(corrMode),LogOrigin(className_,funcName,WHERE)) ) ;
     110      string corrModes[3] ;
     111      Int numCorr = split( corrMode, corrModes, 3, "+" ) ;
     112      for ( Int ic = 0 ; ic < numCorr ; ic++ ) {
     113        if ( corrModes[ic] == "ao" ) {
     114          corrMode_.set( AUTO_ONLY ) ;
     115        }
     116        else if ( corrModes[ic] == "ca" ) {
     117          corrMode_.set( CROSS_AND_AUTO ) ;
     118        }
     119      }
     120      //delete corrModes ;
     121      if ( corrMode_.size() == 0 ) {
     122        logsink_->postLocally( LogMessage( "Invalid option for correlation mode: "+String::toString(corrMode), LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ;
     123        status = false ;
     124      }
     125    }
     126
     127//     logsink_->postLocally( LogMessage( "### asdmrec summary ###", LogOrigin(className_,funcName,WHERE) ) ) ;
     128//     ostringstream oss ;
     129//     asdmrec.print( oss ) ;
     130//     logsink_->postLocally( LogMessage( oss.str(), LogOrigin(className_,funcName,WHERE) ) ) ;
     131//     logsink_->postLocally( LogMessage( "#######################", LogOrigin(className_,funcName,WHERE) ) ) ;
    70132  }
    71133
     
    73135  asdm_ = new ASDM() ;
    74136  asdm_->setFromFile( filename ) ;
    75   cout << "name = " << asdm_->getName() << endl ;
    76137
    77138  if ( antennaId_ == -1 ) {
     
    120181  processStation() ;
    121182
    122   cout << "antennaId_ = " << antennaId_ << endl ;
    123   cout << "antennaName_ = " << antennaName_ << endl ;
     183  logsink_->postLocally( LogMessage(  "antennaId_ = "+String::toString(antennaId_), LogOrigin() ) ) ;
     184  logsink_->postLocally( LogMessage(  "antennaName_ = "+antennaName_, LogOrigin() ) ) ;
    124185
    125186  return true ;
    126187}
    127188
    128 void ASDMReader::fill()
    129 {
    130 }
     189// void ASDMReader::fill()
     190// {
     191// }
    131192
    132193void ASDMReader::close()
     
    163224                             casa::String &poltype )
    164225{
     226  String funcName = "fillHeader" ;
    165227
    166228  ExecBlockTable &ebtab = asdm_->getExecBlock() ;
     
    178240  // <telescopeName>//<antennaName>@stationName
    179241  antennaname = telescopeName + "//" + antennaName_ + "@" + stationName ;
    180   cout << "antennaName = " << antennaname << endl ;
     242  //logsink_->postLocally( LogMessage("antennaName = "+antennaname,LogOrigin(className_,funcName,WHERE)) ) ;
    181243
    182244  // antennaposition
     
    215277  nchan = casa::Int( *max_element( nchans.begin(), nchans.end() ) ) ;
    216278
    217   cout << "refidx = " << refidx << endl ;
     279  //logsink_->postLocally( LogMessage("refidx = "+String::toString(refidx),LogOrigin(className_,funcName,WHERE)) ) ;
    218280
    219281  // bandwidth
     
    232294  if ( spwrows[refidx]->isMeasFreqRefExists() ) {
    233295    string mfr = CFrequencyReferenceCode::name( spwrows[refidx]->getMeasFreqRef() ) ;
    234     cout << "measFreqRef = " << mfr << endl ;
    235296    if (mfr == "TOPO") {
    236297      freqref = "TOPOCENT";
     
    336397void ASDMReader::selectConfigDescription()
    337398{
     399  String funcName = "selectConfigDescription" ;
     400
    338401  vector<ConfigDescriptionRow *> cdrows = asdm_->getConfigDescription().get() ;
    339402  vector<Tag> cdidTags ;
    340403  for ( unsigned int irow = 0 ; irow < cdrows.size() ; irow++ ) {
    341     cout << "correlationMode[" << irow << "] = " << cdrows[irow]->getCorrelationMode() << endl ;
     404    //logsink_->postLocally( LogMessage("correlationMode["+String::toString(irow)+"] = "+String::toString(cdrows[irow]->getCorrelationMode()),LogOrigin(className_,funcName,WHERE)) ) ;
    342405    if ( cdrows[irow]->getCorrelationMode() != CROSS_ONLY ) {
    343406      cdidTags.push_back( cdrows[irow]->getConfigDescriptionId() ) ;
     
    370433casa::Vector<casa::uInt> ASDMReader::getFieldIdList()
    371434{
     435  String funcName = "getFieldIdList" ;
     436
    372437  vector<FieldRow *> frows = asdm_->getField().get() ;
    373438  fieldIdList_.resize( frows.size() ) ;
    374439  for ( unsigned int irow = 0 ; irow < frows.size() ; irow++ ) {
    375     cout << "fieldId[" << irow << "]=" << frows[irow]->getFieldId().toString() << endl ;
     440    //logsink_->postLocally( LogMessage("fieldId["+String::toString(irow)+"]="+String(frows[irow]->getFieldId().toString()),LogOrigin(className_,funcName,WHERE)) ) ;
    376441    fieldIdList_[irow] = frows[irow]->getFieldId().getTagValue() ;
    377442  }
     
    389454void ASDMReader::select()
    390455{
    391   // selection by CorrelationMode and AtmPhaseCorrection
     456  // selection by input CorrelationMode
     457  EnumSet<CorrelationMode> esCorrs ;
     458//   esCorrs.set( CROSS_AND_AUTO ) ;
     459//   esCorrs.set( AUTO_ONLY ) ;
     460//   esCorrs.set( corrMode_ ) ;
     461//   sdmBin_->select( esCorrs ) ;
     462  sdmBin_->select( corrMode_ ) ;
     463
     464  // selection by TimeSampling
     465  sdmBin_->select( timeSampling_ ) ;
     466
     467  // selection by AtmPhaseCorrection and output CorrelationMode
    392468  EnumSet<AtmPhaseCorrection> esApcs ;
    393 //   esApcs.set( AP_UNCORRECTED ) ;
    394 //   esApcs.set( AP_CORRECTED ) ;
    395469  esApcs.set( apc_ ) ;
    396   EnumSet<CorrelationMode> esCorrs ;
    397   esCorrs.set( CROSS_AND_AUTO ) ;
    398   esCorrs.set( AUTO_ONLY ) ;
     470  // always take only autocorrelation data
    399471  Enum<CorrelationMode> esCorr = AUTO_ONLY ;
    400   sdmBin_->select( esCorrs ) ;
    401472  sdmBin_->selectDataSubset( esCorr, esApcs ) ;
    402473
     
    419490    status = (casa::Bool)(sdmBin_->acceptMainRow( mainRow_[row_] )) ;
    420491  }
    421   cout << "setMainRow: status = " << status << endl ;
    422492  return status ;
    423493}
     
    425495casa::Bool ASDMReader::setMainRow( casa::uInt configDescId, casa::uInt fieldId )
    426496{
    427   cout << "setMainRow " << configDescId << " " << fieldId << endl ;
    428497  clearMainRow() ;
    429498
     
    431500  Tag fieldTag( (unsigned int)fieldId, TagType::Field ) ;
    432501  mainRow_ = casa::Vector<MainRow *>( *(asdm_->getMain().getByContext( configDescTag, fieldTag ) ) ) ;
    433 
    434   cout << "mainRow_.size() = " << mainRow_.size() << endl ;
    435502 
    436503  return true ;
     
    444511void ASDMReader::setupIFNO()
    445512{
     513  String funcName = "setupIFNO" ;
     514
    446515  vector<SpectralWindowRow *> spwrows = asdm_->getSpectralWindow().get() ;
    447516  unsigned int nrow = spwrows.size() ;
     
    452521    casa::uInt index ;
    453522    if ( isWVR( spwrows[irow] ) ) {
    454       cout << spwrows[irow]->getSpectralWindowId().toString() << " is WVR" << endl ;
     523      //logsink_->postLocally( LogMessage(spwrows[irow]->getSpectralWindowId().toString()+" is WVR",LogOrigin(className_,funcName,WHERE)) ) ;
    455524      index = wvridx ;
    456525    }
     
    459528    }
    460529    ifno_.insert( pair<Tag,casa::uInt>(spwrows[irow]->getSpectralWindowId(),index) ) ;
    461     cout << spwrows[irow]->getSpectralWindowId().toString() << ": IFNO=" << index << endl ;
     530    //logsink_->postLocally( LogMessage(spwrows[irow]->getSpectralWindowId().toString()+": IFNO="+String::toString(index),LogOrigin(className_,funcName,WHERE)) ) ;
    462531  }
    463532}
     
    473542}
    474543
    475 casa::Vector<casa::uInt> ASDMReader::getDataDescIdList( casa::uInt cdid )
    476 {
    477   Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;
    478   ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;
    479   vector<Tag> ddTags = cdrow->getDataDescriptionId() ;
    480   casa::Vector<casa::uInt> ddidList( ddTags.size() ) ;
    481   for ( unsigned int idd = 0 ; idd < ddTags.size() ; idd++ ) {
    482     ddidList[idd] = ddTags[idd].getTagValue() ;
    483   }
    484   return ddidList ;
    485 }
    486 
    487 casa::Vector<casa::uInt> ASDMReader::getSwitchCycleIdList( casa::uInt cdid )
    488 {
    489   Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;
    490   ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;
    491   vector<Tag> scTags = cdrow->getSwitchCycleId() ;
    492   casa::Vector<casa::uInt> scidList( scTags.size() ) ;
    493   for ( unsigned int idd = 0 ; idd < scTags.size() ; idd++ ) {
    494     scidList[idd] = scTags[idd].getTagValue() ;
    495   }
    496   return scidList ;
    497 }
    498 
    499 casa::Vector<casa::uInt> ASDMReader::getFeedIdList( casa::uInt cdid )
    500 {
    501   Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;
    502   ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;
    503   casa::Vector<casa::uInt> feedIdList ;
    504   vector<int> feedIds = cdrow->getFeedId() ;
    505   for ( unsigned int ife = 0 ; ife < feedIds.size() ; ife++ ) {
    506     cout << "feedIds[" << ife << "]=" << feedIds[ife] << endl ;
    507     if ( casa::anyEQ( feedIdList, casa::uInt( feedIds[ife] ) ) )
    508       continue ;
    509     if ( casa::anyEQ( feedIdList_, casa::uInt( feedIds[ife] ) ) ) {
    510       casa::uInt oldsize = feedIdList.size() ;
    511       feedIdList.resize( oldsize+1, true ) ;
    512       feedIdList[oldsize] = casa::uInt( feedIds[ife] ) ;
    513     }
    514   }
    515   cout << "feedIdList.size() = " << feedIdList.size() << endl ;
    516   return feedIdList ;
    517 }
     544// casa::Vector<casa::uInt> ASDMReader::getDataDescIdList( casa::uInt cdid )
     545// {
     546//   Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;
     547//   ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;
     548//   vector<Tag> ddTags = cdrow->getDataDescriptionId() ;
     549//   casa::Vector<casa::uInt> ddidList( ddTags.size() ) ;
     550//   for ( unsigned int idd = 0 ; idd < ddTags.size() ; idd++ ) {
     551//     ddidList[idd] = ddTags[idd].getTagValue() ;
     552//   }
     553//   return ddidList ;
     554// }
     555
     556// casa::Vector<casa::uInt> ASDMReader::getSwitchCycleIdList( casa::uInt cdid )
     557// {
     558//   Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;
     559//   ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;
     560//   vector<Tag> scTags = cdrow->getSwitchCycleId() ;
     561//   casa::Vector<casa::uInt> scidList( scTags.size() ) ;
     562//   for ( unsigned int idd = 0 ; idd < scTags.size() ; idd++ ) {
     563//     scidList[idd] = scTags[idd].getTagValue() ;
     564//   }
     565//   return scidList ;
     566// }
     567
     568// casa::Vector<casa::uInt> ASDMReader::getFeedIdList( casa::uInt cdid )
     569// {
     570//   String funcName = "getFeedIdList" ;
     571//   
     572//   Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;
     573//   ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;
     574//   casa::Vector<casa::uInt> feedIdList ;
     575//   vector<int> feedIds = cdrow->getFeedId() ;
     576//   for ( unsigned int ife = 0 ; ife < feedIds.size() ; ife++ ) {
     577//     logsink_->postLocally( LogMessage("feedIds["+String::toString(ife)+"]="+String::toString(feedIds[ife]),LogOrigin(className_,funcName,WHERE)) ) ;
     578//     if ( casa::anyEQ( feedIdList, casa::uInt( feedIds[ife] ) ) )
     579//       continue ;
     580//     if ( casa::anyEQ( feedIdList_, casa::uInt( feedIds[ife] ) ) ) {
     581//       casa::uInt oldsize = feedIdList.size() ;
     582//       feedIdList.resize( oldsize+1, true ) ;
     583//       feedIdList[oldsize] = casa::uInt( feedIds[ife] ) ;
     584//     }
     585//   }
     586//   logsink_->postLocally( LogMessage("feedIdList.size() = "+String::toString(feedIdList.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     587//   return feedIdList ;
     588// }
    518589
    519590casa::Bool ASDMReader::setData()
    520591{
    521   cout << "try to retrieve binary data" << endl ;
     592  String funcName = "setData" ;
     593
     594  //logsink_->postLocally( LogMessage("try to retrieve binary data",LogOrigin(className_,funcName,WHERE)) ) ;
    522595 
     596//   EnumSet<AtmPhaseCorrection> esApcs ;
     597//   esApcs.set( apc_ ) ;
     598//   // always take only autocorrelation data
     599//   Enum<CorrelationMode> esCorr = AUTO_ONLY ;
     600//   vmsData_ = sdmBin_->getDataCols( esCorr, esApcs ) ;
     601
     602  // 2011/07/06 TN
     603  // Workaround to avoid unwanted message from SDMBinData::getDataCols()
     604  ostringstream oss ;
     605  streambuf *buforg = cout.rdbuf(oss.rdbuf()) ;
    523606  vmsData_ = sdmBin_->getDataCols() ;
    524 
    525 
    526   cout << "succeeded" << endl ;
    527 
    528   cout << "processorId = " << vmsData_->processorId << endl ;
    529   cout << "v_time.size() = " << vmsData_->v_time.size() << endl ;
    530   cout << "   v_time[0] = " << vmsData_->v_time[0] << endl ;
    531   cout << "v_interval.size() = " << vmsData_->v_interval.size() << endl ;
    532   cout << "   v_interval[0] = " << vmsData_->v_interval[0] << endl ;
    533   cout << "v_atmPhaseCorrection.size() = " << vmsData_->v_atmPhaseCorrection.size() << endl ;
    534   cout << "binNum = " << vmsData_->binNum << endl ;
    535   cout << "v_projectPath.size() = " << vmsData_->v_projectPath.size() << endl ;
    536   cout << "v_antennaId1.size() = " << vmsData_->v_antennaId1.size() << endl ;
    537   cout << "v_antennaId2.size() = " << vmsData_->v_antennaId2.size() << endl ;
    538   cout << "v_feedId1.size() = " << vmsData_->v_feedId1.size() << endl ;
    539   cout << "v_feedId2.size() = " << vmsData_->v_feedId2.size() << endl ;
    540   cout << "v_dataDescId.size() = " << vmsData_->v_dataDescId.size() << endl ;
    541   cout << "v_timeCentroid.size() = " << vmsData_->v_timeCentroid.size() << endl ;
    542   cout << "v_exposure.size() = " << vmsData_->v_exposure.size() << endl ;
    543   cout << "v_numData.size() = " << vmsData_->v_numData.size() << endl ;
    544   cout << "vv_dataShape.size() = " << vmsData_->vv_dataShape.size() << endl ;
    545   cout << "v_m_data.size() = " << vmsData_->v_m_data.size() << endl ;
    546   cout << "v_phaseDir.size() = " << vmsData_->v_phaseDir.size() << endl ;
    547   cout << "v_stateId.size() = " << vmsData_->v_stateId.size() << endl ;
    548   cout << "v_msState.size() = " << vmsData_->v_msState.size() << endl ;
    549   cout << "v_flag.size() = " << vmsData_->v_flag.size() << endl ;
     607  cout.rdbuf(buforg) ;
     608
     609//   logsink_->postLocally( LogMessage("oss.str() = "+oss.str(),LogOrigin(className_,funcName,WHERE)) ) ;
     610//   cout << "This is test: oss.str()=" << oss.str() << endl ;
     611
     612
     613  //logsink_->postLocally( LogMessage("processorId = "+String::toString(vmsData_->processorId),LogOrigin(className_,funcName,WHERE)) ) ;
     614  //logsink_->postLocally( LogMessage("v_time.size() = "+String::toString(vmsData_->v_time.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     615  //logsink_->postLocally( LogMessage("   v_time[0] = "+String::toString(vmsData_->v_time[0]),LogOrigin(className_,funcName,WHERE)) ) ;
     616  //logsink_->postLocally( LogMessage("v_interval.size() = "+String::toString(vmsData_->v_interval.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     617  //logsink_->postLocally( LogMessage("   v_interval[0] = "+String::toString(vmsData_->v_interval[0]),LogOrigin(className_,funcName,WHERE)) ) ;
     618  //logsink_->postLocally( LogMessage("v_atmPhaseCorrection.size() = "+String::toString(vmsData_->v_atmPhaseCorrection.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     619  //logsink_->postLocally( LogMessage("binNum = "+String::toString(vmsData_->binNum),LogOrigin(className_,funcName,WHERE)) ) ;
     620  //logsink_->postLocally( LogMessage("v_projectPath.size() = "+String::toString(vmsData_->v_projectPath.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     621  //logsink_->postLocally( LogMessage("v_antennaId1.size() = "+String::toString(vmsData_->v_antennaId1.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     622  //logsink_->postLocally( LogMessage("v_antennaId2.size() = "+String::toString(vmsData_->v_antennaId2.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     623  //logsink_->postLocally( LogMessage("v_feedId1.size() = "+String::toString(vmsData_->v_feedId1.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     624  //logsink_->postLocally( LogMessage("v_feedId2.size() = "+String::toString(vmsData_->v_feedId2.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     625  //logsink_->postLocally( LogMessage("v_dataDescId.size() = "+String::toString(vmsData_->v_dataDescId.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     626  //logsink_->postLocally( LogMessage("v_timeCentroid.size() = "+String::toString(vmsData_->v_timeCentroid.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     627  //logsink_->postLocally( LogMessage("v_exposure.size() = "+String::toString(vmsData_->v_exposure.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     628  //logsink_->postLocally( LogMessage("v_numData.size() = "+String::toString(vmsData_->v_numData.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     629  //logsink_->postLocally( LogMessage("vv_dataShape.size() = "+String::toString(vmsData_->vv_dataShape.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     630  //logsink_->postLocally( LogMessage("v_m_data.size() = "+String::toString(vmsData_->v_m_data.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     631  //logsink_->postLocally( LogMessage("v_phaseDir.size() = "+String::toString(vmsData_->v_phaseDir.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     632  //logsink_->postLocally( LogMessage("v_stateId.size() = "+String::toString(vmsData_->v_stateId.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     633  //logsink_->postLocally( LogMessage("v_msState.size() = "+String::toString(vmsData_->v_msState.size()),LogOrigin(className_,funcName,WHERE)) ) ;
     634  //logsink_->postLocally( LogMessage("v_flag.size() = "+String::toString(vmsData_->v_flag.size()),LogOrigin(className_,funcName,WHERE)) ) ;
    550635
    551636  dataIdList_.clear() ;
     
    557642  }
    558643  numData_ = dataIdList_.size() ;
    559   cout << "numData_ = " << numData_ << endl ;
    560 
    561 //  unsigned int numAnt1 = vmsData_->v_antennaId1.size() ;
    562 //  unsigned int numAnt2 = vmsData_->v_antennaId2.size() ;
    563 //   for ( unsigned int i = 0 ; i < numAnt1 ; i++ ) {
    564 //     if ( i == 0 )
    565 //       cout << "antenna1: " ;
    566 //     cout << vmsData_->v_antennaId1[i] << " " ;
    567 //   }
    568 //   cout << endl ;
    569 //   for ( unsigned int i = 0 ; i < numAnt2 ; i++ ) {
    570 //     if ( i == 0 )
    571 //       cout << "antenna2: " ;
    572 //     cout << vmsData_->v_antennaId2[i] << " " ;
    573 //   }
    574   cout << endl ;
    575   cout << "dataSize = " << mainRow_[row_]->getDataSize() << endl ;
     644  //logsink_->postLocally( LogMessage("numData_ = "+String::toString(numData_),LogOrigin(className_,funcName,WHERE)) ) ;
     645  //logsink_->postLocally( LogMessage("dataSize = "+String::toString(mainRow_[row_]->getDataSize()),LogOrigin(className_,funcName,WHERE)) ) ;
    576646
    577647  return true ;
     
    604674                               double &incr )
    605675{
    606   cout << "getFrequency()" << endl ;
     676  String funcName = "getFrequency" ;
     677
    607678  Tag ddTag( vmsData_->v_dataDescId[dataIdList_[idx]], TagType::DataDescription ) ;
    608679  DataDescriptionRow *ddrow = asdm_->getDataDescription().getRowByKey( ddTag ) ;
     
    611682  int nchan = spwrow->getNumChan() ;
    612683  if ( nchan == 1 ) {
    613     cout << "channel averaged data" << endl ;
     684    //logsink_->postLocally( LogMessage("channel averaged data",LogOrigin(className_,funcName,WHERE)) ) ;
    614685    refpix = 0.0 ;
    615686    incr = spwrow->getTotBandwidth().get() ;
     
    626697  else if ( nchan % 2 ) {
    627698    // odd
    628     cout << "odd case" << endl ;
     699    //logsink_->postLocally( LogMessage("odd case",LogOrigin(className_,funcName,WHERE)) ) ;
    629700    refpix = 0.5 * ( (double)nchan - 1.0 ) ;
    630701    int ic = ( nchan - 1 ) / 2 ;
     
    662733  else {
    663734    // even
    664     cout << "even case" << endl ;
     735    //logsink_->postLocally( LogMessage("even case",LogOrigin(className_,funcName,WHERE)) ) ;
    665736    refpix = 0.5 * ( (double)nchan - 1.0 ) ;
    666737    int ic = nchan / 2 ;
     
    697768    }     
    698769  }
    699   cout << "finished getFrequency()" << endl ;
    700770}
    701771
    702772vector<double> ASDMReader::getRestFrequency( unsigned int idx )
    703773{
    704   cout << "getRestFrequency" << endl ;
    705774  vector<double> rf( 0 ) ;
    706775  unsigned int index = dataIdList_[idx] ;
     
    713782  FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ;
    714783  if ( frow->isSourceIdExists() ) {
    715     cout << "sourceId exists" << endl ;
     784    //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ;
    716785    int sid = frow->getSourceId() ;
    717786    SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ;
    718787    if ( srow->isRestFrequencyExists() ) {
    719       cout << "restFrequency exists" << endl ;
     788      //logsink_->postLocally( LogMessage("restFrequency exists",LogOrigin(className_,funcName,WHERE)) ) ;
    720789      vector<Frequency> restfreq = srow->getRestFrequency() ;
    721790      rf.resize( restfreq.size() ) ;
     
    724793    }
    725794  }
    726   cout << "finished getRestFrequency()" << endl ;
    727795  return rf ;
    728796}
     
    751819  string srcname ;
    752820  if ( frow->isSourceIdExists() ) {
    753     cout << "sourceId exists" << endl ;
     821    //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ;
    754822    int sid = frow->getSourceId() ;
    755823    SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ;
     
    846914unsigned int ASDMReader::getSubscanNo( unsigned int idx )
    847915{
    848   //cout << "subscan" << vmsData_->v_msState[dataIdList_[idx]].subscanNum
    849   //     << ": obsmode=" << vmsData_->v_msState[dataIdList_[idx]].obsMode << endl ;
     916  //logsink_->postLocally( LogMessage("subscan"+String::toString(vmsData_->v_msState[dataIdList_[idx]].subscanNum)+": obsmode="+String::toString(vmsData_->v_msState[dataIdList_[idx]].obsMode),LogOrigin(className_,funcName,WHERE)) ) ;
    850917  return vmsData_->v_msState[dataIdList_[idx]].subscanNum ;
    851918}
     
    864931  string srcname ;
    865932  if ( frow->isSourceIdExists() ) {
    866     cout << "sourceId exists" << endl ;
     933    //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ;
    867934    int sid = frow->getSourceId() ;
    868935    SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ;
     
    893960  string srcname ;
    894961  if ( frow->isSourceIdExists() ) {
    895     cout << "sourceId exists" << endl ;
     962    //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ;
    896963    int sid = frow->getSourceId() ;
    897964    SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ;
     
    916983  string srcname ;
    917984  if ( frow->isSourceIdExists() ) {
    918     cout << "sourceId exists" << endl ;
     985    //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ;
    919986    int sid = frow->getSourceId() ;
    920987    SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ;
     
    10881155                                 float &windaz )
    10891156{
    1090   cout << "getWeatherInfo() start" << endl ;
    10911157  temperature = 0.0 ;
    10921158  pressure = 0.0 ;
     
    10951161  windaz = 0.0 ;
    10961162
    1097   cout << "weatherStationId_ = " << weatherStationId_ << endl ;
     1163  //logsink_->postLocally( LogMessage("weatherStationId_ = "+String::toString(weatherStationId_),LogOrigin(className_,funcName,WHERE)) ) ;
    10981164
    10991165  WeatherTable &wtab = asdm_->getWeather() ;
     
    11051171  //Tag sttag = (asdm_->getAntenna().getRowByKey( anttag ))->getStationId() ;
    11061172  Tag sttag( (unsigned int)weatherStationId_, TagType::Station ) ;
    1107   cout << "v_interval=" << vmsData_->v_interval[index] << endl ;
    11081173  //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ;
    11091174  double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;
    11101175  ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;
    1111   cout << "start " << tint.getStartInMJD() << " duration " << tint.getDurationInNanoSeconds() << endl ;
    11121176  //WeatherRow *wrow = wtab.getRowByKey( sttag, tint ) ;
    11131177  vector<WeatherRow *> *wrows = wtab.getByContext( sttag ) ;
    11141178  WeatherRow *wrow = (*wrows)[0] ;
    11151179  unsigned int nrow = wrows->size() ;
    1116   cout << "There are " << nrow << " rows for given context" << endl ;
     1180  //logsink_->postLocally( LogMessage("There are "+String::toString(nrow)+" rows for given context: stationId "+String::toString(weatherStationId_),LogOrigin(className_,funcName,WHERE)) ) ;
    11171181  ArrayTime startTime = tint.getStart() ;
    11181182  if ( startTime < (*wrows)[0]->getTimeInterval().getStart() ) {
     
    11341198      wrow = (*wrows)[irow-1] ;
    11351199      if ( startTime < (*wrows)[irow]->getTimeInterval().getStart() ) {
    1136         cout << "irow = " << irow << endl ;
    11371200        temperature = wrow->getTemperature().get() ;
    11381201        pressure = wrow->getPressure().get() ;
     
    11441207    }
    11451208  }
    1146  
    1147 
    1148   cout << "temperature = " << temperature << endl ;
    1149 
    1150   cout << "getWeatherInfo() end" << endl ;
     1209
    11511210  return ;
    11521211}
     
    12071266                                  vector<double> &srate )
    12081267{
    1209   cout << "getPointingInfo() start" << endl ;
     1268  String funcName = "getPointingInfo" ;
     1269
    12101270  dir.resize(0) ;
    12111271  az = -1.0 ;
     
    12231283
    12241284  unsigned int nrow = prows->size() ;
    1225   cout << "There are " << nrow << " rows" << endl ;
     1285  //logsink_->postLocally( LogMessage("There are " << nrow << " rows for given context: antennaId "+String::toString(antennaId_),LogOrigin(className_,funcName,WHERE)) ) ;
    12261286
    12271287//   for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) {
     
    12301290//     ArrayTime pst = ati.getStart() ;
    12311291//     ArrayTime pet( ati.getStartInMJD()+ati.getDurationInDays() ) ;
    1232 //     cout << "start: " << pst.toFITS() << endl ;
    1233 //     cout << "end: " << pet.toFITS() << endl ;
     1292//     logsink_->postLocally( LogMessage("start: "+pst.toFITS(),LogOrigin(className_,funcName,WHERE)) ) ;
     1293//     logsink_->postLocally( LogMessage("end: "+pet.toFITS(),LogOrigin(className_,funcName,WHERE)) ) ;
    12341294//   }
    12351295 
     
    12591319  ArrayTimeInterval pTime1 = (*prows)[nrow-1]->getTimeInterval() ;
    12601320  if ( tint.getStartInMJD()+tint.getDurationInDays() < pTime0.getStartInMJD() ) {
    1261     cout << "ArrayTimeInterval out of bounds: no data for given position (tint < ptime)" << endl ;
     1321    logsink_->postLocally( LogMessage( "ArrayTimeInterval out of bounds: no data for given position (tint < ptime)", LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ;
    12621322    prow = (*prows)[0] ;
    12631323    //vector< vector<Angle> > dirA = prow->getPointingDirection() ;
     
    12761336  }
    12771337  else if ( tint.getStartInMJD() > pTime1.getStartInMJD()+pTime1.getDurationInDays() ) {
    1278     cout << "ArrayTimeInterval out of bounds: no data for given position (tint > ptime)" << endl ;
     1338    logsink_->postLocally( LogMessage( "ArrayTimeInterval out of bounds: no data for given position (tint > ptime)", LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ;
    12791339    prow = (*prows)[nrow-1] ;
    12801340    int numSample = prow->getNumSample() ;
     
    13221382        break ;
    13231383    }
    1324     cout << "row0 = " << row0 << ", row1 = " << row1 << ", row2 = " << row2 << endl ;
     1384    //logsink_->postLocally( LogMessage("row0 = "+String::toString(row0)+", row1 = "+String::toString(row1)+", row2 = "+String::toString(row2),LogOrigin(className_,funcName,WHERE)) ) ;
    13251385    if ( row0 == -1 && row1 == -1 ) {
    13261386      prow = (*prows)[row2] ;
     
    13791439      prow = (*prows)[row0] ;
    13801440      qrow = (*prows)[row1] ;
    1381       cout << "usePolynomials = " ;
    1382       cout << prow->getUsePolynomials() << endl ;
    13831441      if ( prow->getUsePolynomials() && qrow->getUsePolynomials() ) {
    1384         cout << "usePolynomial = True" << endl ;
     1442        //logsink_->postLocally( LogMessage("usePolynomial = True",LogOrigin(className_,funcName,WHERE)) ) ;
    13851443        if ( row0 == row1 ) {
    13861444          prow = (*prows)[row0] ;
     
    14371495      }
    14381496      else if ( prow->getUsePolynomials() == qrow->getUsePolynomials() ) {
    1439         cout << "numSample == numTerm " << endl ;
     1497        //logsink_->postLocally( LogMessage("numSample == numTerm",LogOrigin(className_,funcName,WHERE)) ) ;
    14401498        for ( int irow = row0 ; irow <= row1 ; irow++ ) {
    14411499          prow = (*prows)[irow] ;
    14421500          int numSample = prow->getNumSample() ;
    1443           cout << "numSample = " << numSample << endl ;
     1501          //logsink_->postLocally( LogMessage("numSample = "+String::toString(numSample),LogOrigin(className_,funcName,WHERE)) ) ;
    14441502          //vector< vector<Angle> > dirA = prow->getPointingDirection() ;
    14451503          vector< vector<Angle> > dirA = prow->getTarget() ;
    14461504          vector< vector<Angle> > offA = prow->getOffset() ;
    14471505          if ( prow->isSampledTimeIntervalExists() ) {
    1448             cout << "sampledTimeIntervalExists" << endl ;
     1506            //logsink_->postLocally( LogMessage("sampledTimeIntervalExists",LogOrigin(className_,funcName,WHERE)) ) ;
    14491507            vector<ArrayTimeInterval> stime = prow->getSampledTimeInterval() ;
    14501508            for ( int isam = 0 ; isam < numSample ; isam++ ) {
     
    14621520            double sampleStart = prow->getTimeInterval().getStartInMJD() ;
    14631521            double sampleInterval = prow->getTimeInterval().getDurationInDays() / (double)numSample ;
    1464             cout << "sampleStart = " << sampleStart << endl ;
    1465             cout << "sampleInterval = " << sampleInterval << endl ;
    1466             cout << "tint = " << tint.toString() << endl ;
     1522            //logsink_->postLocally( LogMessage("sampleStart = "+String::toString(sampleStart),LogOrigin(className_,funcName,WHERE)) )
     1523            //logsink_->postLocally( LogMessage("sampleInterval = "+String::toString(sampleInterval),LogOrigin(className_,funcName,WHERE)) ) ;
     1524            //logsink_->postLocally( LogMessage("tint = "+tint.toString(),LogOrigin(className_,funcName,WHERE)) ) ;
    14671525            for ( int isam = 0 ; isam < numSample ; isam++ ) {
    14681526              ArrayTimeInterval stime( sampleStart+isam*sampleInterval, sampleInterval ) ;
     
    14771535              }
    14781536            }
    1479             cout << "ndir = " << ndir << endl ;
    14801537          }
    14811538        }
     
    14971554    for ( int i = 0 ; i < 3 ; i++ )
    14981555      antpos[i] = antposL[i].get() ;
    1499     cout << "antennaId = " << antennaId_ << endl ;
    1500     cout << "tcen = " << tcen << endl ;
    1501     cout << "antpos = " << antpos << endl ;
     1556    //logsink_->postLocally( LogMessage("tcen = "+String::toString(tcen),LogOrigin(className_,funcName,WHERE)) ) ;
     1557    //logsink_->postLocally( LogMessage("antpos = "+String::toString(antpos),LogOrigin(className_,funcName,WHERE)) ) ;
    15021558    toJ2000( dir, az, el, tcen, antpos ) ;
    15031559
    15041560  }
    15051561
    1506   cout << "getPointingInfo() end" << endl ;
    15071562  return ;
    15081563}
     
    15291584                          casa::Vector<casa::Double> antpos )
    15301585{
     1586  String funcName = "toJ2000" ;
     1587
    15311588  casa::Vector<casa::Double> azel( 2 ) ;
    15321589  azel[0] = az ;
     
    15391596  casa::MPosition mp( casa::MVPosition( qantpos ),
    15401597                      casa::MPosition::ITRF ) ;
    1541   mp.print( cout ) ;
     1598  //ostringstream oss ;
     1599  //mp.print( oss ) ;
     1600  //logsink_->postLocally( LogMessage(oss.str(),LogOrigin(className_,funcName,WHERE)) ) ;
     1601
    15421602  casa::MeasFrame mf( me, mp ) ;
    15431603  casa::MDirection::Convert toj2000( casa::MDirection::AZELGEO,
     
    15491609                                     casa::MDirection::Ref( casa::MDirection::J2000, mf ) ) ;
    15501610  casa::Vector<casa::Double> cdir = toj2000( azel ).getAngle( "rad" ).getValue() ;
    1551   cout << "cdir = " << cdir << endl ;
     1611  //logsink_->postLocally( LogMessage("cdir = "+String::toString(cdir),LogOrigin(className_,funcName,WHERE)) ) ;
    15521612  dir.resize(2) ;
    15531613  dir[0] = (double)(cdir[0]) ;
    15541614  dir[1] = (double)(cdir[1]) ;
    15551615}
     1616
     1617void ASDMReader::setLogger( CountedPtr<LogSinkInterface> &logsink )
     1618{
     1619  logsink_ = logsink ;
     1620}
  • trunk/external-alma/asdm2ASAP/ASDMReader.h

    r2197 r2208  
    77#include <casa/Utilities/CountedPtr.h>
    88#include <casa/Containers/Record.h>
     9#include <casa/Logging/LogSinkInterface.h>
    910#include <ASDMAll.h>
    1011#include <SDMBinData.h>
     
    3536   * fill data
    3637   **/
    37   void fill() ;
     38//   void fill() ;
    3839
    3940  /**
     
    121122
    122123  /**
    123    * set Main rows that matches given context (configDescId and fieldId) to mainRow_
     124   * set Main rows that matches given context (configDescId and fieldId)
     125   * to mainRow_
    124126   *
    125127   * @param configDescId
     
    357359   * @return list of dataDescId
    358360   **/
    359   casa::Vector<casa::uInt> getDataDescIdList( casa::uInt cdid ) ;
     361//   casa::Vector<casa::uInt> getDataDescIdList( casa::uInt cdid ) ;
    360362
    361363  /**
     
    365367   * @return list of dataDescId
    366368   **/
    367   casa::Vector<casa::uInt> getSwitchCycleIdList( casa::uInt cdid ) ;
     369//   casa::Vector<casa::uInt> getSwitchCycleIdList( casa::uInt cdid ) ;
    368370
    369371  /**
     
    375377   * @return list of valid feedId
    376378   **/
    377   casa::Vector<casa::uInt> getFeedIdList( casa::uInt cdid ) ;
     379//   casa::Vector<casa::uInt> getFeedIdList( casa::uInt cdid ) ;
    378380
    379381  /**
     
    390392   **/
    391393  unsigned int getNumData() { return numData_ ; } ;
     394
     395  /**
     396   * set Logger
     397   *
     398   * @param logger (LogSinkInterface)
     399   **/
     400  void setLogger( casa::CountedPtr<casa::LogSinkInterface> &logsink ) ;
    392401
    393402
     
    524533  int weatherStationId_ ; // closest weather station for antennaId_
    525534  AtmPhaseCorrectionMod::AtmPhaseCorrection apc_ ; // ATM phase correction
     535  EnumSet<CorrelationModeMod::CorrelationMode> corrMode_ ; // input correlation mode
     536  EnumSet<TimeSamplingMod::TimeSampling> timeSampling_ ; // time sampling
     537  casa::CountedPtr<casa::LogSinkInterface> logsink_ ; // Logger
     538  casa::String className_ ;
    526539} ;
    527540#endif // ASAP_ASDM_READER_H
  • trunk/external-alma/asdm2ASAP/asdm2ASAP.cc

    r2197 r2208  
    11#include <iostream>
     2#include <fstream>
    23#include <casa/Utilities/Regex.h>
    34#include <casa/Inputs/Input.h>
     
    56#include <casa/Containers/Record.h>
    67#include <casa/OS/Directory.h>
     8#include <casa/Logging/LogIO.h>
     9#include <casa/Logging/LogSink.h>
     10#include <casa/Logging/StreamLogSink.h>
     11#include <casa/Logging/LogFilter.h>
    712#include <Scantable.h>
    813#include "ASDMFiller.h"
     
    1823  Input inp ;
    1924  String indent = "   " ;
    20   String versionInfo = "$Id$\nConverts an ASDM dataset into Scantable.\nUsage:\n"+indent+argv[0]+" -antenna <antenna name or id> -asdm <ASDM directory> -asap <Scantable name>" ;
    21   inp.version( versionInfo ) ;
     25  String versionInfo = "$Id$\nConverts an ASDM dataset into Scantable.\nUsage:\n"+indent+argv[0]+" -antenna <antenna name or id> -asdm <ASDM directory> -asap <Scantable name> [-apc both|yes|no] [-corr-mode ca|ao|ca+ao] [-ocorr-mode ao] [-time-sampling all|integration|subintegration]" ;
     26  Bool helpMode = False ;
     27  for ( int i = 1 ; i < argc ; i++ ) {
     28    if ( strncmp( argv[i], "-h", 2 ) == 0
     29         || strncmp( argv[i], "--help", 6 ) == 0
     30         || strncmp( argv[i], "-v", 2 ) == 0
     31         || strncmp( argv[i], "--version", 9 ) == 0 ) {
     32      helpMode = True ;
     33      break ;
     34    }
     35  }
     36  if ( helpMode )
     37    inp.version( versionInfo ) ;
     38  else
     39    inp.version( "" ) ;
    2240
    2341  inp.create( "antenna", "0", "antenna name or id", "String" ) ;
    2442  inp.create( "asdm", "", "ASDM directory name", "String" ) ;
    2543  inp.create( "asap", "", "Scantable name", "String" ) ;
    26   inp.create( "apc", "False", "Retrieve Atm Phase Corrected data or not", "Bool" ) ;
    27   inp.create( "overwrite", "True", "Overwrite existing Scantable or not", "Bool" ) ;
     44  inp.create( "apc", "both", "Retrieve Atm Phase Corrected data or not: both|yes|no", "String" ) ;
     45  inp.create( "overwrite", "True", "Overwrite existing Scantable or not: True|False", "Bool" ) ;
     46  inp.create( "corr-mode", "ca+ao", "Input correlator mode: ca+ao|ca|ao", "String" ) ;
     47  inp.create( "ocorr-mode", "ao", "Output correlator mode: ao", "String" ) ;
     48  inp.create( "time-sampling", "all", "time sampling mode: all|integration|subintegration", "String" ) ;
     49  inp.create( "logfile", "", "logger output", "String" ) ;
    2850  inp.readArguments( argc, argv ) ;
    2951
     
    3153  string antenna = inp.getString( "antenna" ) ;
    3254  string asapname = inp.getString( "asap" ) ;
    33   Bool apcCorrected = inp.getBool( "apc" ) ;
     55  string apc = inp.getString( "apc" ) ;
    3456  Bool overwrite = inp.getBool( "overwrite" ) ;
     57  string corrMode = inp.getString( "corr-mode" ) ;
     58  string timeSampling = inp.getString( "time-sampling" ) ;
     59  string logfile = inp.getString( "logfile" ) ;
    3560   
    36    
    37   // create ASDMFiller object
    38   CountedPtr<Scantable> stable( new Scantable() ) ;
    39   ASDMFiller *filler = new ASDMFiller( stable ) ;
    40 
    41   // open data
    42   Record rec ;
    43   Record asdmRec ;
    44   Regex reg( "[0-9]+$" ) ;
    45   asdmRec.define( "apc", apcCorrected ) ;
    46   if ( reg.match( antenna.c_str(), antenna.size() ) != String::npos ) {
    47     // antenna is specifiec as id
    48     int aid = atoi( antenna.c_str() ) ;
    49     asdmRec.define( "antenna", aid ) ;
     61  int numApc = 1 ;
     62  Vector<Bool> apcCorrected ;
     63  apcCorrected.resize( numApc ) ;
     64  if ( apc == "both" ) {
     65    numApc = 2 ;
     66    apcCorrected.resize( numApc ) ;
     67    apcCorrected[0] = True ;
     68    apcCorrected[1] = False ;
     69  }
     70  else if ( apc == "yes" ) {
     71    apcCorrected.resize( numApc ) ;
     72    apcCorrected[0] = True ;
     73  }
     74  else if ( apc == "no" ) {
     75    apcCorrected.resize( numApc ) ;
     76    apcCorrected[0] = False ;
    5077  }
    5178  else {
    52     // antenna is specified as name
    53     asdmRec.define( "antenna", antenna ) ;
     79    throw AipsError( "Unrecognized value for -apc option" ) ;
    5480  }
    55   rec.defineRecord( "asdm", asdmRec ) ;
    56   filler->open( asdmname, rec ) ;
     81   
    5782
    58   // output filename
    59   CountedPtr<ASDMReader> reader = filler->getReader() ;
    60   string aname = reader->getAntennaName() ;
    61   int aid = reader->getAntennaId() ;
    62   if ( asapname.size() == 0 ) {
    63     asapname = asdmname + "." + aname + ".asap" ;
     83  ofstream ofs ;
     84  CountedPtr<LogSinkInterface> logsink_p ;
     85  String funcname( argv[0] ) ;
     86  if ( logfile.size() != 0 ) {
     87    ofs.open( logfile.c_str(), ios_base::app ) ;
     88    logsink_p = new StreamLogSink( &ofs ) ;
     89    logsink_p->cerrToo( false ) ;
     90  }
     91  else {
     92    logsink_p = new StreamLogSink() ;
    6493  }
     94  // create ASDMFiller object
     95  //logsink_p->postLocally( LogMessage( "numApc = "+String::toString(numApc), LogOrigin(funcname,WHERE) ) ) ;
     96  for ( int iapc = 0 ; iapc < numApc ; iapc++ ) {
     97    CountedPtr<Scantable> stable( new Scantable() ) ;
     98    ASDMFiller *filler = new ASDMFiller( stable ) ;
    6599
    66   cout << "specified option summary:" << endl ;
    67   cout << "   antenna = " << antenna << " (ID: " << aid << ")" << endl ;
    68   cout << "   asdmname = " << asdmname << endl ;
    69   cout << "   asapname = " << asapname << endl ;
    70   cout << "   apcCorrected = " << apcCorrected << endl ;
     100    // set logger
     101    filler->setLogger( logsink_p ) ;
    71102
    72   // save scantable on disk
    73   Directory dir( asapname ) ;
    74   if ( dir.exists() ) {
    75     if ( overwrite ) {
    76       cout << "Delete existing file..." << endl ;
    77       dir.removeRecursive() ;
     103    // open data
     104    Record rec ;
     105    Record asdmRec ;
     106    Regex reg( "[0-9]+$" ) ;
     107    //asdmRec.define( "apc", apcCorrected ) ;
     108    asdmRec.define( "apc", apcCorrected[iapc] ) ;
     109    asdmRec.define( "corr", corrMode ) ;
     110    asdmRec.define( "sampling", timeSampling ) ;
     111    if ( reg.match( antenna.c_str(), antenna.size() ) != String::npos ) {
     112      // antenna is specifiec as id
     113      int aid = atoi( antenna.c_str() ) ;
     114      asdmRec.define( "antenna", aid ) ;
    78115    }
    79116    else {
    80       cerr << "Output file " << asapname << " exists." << endl ;
    81       return 1 ;
     117      // antenna is specified as name
     118      asdmRec.define( "antenna", antenna ) ;
    82119    }
     120    rec.defineRecord( "asdm", asdmRec ) ;
     121    filler->open( asdmname, rec ) ;
     122   
     123    // output filename
     124    CountedPtr<ASDMReader> reader = filler->getReader() ;
     125    string aname = reader->getAntennaName() ;
     126    int aid = reader->getAntennaId() ;
     127    string outname = asapname ;
     128    if ( asapname.size() == 0 ) {
     129      outname = asdmname + "." + aname + ".asap" ;
     130    }
     131    if ( apcCorrected[iapc] == True ) {
     132      outname += ".wvr-corrected" ;
     133    }
     134   
     135    //logsink_p->postLocally( LogMessage("specified option summary:",LogOrigin(funcname,WHERE)) ) ;
     136    //logsink_p->postLocally( LogMessage("   antenna = "+String(aname)+" (ID: "+String::toString(aid)+")",LogOrigin(funcname,WHERE)) ) ;
     137    //logsink_p->postLocally( LogMessage("   asdmname = "+asdmname,LogOrigin(funcname,WHERE)) ) ;
     138    //logsink_p->postLocally( LogMessage("   asapname = "+outname,LogOrigin(funcname,WHERE)) ) ;
     139    //logsink_p->postLocally( LogMessage("   apcCorrected = "+String::toString(apcCorrected[iapc]),LogOrigin(funcname,WHERE) ) ) ;
     140    //logsink_p->postLocally( LogMessage("   timeSampling = "+timeSampling,LogOrigin(funcname,WHERE) ) ) ;
     141    //logsink_p->postLocally( LogMessage("   corrMode = "+corrMode,LogOrigin(funcname,WHERE) ) ) ;
     142   
     143    // save scantable on disk
     144    Directory dir( outname ) ;
     145    if ( dir.exists() ) {
     146      if ( overwrite ) {
     147        //*os << "Delete existing file " << outname << " ..." << LogIO::POST ;
     148        logsink_p->postLocally( LogMessage("Delete existing file "+outname+" ...",LogOrigin(funcname,WHERE)) ) ;
     149        dir.removeRecursive() ;
     150      }
     151      else {
     152        //*os << LogIO::WARN << "Output file " << outname << " exists." << LogIO::POST ;
     153        logsink_p->postLocally( LogMessage("Output file "+outname+" exists.",LogOrigin(funcname,WHERE),LogMessage::WARN) ) ;
     154        return 1 ;
     155      }
     156    }
     157   
     158    // fill data
     159    filler->fill() ;
     160   
     161    // close data
     162    filler->close() ;
     163   
     164    // save data only if nrow is not zero
     165    if ( stable->nrow() > 0 ) {
     166      //*os << "Creating " << outname << "..." << LogIO::POST ;
     167      logsink_p->postLocally( LogMessage("Creating "+outname+"...",LogOrigin(funcname,WHERE)) ) ;
     168      stable->makePersistent( outname ) ;
     169    }
     170    else {
     171      //*os << outname << " will not be created since there are no data associate with the selection" << LogIO::POST ;
     172      logsink_p->postLocally( LogMessage(outname+" will not be created since there are no data associate with the selection",LogOrigin(funcname,WHERE)) ) ;
     173    }
     174   
     175    // finalize
     176    reader = 0 ;
     177    delete filler ;
     178   
    83179  }
    84 
    85   // fill data
    86   filler->fill() ;
    87 
    88   // close data
    89   filler->close() ;
    90 
    91   // save data
    92   stable->makePersistent( asapname ) ;
    93 
    94   // finalize
    95   reader = 0 ;
    96   delete filler ;
     180 
     181  if ( logfile.size() != 0 )
     182    ofs.close() ;
     183  //delete os ;
    97184
    98185  return 0 ;
Note: See TracChangeset for help on using the changeset viewer.