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


File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.