Changeset 2208
- Timestamp:
- 07/06/11 16:52:38 (13 years ago)
- Location:
- trunk/external-alma/asdm2ASAP
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external-alma/asdm2ASAP/ASDMFiller.cc
r2197 r2208 12 12 #include <casa/Arrays/Matrix.h> 13 13 #include <casa/Quanta/MVTime.h> 14 #include <casa/Logging/LogMessage.h> 14 15 15 16 #include "ASDMFiller.h" … … 22 23 : FillerBase( stable ), 23 24 antennaId_( -1 ), 24 antennaName_( "" ) 25 { 26 cout << "This is constructor of ASDMFiller" << endl ; 27 25 antennaName_( "" ), 26 className_("ASDMFiller") 27 { 28 28 reader_ = new ASDMReader() ; 29 30 cout << "input filename is " << stable->table().tableName() << endl ;31 29 } 32 30 33 31 ASDMFiller::~ASDMFiller() 34 32 { 35 cout << "This is destructor of ASDMFiller" << endl ; 33 // nothing to do? 34 logsink_ = 0 ; 35 } 36 37 void ASDMFiller::setLogger( CountedPtr<LogSinkInterface> &logsink ) 38 { 39 logsink_ = logsink ; 40 if ( !(reader_.null()) ) { 41 reader_->setLogger( logsink ) ; 42 } 36 43 } 37 44 38 45 bool ASDMFiller::open( const string &filename, const Record &rec ) 39 46 { 47 String funcName = "open" ; 40 48 bool status = reader_->open( filename, rec ) ; 41 49 … … 43 51 antennaName_ = reader_->getAntennaName() ; 44 52 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)) ) ; 47 55 48 56 return status ; … … 51 59 void ASDMFiller::fill() 52 60 { 61 String funcName = "fill" ; 62 53 63 // header 54 64 fillHeader() ; … … 65 75 uInt numConfigDescId = configDescIdList.size() ; 66 76 67 cout << "configDescIdList = " << configDescIdList << endl;77 //logsink->postLocally( LogMessage("configDescIdList = "+String::toString(configDescIdList),LogOrigin(className_,funcName,WHERE)) ) ; 68 78 69 79 // get field list … … 71 81 uInt numFieldId = fieldIdList.size() ; 72 82 73 cout << "fieldIdList = " << fieldIdList << endl;83 //logsink->postLocally( LogMessage("fieldIdList = "+String::toString(fieldIdList),LogOrigin(className_,funcName,WHERE)) ) ; 74 84 75 85 // BEAMNO is always 0 since ALMA antenna is single beam … … 83 93 84 94 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() ;90 95 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)) ) ; 93 97 94 98 //Bool status = reader_->setMainRow( configDescIdList[icon], fieldIdList[ifield] ) ; 95 99 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)) ) ; 98 101 continue ; 99 102 } … … 102 105 uInt nrow = reader_->getNumMainRow() ; 103 106 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)) ) ; 105 108 106 109 // CYCLENO … … 112 115 if ( !(reader_->setMainRow( irow )) ) { 113 116 // 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)) ) ; 115 118 continue ; 116 119 } … … 122 125 // set data 123 126 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 ; 126 130 } 127 131 … … 235 239 toJ2000( direction, az, el, mjd, antpos ) ; 236 240 } 237 cout << "direction = " << direction << endl;241 //logsink_->postLocally( LogMessage("direction = "+String::toString(direction),LogOrigin(className_,funcName,WHERE)) ) ; 238 242 setDirection( direction, (casa::Float)az, (casa::Float)el ) ; 239 243 240 244 // loop on polarization 241 245 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 250 257 //int numPol = reader_->getNumPol( idata ) ; 251 258 unsigned int numPol = dataShape[0] ; 252 259 unsigned int numChan = dataShape[1] ; 253 260 254 cout << "numPol = " << numPol << endl;261 //logsink_->postLocally( LogMessage("numPol = "+String::toString(numPol),LogOrigin(className_,funcName,WHERE)) ) ; 255 262 256 263 // OPACITY … … 295 302 } 296 303 } 297 298 cout << "filled" << endl ;299 304 300 305 return ; … … 481 486 Vector<casa::Double> antpos ) 482 487 { 488 String funcName = "toJ2000" ; 489 483 490 Vector<casa::Double> azel( 2 ) ; 484 491 azel[0] = az ; … … 491 498 MPosition mp( MVPosition( qantpos ), 492 499 MPosition::ITRF ) ; 493 mp.print( cout) ;500 // mp.print( os_.output() ) ; 494 501 MeasFrame mf( me, mp ) ; 495 502 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,501 503 MDirection::Ref( MDirection::J2000, mf ) ) ; 502 504 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 3 3 4 4 #include <string> 5 6 #include <casa/Logging/LogSinkInterface.h> 5 7 6 8 #include <FillerBase.h> … … 25 27 // get reader object 26 28 casa::CountedPtr<ASDMReader> getReader() { return reader_ ; } ; 29 30 // set logger 31 void setLogger( casa::CountedPtr<casa::LogSinkInterface> &logsink ) ; 27 32 28 33 private: … … 75 80 casa::Record ifrec_ ; 76 81 82 casa::CountedPtr<casa::LogSinkInterface> logsink_ ; 83 84 casa::String className_ ; 85 77 86 } ; 78 87 #endif // ASAP_ASDM_FILLER_H -
trunk/external-alma/asdm2ASAP/ASDMReader.cc
r2197 r2208 8 8 #include <measures/Measures/MeasFrame.h> 9 9 #include <measures/Measures/MeasConvert.h> 10 #include <casa/Logging/LogMessage.h> 10 11 11 12 #include "ASDMReader.h" … … 19 20 // sec to day 20 21 double s2d = 1.0 / 86400.0 ; 21 22 22 23 23 ASDMReader::ASDMReader() … … 28 28 antennaName_( "" ), 29 29 row_(-1), 30 apc_(AP_CORRECTED) 31 { 32 cout << "This is constructor of ASDMReader" << endl ; 33 30 apc_(AP_CORRECTED), 31 className_("ASDMReader") 32 { 34 33 configDescIdList_.resize(0) ; 35 34 feedIdList_.resize(0) ; … … 37 36 mainRow_.resize(0) ; 38 37 ifno_.clear() ; 39 38 corrMode_.reset() ; 39 timeSampling_.reset() ; 40 40 } 41 41 42 42 ASDMReader::~ASDMReader() 43 43 { 44 cout << "This is destructor of ASDMReader" << endl ; 44 close() ; 45 logsink_ = 0 ; 45 46 } 46 47 47 48 bool ASDMReader::open( const string &filename, const casa::Record &rec ) 48 49 { 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 49 60 // parsing ASDM options 50 61 if ( rec.isDefined( "asdm" ) ) { 51 62 casa::Record asdmrec = rec.asRecord( "asdm" ) ; 63 64 // antenna 52 65 if ( asdmrec.isDefined( "antenna" ) ) { 53 66 if ( asdmrec.type( asdmrec.fieldNumber( "antenna" ) ) == casa::TpInt ) { … … 61 74 antennaId_ = 0 ; 62 75 } 76 77 // ATM phase correction 63 78 if ( asdmrec.isDefined( "apc" ) ) { 64 79 if ( asdmrec.asBool( "apc" ) ) … … 67 82 apc_ = AP_UNCORRECTED ; 68 83 } 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) ) ) ; 70 132 } 71 133 … … 73 135 asdm_ = new ASDM() ; 74 136 asdm_->setFromFile( filename ) ; 75 cout << "name = " << asdm_->getName() << endl ;76 137 77 138 if ( antennaId_ == -1 ) { … … 120 181 processStation() ; 121 182 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() ) ) ; 124 185 125 186 return true ; 126 187 } 127 188 128 void ASDMReader::fill()129 {130 }189 // void ASDMReader::fill() 190 // { 191 // } 131 192 132 193 void ASDMReader::close() … … 163 224 casa::String &poltype ) 164 225 { 226 String funcName = "fillHeader" ; 165 227 166 228 ExecBlockTable &ebtab = asdm_->getExecBlock() ; … … 178 240 // <telescopeName>//<antennaName>@stationName 179 241 antennaname = telescopeName + "//" + antennaName_ + "@" + stationName ; 180 cout << "antennaName = " << antennaname << endl;242 //logsink_->postLocally( LogMessage("antennaName = "+antennaname,LogOrigin(className_,funcName,WHERE)) ) ; 181 243 182 244 // antennaposition … … 215 277 nchan = casa::Int( *max_element( nchans.begin(), nchans.end() ) ) ; 216 278 217 cout << "refidx = " << refidx << endl;279 //logsink_->postLocally( LogMessage("refidx = "+String::toString(refidx),LogOrigin(className_,funcName,WHERE)) ) ; 218 280 219 281 // bandwidth … … 232 294 if ( spwrows[refidx]->isMeasFreqRefExists() ) { 233 295 string mfr = CFrequencyReferenceCode::name( spwrows[refidx]->getMeasFreqRef() ) ; 234 cout << "measFreqRef = " << mfr << endl ;235 296 if (mfr == "TOPO") { 236 297 freqref = "TOPOCENT"; … … 336 397 void ASDMReader::selectConfigDescription() 337 398 { 399 String funcName = "selectConfigDescription" ; 400 338 401 vector<ConfigDescriptionRow *> cdrows = asdm_->getConfigDescription().get() ; 339 402 vector<Tag> cdidTags ; 340 403 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)) ) ; 342 405 if ( cdrows[irow]->getCorrelationMode() != CROSS_ONLY ) { 343 406 cdidTags.push_back( cdrows[irow]->getConfigDescriptionId() ) ; … … 370 433 casa::Vector<casa::uInt> ASDMReader::getFieldIdList() 371 434 { 435 String funcName = "getFieldIdList" ; 436 372 437 vector<FieldRow *> frows = asdm_->getField().get() ; 373 438 fieldIdList_.resize( frows.size() ) ; 374 439 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)) ) ; 376 441 fieldIdList_[irow] = frows[irow]->getFieldId().getTagValue() ; 377 442 } … … 389 454 void ASDMReader::select() 390 455 { 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 392 468 EnumSet<AtmPhaseCorrection> esApcs ; 393 // esApcs.set( AP_UNCORRECTED ) ;394 // esApcs.set( AP_CORRECTED ) ;395 469 esApcs.set( apc_ ) ; 396 EnumSet<CorrelationMode> esCorrs ; 397 esCorrs.set( CROSS_AND_AUTO ) ; 398 esCorrs.set( AUTO_ONLY ) ; 470 // always take only autocorrelation data 399 471 Enum<CorrelationMode> esCorr = AUTO_ONLY ; 400 sdmBin_->select( esCorrs ) ;401 472 sdmBin_->selectDataSubset( esCorr, esApcs ) ; 402 473 … … 419 490 status = (casa::Bool)(sdmBin_->acceptMainRow( mainRow_[row_] )) ; 420 491 } 421 cout << "setMainRow: status = " << status << endl ;422 492 return status ; 423 493 } … … 425 495 casa::Bool ASDMReader::setMainRow( casa::uInt configDescId, casa::uInt fieldId ) 426 496 { 427 cout << "setMainRow " << configDescId << " " << fieldId << endl ;428 497 clearMainRow() ; 429 498 … … 431 500 Tag fieldTag( (unsigned int)fieldId, TagType::Field ) ; 432 501 mainRow_ = casa::Vector<MainRow *>( *(asdm_->getMain().getByContext( configDescTag, fieldTag ) ) ) ; 433 434 cout << "mainRow_.size() = " << mainRow_.size() << endl ;435 502 436 503 return true ; … … 444 511 void ASDMReader::setupIFNO() 445 512 { 513 String funcName = "setupIFNO" ; 514 446 515 vector<SpectralWindowRow *> spwrows = asdm_->getSpectralWindow().get() ; 447 516 unsigned int nrow = spwrows.size() ; … … 452 521 casa::uInt index ; 453 522 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)) ) ; 455 524 index = wvridx ; 456 525 } … … 459 528 } 460 529 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)) ) ; 462 531 } 463 532 } … … 473 542 } 474 543 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 // } 518 589 519 590 casa::Bool ASDMReader::setData() 520 591 { 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)) ) ; 522 595 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()) ; 523 606 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)) ) ; 550 635 551 636 dataIdList_.clear() ; … … 557 642 } 558 643 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)) ) ; 576 646 577 647 return true ; … … 604 674 double &incr ) 605 675 { 606 cout << "getFrequency()" << endl ; 676 String funcName = "getFrequency" ; 677 607 678 Tag ddTag( vmsData_->v_dataDescId[dataIdList_[idx]], TagType::DataDescription ) ; 608 679 DataDescriptionRow *ddrow = asdm_->getDataDescription().getRowByKey( ddTag ) ; … … 611 682 int nchan = spwrow->getNumChan() ; 612 683 if ( nchan == 1 ) { 613 cout << "channel averaged data" << endl;684 //logsink_->postLocally( LogMessage("channel averaged data",LogOrigin(className_,funcName,WHERE)) ) ; 614 685 refpix = 0.0 ; 615 686 incr = spwrow->getTotBandwidth().get() ; … … 626 697 else if ( nchan % 2 ) { 627 698 // odd 628 cout << "odd case" << endl;699 //logsink_->postLocally( LogMessage("odd case",LogOrigin(className_,funcName,WHERE)) ) ; 629 700 refpix = 0.5 * ( (double)nchan - 1.0 ) ; 630 701 int ic = ( nchan - 1 ) / 2 ; … … 662 733 else { 663 734 // even 664 cout << "even case" << endl;735 //logsink_->postLocally( LogMessage("even case",LogOrigin(className_,funcName,WHERE)) ) ; 665 736 refpix = 0.5 * ( (double)nchan - 1.0 ) ; 666 737 int ic = nchan / 2 ; … … 697 768 } 698 769 } 699 cout << "finished getFrequency()" << endl ;700 770 } 701 771 702 772 vector<double> ASDMReader::getRestFrequency( unsigned int idx ) 703 773 { 704 cout << "getRestFrequency" << endl ;705 774 vector<double> rf( 0 ) ; 706 775 unsigned int index = dataIdList_[idx] ; … … 713 782 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 714 783 if ( frow->isSourceIdExists() ) { 715 cout << "sourceId exists" << endl;784 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 716 785 int sid = frow->getSourceId() ; 717 786 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; 718 787 if ( srow->isRestFrequencyExists() ) { 719 cout << "restFrequency exists" << endl;788 //logsink_->postLocally( LogMessage("restFrequency exists",LogOrigin(className_,funcName,WHERE)) ) ; 720 789 vector<Frequency> restfreq = srow->getRestFrequency() ; 721 790 rf.resize( restfreq.size() ) ; … … 724 793 } 725 794 } 726 cout << "finished getRestFrequency()" << endl ;727 795 return rf ; 728 796 } … … 751 819 string srcname ; 752 820 if ( frow->isSourceIdExists() ) { 753 cout << "sourceId exists" << endl;821 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 754 822 int sid = frow->getSourceId() ; 755 823 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; … … 846 914 unsigned int ASDMReader::getSubscanNo( unsigned int idx ) 847 915 { 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)) ) ; 850 917 return vmsData_->v_msState[dataIdList_[idx]].subscanNum ; 851 918 } … … 864 931 string srcname ; 865 932 if ( frow->isSourceIdExists() ) { 866 cout << "sourceId exists" << endl;933 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 867 934 int sid = frow->getSourceId() ; 868 935 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; … … 893 960 string srcname ; 894 961 if ( frow->isSourceIdExists() ) { 895 cout << "sourceId exists" << endl;962 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 896 963 int sid = frow->getSourceId() ; 897 964 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; … … 916 983 string srcname ; 917 984 if ( frow->isSourceIdExists() ) { 918 cout << "sourceId exists" << endl;985 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 919 986 int sid = frow->getSourceId() ; 920 987 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; … … 1088 1155 float &windaz ) 1089 1156 { 1090 cout << "getWeatherInfo() start" << endl ;1091 1157 temperature = 0.0 ; 1092 1158 pressure = 0.0 ; … … 1095 1161 windaz = 0.0 ; 1096 1162 1097 cout << "weatherStationId_ = " << weatherStationId_ << endl;1163 //logsink_->postLocally( LogMessage("weatherStationId_ = "+String::toString(weatherStationId_),LogOrigin(className_,funcName,WHERE)) ) ; 1098 1164 1099 1165 WeatherTable &wtab = asdm_->getWeather() ; … … 1105 1171 //Tag sttag = (asdm_->getAntenna().getRowByKey( anttag ))->getStationId() ; 1106 1172 Tag sttag( (unsigned int)weatherStationId_, TagType::Station ) ; 1107 cout << "v_interval=" << vmsData_->v_interval[index] << endl ;1108 1173 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 1109 1174 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 1110 1175 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 1111 cout << "start " << tint.getStartInMJD() << " duration " << tint.getDurationInNanoSeconds() << endl ;1112 1176 //WeatherRow *wrow = wtab.getRowByKey( sttag, tint ) ; 1113 1177 vector<WeatherRow *> *wrows = wtab.getByContext( sttag ) ; 1114 1178 WeatherRow *wrow = (*wrows)[0] ; 1115 1179 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)) ) ; 1117 1181 ArrayTime startTime = tint.getStart() ; 1118 1182 if ( startTime < (*wrows)[0]->getTimeInterval().getStart() ) { … … 1134 1198 wrow = (*wrows)[irow-1] ; 1135 1199 if ( startTime < (*wrows)[irow]->getTimeInterval().getStart() ) { 1136 cout << "irow = " << irow << endl ;1137 1200 temperature = wrow->getTemperature().get() ; 1138 1201 pressure = wrow->getPressure().get() ; … … 1144 1207 } 1145 1208 } 1146 1147 1148 cout << "temperature = " << temperature << endl ; 1149 1150 cout << "getWeatherInfo() end" << endl ; 1209 1151 1210 return ; 1152 1211 } … … 1207 1266 vector<double> &srate ) 1208 1267 { 1209 cout << "getPointingInfo() start" << endl ; 1268 String funcName = "getPointingInfo" ; 1269 1210 1270 dir.resize(0) ; 1211 1271 az = -1.0 ; … … 1223 1283 1224 1284 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)) ) ; 1226 1286 1227 1287 // for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { … … 1230 1290 // ArrayTime pst = ati.getStart() ; 1231 1291 // 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)) ) ; 1234 1294 // } 1235 1295 … … 1259 1319 ArrayTimeInterval pTime1 = (*prows)[nrow-1]->getTimeInterval() ; 1260 1320 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 ) ) ; 1262 1322 prow = (*prows)[0] ; 1263 1323 //vector< vector<Angle> > dirA = prow->getPointingDirection() ; … … 1276 1336 } 1277 1337 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 ) ) ; 1279 1339 prow = (*prows)[nrow-1] ; 1280 1340 int numSample = prow->getNumSample() ; … … 1322 1382 break ; 1323 1383 } 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)) ) ; 1325 1385 if ( row0 == -1 && row1 == -1 ) { 1326 1386 prow = (*prows)[row2] ; … … 1379 1439 prow = (*prows)[row0] ; 1380 1440 qrow = (*prows)[row1] ; 1381 cout << "usePolynomials = " ;1382 cout << prow->getUsePolynomials() << endl ;1383 1441 if ( prow->getUsePolynomials() && qrow->getUsePolynomials() ) { 1384 cout << "usePolynomial = True" << endl;1442 //logsink_->postLocally( LogMessage("usePolynomial = True",LogOrigin(className_,funcName,WHERE)) ) ; 1385 1443 if ( row0 == row1 ) { 1386 1444 prow = (*prows)[row0] ; … … 1437 1495 } 1438 1496 else if ( prow->getUsePolynomials() == qrow->getUsePolynomials() ) { 1439 cout << "numSample == numTerm " << endl;1497 //logsink_->postLocally( LogMessage("numSample == numTerm",LogOrigin(className_,funcName,WHERE)) ) ; 1440 1498 for ( int irow = row0 ; irow <= row1 ; irow++ ) { 1441 1499 prow = (*prows)[irow] ; 1442 1500 int numSample = prow->getNumSample() ; 1443 cout << "numSample = " << numSample << endl;1501 //logsink_->postLocally( LogMessage("numSample = "+String::toString(numSample),LogOrigin(className_,funcName,WHERE)) ) ; 1444 1502 //vector< vector<Angle> > dirA = prow->getPointingDirection() ; 1445 1503 vector< vector<Angle> > dirA = prow->getTarget() ; 1446 1504 vector< vector<Angle> > offA = prow->getOffset() ; 1447 1505 if ( prow->isSampledTimeIntervalExists() ) { 1448 cout << "sampledTimeIntervalExists" << endl;1506 //logsink_->postLocally( LogMessage("sampledTimeIntervalExists",LogOrigin(className_,funcName,WHERE)) ) ; 1449 1507 vector<ArrayTimeInterval> stime = prow->getSampledTimeInterval() ; 1450 1508 for ( int isam = 0 ; isam < numSample ; isam++ ) { … … 1462 1520 double sampleStart = prow->getTimeInterval().getStartInMJD() ; 1463 1521 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)) ) ; 1467 1525 for ( int isam = 0 ; isam < numSample ; isam++ ) { 1468 1526 ArrayTimeInterval stime( sampleStart+isam*sampleInterval, sampleInterval ) ; … … 1477 1535 } 1478 1536 } 1479 cout << "ndir = " << ndir << endl ;1480 1537 } 1481 1538 } … … 1497 1554 for ( int i = 0 ; i < 3 ; i++ ) 1498 1555 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)) ) ; 1502 1558 toJ2000( dir, az, el, tcen, antpos ) ; 1503 1559 1504 1560 } 1505 1561 1506 cout << "getPointingInfo() end" << endl ;1507 1562 return ; 1508 1563 } … … 1529 1584 casa::Vector<casa::Double> antpos ) 1530 1585 { 1586 String funcName = "toJ2000" ; 1587 1531 1588 casa::Vector<casa::Double> azel( 2 ) ; 1532 1589 azel[0] = az ; … … 1539 1596 casa::MPosition mp( casa::MVPosition( qantpos ), 1540 1597 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 1542 1602 casa::MeasFrame mf( me, mp ) ; 1543 1603 casa::MDirection::Convert toj2000( casa::MDirection::AZELGEO, … … 1549 1609 casa::MDirection::Ref( casa::MDirection::J2000, mf ) ) ; 1550 1610 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)) ) ; 1552 1612 dir.resize(2) ; 1553 1613 dir[0] = (double)(cdir[0]) ; 1554 1614 dir[1] = (double)(cdir[1]) ; 1555 1615 } 1616 1617 void ASDMReader::setLogger( CountedPtr<LogSinkInterface> &logsink ) 1618 { 1619 logsink_ = logsink ; 1620 } -
trunk/external-alma/asdm2ASAP/ASDMReader.h
r2197 r2208 7 7 #include <casa/Utilities/CountedPtr.h> 8 8 #include <casa/Containers/Record.h> 9 #include <casa/Logging/LogSinkInterface.h> 9 10 #include <ASDMAll.h> 10 11 #include <SDMBinData.h> … … 35 36 * fill data 36 37 **/ 37 void fill() ;38 // void fill() ; 38 39 39 40 /** … … 121 122 122 123 /** 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_ 124 126 * 125 127 * @param configDescId … … 357 359 * @return list of dataDescId 358 360 **/ 359 casa::Vector<casa::uInt> getDataDescIdList( casa::uInt cdid ) ;361 // casa::Vector<casa::uInt> getDataDescIdList( casa::uInt cdid ) ; 360 362 361 363 /** … … 365 367 * @return list of dataDescId 366 368 **/ 367 casa::Vector<casa::uInt> getSwitchCycleIdList( casa::uInt cdid ) ;369 // casa::Vector<casa::uInt> getSwitchCycleIdList( casa::uInt cdid ) ; 368 370 369 371 /** … … 375 377 * @return list of valid feedId 376 378 **/ 377 casa::Vector<casa::uInt> getFeedIdList( casa::uInt cdid ) ;379 // casa::Vector<casa::uInt> getFeedIdList( casa::uInt cdid ) ; 378 380 379 381 /** … … 390 392 **/ 391 393 unsigned int getNumData() { return numData_ ; } ; 394 395 /** 396 * set Logger 397 * 398 * @param logger (LogSinkInterface) 399 **/ 400 void setLogger( casa::CountedPtr<casa::LogSinkInterface> &logsink ) ; 392 401 393 402 … … 524 533 int weatherStationId_ ; // closest weather station for antennaId_ 525 534 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_ ; 526 539 } ; 527 540 #endif // ASAP_ASDM_READER_H -
trunk/external-alma/asdm2ASAP/asdm2ASAP.cc
r2197 r2208 1 1 #include <iostream> 2 #include <fstream> 2 3 #include <casa/Utilities/Regex.h> 3 4 #include <casa/Inputs/Input.h> … … 5 6 #include <casa/Containers/Record.h> 6 7 #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> 7 12 #include <Scantable.h> 8 13 #include "ASDMFiller.h" … … 18 23 Input inp ; 19 24 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( "" ) ; 22 40 23 41 inp.create( "antenna", "0", "antenna name or id", "String" ) ; 24 42 inp.create( "asdm", "", "ASDM directory name", "String" ) ; 25 43 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" ) ; 28 50 inp.readArguments( argc, argv ) ; 29 51 … … 31 53 string antenna = inp.getString( "antenna" ) ; 32 54 string asapname = inp.getString( "asap" ) ; 33 Bool apcCorrected = inp.getBool( "apc" ) ;55 string apc = inp.getString( "apc" ) ; 34 56 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" ) ; 35 60 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 ; 50 77 } 51 78 else { 52 // antenna is specified as name 53 asdmRec.define( "antenna", antenna ) ; 79 throw AipsError( "Unrecognized value for -apc option" ) ; 54 80 } 55 rec.defineRecord( "asdm", asdmRec ) ; 56 filler->open( asdmname, rec ) ; 81 57 82 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() ; 64 93 } 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 ) ; 65 99 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 ) ; 71 102 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 ) ; 78 115 } 79 116 else { 80 cerr << "Output file " << asapname << " exists." << endl ;81 return 1;117 // antenna is specified as name 118 asdmRec.define( "antenna", antenna ) ; 82 119 } 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 83 179 } 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 ; 97 184 98 185 return 0 ;
Note:
See TracChangeset
for help on using the changeset viewer.