Changeset 2301
- Timestamp:
- 09/16/11 14:02:21 (13 years ago)
- Location:
- trunk/external-alma
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external-alma/asdm2ASAP/ASDMFiller.cc
r2273 r2301 103 103 104 104 // CYCLENO 105 unsigned int cycleno = 0 ; 105 //unsigned int cycleno = 0 ; 106 map< unsigned int, unsigned int > cycleno ; 107 map< unsigned int, unsigned int >::iterator citer ; 106 108 107 109 for ( unsigned int ifield = 0 ; ifield < numFieldId ; ifield++ ) { … … 130 132 131 133 // scan and subscan 132 unsigned int scanno = reader_->getScanNo() ; 134 //unsigned int scanno = reader_->getScanNo() ; 135 unsigned int scanno = reader_->getScanNoOfCurrentRow() ; 133 136 //uInt subscanno = reader_->getSubscanNo() ; 137 citer = cycleno.find( scanno ) ; 138 if ( citer == cycleno.end() ) 139 cycleno[scanno] = 0 ; 134 140 135 141 // set data … … 147 153 148 154 for ( unsigned int idata = 0 ; idata < numData ; idata++ ) { 155 // prepare to extract binary data 156 reader_->prepareData( idata ) ; 149 157 150 158 // subscan number 151 unsigned int subscanno = reader_->getSubscanNo( idata ) ; 159 //unsigned int subscanno = reader_->getSubscanNo( idata ) ; 160 unsigned int subscanno = reader_->getSubscanNo() ; 152 161 153 162 // IFNO 154 uInt ifno = reader_->getIFNo( idata ) ; 155 156 // rest frequency 157 vector<double> rf = reader_->getRestFrequency( idata ) ; 163 //uInt ifno = reader_->getIFNo( idata ) ; 164 uInt ifno = reader_->getIFNo() ; 165 166 // source spec 167 int srctype = reader_->getSrcType( scanno, subscanno ) ; 168 string srcname ; 169 string fieldname ; 170 vector<double> srcDirection ; 171 vector<double> srcProperMotion ; 172 double sysVel ; 173 vector<double> rf ; 174 //reader_->getSourceProperty( idata, 175 // srcname, 176 // fieldname, 177 // srcDirection, 178 // srcProperMotion, 179 // sysVel, 180 // rf ) ; 181 reader_->getSourceProperty( srcname, 182 fieldname, 183 srcDirection, 184 srcProperMotion, 185 sysVel, 186 rf ) ; 158 187 159 188 // fill MOLECULE_ID and add MOLECULES row if necessary … … 164 193 165 194 // time and interval 166 casa::Double mjd = (casa::Double)(reader_->getTime( idata )) ; 167 casa::Double interval = (casa::Double)(reader_->getInterval( idata )) ; 195 //casa::Double mjd = (casa::Double)(reader_->getTime( idata )) ; 196 //casa::Double interval = (casa::Double)(reader_->getInterval( idata )) ; 197 casa::Double mjd = (casa::Double)(reader_->getTime()) ; 198 casa::Double interval = (casa::Double)(reader_->getInterval()) ; 168 199 169 200 // fill TIME and INTERVAL 170 201 setTime( mjd, interval ) ; 171 172 173 // source spec174 string srcname = reader_->getSourceName( idata ) ;175 string fieldname = reader_->getFieldName( idata ) ;176 int srctype = reader_->getSrcType( scanno, subscanno ) ;177 vector<double> srcDirection = reader_->getSourceDirection( idata ) ;178 //vector<double> srcDirection ;179 //string srcDirRef ;180 //reader_->getSourceDirection( idata, srcDirection, srcDirRef ) ;181 vector<double> srcProperMotion = reader_->getSourceProperMotion( idata ) ;182 double sysVel = reader_->getSysVel( idata ) ;183 202 184 203 // fill SRCNAME, SRCTYPE, FIELDNAME, SRCDIRECTION, SRCPROPERMOTION, and SRCVELOCITY … … 192 211 193 212 // fill FLAGROW 194 unsigned int flagrow = reader_->getFlagRow( idata ) ; 213 //unsigned int flagrow = reader_->getFlagRow( idata ) ; 214 unsigned int flagrow = reader_->getFlagRow() ; 195 215 setFlagrow( (uInt)flagrow ) ; 196 216 … … 201 221 float windspeed ; 202 222 float windaz ; 203 reader_->getWeatherInfo( idata, 204 temperature, 223 //reader_->getWeatherInfo( idata, 224 // temperature, 225 // pressure, 226 // humidity, 227 // windspeed, 228 // windaz ) ; 229 reader_->getWeatherInfo( temperature, 205 230 pressure, 206 231 humidity, … … 218 243 double el ; 219 244 vector<double> srate ; 220 reader_->getPointingInfo( idata, 221 dir, 245 //reader_->getPointingInfo( idata, 246 // dir, 247 // az, 248 // el, 249 // srate ) ; 250 reader_->getPointingInfo( dir, 222 251 az, 223 252 el, … … 246 275 } 247 276 else { 248 reader_->getFrequency( idata, refpix, refval, incr, freqref ) ; 277 //reader_->getFrequency( idata, refpix, refval, incr, freqref ) ; 278 reader_->getFrequency( refpix, refval, incr, freqref ) ; 249 279 refval = (double)toLSRK( casa::Double(refval), 250 280 String(freqref), … … 261 291 262 292 // loop on polarization 263 vector<unsigned int> dataShape = reader_->getDataShape( idata ) ; 293 //vector<unsigned int> dataShape = reader_->getDataShape( idata ) ; 294 vector<unsigned int> dataShape = reader_->getDataShape() ; 264 295 // ostringstream oss ; 265 296 // for ( unsigned int i = 0 ; i < dataShape.size() ; i++ ) { … … 280 311 281 312 // OPACITY 282 vector<float> tau = reader_->getOpacity( idata ) ; 313 //vector<float> tau = reader_->getOpacity( idata ) ; 314 vector<float> tau = reader_->getOpacity() ; 283 315 Vector<casa::Float> opacity = toVector( tau, numPol ) ; 284 316 285 317 // SPECTRA, FLAGTRA, TSYS, TCAL 286 float *sp = reader_->getSpectrum( idata ) ; 318 //float *sp = reader_->getSpectrum( idata ) ; 319 float *sp = reader_->getSpectrum() ; 287 320 vector< vector<float> > ts ; 288 321 vector< vector<float> > tc ; 289 reader_->getTcalAndTsys( idata, tc, ts ) ; 322 //reader_->getTcalAndTsys( idata, tc, ts ) ; 323 reader_->getTcalAndTsys( tc, ts ) ; 290 324 Matrix<casa::Float> spectra = toMatrix( sp, numPol, numChan ) ; 291 325 Vector<uChar> flagtra( numChan, 0 ) ; … … 300 334 301 335 // fill SCANNO, CYCLENO, IFNO, POLNO, and BEAMNO 302 setIndex( (uInt)scanno-1, (uInt)cycleno , ifno, ipol, beamno ) ;336 setIndex( (uInt)scanno-1, (uInt)cycleno[scanno], ifno, ipol, beamno ) ; 303 337 304 338 // fill SPECTRA, FLAGTRA, TSYS … … 316 350 317 351 // increment CYCLENO 318 cycleno ++ ;352 cycleno[scanno]++ ; 319 353 } 320 354 } -
trunk/external-alma/asdm2ASAP/ASDMReader.cc
r2299 r2301 1 1 #include <iostream> 2 2 #include <sstream> 3 #include "limits.h" 4 #include "float.h" 3 5 4 6 #include <measures/Measures/MEpoch.h> … … 28 30 antennaId_( -1 ), 29 31 antennaName_( "" ), 32 stationName_( "" ), 30 33 row_(-1), 31 34 apc_(AP_CORRECTED), 32 className_("ASDMReader") 35 className_("ASDMReader"), 36 dataIndex_( UINT_MAX ), 37 //antennaRow_p( 0 ), 38 //stationRow_p( 0 ), 39 specWinRow_p( 0 ), 40 polarizationRow_p( 0 ), 41 fieldRow_p( 0 ) 33 42 { 34 43 configDescIdList_.resize(0) ; … … 166 175 // create ASDM object 167 176 asdm_ = new ASDM() ; 168 // avoid unwanted message to stdout169 //ostringstream oss ;170 //streambuf *buforg = cout.rdbuf(oss.rdbuf()) ;171 177 asdm_->setFromFile( filename ) ; 172 //cout.rdbuf(buforg) ; 173 178 179 AntennaTable &atab = asdm_->getAntenna() ; 180 AntennaRow *antennaRow ; 174 181 if ( antennaId_ == -1 ) { 175 AntennaTable &atab = asdm_->getAntenna() ;176 182 vector<AntennaRow *> rows = atab.get() ; 177 183 int idx = -1 ; … … 189 195 antennaId_ = idx ; 190 196 } 191 } 197 antennaTag_ = Tag( antennaId_, TagType::Antenna ) ; 198 antennaRow = rows[antennaId_] ; 199 } 200 else { 201 antennaTag_ = Tag( antennaId_, TagType::Antenna ) ; 202 antennaRow = atab.getRowByKey( antennaTag_ ) ; 203 if ( antennaRow == 0 ) { 204 close() ; 205 throw (casa::AipsError( "AntennaId " + casa::String::toString(antennaId_) + " is invalid." ) ) ; 206 } 207 } 208 192 209 193 210 // set antenna name 194 211 if ( antennaName_.size() == 0 ) { 195 AntennaTable &atab = asdm_->getAntenna() ; 196 Tag tag( antennaId_, TagType::Antenna ) ; 197 AntennaRow *arow = atab.getRowByKey( tag ) ; 198 if ( arow == 0 ) { 199 close() ; 200 throw (casa::AipsError( tag.toString() + " not found." )) ; 201 } 202 else { 203 antennaName_ = casa::String( arow->getName() ) ; 204 } 205 } 212 antennaName_ = casa::String( antennaRow->getName() ) ; 213 } 214 215 // get Station row 216 StationRow *stationRow = antennaRow->getStationUsingStationId() ; 217 218 // station name 219 stationName_ = casa::String( stationRow->getName() ) ; 220 221 // antenna position 222 antennaPosition_.resize( 3 ) ; 223 vector<Length> antpos = stationRow->getPosition() ; 224 for ( casa::uInt i = 0 ; i < 3 ; i++ ) 225 antennaPosition_[i] = Quantity( casa::Double( antpos[i].get() ), Unit( "m" ) ) ; 206 226 207 227 // create SDMBinData object … … 266 286 ExecBlockRow *ebrow = ebtab.get()[0] ; 267 287 casa::String telescopeName( ebrow->getTelescopeName() ) ; 268 AntennaTable &atab = asdm_->getAntenna() ; 269 AntennaRow *arow = atab.getRowByKey( Tag( antennaId_, TagType::Antenna ) ) ; 270 //StationTable &stab = asdm_->getStation() ; 271 //StationRow *srow = stab.getRowByKey( arow->getStationId() ) ; 272 StationRow *srow = arow->getStationUsingStationId() ; 273 casa::String stationName( srow->getName() ) ; 288 //casa::String stationName( stationRow_p->getName() ) ; 274 289 275 290 // antennaname 276 291 // <telescopeName>//<antennaName>@stationName 277 antennaname = telescopeName + "//" + antennaName_ + "@" + stationName ;292 antennaname = telescopeName + "//" + antennaName_ + "@" + stationName_ ; 278 293 //logsink_->postLocally( LogMessage("antennaName = "+antennaname,LogOrigin(className_,funcName,WHERE)) ) ; 279 294 280 295 // antennaposition 281 //vector<Length> antpos = arow->getPosition() ;282 vector<Length> antpos = srow->getPosition() ;283 296 antennaposition.resize( 3 ) ; 284 297 for ( casa::uInt i = 0 ; i < 3 ; i++ ) 285 antennaposition[i] = casa::Double( antpos[i].get() ) ;298 antennaposition[i] = antennaPosition_[i].getValue( Unit("m") ) ; 286 299 287 300 // observer … … 521 534 casa::Bool status = true ; 522 535 row_ = irow ; 536 execBlockTag_ = mainRow_[row_]->getExecBlockId() ; 523 537 524 538 unsigned int cdid = mainRow_[row_]->getConfigDescriptionId().getTagValue() ; … … 579 593 return false ; 580 594 } 581 582 // casa::Vector<casa::uInt> ASDMReader::getDataDescIdList( casa::uInt cdid )583 // {584 // Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;585 // ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;586 // vector<Tag> ddTags = cdrow->getDataDescriptionId() ;587 // casa::Vector<casa::uInt> ddidList( ddTags.size() ) ;588 // for ( unsigned int idd = 0 ; idd < ddTags.size() ; idd++ ) {589 // ddidList[idd] = ddTags[idd].getTagValue() ;590 // }591 // return ddidList ;592 // }593 594 // casa::Vector<casa::uInt> ASDMReader::getSwitchCycleIdList( casa::uInt cdid )595 // {596 // Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;597 // ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;598 // vector<Tag> scTags = cdrow->getSwitchCycleId() ;599 // casa::Vector<casa::uInt> scidList( scTags.size() ) ;600 // for ( unsigned int idd = 0 ; idd < scTags.size() ; idd++ ) {601 // scidList[idd] = scTags[idd].getTagValue() ;602 // }603 // return scidList ;604 // }605 606 // casa::Vector<casa::uInt> ASDMReader::getFeedIdList( casa::uInt cdid )607 // {608 // casa::String funcName = "getFeedIdList" ;609 //610 // Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;611 // ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;612 // casa::Vector<casa::uInt> feedIdList ;613 // vector<int> feedIds = cdrow->getFeedId() ;614 // for ( unsigned int ife = 0 ; ife < feedIds.size() ; ife++ ) {615 // logsink_->postLocally( LogMessage("feedIds["+String::toString(ife)+"]="+String::toString(feedIds[ife]),LogOrigin(className_,funcName,WHERE)) ) ;616 // if ( casa::anyEQ( feedIdList, casa::uInt( feedIds[ife] ) ) )617 // continue ;618 // if ( casa::anyEQ( feedIdList_, casa::uInt( feedIds[ife] ) ) ) {619 // casa::uInt oldsize = feedIdList.size() ;620 // feedIdList.resize( oldsize+1, true ) ;621 // feedIdList[oldsize] = casa::uInt( feedIds[ife] ) ;622 // }623 // }624 // logsink_->postLocally( LogMessage("feedIdList.size() = "+String::toString(feedIdList.size()),LogOrigin(className_,funcName,WHERE)) ) ;625 // return feedIdList ;626 // }627 595 628 596 casa::Bool ASDMReader::setData() … … 686 654 } 687 655 656 void ASDMReader::prepareData( unsigned int idx ) 657 { 658 unsigned int i = dataIdList_[idx] ; 659 if ( i != dataIndex_ ) { 660 dataIndex_ = dataIdList_[idx] ; 661 Tag dataDescTag( vmsData_->v_dataDescId[dataIndex_], TagType::DataDescription ) ; 662 DataDescriptionRow *dataDescRow = asdm_->getDataDescription().getRowByKey( dataDescTag ) ; 663 specWinTag_ = dataDescRow->getSpectralWindowId() ; 664 specWinRow_p = dataDescRow->getSpectralWindowUsingSpectralWindowId() ; 665 polarizationRow_p = dataDescRow->getPolarizationUsingPolOrHoloId() ; 666 Tag fieldTag( vmsData_->v_fieldId[dataIndex_], TagType::Field ) ; 667 fieldRow_p = asdm_->getField().getRowByKey( fieldTag ) ; 668 double startSec = vmsData_->v_time[dataIndex_] - 0.5 * vmsData_->v_interval[dataIndex_] ; 669 timeInterval_ = ArrayTimeInterval( startSec*s2d, vmsData_->v_interval[dataIndex_]*s2d ) ; 670 } 671 } 672 688 673 casa::uInt ASDMReader::getIFNo( unsigned int idx ) 689 674 { 690 Tag ddTag( vmsData_->v_dataDescId[dataIdList_[idx]], TagType::DataDescription ) ; 691 DataDescriptionRow *ddrow = asdm_->getDataDescription().getRowByKey( ddTag ) ; 692 Tag spwid = ddrow->getSpectralWindowId() ; 693 map<Tag,casa::uInt>::iterator iter = ifno_.find( spwid ) ; 675 prepareData( idx ) ; 676 return getIFNo() ; 677 } 678 679 casa::uInt ASDMReader::getIFNo() 680 { 681 map<Tag,casa::uInt>::iterator iter = ifno_.find( specWinTag_ ) ; 694 682 if ( iter != ifno_.end() ) 695 683 return iter->second ; … … 701 689 int ASDMReader::getNumPol( unsigned int idx ) 702 690 { 703 Tag ddTag( vmsData_->v_dataDescId[dataIdList_[idx]], TagType::DataDescription ) ; 704 DataDescriptionRow *ddrow = asdm_->getDataDescription().getRowByKey( ddTag ) ; 705 PolarizationRow *polrow = ddrow->getPolarizationUsingPolOrHoloId() ; 706 return polrow->getNumCorr() ; 691 prepareData( idx ) ; 692 return getNumPol() ; 693 } 694 695 int ASDMReader::getNumPol() 696 { 697 return polarizationRow_p->getNumCorr() ; 707 698 } 708 699 … … 713 704 string &freqref ) 714 705 { 706 prepareData( idx ) ; 707 getFrequency( refpix, refval, incr, freqref ) ; 708 } 709 710 void ASDMReader::getFrequency( double &refpix, 711 double &refval, 712 double &incr, 713 string &freqref ) 714 { 715 715 casa::String funcName = "getFrequency" ; 716 716 717 Tag ddTag( vmsData_->v_dataDescId[dataIdList_[idx]], TagType::DataDescription ) ; 718 DataDescriptionRow *ddrow = asdm_->getDataDescription().getRowByKey( ddTag ) ; 719 //Tag spwid = ddrow->getSpectralWindowId() ; 720 SpectralWindowRow *spwrow = ddrow->getSpectralWindowUsingSpectralWindowId() ; 721 int nchan = spwrow->getNumChan() ; 717 int nchan = specWinRow_p->getNumChan() ; 722 718 freqref = "TOPO" ; 723 if ( sp wrow->isMeasFreqRefExists() )724 freqref = CFrequencyReferenceCode::toString( sp wrow->getMeasFreqRef() ) ;719 if ( specWinRow_p->isMeasFreqRefExists() ) 720 freqref = CFrequencyReferenceCode::toString( specWinRow_p->getMeasFreqRef() ) ; 725 721 if ( nchan == 1 ) { 726 722 //logsink_->postLocally( LogMessage("channel averaged data",LogOrigin(className_,funcName,WHERE)) ) ; 727 723 refpix = 0.0 ; 728 incr = sp wrow->getTotBandwidth().get() ;729 if ( sp wrow->isChanFreqStartExists() ) {730 refval = sp wrow->getChanFreqStart().get() ;731 } 732 else if ( sp wrow->isChanFreqArrayExists() ) {733 refval = sp wrow->getChanFreqArray()[0].get() ;724 incr = specWinRow_p->getTotBandwidth().get() ; 725 if ( specWinRow_p->isChanFreqStartExists() ) { 726 refval = specWinRow_p->getChanFreqStart().get() ; 727 } 728 else if ( specWinRow_p->isChanFreqArrayExists() ) { 729 refval = specWinRow_p->getChanFreqArray()[0].get() ; 734 730 } 735 731 else { … … 742 738 refpix = 0.5 * ( (double)nchan - 1.0 ) ; 743 739 int ic = ( nchan - 1 ) / 2 ; 744 if ( sp wrow->isChanWidthExists() ) {745 incr = sp wrow->getChanWidth().get() ;746 } 747 else if ( sp wrow->isChanWidthArrayExists() ) {748 incr = sp wrow->getChanWidthArray()[0].get() ;740 if ( specWinRow_p->isChanWidthExists() ) { 741 incr = specWinRow_p->getChanWidth().get() ; 742 } 743 else if ( specWinRow_p->isChanWidthArrayExists() ) { 744 incr = specWinRow_p->getChanWidthArray()[0].get() ; 749 745 } 750 746 else { 751 747 throw (casa::AipsError( "Either chanWidthArray or chanWidth must exist." )) ; 752 748 } 753 if ( sp wrow->isChanFreqStepExists() ) {754 if ( sp wrow->getChanFreqStep().get() < 0.0 )749 if ( specWinRow_p->isChanFreqStepExists() ) { 750 if ( specWinRow_p->getChanFreqStep().get() < 0.0 ) 755 751 incr *= -1.0 ; 756 752 } 757 else if ( sp wrow->isChanFreqArrayExists() ) {758 vector<Frequency> chanFreqArr = sp wrow->getChanFreqArray() ;753 else if ( specWinRow_p->isChanFreqArrayExists() ) { 754 vector<Frequency> chanFreqArr = specWinRow_p->getChanFreqArray() ; 759 755 if ( chanFreqArr[0].get() > chanFreqArr[1].get() ) 760 756 incr *= -1.0 ; … … 763 759 throw (casa::AipsError( "Either chanFreqArray or chanFreqStep must exist." )) ; 764 760 } 765 if ( sp wrow->isChanFreqStartExists() ) {766 refval = sp wrow->getChanFreqStart().get() + refpix * incr ;767 } 768 else if ( sp wrow->isChanFreqArrayExists() ) {769 refval = sp wrow->getChanFreqArray()[ic].get() ;761 if ( specWinRow_p->isChanFreqStartExists() ) { 762 refval = specWinRow_p->getChanFreqStart().get() + refpix * incr ; 763 } 764 else if ( specWinRow_p->isChanFreqArrayExists() ) { 765 refval = specWinRow_p->getChanFreqArray()[ic].get() ; 770 766 } 771 767 else { … … 778 774 refpix = 0.5 * ( (double)nchan - 1.0 ) ; 779 775 int ic = nchan / 2 ; 780 if ( sp wrow->isChanWidthExists() ) {781 incr = sp wrow->getChanWidth().get() ;782 } 783 else if ( sp wrow->isChanWidthArrayExists() ) {784 incr = sp wrow->getChanWidthArray()[0].get() ;776 if ( specWinRow_p->isChanWidthExists() ) { 777 incr = specWinRow_p->getChanWidth().get() ; 778 } 779 else if ( specWinRow_p->isChanWidthArrayExists() ) { 780 incr = specWinRow_p->getChanWidthArray()[0].get() ; 785 781 } 786 782 else { 787 783 throw (casa::AipsError( "Either chanWidthArray or chanWidth must exist." )) ; 788 784 } 789 if ( sp wrow->isChanFreqStepExists() ) {790 if ( sp wrow->getChanFreqStep().get() < 0.0 )785 if ( specWinRow_p->isChanFreqStepExists() ) { 786 if ( specWinRow_p->getChanFreqStep().get() < 0.0 ) 791 787 incr *= -1.0 ; 792 788 } 793 else if ( sp wrow->isChanFreqArrayExists() ) {794 vector<Frequency> chanFreqArr = sp wrow->getChanFreqArray() ;789 else if ( specWinRow_p->isChanFreqArrayExists() ) { 790 vector<Frequency> chanFreqArr = specWinRow_p->getChanFreqArray() ; 795 791 if ( chanFreqArr[0].get() > chanFreqArr[1].get() ) 796 792 incr *= -1.0 ; … … 799 795 throw (casa::AipsError( "Either chanFreqArray or chanFreqStep must exist." )) ; 800 796 } 801 if ( sp wrow->isChanFreqStartExists() ) {802 refval = sp wrow->getChanFreqStart().get() + refpix * incr ;803 } 804 else if ( sp wrow->isChanFreqArrayExists() ) {805 vector<Frequency> freqs = sp wrow->getChanFreqArray() ;797 if ( specWinRow_p->isChanFreqStartExists() ) { 798 refval = specWinRow_p->getChanFreqStart().get() + refpix * incr ; 799 } 800 else if ( specWinRow_p->isChanFreqArrayExists() ) { 801 vector<Frequency> freqs = specWinRow_p->getChanFreqArray() ; 806 802 refval = 0.5 * ( freqs[ic-1].get() + freqs[ic].get() ) ; 807 803 } … … 812 808 } 813 809 814 vector<double> ASDMReader::getRestFrequency( unsigned int idx ) 815 { 816 vector<double> rf( 0 ) ; 817 unsigned int index = dataIdList_[idx] ; 818 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 819 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 820 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 821 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 822 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 823 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ; 824 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 825 if ( frow->isSourceIdExists() ) { 826 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 827 int sid = frow->getSourceId() ; 828 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; 810 double ASDMReader::getTime( unsigned int idx ) 811 { 812 prepareData( idx ) ; 813 return getTime() ; 814 } 815 816 double ASDMReader::getTime() 817 { 818 double tsec = vmsData_->v_time[dataIndex_] ; 819 return tsec * s2d ; 820 } 821 822 double ASDMReader::getInterval( unsigned int idx ) 823 { 824 prepareData( idx ) ; 825 return getInterval() ; 826 } 827 828 double ASDMReader::getInterval() 829 { 830 return vmsData_->v_interval[dataIndex_] ; 831 } 832 833 void ASDMReader::getSourceProperty( unsigned int idx, 834 string &srcname, 835 string &fieldname, 836 vector<double> &srcdir, 837 vector<double> &srcpm, 838 double &sysvel, 839 vector<double> &restfreq ) 840 { 841 prepareData( idx ) ; 842 getSourceProperty( srcname, fieldname, srcdir, srcpm, sysvel, restfreq ) ; 843 } 844 845 void ASDMReader::getSourceProperty( string &srcname, 846 string &fieldname, 847 vector<double> &srcdir, 848 vector<double> &srcpm, 849 double &sysvel, 850 vector<double> &restfreq ) 851 { 852 ostringstream oss ; 853 oss << fieldRow_p->getFieldName() << "__" << vmsData_->v_fieldId[dataIndex_] ; 854 fieldname = oss.str() ; 855 if ( fieldRow_p->isSourceIdExists() ) { 856 int sourceId = fieldRow_p->getSourceId() ; 857 SourceRow *srow = asdm_->getSource().getRowByKey( sourceId, timeInterval_, specWinTag_ ) ; 858 859 // source name 860 srcname = srow->getSourceName() ; 861 862 // source direction 863 vector<Angle> srcdirA = srow->getDirection() ; 864 srcdir.resize( 2 ) ; 865 srcdir[0] = limitedAngle( srcdirA[0].get() ) ; 866 srcdir[1] = limitedAngle( srcdirA[1].get() ) ; 867 if ( srow->isDirectionCodeExists() ) { 868 DirectionReferenceCode dircode = srow->getDirectionCode() ; 869 //logsink_->postLocally( LogMessage("dircode="+CDirectionReferenceCode::toString(dircode),LogOrigin(className_,funcName,WHERE)) ) ; 870 if ( dircode != J2000 ) { 871 // if not J2000, need direction conversion 872 String ref( CDirectionReferenceCode::toString( dircode ) ) ; 873 double mjd = vmsData_->v_time[dataIndex_] * s2d ; 874 srcdir = toJ2000( srcdir, ref, mjd, antennaPosition_ ) ; 875 } 876 } 877 878 // source proper motion 879 srcpm.resize( 2 ) ; 880 vector<AngularRate> srcpmA = srow->getProperMotion() ; 881 srcpm[0] = srcpmA[0].get() ; 882 srcpm[1] = srcpmA[1].get() ; 883 884 // systemic velocity 885 if ( srow->isSysVelExists() ) { 886 vector<Speed> sysvelV = srow->getSysVel() ; 887 if ( sysvelV.size() > 0 ) 888 sysvel = sysvelV[0].get() ; 889 } 890 else { 891 sysvel = 0.0 ; 892 } 893 894 // rest frequency 829 895 if ( srow->isRestFrequencyExists() ) { 830 896 //logsink_->postLocally( LogMessage("restFrequency exists",LogOrigin(className_,funcName,WHERE)) ) ; 831 vector<Frequency> r estfreq= srow->getRestFrequency() ;832 r f.resize( restfreq.size() ) ;897 vector<Frequency> rf = srow->getRestFrequency() ; 898 restfreq.resize( rf.size() ) ; 833 899 for ( unsigned int i = 0 ; i < restfreq.size() ; i++ ) 834 rf[i] = restfreq[i].get() ; 835 } 836 } 837 return rf ; 838 } 839 840 double ASDMReader::getTime( unsigned int idx ) 841 { 842 double tsec = vmsData_->v_time[dataIdList_[idx]] ; 843 return tsec * s2d ; 844 } 845 846 double ASDMReader::getInterval( unsigned int idx ) 847 { 848 return vmsData_->v_interval[dataIdList_[idx]] ; 849 } 850 851 string ASDMReader::getSourceName( unsigned int idx ) 852 { 853 unsigned int index = dataIdList_[idx] ; 854 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 855 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 856 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 857 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 858 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 859 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ; 860 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 861 string srcname ; 862 if ( frow->isSourceIdExists() ) { 863 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 864 int sid = frow->getSourceId() ; 865 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; 866 srcname = srow->getSourceName() ; 900 restfreq[i] = rf[i].get() ; 901 } 902 else { 903 restfreq.resize( 0 ) ; 904 } 867 905 } 868 906 else { 869 srcname = frow->getFieldName() ; 870 } 871 return srcname ; 872 } 873 874 string ASDMReader::getFieldName( unsigned int idx ) 875 { 876 int fid = vmsData_->v_fieldId[dataIdList_[idx]] ; 877 Tag ftag( fid, TagType::Field ) ; 878 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 879 ostringstream oss ; 880 oss << frow->getFieldName() << "__" << fid ; 881 return oss.str() ; 907 srcname = fieldRow_p->getFieldName() ; 908 srcdir.resize( 2 ) ; 909 srcdir[0] = 0.0 ; 910 srcdir[1] = 0.0 ; 911 srcpm = srcdir ; 912 sysvel = 0.0 ; 913 restfreq.resize( 0 ) ; 914 } 882 915 } 883 916 … … 886 919 { 887 920 int srctype = SrcType::NOTYPE ; 888 Tag ebtag = mainRow_[row_]->getExecBlockId() ; 889 ScanRow *scanrow = asdm_->getScan().getRowByKey( ebtag, (int)scan ) ; 921 ScanRow *scanrow = asdm_->getScan().getRowByKey( execBlockTag_, (int)scan ) ; 890 922 ScanIntent scanIntent = scanrow->getScanIntent()[0] ; 891 SubscanRow *subrow = asdm_->getSubscan().getRowByKey( e btag, (int)scan, (int)subscan ) ;923 SubscanRow *subrow = asdm_->getSubscan().getRowByKey( execBlockTag_, (int)scan, (int)subscan ) ; 892 924 SubscanIntent subIntent = subrow->getSubscanIntent() ; 893 925 SwitchingMode swmode = NO_SWITCHING ; … … 997 1029 unsigned int ASDMReader::getSubscanNo( unsigned int idx ) 998 1030 { 1031 prepareData( idx ) ; 1032 return getSubscanNo() ; 1033 } 1034 1035 unsigned int ASDMReader::getSubscanNo() 1036 { 999 1037 //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)) ) ; 1000 return vmsData_->v_msState[dataIdList_[idx]].subscanNum ; 1001 } 1002 1003 vector<double> ASDMReader::getSourceDirection( unsigned int idx ) 1004 { 1005 vector<double> dir( 2, 0.0 ) ; 1006 unsigned int index = dataIdList_[idx] ; 1007 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 1008 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 1009 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 1010 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 1011 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 1012 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ; 1013 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 1014 string srcname ; 1015 if ( frow->isSourceIdExists() ) { 1016 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 1017 int sid = frow->getSourceId() ; 1018 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; 1019 vector<Angle> srcdir = srow->getDirection() ; 1020 dir[0] = limitedAngle( srcdir[0].get() ) ; 1021 dir[1] = limitedAngle( srcdir[1].get() ) ; 1022 if ( srow->isDirectionCodeExists() ) { 1023 DirectionReferenceCode dircode = srow->getDirectionCode() ; 1024 //logsink_->postLocally( LogMessage("dircode="+CDirectionReferenceCode::toString(dircode),LogOrigin(className_,funcName,WHERE)) ) ; 1025 if ( dircode != J2000 ) { 1026 // if not J2000, need direction conversion 1027 string ref = CDirectionReferenceCode::toString( dircode ) ; 1028 double mjd = vmsData_->v_time[index] * s2d ; 1029 Tag atag( antennaId_, TagType::Antenna ) ; 1030 AntennaRow *arow = asdm_->getAntenna().getRowByKey( atag ) ; 1031 StationRow *srow = arow->getStationUsingStationId() ; 1032 vector<Length> antposL = srow->getPosition() ; 1033 casa::Vector<casa::Double> antpos( 3 ) ; 1034 for ( int i = 0 ; i < 3 ; i++ ) 1035 antpos[i] = antposL[i].get() ; 1036 dir = toJ2000( dir, ref, mjd, antpos ) ; 1037 } 1038 } 1039 } 1040 return dir ; 1041 } 1042 1043 void ASDMReader::getSourceDirection( unsigned int idx, 1044 vector<double> &dir, 1045 string &ref ) 1046 { 1047 dir.resize( 2 ) ; 1048 dir[0] = 0.0 ; 1049 dir[1] = 0.0 ; 1050 ref = "J2000" ; 1051 unsigned int index = dataIdList_[idx] ; 1052 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 1053 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 1054 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 1055 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 1056 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 1057 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ; 1058 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 1059 string srcname ; 1060 if ( frow->isSourceIdExists() ) { 1061 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 1062 int sid = frow->getSourceId() ; 1063 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; 1064 vector<Angle> srcdir = srow->getDirection() ; 1065 if ( srow->isDirectionCodeExists() ) { 1066 ref = CDirectionReferenceCode::toString( srow->getDirectionCode() ) ; 1067 } 1068 dir[0] = limitedAngle( srcdir[0].get() ) ; 1069 dir[1] = limitedAngle( srcdir[1].get() ) ; 1070 } 1038 return vmsData_->v_msState[dataIndex_].subscanNum ; 1071 1039 } 1072 1040 … … 1085 1053 } 1086 1054 1087 vector<double> ASDMReader::getSourceProperMotion( unsigned int idx )1088 {1089 vector<double> pm( 2, 0.0 ) ;1090 unsigned int index = dataIdList_[idx] ;1091 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ;1092 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;1093 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;1094 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ;1095 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ;1096 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ;1097 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ;1098 string srcname ;1099 if ( frow->isSourceIdExists() ) {1100 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ;1101 int sid = frow->getSourceId() ;1102 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ;1103 vector<AngularRate> srcpm = srow->getProperMotion() ;1104 pm[0] = srcpm[0].get() ;1105 pm[1] = srcpm[1].get() ;1106 }1107 return pm ;1108 }1109 1110 double ASDMReader::getSysVel( unsigned int idx )1111 {1112 double sysvel = 0.0 ;1113 unsigned int index = dataIdList_[idx] ;1114 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ;1115 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;1116 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;1117 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ;1118 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ;1119 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ;1120 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ;1121 string srcname ;1122 if ( frow->isSourceIdExists() ) {1123 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ;1124 int sid = frow->getSourceId() ;1125 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ;1126 if ( srow->isSysVelExists() ) {1127 vector<Speed> sysvelV = srow->getSysVel() ;1128 if ( sysvelV.size() > 0 )1129 sysvel = sysvelV[0].get() ;1130 }1131 }1132 return sysvel ;1133 }1134 1135 1055 unsigned int ASDMReader::getFlagRow( unsigned int idx ) 1136 1056 { 1137 return vmsData_->v_flag[dataIdList_[idx]] ; 1057 prepareData( idx ) ; 1058 return getFlagRow() ; 1059 } 1060 1061 unsigned int ASDMReader::getFlagRow() 1062 { 1063 return vmsData_->v_flag[dataIndex_] ; 1138 1064 } 1139 1065 1140 1066 vector<unsigned int> ASDMReader::getDataShape( unsigned int idx ) 1141 1067 { 1142 return vmsData_->vv_dataShape[dataIdList_[idx]] ; 1068 prepareData( idx ) ; 1069 return getDataShape() ; 1070 } 1071 1072 vector<unsigned int> ASDMReader::getDataShape() 1073 { 1074 return vmsData_->vv_dataShape[dataIndex_] ; 1143 1075 } 1144 1076 1145 1077 float * ASDMReader::getSpectrum( unsigned int idx ) 1146 1078 { 1147 map<AtmPhaseCorrection, float*> data = vmsData_->v_m_data[dataIdList_[idx]] ; 1079 prepareData( idx ) ; 1080 return getSpectrum() ; 1081 } 1082 1083 float * ASDMReader::getSpectrum() 1084 { 1085 map<AtmPhaseCorrection, float*> data = vmsData_->v_m_data[dataIndex_] ; 1148 1086 //map<AtmPhaseCorrection, float*>::iterator iter = data.find(AP_UNCORRECTED) ; 1149 1087 map<AtmPhaseCorrection, float*>::iterator iter = data.find(apc_) ; … … 1152 1090 } 1153 1091 1154 // bool * ASDMReader::getFlagChannel( unsigned int idx )1155 // {1156 // return 0 ;1157 // }1158 1159 1092 vector< vector<float> > ASDMReader::getTsys( unsigned int idx ) 1160 1093 { 1094 prepareData( idx ) ; 1095 return getTsys() ; 1096 } 1097 1098 vector< vector<float> > ASDMReader::getTsys() 1099 { 1161 1100 vector< vector<float> > defaultTsys( 1, vector<float>( 1, 1.0 ) ) ; 1162 SysCalRow *scrow = getSysCalRow( idx) ;1101 SysCalRow *scrow = getSysCalRow() ; 1163 1102 if ( scrow != 0 && scrow->isTsysSpectrumExists() ) { 1164 1103 vector< vector<Temperature> > tsysSpec = scrow->getTsysSpectrum() ; … … 1188 1127 vector< vector<float> > ASDMReader::getTcal( unsigned int idx ) 1189 1128 { 1129 prepareData( idx ) ; 1130 return getTcal() ; 1131 } 1132 1133 vector< vector<float> > ASDMReader::getTcal() 1134 { 1190 1135 vector< vector<float> > defaultTcal( 1, vector<float>( 1, 1.0 ) ) ; 1191 SysCalRow *scrow = getSysCalRow( idx) ;1136 SysCalRow *scrow = getSysCalRow() ; 1192 1137 if ( scrow != 0 && scrow->isTcalSpectrumExists() ) { 1193 1138 vector< vector<Temperature> > tcalSpec = scrow->getTcalSpectrum() ; … … 1219 1164 vector< vector<float> > &tsys ) 1220 1165 { 1166 prepareData( idx ) ; 1167 getTcalAndTsys( tcal, tsys ) ; 1168 } 1169 1170 void ASDMReader::getTcalAndTsys( vector< vector<float> > &tcal, 1171 vector< vector<float> > &tsys ) 1172 { 1221 1173 String funcName = "getTcalAndTsys" ; 1222 1174 1223 1175 vector< vector<float> > defaultT( 1, vector<float>( 1, 1.0 ) ) ; 1224 SysCalRow *scrow = getSysCalRow( idx) ;1176 SysCalRow *scrow = getSysCalRow() ; 1225 1177 if ( scrow == 0 ) { 1226 1178 tcal = defaultT ; … … 1263 1215 vector<float> ASDMReader::getOpacity( unsigned int idx ) 1264 1216 { 1217 prepareData( idx ) ; 1218 return getOpacity() ; 1219 } 1220 1221 vector<float> ASDMReader::getOpacity() 1222 { 1265 1223 vector<float> tau(0) ; 1266 1224 CalAtmosphereTable &atmtab = asdm_->getCalAtmosphere() ; 1267 1225 unsigned int nrow = atmtab.size() ; 1268 1226 if ( nrow > 0 ) { 1269 unsigned int index = dataIdList_[idx] ;1270 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ;1271 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;1272 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;1273 1227 //int feedid = vmsData_->v_feedId1[index] ; 1274 //Tag atag( antennaId_, TagType::Antenna ) ;1275 //Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ;1276 //DataDescriptionRow *ddrow = asdm_->getDataDescription().getRowByKey(ddtag) ;1277 //Tag spwtag = ddrow->getSpectralWindowId() ;1278 //SpectralWindowRow *spwrow = ddrow->getSpectralWindowUsingSpectralWindowId() ;1279 1228 //BasebandName bbname = spwrow->getBasebandName() ; 1280 1229 //FeedRow *frow = asdm_->getFeed().getRowByKey( atag, spwtag, tint, feedid ) ; … … 1284 1233 //ReceiverBand rb = rrows[0]->getFrequencyBand() ; 1285 1234 int row0 = -1 ; 1286 double eps = tint.getStart().getMJD();1235 double eps = DBL_MAX ; 1287 1236 for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { 1288 1237 CalAtmosphereRow *atmrow = atmrows[irow] ; … … 1293 1242 continue ; 1294 1243 else { 1295 double dt = ti nt.getStart().getMJD() - atmrow->getEndValidTime().getMJD() ;1244 double dt = timeInterval_.getStart().getMJD() - atmrow->getEndValidTime().getMJD() ; 1296 1245 if ( dt >= 0 && dt < eps ) { 1297 1246 eps = dt ; … … 1319 1268 float &windaz ) 1320 1269 { 1270 prepareData( idx ) ; 1271 getWeatherInfo( temperature, pressure, humidity, windspeed, windaz ) ; 1272 } 1273 1274 void ASDMReader::getWeatherInfo( float &temperature, 1275 float &pressure, 1276 float &humidity, 1277 float &windspeed, 1278 float &windaz ) 1279 { 1321 1280 casa::String funcName = "getWeatherInfo" ; 1322 1281 … … 1333 1292 return ; 1334 1293 1335 unsigned int index = dataIdList_[idx] ;1336 //Tag anttag( antennaId_, TagType::Antenna ) ;1337 //Tag sttag = (asdm_->getAntenna().getRowByKey( anttag ))->getStationId() ;1338 1294 Tag sttag( (unsigned int)weatherStationId_, TagType::Station ) ; 1339 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ;1340 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;1341 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;1342 1295 //WeatherRow *wrow = wtab.getRowByKey( sttag, tint ) ; 1343 1296 vector<WeatherRow *> *wrows = wtab.getByContext( sttag ) ; … … 1345 1298 unsigned int nrow = wrows->size() ; 1346 1299 //logsink_->postLocally( LogMessage("There are "+String::toString(nrow)+" rows for given context: stationId "+String::toString(weatherStationId_),LogOrigin(className_,funcName,WHERE)) ) ; 1347 ArrayTime startTime = getMidTime( ti nt) ;1300 ArrayTime startTime = getMidTime( timeInterval_ ) ; 1348 1301 if ( startTime < (*wrows)[0]->getTimeInterval().getStart() ) { 1349 1302 temperature = (*wrows)[0]->getTemperature().get() ; … … 1405 1358 return -1 ; 1406 1359 1407 Tag atag( antennaId_, TagType::Antenna ) ;1408 Tag stag = (asdm_->getAntenna().getRowByKey( atag ))->getStationId() ;1409 1360 vector<double> apos( 3 ) ; 1410 1361 StationTable &stab = asdm_->getStation() ; 1411 StationRow *srow = stab.getRowByKey( stag ) ; 1412 vector<Length> pos = srow->getPosition() ; 1413 apos[0] = pos[0].get() ; 1414 apos[1] = pos[1].get() ; 1415 apos[2] = pos[2].get() ; 1362 apos[0] = antennaPosition_[0].getValue( Unit("m") ) ; 1363 apos[1] = antennaPosition_[1].getValue( Unit("m") ) ; 1364 apos[2] = antennaPosition_[2].getValue( Unit("m") ) ; 1416 1365 1417 double eps = 1.0e20;1366 double eps = DBL_MAX ; 1418 1367 int retval = -1 ; 1419 1368 for ( unsigned int ir = 0 ; ir < weatherStation_.size() ; ir++ ) { 1420 srow = stab.getRowByKey( weatherStation_[ir] ) ;1369 StationRow *srow = stab.getRowByKey( weatherStation_[ir] ) ; 1421 1370 vector<Length> wpos = srow->getPosition() ; 1422 1371 double dist = (apos[0]-wpos[0].get())*(apos[0]-wpos[0].get()) … … 1437 1386 vector<double> &srate ) 1438 1387 { 1388 prepareData( idx ) ; 1389 getPointingInfo( dir, az, el, srate ) ; 1390 } 1391 1392 void ASDMReader::getPointingInfo( vector<double> &dir, 1393 double &az, 1394 double &el, 1395 vector<double> &srate ) 1396 { 1439 1397 String funcName = "getPointingInfo" ; 1440 1398 … … 1444 1402 srate.resize(0) ; 1445 1403 1446 Tag atag( antennaId_, TagType::Antenna ) ; 1447 unsigned int index = dataIdList_[idx] ; 1448 vector<PointingRow *> *prows = asdm_->getPointing().getByContext( atag ) ; 1404 //Tag atag( antennaId_, TagType::Antenna ) ; 1405 //unsigned int index = dataIdList_[idx] ; 1406 //vector<PointingRow *> *prows = asdm_->getPointing().getByContext( atag ) ; 1407 vector<PointingRow *> *prows = asdm_->getPointing().getByContext( antennaTag_ ) ; 1449 1408 1450 1409 if ( prows == 0 ) … … 1454 1413 PointingRow *qrow ; 1455 1414 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 1456 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;1457 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;1415 //double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 1416 //ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 1458 1417 1459 1418 unsigned int nrow = prows->size() ; … … 1475 1434 el = 0.0 ; 1476 1435 //double tcen = 0.0 ; 1477 double tcen = getMidTime( tint ).getMJD() ; 1436 //double tcen = getMidTime( tint ).getMJD() ; 1437 double tcen = getMidTime( timeInterval_ ).getMJD() ; 1478 1438 1479 1439 // … … 1492 1452 ArrayTimeInterval pTime1 = (*prows)[nrow-1]->getTimeInterval() ; 1493 1453 //if ( tint.getStartInMJD()+tint.getDurationInDays() < pTime0.getStartInMJD() ) { 1494 if ( getEndTime( tint ) < getStartTime( pTime0 ) ) { 1454 //if ( getEndTime( tint ) < getStartTime( pTime0 ) ) { 1455 if ( getEndTime( timeInterval_ ) < getStartTime( pTime0 ) ) { 1495 1456 logsink_->postLocally( LogMessage( "ArrayTimeInterval out of bounds: no data for given position (tint < ptime)", LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; 1496 1457 prow = (*prows)[0] ; … … 1504 1465 } 1505 1466 //else if ( tint.getStartInMJD() > pTime1.getStartInMJD()+pTime1.getDurationInDays() ) { 1506 else if ( getStartTime( tint ) > getEndTime( pTime1 ) ) { 1467 //else if ( getStartTime( tint ) > getEndTime( pTime1 ) ) { 1468 else if ( getStartTime( timeInterval_ ) > getEndTime( pTime1 ) ) { 1507 1469 logsink_->postLocally( LogMessage( "ArrayTimeInterval out of bounds: no data for given position (tint > ptime)", LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; 1508 1470 prow = (*prows)[nrow-1] ; … … 1523 1485 } 1524 1486 else { 1525 ArrayTime startTime = tint.getStart() ; 1526 ArrayTime endTime = getEndTime( tint ) ; 1487 //ArrayTime startTime = tint.getStart() ; 1488 //ArrayTime endTime = getEndTime( tint ) ; 1489 ArrayTime startTime = timeInterval_.getStart() ; 1490 ArrayTime endTime = getEndTime( timeInterval_ ) ; 1527 1491 int row0 = -1 ; 1528 1492 int row1 = -1 ; 1529 1493 int row2 = -1 ; 1530 double dt0 = getMidTime( tint ).getMJD() ; 1494 //double dt0 = getMidTime( tint ).getMJD() ; 1495 double dt0 = getMidTime( timeInterval_ ).getMJD() ; 1531 1496 for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { 1532 1497 prow = (*prows)[irow] ; 1533 double dt = getMidTime( tint ).getMJD() - getMidTime( prow->getTimeInterval() ).getMJD() ; 1498 //double dt = getMidTime( tint ).getMJD() - getMidTime( prow->getTimeInterval() ).getMJD() ; 1499 double dt = getMidTime( timeInterval_ ).getMJD() - getMidTime( prow->getTimeInterval() ).getMJD() ; 1534 1500 if ( dt > 0 && dt < dt0 ) { 1535 1501 dt0 = dt ; … … 1636 1602 for ( int isam = 0 ; isam < numSample ; isam++ ) { 1637 1603 //if ( tint.overlaps( stime[isam] ) ) { 1638 if ( tint.contains( stime[isam] ) ) { 1604 //if ( tint.contains( stime[isam] ) ) { 1605 if ( timeInterval_.contains( stime[isam] ) ) { 1639 1606 az += dirA[isam][0] ; 1640 1607 el += dirA[isam][1] ; … … 1653 1620 ArrayTimeInterval stime( sampleStart+isam*sampleInterval, sampleInterval ) ; 1654 1621 //if ( tint.overlaps( stime ) ) { 1655 if ( tint.contains( stime ) ) { 1622 //if ( tint.contains( stime ) ) { 1623 if ( timeInterval_.contains( stime ) ) { 1656 1624 az += dirA[isam][0] ; 1657 1625 el += dirA[isam][1] ; … … 1673 1641 } 1674 1642 1675 AntennaRow *arow = asdm_->getAntenna().getRowByKey( Tag( antennaId_, TagType::Antenna ) ) ; 1676 StationRow *srow = arow->getStationUsingStationId() ; 1677 vector<Length> antposL = srow->getPosition() ; 1678 casa::Vector<casa::Double> antpos( 3 ) ; 1679 for ( int i = 0 ; i < 3 ; i++ ) 1680 antpos[i] = antposL[i].get() ; 1681 //logsink_->postLocally( LogMessage("tcen = "+String::toString(tcen),LogOrigin(className_,funcName,WHERE)) ) ; 1682 //logsink_->postLocally( LogMessage("antpos = "+String::toString(antpos),LogOrigin(className_,funcName,WHERE)) ) ; 1683 toJ2000( dir, az, el, tcen, antpos ) ; 1684 1643 toJ2000( dir, az, el, tcen, antennaPosition_ ) ; 1685 1644 } 1686 1645 … … 1704 1663 1705 1664 void ASDMReader::toJ2000( vector<double> &dir, 1706 double az, 1707 double el, 1708 double mjd, 1709 casa::Vector<casa::Double> antpos ) 1665 double &az, 1666 double &el, 1667 double &mjd, 1668 casa::Vector<casa::Quantity> &antpos ) 1669 // casa::Vector<casa::Double> antpos ) 1710 1670 { 1711 1671 String funcName = "toJ2000" ; 1712 1672 1673 String ref = "AZELGEO" ; 1713 1674 vector<double> azel( 2 ) ; 1714 1675 azel[0] = az ; 1715 1676 azel[1] = el ; 1716 dir = toJ2000( azel, "AZELGEO", mjd, antpos ) ; 1717 } 1718 1719 vector<double> ASDMReader::toJ2000( vector<double> dir, 1720 casa::String dirref, 1721 double mjd, 1722 casa::Vector<casa::Double> antpos ) 1677 dir = toJ2000( azel, ref, mjd, antpos ) ; 1678 } 1679 1680 vector<double> ASDMReader::toJ2000( vector<double> &dir, 1681 casa::String &dirref, 1682 double &mjd, 1683 casa::Vector<casa::Quantity> &antpos ) 1684 // casa::Vector<casa::Double> antpos ) 1723 1685 { 1724 1686 casa::String funcName = "toJ2000" ; … … 1727 1689 if ( dirref != "J2000" ) { 1728 1690 casa::MEpoch me( casa::Quantity( (casa::Double)mjd, "d" ), casa::MEpoch::UTC ) ; 1729 casa::Vector<casa::Quantity> qantpos( 3 ) ; 1730 qantpos[0] = casa::Quantity( antpos[0], "m" ) ; 1731 qantpos[1] = casa::Quantity( antpos[1], "m" ) ; 1732 qantpos[2] = casa::Quantity( antpos[2], "m" ) ; 1733 casa::MPosition mp( casa::MVPosition( qantpos ), 1691 casa::MPosition mp( casa::MVPosition( antpos ), 1734 1692 casa::MPosition::ITRF ) ; 1735 1693 //ostringstream oss ; … … 1827 1785 SysCalRow *ASDMReader::getSysCalRow( unsigned int idx ) 1828 1786 { 1787 prepareData( idx ) ; 1788 return getSysCalRow() ; 1789 } 1790 1791 SysCalRow *ASDMReader::getSysCalRow() 1792 { 1829 1793 String funcName = "getSysCalRow" ; 1830 1794 1831 1795 SysCalRow *row = 0 ; 1832 unsigned int index = dataIdList_[idx] ; 1833 Tag anttag( antennaId_, TagType::Antenna ) ; 1834 int feedid = vmsData_->v_feedId1[index] ; 1835 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 1836 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 1837 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 1838 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 1839 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 1840 //int nchan = asdm_->getSpectralWindow().getRowByKey(spwtag)->getNumChan() ; 1841 vector< vector<float> > defaultTsys( 1, vector<float>( 1, 1.0 ) ) ; 1796 int feedid = vmsData_->v_feedId1[dataIndex_] ; 1842 1797 SysCalTable &sctab = asdm_->getSysCal() ; 1843 //vector<SysCalRow *> rows = sctab.get() ; 1844 vector<SysCalRow *> *rows = sctab.getByContext( anttag, spwtag, feedid ) ; 1798 vector<SysCalRow *> *rows = sctab.getByContext( antennaTag_, specWinTag_, feedid ) ; 1845 1799 //if ( nrow == 0 ) { 1846 1800 if ( rows == 0 ) { … … 1855 1809 scindex = 0 ; 1856 1810 } 1857 else if ( getEndTime( ti nt) <= getStartTime( (*rows)[0]->getTimeInterval() ) )1811 else if ( getEndTime( timeInterval_ ) <= getStartTime( (*rows)[0]->getTimeInterval() ) ) 1858 1812 scindex = 0 ; 1859 1813 else { 1860 1814 for ( unsigned int irow = 0 ; irow < nrow-1 ; irow++ ) { 1861 ArrayTime t = getMidTime( ti nt) ;1815 ArrayTime t = getMidTime( timeInterval_ ) ; 1862 1816 if ( t > getStartTime( (*rows)[irow]->getTimeInterval() ) 1863 1817 && t <= getStartTime( (*rows)[irow+1]->getTimeInterval() ) ) { -
trunk/external-alma/asdm2ASAP/ASDMReader.h
r2254 r2301 143 143 * @return scan number 144 144 **/ 145 unsigned int getScanNo () { return (unsigned int)(mainRow_[row_]->getScanNumber()) ; } ;145 unsigned int getScanNoOfCurrentRow() { return (unsigned int)(mainRow_[row_]->getScanNumber()) ; } ; 146 146 147 147 /** … … 150 150 * @return subscan number 151 151 **/ 152 unsigned int getSubscanNo() { return (unsigned int)(mainRow_[row_]->getSubscanNumber()) ; } ; 152 unsigned int getSubscanNoOfCurrentRow() { return (unsigned int)(mainRow_[row_]->getSubscanNumber()) ; } ; 153 154 /** 155 * set data index 156 * 157 * @param idx for vmsData_ 158 **/ 159 void prepareData( unsigned int idx ) ; 153 160 154 161 /** … … 159 166 **/ 160 167 unsigned int getSubscanNo( unsigned int idx ) ; 168 unsigned int getSubscanNo() ; 161 169 162 170 /** … … 167 175 **/ 168 176 casa::uInt getIFNo( unsigned int idx ) ; 177 casa::uInt getIFNo() ; 169 178 170 179 /** … … 175 184 **/ 176 185 int getNumPol( unsigned int idx ) ; 186 int getNumPol() ; 177 187 178 188 /** … … 190 200 double &incr, 191 201 std::string &freqref ) ; 192 193 /** 194 * get rest frequencies for given index 195 * 196 * @param idx for vmsData_ 197 * @return rest frequencies 198 **/ 199 vector<double> getRestFrequency( unsigned int idx ) ; 202 void getFrequency( double &refpix, 203 double &refval, 204 double &incr, 205 std::string &freqref ) ; 200 206 201 207 /** … … 206 212 **/ 207 213 double getTime( unsigned int idx ) ; 214 double getTime() ; 208 215 209 216 /** … … 214 221 **/ 215 222 double getInterval( unsigned int idx ) ; 216 217 /** 218 * get source name for given index 219 * 220 * @param idx for vmsData_ 221 * @return source name 222 **/ 223 string getSourceName( unsigned int idx ) ; 224 225 /** 226 * get field name for given index 227 * field name = fieldName + "__" + fieldId 228 * 229 * @param idx for vmsData_ 230 * @return field name 231 **/ 232 string getFieldName( unsigned int idx ) ; 233 234 /** 235 * get source direction for given index 236 * 237 * @param idx for vmsData_ 238 * @return source direction as vector<double> 239 **/ 240 std::vector<double> getSourceDirection( unsigned int idx ) ; 241 void getSourceDirection( unsigned int idx, 242 std::vector<double> &dir, 243 std::string &ref ) ; 223 double getInterval() ; 244 224 245 225 /** … … 253 233 254 234 /** 255 * get source proper motion for given index256 *257 * @param idx for vmsData_258 * @return source proper motion as vector<double>259 **/260 std::vector<double> getSourceProperMotion( unsigned int idx ) ;261 262 /**263 * get systemic velocity of the source for given index264 * at the moment return 0-th element of sysVel vector265 *266 * @param idx for vmsData_267 * @return systemic velocity of the source268 **/269 double getSysVel( unsigned int idx ) ;270 271 /**272 235 * get row-based flag for given index 273 236 * … … 276 239 **/ 277 240 unsigned int getFlagRow( unsigned int idx ) ; 241 unsigned int getFlagRow() ; 278 242 279 243 /** … … 284 248 **/ 285 249 std::vector<unsigned int> getDataShape( unsigned int idx ) ; 250 std::vector<unsigned int> getDataShape() ; 286 251 287 252 /** … … 292 257 **/ 293 258 float *getSpectrum( unsigned int idx ) ; 294 295 /** 296 * get channel flag data for given index 297 * 298 * @param idx for vmsData_ 299 * @return channel flag 300 **/ 301 //bool *getFlagChannel( unsigned int idx ) ; 259 float *getSpectrum() ; 260 261 /** 262 * get Tsys for given index 263 * 264 * @param idx for vmsData_ 265 * @return Tsys 266 **/ 267 std::vector< std::vector<float> > getTsys( unsigned int idx ) ; 268 std::vector< std::vector<float> > getTsys() ; 302 269 303 270 /** 304 * get Tsys for given index305 *306 * @param idx for vmsData_307 * @return Tsys308 **/309 std::vector< std::vector<float> > getTsys( unsigned int idx ) ;310 311 /**312 271 * get Tcal for given index 313 272 * … … 316 275 **/ 317 276 std::vector< std::vector<float> > getTcal( unsigned int idx ) ; 277 std::vector< std::vector<float> > getTcal() ; 318 278 319 279 /** … … 327 287 std::vector< std::vector<float> > &tcal, 328 288 std::vector< std::vector<float> > &tsys ) ; 289 void getTcalAndTsys( std::vector< std::vector<float> > &tcal, 290 std::vector< std::vector<float> > &tsys ) ; 329 291 330 292 /** … … 335 297 **/ 336 298 std::vector<float> getOpacity( unsigned int idx ) ; 299 std::vector<float> getOpacity() ; 337 300 338 301 /** … … 352 315 float &windspeed, 353 316 float &windaz ) ; 317 void getWeatherInfo( float &temperature, 318 float &pressure, 319 float &humidity, 320 float &windspeed, 321 float &windaz ) ; 354 322 355 323 /** … … 367 335 double &el, 368 336 std::vector<double> &srate ) ; 337 void getPointingInfo( std::vector<double> &dir, 338 double &az, 339 double &el, 340 std::vector<double> &srate ) ; 369 341 370 342 /** … … 379 351 380 352 /** 381 * get list of dataDescId for given configDescId 382 * 383 * @param configDescId 384 * @return list of dataDescId 385 **/ 386 // casa::Vector<casa::uInt> getDataDescIdList( casa::uInt cdid ) ; 387 388 /** 389 * get list of switchCycleId for given configDescId 390 * 391 * @param configDescId 392 * @return list of dataDescId 393 **/ 394 // casa::Vector<casa::uInt> getSwitchCycleIdList( casa::uInt cdid ) ; 395 396 /** 397 * get list of feedId for given configDescId 398 * 399 * only return list of feedId that corresponds to specified antenna. 400 * 401 * @param configDescId 402 * @return list of valid feedId 403 **/ 404 // casa::Vector<casa::uInt> getFeedIdList( casa::uInt cdid ) ; 353 * get source properties 354 * 355 * @param idx for vmsData_ 356 * @param srcname source name 357 * @param fieldname field name 358 * @param srcdir source direction 359 * @param srcpm source proper motion 360 * @param sysvel systemic velocity of the source 361 * @param restfreq rest frequency 362 **/ 363 void getSourceProperty( unsigned int idx, 364 std::string &srcname, 365 std::string &fieldname, 366 std::vector<double> &srcdir, 367 std::vector<double> &srcpm, 368 double &sysvel, 369 std::vector<double> &restfreq ) ; 370 void getSourceProperty( std::string &srcname, 371 std::string &fieldname, 372 std::vector<double> &srcdir, 373 std::vector<double> &srcpm, 374 double &sysvel, 375 std::vector<double> &restfreq ) ; 405 376 406 377 /** … … 516 487 **/ 517 488 void toJ2000( std::vector<double> &dir, 518 double az,519 double el,520 double mjd,521 casa::Vector<casa:: Double>antpos ) ;489 double &az, 490 double &el, 491 double &mjd, 492 casa::Vector<casa::Quantity> &antpos ) ; 522 493 523 494 /** … … 530 501 * @return new direction 531 502 **/ 532 std::vector<double> toJ2000( std::vector<double> dir,533 casa::String dirref,534 double mjd,535 casa::Vector<casa:: Double>antpos ) ;503 std::vector<double> toJ2000( std::vector<double> &dir, 504 casa::String &dirref, 505 double &mjd, 506 casa::Vector<casa::Quantity> &antpos ) ; 536 507 /** 537 508 * get nIF … … 548 519 **/ 549 520 asdm::SysCalRow *getSysCalRow( unsigned int idx ) ; 521 asdm::SysCalRow *getSysCalRow() ; 550 522 551 523 /** … … 595 567 * vector< unsigned int > v_flag 596 568 **/ 597 const sdmbin::VMSData *vmsData_ ; 569 const sdmbin::VMSData *vmsData_ ; 570 598 571 casa::Int antennaId_ ; // antenna id 599 572 casa::String antennaName_ ; // antenna name 600 casa::Vector<asdm::MainRow *> mainRow_ ; // list of pointers to all Main rows 573 casa::String stationName_ ; // station name 574 casa::Vector<casa::Quantity> antennaPosition_ ; // antenna position 601 575 casa::Vector<casa::uInt> configDescIdList_ ; // list of valid configDescriptionId 602 576 casa::Vector<casa::uInt> feedIdList_ ; // list of valid feedId … … 615 589 casa::CountedPtr<casa::LogSinkInterface> logsink_ ; // Logger 616 590 casa::String className_ ; 591 unsigned int dataIndex_ ; 592 593 // Tables/Rows for ASDM 594 casa::Vector<asdm::MainRow *> mainRow_ ; // list of pointers to all Main rows 595 //asdm::AntennaRow *antennaRow_p ; // pointer to target Antenna row 596 //asdm::StationRow *stationRow_p ; // pointer to target Station row that target antenna is located 597 asdm::SpectralWindowRow *specWinRow_p ; // pointer to SpectralWindow row 598 asdm::PolarizationRow *polarizationRow_p ; // pointer to Polarization row 599 asdm::FieldRow *fieldRow_p ; // pointer to Field row 600 601 // Tags 602 asdm::Tag antennaTag_ ; 603 asdm::Tag specWinTag_ ; 604 asdm::Tag execBlockTag_ ; 605 606 // time 607 asdm::ArrayTimeInterval timeInterval_ ; 617 608 } ; 618 609 #endif // ASAP_ASDM_READER_H -
trunk/external-alma/oldasdm2ASAP/OldASDMFiller.cc
r2273 r2301 103 103 104 104 // CYCLENO 105 unsigned int cycleno = 0 ; 105 //unsigned int cycleno = 0 ; 106 map< unsigned int, unsigned int > cycleno ; 107 map< unsigned int, unsigned int >::iterator citer ; 106 108 107 109 for ( unsigned int ifield = 0 ; ifield < numFieldId ; ifield++ ) { … … 125 127 if ( !(reader_->setMainRow( irow )) ) { 126 128 // skip row since the row doesn't have valid configDescId 127 //logsink_->postLocally( LogMessage("skip "+String::toString(irow) ,LogOrigin(className_,funcName,WHERE)) ) ;129 //logsink_->postLocally( LogMessage("skip "+String::toString(irow)+" since OldASDMReader::setMainrow() returns False",LogOrigin(className_,funcName,WHERE)) ) ; 128 130 continue ; 129 131 } 130 132 131 133 // scan and subscan 132 unsigned int scanno = reader_->getScanNo() ; 134 //unsigned int scanno = reader_->getScanNo() ; 135 unsigned int scanno = reader_->getScanNoOfCurrentRow() ; 133 136 //uInt subscanno = reader_->getSubscanNo() ; 137 citer = cycleno.find( scanno ) ; 138 if ( citer == cycleno.end() ) 139 cycleno[scanno] = 0 ; 134 140 135 141 // set data 136 142 if ( !(reader_->setData()) ) { 137 143 // skip row since reader failed to retrieve data 138 //logsink_->postLocally( LogMessage("skip "+String::toString(irow) ,LogOrigin(className_,funcName,WHERE)) ) ;144 //logsink_->postLocally( LogMessage("skip "+String::toString(irow)+" since OldASDMReader::setData() returns False",LogOrigin(className_,funcName,WHERE)) ) ; 139 145 continue ; 140 146 } … … 147 153 148 154 for ( unsigned int idata = 0 ; idata < numData ; idata++ ) { 155 // prepare to extract binary data 156 reader_->prepareData( idata ) ; 149 157 150 158 // subscan number 151 unsigned int subscanno = reader_->getSubscanNo( idata ) ; 159 //unsigned int subscanno = reader_->getSubscanNo( idata ) ; 160 unsigned int subscanno = reader_->getSubscanNo() ; 152 161 153 162 // IFNO 154 uInt ifno = reader_->getIFNo( idata ) ; 155 156 // rest frequency 157 vector<double> rf = reader_->getRestFrequency( idata ) ; 163 //uInt ifno = reader_->getIFNo( idata ) ; 164 uInt ifno = reader_->getIFNo() ; 165 166 // source spec 167 int srctype = reader_->getSrcType( scanno, subscanno ) ; 168 string srcname ; 169 string fieldname ; 170 vector<double> srcDirection ; 171 vector<double> srcProperMotion ; 172 double sysVel ; 173 vector<double> rf ; 174 //reader_->getSourceProperty( idata, 175 // srcname, 176 // fieldname, 177 // srcDirection, 178 // srcProperMotion, 179 // sysVel, 180 // rf ) ; 181 reader_->getSourceProperty( srcname, 182 fieldname, 183 srcDirection, 184 srcProperMotion, 185 sysVel, 186 rf ) ; 158 187 159 188 // fill MOLECULE_ID and add MOLECULES row if necessary … … 164 193 165 194 // time and interval 166 casa::Double mjd = (casa::Double)(reader_->getTime( idata )) ; 167 casa::Double interval = (casa::Double)(reader_->getInterval( idata )) ; 195 //casa::Double mjd = (casa::Double)(reader_->getTime( idata )) ; 196 //casa::Double interval = (casa::Double)(reader_->getInterval( idata )) ; 197 casa::Double mjd = (casa::Double)(reader_->getTime()) ; 198 casa::Double interval = (casa::Double)(reader_->getInterval()) ; 168 199 169 200 // fill TIME and INTERVAL 170 201 setTime( mjd, interval ) ; 171 172 173 // source spec174 string srcname = reader_->getSourceName( idata ) ;175 string fieldname = reader_->getFieldName( idata ) ;176 int srctype = reader_->getSrcType( scanno, subscanno ) ;177 vector<double> srcDirection = reader_->getSourceDirection( idata ) ;178 //vector<double> srcDirection ;179 //string srcDirRef ;180 //reader_->getSourceDirection( idata, srcDirection, srcDirRef ) ;181 vector<double> srcProperMotion = reader_->getSourceProperMotion( idata ) ;182 double sysVel = reader_->getSysVel( idata ) ;183 202 184 203 // fill SRCNAME, SRCTYPE, FIELDNAME, SRCDIRECTION, SRCPROPERMOTION, and SRCVELOCITY … … 192 211 193 212 // fill FLAGROW 194 unsigned int flagrow = reader_->getFlagRow( idata ) ; 213 //unsigned int flagrow = reader_->getFlagRow( idata ) ; 214 unsigned int flagrow = reader_->getFlagRow() ; 195 215 setFlagrow( (uInt)flagrow ) ; 196 216 … … 201 221 float windspeed ; 202 222 float windaz ; 203 reader_->getWeatherInfo( idata, 204 temperature, 223 //reader_->getWeatherInfo( idata, 224 // temperature, 225 // pressure, 226 // humidity, 227 // windspeed, 228 // windaz ) ; 229 reader_->getWeatherInfo( temperature, 205 230 pressure, 206 231 humidity, … … 218 243 double el ; 219 244 vector<double> srate ; 220 reader_->getPointingInfo( idata, 221 dir, 245 //reader_->getPointingInfo( idata, 246 // dir, 247 // az, 248 // el, 249 // srate ) ; 250 reader_->getPointingInfo( dir, 222 251 az, 223 252 el, … … 246 275 } 247 276 else { 248 reader_->getFrequency( idata, refpix, refval, incr, freqref ) ; 277 //reader_->getFrequency( idata, refpix, refval, incr, freqref ) ; 278 reader_->getFrequency( refpix, refval, incr, freqref ) ; 249 279 refval = (double)toLSRK( casa::Double(refval), 250 280 String(freqref), … … 261 291 262 292 // loop on polarization 263 vector<unsigned int> dataShape = reader_->getDataShape( idata ) ; 293 //vector<unsigned int> dataShape = reader_->getDataShape( idata ) ; 294 vector<unsigned int> dataShape = reader_->getDataShape() ; 264 295 // ostringstream oss ; 265 296 // for ( unsigned int i = 0 ; i < dataShape.size() ; i++ ) { … … 271 302 // oss << dataShape[i] << ", " ; 272 303 // } 273 //logsink_->postLocally( LogMessage(oss.str(),LogOrigin(className_,funcName,WHERE)) ) ;304 //logsink_->postLocally( LogMessage(oss.str(),LogOrigin(className_,funcName,WHERE)) ) ; 274 305 275 306 //int numPol = reader_->getNumPol( idata ) ; … … 280 311 281 312 // OPACITY 282 vector<float> tau = reader_->getOpacity( idata ) ; 313 //vector<float> tau = reader_->getOpacity( idata ) ; 314 vector<float> tau = reader_->getOpacity() ; 283 315 Vector<casa::Float> opacity = toVector( tau, numPol ) ; 284 316 285 317 // SPECTRA, FLAGTRA, TSYS, TCAL 286 float *sp = reader_->getSpectrum( idata ) ; 287 //vector< vector<float> > ts = reader_->getTsys( idata ) ; 288 //vector< vector<float> > tc = reader_->getTcal( idata ) ; 318 //float *sp = reader_->getSpectrum( idata ) ; 319 float *sp = reader_->getSpectrum() ; 289 320 vector< vector<float> > ts ; 290 321 vector< vector<float> > tc ; 291 reader_->getTcalAndTsys( idata, tc, ts ) ; 322 //reader_->getTcalAndTsys( idata, tc, ts ) ; 323 reader_->getTcalAndTsys( tc, ts ) ; 292 324 Matrix<casa::Float> spectra = toMatrix( sp, numPol, numChan ) ; 293 325 Vector<uChar> flagtra( numChan, 0 ) ; … … 302 334 303 335 // fill SCANNO, CYCLENO, IFNO, POLNO, and BEAMNO 304 setIndex( (uInt)scanno-1, (uInt)cycleno , ifno, ipol, beamno ) ;336 setIndex( (uInt)scanno-1, (uInt)cycleno[scanno], ifno, ipol, beamno ) ; 305 337 306 338 // fill SPECTRA, FLAGTRA, TSYS … … 318 350 319 351 // increment CYCLENO 320 cycleno ++ ;352 cycleno[scanno]++ ; 321 353 } 322 354 } -
trunk/external-alma/oldasdm2ASAP/OldASDMReader.cc
r2299 r2301 1 1 #include <iostream> 2 2 #include <sstream> 3 #include "limits.h" 4 #include "float.h" 3 5 4 6 #include <measures/Measures/MEpoch.h> … … 28 30 antennaId_( -1 ), 29 31 antennaName_( "" ), 32 stationName_( "" ), 30 33 row_(-1), 31 34 apc_(AP_CORRECTED), 32 className_("OldASDMReader") 35 className_("OldASDMReader"), 36 dataIndex_( UINT_MAX ), 37 //antennaRow_p( 0 ), 38 //stationRow_p( 0 ), 39 specWinRow_p( 0 ), 40 polarizationRow_p( 0 ), 41 fieldRow_p( 0 ) 33 42 { 34 43 configDescIdList_.resize(0) ; … … 168 177 asdm_->setFromFile( filename ) ; 169 178 179 AntennaTable &atab = asdm_->getAntenna() ; 180 AntennaRow *antennaRow ; 170 181 if ( antennaId_ == -1 ) { 171 AntennaTable &atab = asdm_->getAntenna() ;172 182 vector<AntennaRow *> rows = atab.get() ; 173 183 int idx = -1 ; … … 185 195 antennaId_ = idx ; 186 196 } 187 } 197 antennaTag_ = Tag( antennaId_, TagType::Antenna ) ; 198 antennaRow = rows[antennaId_] ; 199 } 200 else { 201 antennaTag_ = Tag( antennaId_, TagType::Antenna ) ; 202 antennaRow = atab.getRowByKey( antennaTag_ ) ; 203 if ( antennaRow == 0 ) { 204 close() ; 205 throw (casa::AipsError( "AntennaId " + casa::String::toString(antennaId_) + " is invalid." ) ) ; 206 } 207 } 208 188 209 189 210 // set antenna name 190 211 if ( antennaName_.size() == 0 ) { 191 AntennaTable &atab = asdm_->getAntenna() ; 192 Tag tag( antennaId_, TagType::Antenna ) ; 193 AntennaRow *arow = atab.getRowByKey( tag ) ; 194 if ( arow == 0 ) { 195 close() ; 196 throw (casa::AipsError( tag.toString() + " not found." )) ; 197 } 198 else { 199 antennaName_ = casa::String( arow->getName() ) ; 200 } 201 } 212 antennaName_ = casa::String( antennaRow->getName() ) ; 213 } 214 215 // get Station row 216 StationRow *stationRow = antennaRow->getStationUsingStationId() ; 217 218 // station name 219 stationName_ = casa::String( stationRow->getName() ) ; 220 221 // antenna position 222 antennaPosition_.resize( 3 ) ; 223 vector<Length> antpos = stationRow->getPosition() ; 224 for ( casa::uInt i = 0 ; i < 3 ; i++ ) 225 antennaPosition_[i] = Quantity( casa::Double( antpos[i].get() ), Unit( "m" ) ) ; 202 226 203 227 // create SDMBinData object … … 213 237 processStation() ; 214 238 215 logsink_->postLocally( LogMessage( "antennaId_ = "+String::toString(antennaId_), LogOrigin(className_,funcName,WHERE) ) ) ;216 logsink_->postLocally( LogMessage( "antennaName_ = "+antennaName_, LogOrigin(className_,funcName,WHERE) ) ) ;239 //logsink_->postLocally( LogMessage( "antennaId_ = "+String::toString(antennaId_), LogOrigin(className_,funcName,WHERE) ) ) ; 240 //logsink_->postLocally( LogMessage( "antennaName_ = "+antennaName_, LogOrigin(className_,funcName,WHERE) ) ) ; 217 241 218 242 return true ; … … 262 286 ExecBlockRow *ebrow = ebtab.get()[0] ; 263 287 casa::String telescopeName( ebrow->getTelescopeName() ) ; 264 AntennaTable &atab = asdm_->getAntenna() ; 265 AntennaRow *arow = atab.getRowByKey( Tag( antennaId_, TagType::Antenna ) ) ; 266 //StationTable &stab = asdm_->getStation() ; 267 //StationRow *srow = stab.getRowByKey( arow->getStationId() ) ; 268 StationRow *srow = arow->getStationUsingStationId() ; 269 casa::String stationName( srow->getName() ) ; 288 //casa::String stationName( stationRow_p->getName() ) ; 270 289 271 290 // antennaname 272 291 // <telescopeName>//<antennaName>@stationName 273 antennaname = telescopeName + "//" + antennaName_ + "@" + stationName ;292 antennaname = telescopeName + "//" + antennaName_ + "@" + stationName_ ; 274 293 //logsink_->postLocally( LogMessage("antennaName = "+antennaname,LogOrigin(className_,funcName,WHERE)) ) ; 275 294 276 295 // antennaposition 277 //vector<Length> antpos = arow->getPosition() ;278 vector<Length> antpos = srow->getPosition() ;279 296 antennaposition.resize( 3 ) ; 280 297 for ( casa::uInt i = 0 ; i < 3 ; i++ ) 281 antennaposition[i] = casa::Double( antpos[i].get() ) ;298 antennaposition[i] = antennaPosition_[i].getValue( Unit("m") ) ; 282 299 283 300 // observer … … 517 534 casa::Bool status = true ; 518 535 row_ = irow ; 536 execBlockTag_ = mainRow_[row_]->getExecBlockId() ; 519 537 520 538 unsigned int cdid = mainRow_[row_]->getConfigDescriptionId().getTagValue() ; … … 575 593 return false ; 576 594 } 577 578 // casa::Vector<casa::uInt> OldASDMReader::getDataDescIdList( casa::uInt cdid )579 // {580 // Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;581 // ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;582 // vector<Tag> ddTags = cdrow->getDataDescriptionId() ;583 // casa::Vector<casa::uInt> ddidList( ddTags.size() ) ;584 // for ( unsigned int idd = 0 ; idd < ddTags.size() ; idd++ ) {585 // ddidList[idd] = ddTags[idd].getTagValue() ;586 // }587 // return ddidList ;588 // }589 590 // casa::Vector<casa::uInt> OldASDMReader::getSwitchCycleIdList( casa::uInt cdid )591 // {592 // Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;593 // ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;594 // vector<Tag> scTags = cdrow->getSwitchCycleId() ;595 // casa::Vector<casa::uInt> scidList( scTags.size() ) ;596 // for ( unsigned int idd = 0 ; idd < scTags.size() ; idd++ ) {597 // scidList[idd] = scTags[idd].getTagValue() ;598 // }599 // return scidList ;600 // }601 602 // casa::Vector<casa::uInt> OldASDMReader::getFeedIdList( casa::uInt cdid )603 // {604 // casa::String funcName = "getFeedIdList" ;605 //606 // Tag cdTag( (unsigned int)cdid, TagType::ConfigDescription ) ;607 // ConfigDescriptionRow *cdrow = asdm_->getConfigDescription().getRowByKey( cdTag ) ;608 // casa::Vector<casa::uInt> feedIdList ;609 // vector<int> feedIds = cdrow->getFeedId() ;610 // for ( unsigned int ife = 0 ; ife < feedIds.size() ; ife++ ) {611 // logsink_->postLocally( LogMessage("feedIds["+String::toString(ife)+"]="+String::toString(feedIds[ife]),LogOrigin(className_,funcName,WHERE)) ) ;612 // if ( casa::anyEQ( feedIdList, casa::uInt( feedIds[ife] ) ) )613 // continue ;614 // if ( casa::anyEQ( feedIdList_, casa::uInt( feedIds[ife] ) ) ) {615 // casa::uInt oldsize = feedIdList.size() ;616 // feedIdList.resize( oldsize+1, true ) ;617 // feedIdList[oldsize] = casa::uInt( feedIds[ife] ) ;618 // }619 // }620 // logsink_->postLocally( LogMessage("feedIdList.size() = "+String::toString(feedIdList.size()),LogOrigin(className_,funcName,WHERE)) ) ;621 // return feedIdList ;622 // }623 595 624 596 casa::Bool OldASDMReader::setData() … … 682 654 } 683 655 656 void OldASDMReader::prepareData( unsigned int idx ) 657 { 658 unsigned int i = dataIdList_[idx] ; 659 if ( i != dataIndex_ ) { 660 dataIndex_ = dataIdList_[idx] ; 661 Tag dataDescTag( vmsData_->v_dataDescId[dataIndex_], TagType::DataDescription ) ; 662 DataDescriptionRow *dataDescRow = asdm_->getDataDescription().getRowByKey( dataDescTag ) ; 663 specWinTag_ = dataDescRow->getSpectralWindowId() ; 664 specWinRow_p = dataDescRow->getSpectralWindowUsingSpectralWindowId() ; 665 polarizationRow_p = dataDescRow->getPolarizationUsingPolOrHoloId() ; 666 Tag fieldTag( vmsData_->v_fieldId[dataIndex_], TagType::Field ) ; 667 fieldRow_p = asdm_->getField().getRowByKey( fieldTag ) ; 668 double startSec = vmsData_->v_time[dataIndex_] - 0.5 * vmsData_->v_interval[dataIndex_] ; 669 timeInterval_ = ArrayTimeInterval( startSec*s2d, vmsData_->v_interval[dataIndex_]*s2d ) ; 670 } 671 } 672 684 673 casa::uInt OldASDMReader::getIFNo( unsigned int idx ) 685 674 { 686 Tag ddTag( vmsData_->v_dataDescId[dataIdList_[idx]], TagType::DataDescription ) ; 687 DataDescriptionRow *ddrow = asdm_->getDataDescription().getRowByKey( ddTag ) ; 688 Tag spwid = ddrow->getSpectralWindowId() ; 689 map<Tag,casa::uInt>::iterator iter = ifno_.find( spwid ) ; 675 prepareData( idx ) ; 676 return getIFNo() ; 677 } 678 679 casa::uInt OldASDMReader::getIFNo() 680 { 681 map<Tag,casa::uInt>::iterator iter = ifno_.find( specWinTag_ ) ; 690 682 if ( iter != ifno_.end() ) 691 683 return iter->second ; … … 697 689 int OldASDMReader::getNumPol( unsigned int idx ) 698 690 { 699 Tag ddTag( vmsData_->v_dataDescId[dataIdList_[idx]], TagType::DataDescription ) ; 700 DataDescriptionRow *ddrow = asdm_->getDataDescription().getRowByKey( ddTag ) ; 701 PolarizationRow *polrow = ddrow->getPolarizationUsingPolOrHoloId() ; 702 return polrow->getNumCorr() ; 691 prepareData( idx ) ; 692 return getNumPol() ; 693 } 694 695 int OldASDMReader::getNumPol() 696 { 697 return polarizationRow_p->getNumCorr() ; 703 698 } 704 699 … … 709 704 string &freqref ) 710 705 { 706 prepareData( idx ) ; 707 getFrequency( refpix, refval, incr, freqref ) ; 708 } 709 710 void OldASDMReader::getFrequency( double &refpix, 711 double &refval, 712 double &incr, 713 string &freqref ) 714 { 711 715 casa::String funcName = "getFrequency" ; 712 716 713 Tag ddTag( vmsData_->v_dataDescId[dataIdList_[idx]], TagType::DataDescription ) ; 714 DataDescriptionRow *ddrow = asdm_->getDataDescription().getRowByKey( ddTag ) ; 715 //Tag spwid = ddrow->getSpectralWindowId() ; 716 SpectralWindowRow *spwrow = ddrow->getSpectralWindowUsingSpectralWindowId() ; 717 int nchan = spwrow->getNumChan() ; 717 int nchan = specWinRow_p->getNumChan() ; 718 718 freqref = "TOPO" ; 719 if ( sp wrow->isMeasFreqRefExists() )720 freqref = CFrequencyReferenceCode::toString( sp wrow->getMeasFreqRef() ) ;719 if ( specWinRow_p->isMeasFreqRefExists() ) 720 freqref = CFrequencyReferenceCode::toString( specWinRow_p->getMeasFreqRef() ) ; 721 721 if ( nchan == 1 ) { 722 722 //logsink_->postLocally( LogMessage("channel averaged data",LogOrigin(className_,funcName,WHERE)) ) ; 723 723 refpix = 0.0 ; 724 incr = sp wrow->getTotBandwidth().get() ;725 if ( sp wrow->isChanFreqStartExists() ) {726 refval = sp wrow->getChanFreqStart().get() ;727 } 728 else if ( sp wrow->isChanFreqArrayExists() ) {729 refval = sp wrow->getChanFreqArray()[0].get() ;724 incr = specWinRow_p->getTotBandwidth().get() ; 725 if ( specWinRow_p->isChanFreqStartExists() ) { 726 refval = specWinRow_p->getChanFreqStart().get() ; 727 } 728 else if ( specWinRow_p->isChanFreqArrayExists() ) { 729 refval = specWinRow_p->getChanFreqArray()[0].get() ; 730 730 } 731 731 else { … … 738 738 refpix = 0.5 * ( (double)nchan - 1.0 ) ; 739 739 int ic = ( nchan - 1 ) / 2 ; 740 if ( sp wrow->isChanWidthExists() ) {741 incr = sp wrow->getChanWidth().get() ;742 } 743 else if ( sp wrow->isChanWidthArrayExists() ) {744 incr = sp wrow->getChanWidthArray()[0].get() ;740 if ( specWinRow_p->isChanWidthExists() ) { 741 incr = specWinRow_p->getChanWidth().get() ; 742 } 743 else if ( specWinRow_p->isChanWidthArrayExists() ) { 744 incr = specWinRow_p->getChanWidthArray()[0].get() ; 745 745 } 746 746 else { 747 747 throw (casa::AipsError( "Either chanWidthArray or chanWidth must exist." )) ; 748 748 } 749 if ( sp wrow->isChanFreqStepExists() ) {750 if ( sp wrow->getChanFreqStep().get() < 0.0 )749 if ( specWinRow_p->isChanFreqStepExists() ) { 750 if ( specWinRow_p->getChanFreqStep().get() < 0.0 ) 751 751 incr *= -1.0 ; 752 752 } 753 else if ( sp wrow->isChanFreqArrayExists() ) {754 vector<Frequency> chanFreqArr = sp wrow->getChanFreqArray() ;753 else if ( specWinRow_p->isChanFreqArrayExists() ) { 754 vector<Frequency> chanFreqArr = specWinRow_p->getChanFreqArray() ; 755 755 if ( chanFreqArr[0].get() > chanFreqArr[1].get() ) 756 756 incr *= -1.0 ; … … 759 759 throw (casa::AipsError( "Either chanFreqArray or chanFreqStep must exist." )) ; 760 760 } 761 if ( sp wrow->isChanFreqStartExists() ) {762 refval = sp wrow->getChanFreqStart().get() + refpix * incr ;763 } 764 else if ( sp wrow->isChanFreqArrayExists() ) {765 refval = sp wrow->getChanFreqArray()[ic].get() ;761 if ( specWinRow_p->isChanFreqStartExists() ) { 762 refval = specWinRow_p->getChanFreqStart().get() + refpix * incr ; 763 } 764 else if ( specWinRow_p->isChanFreqArrayExists() ) { 765 refval = specWinRow_p->getChanFreqArray()[ic].get() ; 766 766 } 767 767 else { … … 774 774 refpix = 0.5 * ( (double)nchan - 1.0 ) ; 775 775 int ic = nchan / 2 ; 776 if ( sp wrow->isChanWidthExists() ) {777 incr = sp wrow->getChanWidth().get() ;778 } 779 else if ( sp wrow->isChanWidthArrayExists() ) {780 incr = sp wrow->getChanWidthArray()[0].get() ;776 if ( specWinRow_p->isChanWidthExists() ) { 777 incr = specWinRow_p->getChanWidth().get() ; 778 } 779 else if ( specWinRow_p->isChanWidthArrayExists() ) { 780 incr = specWinRow_p->getChanWidthArray()[0].get() ; 781 781 } 782 782 else { 783 783 throw (casa::AipsError( "Either chanWidthArray or chanWidth must exist." )) ; 784 784 } 785 if ( sp wrow->isChanFreqStepExists() ) {786 if ( sp wrow->getChanFreqStep().get() < 0.0 )785 if ( specWinRow_p->isChanFreqStepExists() ) { 786 if ( specWinRow_p->getChanFreqStep().get() < 0.0 ) 787 787 incr *= -1.0 ; 788 788 } 789 else if ( sp wrow->isChanFreqArrayExists() ) {790 vector<Frequency> chanFreqArr = sp wrow->getChanFreqArray() ;789 else if ( specWinRow_p->isChanFreqArrayExists() ) { 790 vector<Frequency> chanFreqArr = specWinRow_p->getChanFreqArray() ; 791 791 if ( chanFreqArr[0].get() > chanFreqArr[1].get() ) 792 792 incr *= -1.0 ; … … 795 795 throw (casa::AipsError( "Either chanFreqArray or chanFreqStep must exist." )) ; 796 796 } 797 if ( sp wrow->isChanFreqStartExists() ) {798 refval = sp wrow->getChanFreqStart().get() + refpix * incr ;799 } 800 else if ( sp wrow->isChanFreqArrayExists() ) {801 vector<Frequency> freqs = sp wrow->getChanFreqArray() ;797 if ( specWinRow_p->isChanFreqStartExists() ) { 798 refval = specWinRow_p->getChanFreqStart().get() + refpix * incr ; 799 } 800 else if ( specWinRow_p->isChanFreqArrayExists() ) { 801 vector<Frequency> freqs = specWinRow_p->getChanFreqArray() ; 802 802 refval = 0.5 * ( freqs[ic-1].get() + freqs[ic].get() ) ; 803 803 } … … 808 808 } 809 809 810 vector<double> OldASDMReader::getRestFrequency( unsigned int idx ) 811 { 812 vector<double> rf( 0 ) ; 813 unsigned int index = dataIdList_[idx] ; 814 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 815 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 816 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 817 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 818 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 819 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ; 820 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 821 if ( frow->isSourceIdExists() ) { 822 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 823 int sid = frow->getSourceId() ; 824 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; 810 double OldASDMReader::getTime( unsigned int idx ) 811 { 812 prepareData( idx ) ; 813 return getTime() ; 814 } 815 816 double OldASDMReader::getTime() 817 { 818 double tsec = vmsData_->v_time[dataIndex_] ; 819 return tsec * s2d ; 820 } 821 822 double OldASDMReader::getInterval( unsigned int idx ) 823 { 824 prepareData( idx ) ; 825 return getInterval() ; 826 } 827 828 double OldASDMReader::getInterval() 829 { 830 return vmsData_->v_interval[dataIndex_] ; 831 } 832 833 void OldASDMReader::getSourceProperty( unsigned int idx, 834 string &srcname, 835 string &fieldname, 836 vector<double> &srcdir, 837 vector<double> &srcpm, 838 double &sysvel, 839 vector<double> &restfreq ) 840 { 841 prepareData( idx ) ; 842 getSourceProperty( srcname, fieldname, srcdir, srcpm, sysvel, restfreq ) ; 843 } 844 845 void OldASDMReader::getSourceProperty( string &srcname, 846 string &fieldname, 847 vector<double> &srcdir, 848 vector<double> &srcpm, 849 double &sysvel, 850 vector<double> &restfreq ) 851 { 852 ostringstream oss ; 853 oss << fieldRow_p->getFieldName() << "__" << vmsData_->v_fieldId[dataIndex_] ; 854 fieldname = oss.str() ; 855 if ( fieldRow_p->isSourceIdExists() ) { 856 int sourceId = fieldRow_p->getSourceId() ; 857 SourceRow *srow = asdm_->getSource().getRowByKey( sourceId, timeInterval_, specWinTag_ ) ; 858 859 // source name 860 srcname = srow->getSourceName() ; 861 862 // source direction 863 vector<Angle> srcdirA = srow->getDirection() ; 864 srcdir.resize( 2 ) ; 865 srcdir[0] = limitedAngle( srcdirA[0].get() ) ; 866 srcdir[1] = limitedAngle( srcdirA[1].get() ) ; 867 if ( srow->isDirectionCodeExists() ) { 868 DirectionReferenceCode dircode = srow->getDirectionCode() ; 869 //logsink_->postLocally( LogMessage("dircode="+CDirectionReferenceCode::toString(dircode),LogOrigin(className_,funcName,WHERE)) ) ; 870 if ( dircode != J2000 ) { 871 // if not J2000, need direction conversion 872 String ref( CDirectionReferenceCode::toString( dircode ) ) ; 873 double mjd = vmsData_->v_time[dataIndex_] * s2d ; 874 srcdir = toJ2000( srcdir, ref, mjd, antennaPosition_ ) ; 875 } 876 } 877 878 // source proper motion 879 srcpm.resize( 2 ) ; 880 vector<AngularRate> srcpmA = srow->getProperMotion() ; 881 srcpm[0] = srcpmA[0].get() ; 882 srcpm[1] = srcpmA[1].get() ; 883 884 // systemic velocity 885 if ( srow->isSysVelExists() ) { 886 vector<Speed> sysvelV = srow->getSysVel() ; 887 if ( sysvelV.size() > 0 ) 888 sysvel = sysvelV[0].get() ; 889 } 890 else { 891 sysvel = 0.0 ; 892 } 893 894 // rest frequency 825 895 if ( srow->isRestFrequencyExists() ) { 826 896 //logsink_->postLocally( LogMessage("restFrequency exists",LogOrigin(className_,funcName,WHERE)) ) ; 827 vector<Frequency> r estfreq= srow->getRestFrequency() ;828 r f.resize( restfreq.size() ) ;897 vector<Frequency> rf = srow->getRestFrequency() ; 898 restfreq.resize( rf.size() ) ; 829 899 for ( unsigned int i = 0 ; i < restfreq.size() ; i++ ) 830 rf[i] = restfreq[i].get() ; 831 } 832 } 833 return rf ; 834 } 835 836 double OldASDMReader::getTime( unsigned int idx ) 837 { 838 double tsec = vmsData_->v_time[dataIdList_[idx]] ; 839 return tsec * s2d ; 840 } 841 842 double OldASDMReader::getInterval( unsigned int idx ) 843 { 844 return vmsData_->v_interval[dataIdList_[idx]] ; 845 } 846 847 string OldASDMReader::getSourceName( unsigned int idx ) 848 { 849 unsigned int index = dataIdList_[idx] ; 850 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 851 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 852 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 853 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 854 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 855 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ; 856 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 857 string srcname ; 858 if ( frow->isSourceIdExists() ) { 859 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 860 int sid = frow->getSourceId() ; 861 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; 862 srcname = srow->getSourceName() ; 900 restfreq[i] = rf[i].get() ; 901 } 902 else { 903 restfreq.resize( 0 ) ; 904 } 863 905 } 864 906 else { 865 srcname = frow->getFieldName() ; 866 } 867 return srcname ; 868 } 869 870 string OldASDMReader::getFieldName( unsigned int idx ) 871 { 872 int fid = vmsData_->v_fieldId[dataIdList_[idx]] ; 873 Tag ftag( fid, TagType::Field ) ; 874 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 875 ostringstream oss ; 876 oss << frow->getFieldName() << "__" << fid ; 877 return oss.str() ; 907 srcname = fieldRow_p->getFieldName() ; 908 srcdir.resize( 2 ) ; 909 srcdir[0] = 0.0 ; 910 srcdir[1] = 0.0 ; 911 srcpm = srcdir ; 912 sysvel = 0.0 ; 913 restfreq.resize( 0 ) ; 914 } 878 915 } 879 916 … … 882 919 { 883 920 int srctype = SrcType::NOTYPE ; 884 Tag ebtag = mainRow_[row_]->getExecBlockId() ; 885 ScanRow *scanrow = asdm_->getScan().getRowByKey( ebtag, (int)scan ) ; 921 ScanRow *scanrow = asdm_->getScan().getRowByKey( execBlockTag_, (int)scan ) ; 886 922 ScanIntent scanIntent = scanrow->getScanIntent()[0] ; 887 SubscanRow *subrow = asdm_->getSubscan().getRowByKey( e btag, (int)scan, (int)subscan ) ;923 SubscanRow *subrow = asdm_->getSubscan().getRowByKey( execBlockTag_, (int)scan, (int)subscan ) ; 888 924 SubscanIntent subIntent = subrow->getSubscanIntent() ; 889 925 SwitchingMode swmode = NO_SWITCHING ; … … 993 1029 unsigned int OldASDMReader::getSubscanNo( unsigned int idx ) 994 1030 { 1031 prepareData( idx ) ; 1032 return getSubscanNo() ; 1033 } 1034 1035 unsigned int OldASDMReader::getSubscanNo() 1036 { 995 1037 //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)) ) ; 996 return vmsData_->v_msState[dataIdList_[idx]].subscanNum ; 997 } 998 999 vector<double> OldASDMReader::getSourceDirection( unsigned int idx ) 1000 { 1001 vector<double> dir( 2, 0.0 ) ; 1002 unsigned int index = dataIdList_[idx] ; 1003 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 1004 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 1005 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 1006 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 1007 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 1008 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ; 1009 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 1010 string srcname ; 1011 if ( frow->isSourceIdExists() ) { 1012 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 1013 int sid = frow->getSourceId() ; 1014 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; 1015 vector<Angle> srcdir = srow->getDirection() ; 1016 dir[0] = limitedAngle( srcdir[0].get() ) ; 1017 dir[1] = limitedAngle( srcdir[1].get() ) ; 1018 if ( srow->isDirectionCodeExists() ) { 1019 DirectionReferenceCode dircode = srow->getDirectionCode() ; 1020 //logsink_->postLocally( LogMessage("dircode="+CDirectionReferenceCode::toString(dircode),LogOrigin(className_,funcName,WHERE)) ) ; 1021 if ( dircode != J2000 ) { 1022 // if not J2000, need direction conversion 1023 string ref = CDirectionReferenceCode::toString( dircode ) ; 1024 double mjd = vmsData_->v_time[index] * s2d ; 1025 Tag atag( antennaId_, TagType::Antenna ) ; 1026 AntennaRow *arow = asdm_->getAntenna().getRowByKey( atag ) ; 1027 StationRow *srow = arow->getStationUsingStationId() ; 1028 vector<Length> antposL = srow->getPosition() ; 1029 casa::Vector<casa::Double> antpos( 3 ) ; 1030 for ( int i = 0 ; i < 3 ; i++ ) 1031 antpos[i] = antposL[i].get() ; 1032 dir = toJ2000( dir, ref, mjd, antpos ) ; 1033 } 1034 } 1035 } 1036 return dir ; 1037 } 1038 1039 void OldASDMReader::getSourceDirection( unsigned int idx, 1040 vector<double> &dir, 1041 string &ref ) 1042 { 1043 dir.resize( 2 ) ; 1044 dir[0] = 0.0 ; 1045 dir[1] = 0.0 ; 1046 ref = "J2000" ; 1047 unsigned int index = dataIdList_[idx] ; 1048 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 1049 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 1050 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 1051 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 1052 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 1053 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ; 1054 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 1055 string srcname ; 1056 if ( frow->isSourceIdExists() ) { 1057 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 1058 int sid = frow->getSourceId() ; 1059 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; 1060 vector<Angle> srcdir = srow->getDirection() ; 1061 if ( srow->isDirectionCodeExists() ) { 1062 ref = CDirectionReferenceCode::toString( srow->getDirectionCode() ) ; 1063 } 1064 dir[0] = limitedAngle( srcdir[0].get() ) ; 1065 dir[1] = limitedAngle( srcdir[1].get() ) ; 1066 } 1038 return vmsData_->v_msState[dataIndex_].subscanNum ; 1067 1039 } 1068 1040 … … 1081 1053 } 1082 1054 1083 vector<double> OldASDMReader::getSourceProperMotion( unsigned int idx )1084 {1085 vector<double> pm( 2, 0.0 ) ;1086 unsigned int index = dataIdList_[idx] ;1087 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ;1088 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;1089 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;1090 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ;1091 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ;1092 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ;1093 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ;1094 string srcname ;1095 if ( frow->isSourceIdExists() ) {1096 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ;1097 int sid = frow->getSourceId() ;1098 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ;1099 vector<AngularRate> srcpm = srow->getProperMotion() ;1100 pm[0] = srcpm[0].get() ;1101 pm[1] = srcpm[1].get() ;1102 }1103 return pm ;1104 }1105 1106 double OldASDMReader::getSysVel( unsigned int idx )1107 {1108 double sysvel = 0.0 ;1109 unsigned int index = dataIdList_[idx] ;1110 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ;1111 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;1112 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;1113 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ;1114 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ;1115 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ;1116 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ;1117 string srcname ;1118 if ( frow->isSourceIdExists() ) {1119 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ;1120 int sid = frow->getSourceId() ;1121 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ;1122 if ( srow->isSysVelExists() ) {1123 vector<Speed> sysvelV = srow->getSysVel() ;1124 if ( sysvelV.size() > 0 )1125 sysvel = sysvelV[0].get() ;1126 }1127 }1128 return sysvel ;1129 }1130 1131 1055 unsigned int OldASDMReader::getFlagRow( unsigned int idx ) 1132 1056 { 1133 return vmsData_->v_flag[dataIdList_[idx]] ; 1057 prepareData( idx ) ; 1058 return getFlagRow() ; 1059 } 1060 1061 unsigned int OldASDMReader::getFlagRow() 1062 { 1063 return vmsData_->v_flag[dataIndex_] ; 1134 1064 } 1135 1065 1136 1066 vector<unsigned int> OldASDMReader::getDataShape( unsigned int idx ) 1137 1067 { 1138 return vmsData_->vv_dataShape[dataIdList_[idx]] ; 1068 prepareData( idx ) ; 1069 return getDataShape() ; 1070 } 1071 1072 vector<unsigned int> OldASDMReader::getDataShape() 1073 { 1074 return vmsData_->vv_dataShape[dataIndex_] ; 1139 1075 } 1140 1076 1141 1077 float * OldASDMReader::getSpectrum( unsigned int idx ) 1142 1078 { 1143 map<AtmPhaseCorrection, float*> data = vmsData_->v_m_data[dataIdList_[idx]] ; 1079 prepareData( idx ) ; 1080 return getSpectrum() ; 1081 } 1082 1083 float * OldASDMReader::getSpectrum() 1084 { 1085 map<AtmPhaseCorrection, float*> data = vmsData_->v_m_data[dataIndex_] ; 1144 1086 //map<AtmPhaseCorrection, float*>::iterator iter = data.find(AP_UNCORRECTED) ; 1145 1087 map<AtmPhaseCorrection, float*>::iterator iter = data.find(apc_) ; … … 1148 1090 } 1149 1091 1150 // bool * OldASDMReader::getFlagChannel( unsigned int idx )1151 // {1152 // return 0 ;1153 // }1154 1155 1092 vector< vector<float> > OldASDMReader::getTsys( unsigned int idx ) 1156 1093 { 1094 prepareData( idx ) ; 1095 return getTsys() ; 1096 } 1097 1098 vector< vector<float> > OldASDMReader::getTsys() 1099 { 1157 1100 vector< vector<float> > defaultTsys( 1, vector<float>( 1, 1.0 ) ) ; 1158 SysCalRow *scrow = getSysCalRow( idx) ;1101 SysCalRow *scrow = getSysCalRow() ; 1159 1102 if ( scrow != 0 && scrow->isTsysSpectrumExists() ) { 1160 1103 vector< vector<Temperature> > tsysSpec = scrow->getTsysSpectrum() ; … … 1184 1127 vector< vector<float> > OldASDMReader::getTcal( unsigned int idx ) 1185 1128 { 1129 prepareData( idx ) ; 1130 return getTcal() ; 1131 } 1132 1133 vector< vector<float> > OldASDMReader::getTcal() 1134 { 1186 1135 vector< vector<float> > defaultTcal( 1, vector<float>( 1, 1.0 ) ) ; 1187 SysCalRow *scrow = getSysCalRow( idx) ;1136 SysCalRow *scrow = getSysCalRow() ; 1188 1137 if ( scrow != 0 && scrow->isTcalSpectrumExists() ) { 1189 1138 vector< vector<Temperature> > tcalSpec = scrow->getTcalSpectrum() ; … … 1215 1164 vector< vector<float> > &tsys ) 1216 1165 { 1166 prepareData( idx ) ; 1167 getTcalAndTsys( tcal, tsys ) ; 1168 } 1169 1170 void OldASDMReader::getTcalAndTsys( vector< vector<float> > &tcal, 1171 vector< vector<float> > &tsys ) 1172 { 1217 1173 String funcName = "getTcalAndTsys" ; 1218 1174 1219 1175 vector< vector<float> > defaultT( 1, vector<float>( 1, 1.0 ) ) ; 1220 SysCalRow *scrow = getSysCalRow( idx) ;1176 SysCalRow *scrow = getSysCalRow() ; 1221 1177 if ( scrow == 0 ) { 1222 1178 tcal = defaultT ; … … 1259 1215 vector<float> OldASDMReader::getOpacity( unsigned int idx ) 1260 1216 { 1217 prepareData( idx ) ; 1218 return getOpacity() ; 1219 } 1220 1221 vector<float> OldASDMReader::getOpacity() 1222 { 1261 1223 vector<float> tau(0) ; 1262 1224 CalAtmosphereTable &atmtab = asdm_->getCalAtmosphere() ; 1263 1225 unsigned int nrow = atmtab.size() ; 1264 1226 if ( nrow > 0 ) { 1265 unsigned int index = dataIdList_[idx] ;1266 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ;1267 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;1268 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;1269 1227 //int feedid = vmsData_->v_feedId1[index] ; 1270 //Tag atag( antennaId_, TagType::Antenna ) ;1271 //Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ;1272 //DataDescriptionRow *ddrow = asdm_->getDataDescription().getRowByKey(ddtag) ;1273 //Tag spwtag = ddrow->getSpectralWindowId() ;1274 //SpectralWindowRow *spwrow = ddrow->getSpectralWindowUsingSpectralWindowId() ;1275 1228 //BasebandName bbname = spwrow->getBasebandName() ; 1276 1229 //FeedRow *frow = asdm_->getFeed().getRowByKey( atag, spwtag, tint, feedid ) ; … … 1280 1233 //ReceiverBand rb = rrows[0]->getFrequencyBand() ; 1281 1234 int row0 = -1 ; 1282 double eps = tint.getStart().getMJD();1235 double eps = DBL_MAX ; 1283 1236 for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { 1284 1237 CalAtmosphereRow *atmrow = atmrows[irow] ; … … 1289 1242 continue ; 1290 1243 else { 1291 double dt = ti nt.getStart().getMJD() - atmrow->getEndValidTime().getMJD() ;1244 double dt = timeInterval_.getStart().getMJD() - atmrow->getEndValidTime().getMJD() ; 1292 1245 if ( dt >= 0 && dt < eps ) { 1293 1246 eps = dt ; … … 1315 1268 float &windaz ) 1316 1269 { 1270 prepareData( idx ) ; 1271 getWeatherInfo( temperature, pressure, humidity, windspeed, windaz ) ; 1272 } 1273 1274 void OldASDMReader::getWeatherInfo( float &temperature, 1275 float &pressure, 1276 float &humidity, 1277 float &windspeed, 1278 float &windaz ) 1279 { 1317 1280 casa::String funcName = "getWeatherInfo" ; 1318 1281 … … 1329 1292 return ; 1330 1293 1331 unsigned int index = dataIdList_[idx] ;1332 //Tag anttag( antennaId_, TagType::Antenna ) ;1333 //Tag sttag = (asdm_->getAntenna().getRowByKey( anttag ))->getStationId() ;1334 1294 Tag sttag( (unsigned int)weatherStationId_, TagType::Station ) ; 1335 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ;1336 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;1337 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;1338 1295 //WeatherRow *wrow = wtab.getRowByKey( sttag, tint ) ; 1339 1296 vector<WeatherRow *> *wrows = wtab.getByContext( sttag ) ; … … 1341 1298 unsigned int nrow = wrows->size() ; 1342 1299 //logsink_->postLocally( LogMessage("There are "+String::toString(nrow)+" rows for given context: stationId "+String::toString(weatherStationId_),LogOrigin(className_,funcName,WHERE)) ) ; 1343 ArrayTime startTime = getMidTime( ti nt) ;1300 ArrayTime startTime = getMidTime( timeInterval_ ) ; 1344 1301 if ( startTime < (*wrows)[0]->getTimeInterval().getStart() ) { 1345 1302 temperature = (*wrows)[0]->getTemperature().get() ; … … 1401 1358 return -1 ; 1402 1359 1403 Tag atag( antennaId_, TagType::Antenna ) ;1404 Tag stag = (asdm_->getAntenna().getRowByKey( atag ))->getStationId() ;1405 1360 vector<double> apos( 3 ) ; 1406 1361 StationTable &stab = asdm_->getStation() ; 1407 StationRow *srow = stab.getRowByKey( stag ) ; 1408 vector<Length> pos = srow->getPosition() ; 1409 apos[0] = pos[0].get() ; 1410 apos[1] = pos[1].get() ; 1411 apos[2] = pos[2].get() ; 1362 apos[0] = antennaPosition_[0].getValue( Unit("m") ) ; 1363 apos[1] = antennaPosition_[1].getValue( Unit("m") ) ; 1364 apos[2] = antennaPosition_[2].getValue( Unit("m") ) ; 1412 1365 1413 double eps = 1.0e20;1366 double eps = DBL_MAX ; 1414 1367 int retval = -1 ; 1415 1368 for ( unsigned int ir = 0 ; ir < weatherStation_.size() ; ir++ ) { 1416 srow = stab.getRowByKey( weatherStation_[ir] ) ;1369 StationRow *srow = stab.getRowByKey( weatherStation_[ir] ) ; 1417 1370 vector<Length> wpos = srow->getPosition() ; 1418 1371 double dist = (apos[0]-wpos[0].get())*(apos[0]-wpos[0].get()) … … 1433 1386 vector<double> &srate ) 1434 1387 { 1388 prepareData( idx ) ; 1389 getPointingInfo( dir, az, el, srate ) ; 1390 } 1391 1392 void OldASDMReader::getPointingInfo( vector<double> &dir, 1393 double &az, 1394 double &el, 1395 vector<double> &srate ) 1396 { 1435 1397 String funcName = "getPointingInfo" ; 1436 1398 … … 1440 1402 srate.resize(0) ; 1441 1403 1442 Tag atag( antennaId_, TagType::Antenna ) ; 1443 unsigned int index = dataIdList_[idx] ; 1444 vector<PointingRow *> *prows = asdm_->getPointing().getByContext( atag ) ; 1404 //Tag atag( antennaId_, TagType::Antenna ) ; 1405 //unsigned int index = dataIdList_[idx] ; 1406 //vector<PointingRow *> *prows = asdm_->getPointing().getByContext( atag ) ; 1407 vector<PointingRow *> *prows = asdm_->getPointing().getByContext( antennaTag_ ) ; 1445 1408 1446 1409 if ( prows == 0 ) … … 1450 1413 PointingRow *qrow ; 1451 1414 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 1452 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ;1453 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ;1415 //double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 1416 //ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 1454 1417 1455 1418 unsigned int nrow = prows->size() ; … … 1471 1434 el = 0.0 ; 1472 1435 //double tcen = 0.0 ; 1473 double tcen = getMidTime( tint ).getMJD() ; 1436 //double tcen = getMidTime( tint ).getMJD() ; 1437 double tcen = getMidTime( timeInterval_ ).getMJD() ; 1474 1438 1475 1439 // … … 1488 1452 ArrayTimeInterval pTime1 = (*prows)[nrow-1]->getTimeInterval() ; 1489 1453 //if ( tint.getStartInMJD()+tint.getDurationInDays() < pTime0.getStartInMJD() ) { 1490 if ( getEndTime( tint ) < getStartTime( pTime0 ) ) { 1454 //if ( getEndTime( tint ) < getStartTime( pTime0 ) ) { 1455 if ( getEndTime( timeInterval_ ) < getStartTime( pTime0 ) ) { 1491 1456 logsink_->postLocally( LogMessage( "ArrayTimeInterval out of bounds: no data for given position (tint < ptime)", LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; 1492 1457 prow = (*prows)[0] ; … … 1500 1465 } 1501 1466 //else if ( tint.getStartInMJD() > pTime1.getStartInMJD()+pTime1.getDurationInDays() ) { 1502 else if ( getStartTime( tint ) > getEndTime( pTime1 ) ) { 1467 //else if ( getStartTime( tint ) > getEndTime( pTime1 ) ) { 1468 else if ( getStartTime( timeInterval_ ) > getEndTime( pTime1 ) ) { 1503 1469 logsink_->postLocally( LogMessage( "ArrayTimeInterval out of bounds: no data for given position (tint > ptime)", LogOrigin(className_,funcName,WHERE), LogMessage::WARN ) ) ; 1504 1470 prow = (*prows)[nrow-1] ; … … 1519 1485 } 1520 1486 else { 1521 ArrayTime startTime = tint.getStart() ; 1522 ArrayTime endTime = getEndTime( tint ) ; 1487 //ArrayTime startTime = tint.getStart() ; 1488 //ArrayTime endTime = getEndTime( tint ) ; 1489 ArrayTime startTime = timeInterval_.getStart() ; 1490 ArrayTime endTime = getEndTime( timeInterval_ ) ; 1523 1491 int row0 = -1 ; 1524 1492 int row1 = -1 ; 1525 1493 int row2 = -1 ; 1526 double dt0 = getMidTime( tint ).getMJD() ; 1494 //double dt0 = getMidTime( tint ).getMJD() ; 1495 double dt0 = getMidTime( timeInterval_ ).getMJD() ; 1527 1496 for ( unsigned int irow = 0 ; irow < nrow ; irow++ ) { 1528 1497 prow = (*prows)[irow] ; 1529 double dt = getMidTime( tint ).getMJD() - getMidTime( prow->getTimeInterval() ).getMJD() ; 1498 //double dt = getMidTime( tint ).getMJD() - getMidTime( prow->getTimeInterval() ).getMJD() ; 1499 double dt = getMidTime( timeInterval_ ).getMJD() - getMidTime( prow->getTimeInterval() ).getMJD() ; 1530 1500 if ( dt > 0 && dt < dt0 ) { 1531 1501 dt0 = dt ; … … 1632 1602 for ( int isam = 0 ; isam < numSample ; isam++ ) { 1633 1603 //if ( tint.overlaps( stime[isam] ) ) { 1634 if ( tint.contains( stime[isam] ) ) { 1604 //if ( tint.contains( stime[isam] ) ) { 1605 if ( timeInterval_.contains( stime[isam] ) ) { 1635 1606 az += dirA[isam][0] ; 1636 1607 el += dirA[isam][1] ; … … 1649 1620 ArrayTimeInterval stime( sampleStart+isam*sampleInterval, sampleInterval ) ; 1650 1621 //if ( tint.overlaps( stime ) ) { 1651 if ( tint.contains( stime ) ) { 1622 //if ( tint.contains( stime ) ) { 1623 if ( timeInterval_.contains( stime ) ) { 1652 1624 az += dirA[isam][0] ; 1653 1625 el += dirA[isam][1] ; … … 1669 1641 } 1670 1642 1671 AntennaRow *arow = asdm_->getAntenna().getRowByKey( Tag( antennaId_, TagType::Antenna ) ) ; 1672 StationRow *srow = arow->getStationUsingStationId() ; 1673 vector<Length> antposL = srow->getPosition() ; 1674 casa::Vector<casa::Double> antpos( 3 ) ; 1675 for ( int i = 0 ; i < 3 ; i++ ) 1676 antpos[i] = antposL[i].get() ; 1677 //logsink_->postLocally( LogMessage("tcen = "+String::toString(tcen),LogOrigin(className_,funcName,WHERE)) ) ; 1678 //logsink_->postLocally( LogMessage("antpos = "+String::toString(antpos),LogOrigin(className_,funcName,WHERE)) ) ; 1679 toJ2000( dir, az, el, tcen, antpos ) ; 1680 1643 toJ2000( dir, az, el, tcen, antennaPosition_ ) ; 1681 1644 } 1682 1645 … … 1700 1663 1701 1664 void OldASDMReader::toJ2000( vector<double> &dir, 1702 double az, 1703 double el, 1704 double mjd, 1705 casa::Vector<casa::Double> antpos ) 1665 double &az, 1666 double &el, 1667 double &mjd, 1668 casa::Vector<casa::Quantity> &antpos ) 1669 // casa::Vector<casa::Double> antpos ) 1706 1670 { 1707 1671 String funcName = "toJ2000" ; 1708 1672 1673 String ref = "AZELGEO" ; 1709 1674 vector<double> azel( 2 ) ; 1710 1675 azel[0] = az ; 1711 1676 azel[1] = el ; 1712 dir = toJ2000( azel, "AZELGEO", mjd, antpos ) ; 1713 } 1714 1715 vector<double> OldASDMReader::toJ2000( vector<double> dir, 1716 casa::String dirref, 1717 double mjd, 1718 casa::Vector<casa::Double> antpos ) 1677 dir = toJ2000( azel, ref, mjd, antpos ) ; 1678 } 1679 1680 vector<double> OldASDMReader::toJ2000( vector<double> &dir, 1681 casa::String &dirref, 1682 double &mjd, 1683 casa::Vector<casa::Quantity> &antpos ) 1684 // casa::Vector<casa::Double> antpos ) 1719 1685 { 1720 1686 casa::String funcName = "toJ2000" ; … … 1723 1689 if ( dirref != "J2000" ) { 1724 1690 casa::MEpoch me( casa::Quantity( (casa::Double)mjd, "d" ), casa::MEpoch::UTC ) ; 1725 casa::Vector<casa::Quantity> qantpos( 3 ) ; 1726 qantpos[0] = casa::Quantity( antpos[0], "m" ) ; 1727 qantpos[1] = casa::Quantity( antpos[1], "m" ) ; 1728 qantpos[2] = casa::Quantity( antpos[2], "m" ) ; 1729 casa::MPosition mp( casa::MVPosition( qantpos ), 1691 casa::MPosition mp( casa::MVPosition( antpos ), 1730 1692 casa::MPosition::ITRF ) ; 1731 1693 //ostringstream oss ; … … 1823 1785 SysCalRow *OldASDMReader::getSysCalRow( unsigned int idx ) 1824 1786 { 1787 prepareData( idx ) ; 1788 return getSysCalRow() ; 1789 } 1790 1791 SysCalRow *OldASDMReader::getSysCalRow() 1792 { 1825 1793 String funcName = "getSysCalRow" ; 1826 1794 1827 1795 SysCalRow *row = 0 ; 1828 unsigned int index = dataIdList_[idx] ; 1829 Tag anttag( antennaId_, TagType::Antenna ) ; 1830 int feedid = vmsData_->v_feedId1[index] ; 1831 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 1832 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 1833 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 1834 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 1835 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 1836 //int nchan = asdm_->getSpectralWindow().getRowByKey(spwtag)->getNumChan() ; 1837 vector< vector<float> > defaultTsys( 1, vector<float>( 1, 1.0 ) ) ; 1796 int feedid = vmsData_->v_feedId1[dataIndex_] ; 1838 1797 SysCalTable &sctab = asdm_->getSysCal() ; 1839 //vector<SysCalRow *> rows = sctab.get() ; 1840 vector<SysCalRow *> *rows = sctab.getByContext( anttag, spwtag, feedid ) ; 1798 vector<SysCalRow *> *rows = sctab.getByContext( antennaTag_, specWinTag_, feedid ) ; 1841 1799 //if ( nrow == 0 ) { 1842 1800 if ( rows == 0 ) { … … 1851 1809 scindex = 0 ; 1852 1810 } 1853 else if ( getEndTime( ti nt) <= getStartTime( (*rows)[0]->getTimeInterval() ) )1811 else if ( getEndTime( timeInterval_ ) <= getStartTime( (*rows)[0]->getTimeInterval() ) ) 1854 1812 scindex = 0 ; 1855 1813 else { 1856 1814 for ( unsigned int irow = 0 ; irow < nrow-1 ; irow++ ) { 1857 ArrayTime t = getMidTime( ti nt) ;1815 ArrayTime t = getMidTime( timeInterval_ ) ; 1858 1816 if ( t > getStartTime( (*rows)[irow]->getTimeInterval() ) 1859 1817 && t <= getStartTime( (*rows)[irow+1]->getTimeInterval() ) ) { … … 1882 1840 vector< vector<double> > OldASDMReader::pointingDir( PointingRow *row ) 1883 1841 { 1842 //String funcName = "pointingDir" ; 1884 1843 vector< vector<Angle> > aTar = row->getTarget() ; 1885 1844 vector< vector<Angle> > aOff = row->getOffset() ; … … 1904 1863 dir[i][1] = aTar[i][1].get() + aOff[i][1].get() 1905 1864 + aEnc[i][1].get() - aDir[i][1].get() ; 1865 //logsink_->postLocally( LogMessage("tracking offset: ["+String::toString(aEnc[i][0].get()-aDir[i][0].get())+","+String::toString(aEnc[i][0]-aDir[i][0].get())+"]",LogOrigin(className_,funcName,WHERE)) ) ; 1906 1866 } 1907 1867 return dir ; -
trunk/external-alma/oldasdm2ASAP/OldASDMReader.h
r2273 r2301 143 143 * @return scan number 144 144 **/ 145 unsigned int getScanNo () { return (unsigned int)(mainRow_[row_]->getScanNumber()) ; } ;145 unsigned int getScanNoOfCurrentRow() { return (unsigned int)(mainRow_[row_]->getScanNumber()) ; } ; 146 146 147 147 /** … … 150 150 * @return subscan number 151 151 **/ 152 unsigned int getSubscanNo() { return (unsigned int)(mainRow_[row_]->getSubscanNumber()) ; } ; 152 unsigned int getSubscanNoOfCurrentRow() { return (unsigned int)(mainRow_[row_]->getSubscanNumber()) ; } ; 153 154 /** 155 * set data index 156 * 157 * @param idx for vmsData_ 158 **/ 159 void prepareData( unsigned int idx ) ; 153 160 154 161 /** … … 159 166 **/ 160 167 unsigned int getSubscanNo( unsigned int idx ) ; 168 unsigned int getSubscanNo() ; 161 169 162 170 /** … … 167 175 **/ 168 176 casa::uInt getIFNo( unsigned int idx ) ; 177 casa::uInt getIFNo() ; 169 178 170 179 /** … … 175 184 **/ 176 185 int getNumPol( unsigned int idx ) ; 186 int getNumPol() ; 177 187 178 188 /** … … 190 200 double &incr, 191 201 std::string &freqref ) ; 192 193 /** 194 * get rest frequencies for given index 195 * 196 * @param idx for vmsData_ 197 * @return rest frequencies 198 **/ 199 vector<double> getRestFrequency( unsigned int idx ) ; 202 void getFrequency( double &refpix, 203 double &refval, 204 double &incr, 205 std::string &freqref ) ; 200 206 201 207 /** … … 206 212 **/ 207 213 double getTime( unsigned int idx ) ; 214 double getTime() ; 208 215 209 216 /** … … 214 221 **/ 215 222 double getInterval( unsigned int idx ) ; 216 217 /** 218 * get source name for given index 219 * 220 * @param idx for vmsData_ 221 * @return source name 222 **/ 223 string getSourceName( unsigned int idx ) ; 224 225 /** 226 * get field name for given index 227 * field name = fieldName + "__" + fieldId 228 * 229 * @param idx for vmsData_ 230 * @return field name 231 **/ 232 string getFieldName( unsigned int idx ) ; 233 234 /** 235 * get source direction for given index 236 * 237 * @param idx for vmsData_ 238 * @return source direction as vector<double> 239 **/ 240 std::vector<double> getSourceDirection( unsigned int idx ) ; 241 void getSourceDirection( unsigned int idx, 242 std::vector<double> &dir, 243 std::string &ref ) ; 223 double getInterval() ; 244 224 245 225 /** … … 253 233 254 234 /** 255 * get source proper motion for given index256 *257 * @param idx for vmsData_258 * @return source proper motion as vector<double>259 **/260 std::vector<double> getSourceProperMotion( unsigned int idx ) ;261 262 /**263 * get systemic velocity of the source for given index264 * at the moment return 0-th element of sysVel vector265 *266 * @param idx for vmsData_267 * @return systemic velocity of the source268 **/269 double getSysVel( unsigned int idx ) ;270 271 /**272 235 * get row-based flag for given index 273 236 * … … 276 239 **/ 277 240 unsigned int getFlagRow( unsigned int idx ) ; 241 unsigned int getFlagRow() ; 278 242 279 243 /** … … 284 248 **/ 285 249 std::vector<unsigned int> getDataShape( unsigned int idx ) ; 250 std::vector<unsigned int> getDataShape() ; 286 251 287 252 /** … … 292 257 **/ 293 258 float *getSpectrum( unsigned int idx ) ; 294 295 /** 296 * get channel flag data for given index 297 * 298 * @param idx for vmsData_ 299 * @return channel flag 300 **/ 301 //bool *getFlagChannel( unsigned int idx ) ; 259 float *getSpectrum() ; 260 261 /** 262 * get Tsys for given index 263 * 264 * @param idx for vmsData_ 265 * @return Tsys 266 **/ 267 std::vector< std::vector<float> > getTsys( unsigned int idx ) ; 268 std::vector< std::vector<float> > getTsys() ; 302 269 303 270 /** 304 * get Tsys for given index305 *306 * @param idx for vmsData_307 * @return Tsys308 **/309 std::vector< std::vector<float> > getTsys( unsigned int idx ) ;310 311 /**312 271 * get Tcal for given index 313 272 * … … 316 275 **/ 317 276 std::vector< std::vector<float> > getTcal( unsigned int idx ) ; 277 std::vector< std::vector<float> > getTcal() ; 318 278 319 279 /** … … 327 287 std::vector< std::vector<float> > &tcal, 328 288 std::vector< std::vector<float> > &tsys ) ; 289 void getTcalAndTsys( std::vector< std::vector<float> > &tcal, 290 std::vector< std::vector<float> > &tsys ) ; 329 291 330 292 /** … … 335 297 **/ 336 298 std::vector<float> getOpacity( unsigned int idx ) ; 299 std::vector<float> getOpacity() ; 337 300 338 301 /** … … 352 315 float &windspeed, 353 316 float &windaz ) ; 317 void getWeatherInfo( float &temperature, 318 float &pressure, 319 float &humidity, 320 float &windspeed, 321 float &windaz ) ; 354 322 355 323 /** … … 367 335 double &el, 368 336 std::vector<double> &srate ) ; 337 void getPointingInfo( std::vector<double> &dir, 338 double &az, 339 double &el, 340 std::vector<double> &srate ) ; 369 341 370 342 /** … … 379 351 380 352 /** 381 * get list of dataDescId for given configDescId 382 * 383 * @param configDescId 384 * @return list of dataDescId 385 **/ 386 // casa::Vector<casa::uInt> getDataDescIdList( casa::uInt cdid ) ; 387 388 /** 389 * get list of switchCycleId for given configDescId 390 * 391 * @param configDescId 392 * @return list of dataDescId 393 **/ 394 // casa::Vector<casa::uInt> getSwitchCycleIdList( casa::uInt cdid ) ; 395 396 /** 397 * get list of feedId for given configDescId 398 * 399 * only return list of feedId that corresponds to specified antenna. 400 * 401 * @param configDescId 402 * @return list of valid feedId 403 **/ 404 // casa::Vector<casa::uInt> getFeedIdList( casa::uInt cdid ) ; 353 * get source properties 354 * 355 * @param idx for vmsData_ 356 * @param srcname source name 357 * @param fieldname field name 358 * @param srcdir source direction 359 * @param srcpm source proper motion 360 * @param sysvel systemic velocity of the source 361 * @param restfreq rest frequency 362 **/ 363 void getSourceProperty( unsigned int idx, 364 std::string &srcname, 365 std::string &fieldname, 366 std::vector<double> &srcdir, 367 std::vector<double> &srcpm, 368 double &sysvel, 369 std::vector<double> &restfreq ) ; 370 void getSourceProperty( std::string &srcname, 371 std::string &fieldname, 372 std::vector<double> &srcdir, 373 std::vector<double> &srcpm, 374 double &sysvel, 375 std::vector<double> &restfreq ) ; 405 376 406 377 /** … … 516 487 **/ 517 488 void toJ2000( std::vector<double> &dir, 518 double az,519 double el,520 double mjd,521 casa::Vector<casa:: Double>antpos ) ;489 double &az, 490 double &el, 491 double &mjd, 492 casa::Vector<casa::Quantity> &antpos ) ; 522 493 523 494 /** … … 530 501 * @return new direction 531 502 **/ 532 std::vector<double> toJ2000( std::vector<double> dir,533 casa::String dirref,534 double mjd,535 casa::Vector<casa:: Double>antpos ) ;503 std::vector<double> toJ2000( std::vector<double> &dir, 504 casa::String &dirref, 505 double &mjd, 506 casa::Vector<casa::Quantity> &antpos ) ; 536 507 /** 537 508 * get nIF … … 548 519 **/ 549 520 asdm::SysCalRow *getSysCalRow( unsigned int idx ) ; 521 asdm::SysCalRow *getSysCalRow() ; 550 522 551 523 /** … … 595 567 * vector< unsigned int > v_flag 596 568 **/ 597 const sdmbin::VMSData *vmsData_ ; 569 const sdmbin::VMSData *vmsData_ ; 570 598 571 casa::Int antennaId_ ; // antenna id 599 572 casa::String antennaName_ ; // antenna name 600 casa::Vector<asdm::MainRow *> mainRow_ ; // list of pointers to all Main rows 573 casa::String stationName_ ; // station name 574 casa::Vector<casa::Quantity> antennaPosition_ ; // antenna position 601 575 casa::Vector<casa::uInt> configDescIdList_ ; // list of valid configDescriptionId 602 576 casa::Vector<casa::uInt> feedIdList_ ; // list of valid feedId … … 615 589 casa::CountedPtr<casa::LogSinkInterface> logsink_ ; // Logger 616 590 casa::String className_ ; 591 unsigned int dataIndex_ ; 592 593 // Tables/Rows for ASDM 594 casa::Vector<asdm::MainRow *> mainRow_ ; // list of pointers to all Main rows 595 //asdm::AntennaRow *antennaRow_p ; // pointer to target Antenna row 596 //asdm::StationRow *stationRow_p ; // pointer to target Station row that target antenna is located 597 asdm::SpectralWindowRow *specWinRow_p ; // pointer to SpectralWindow row 598 asdm::PolarizationRow *polarizationRow_p ; // pointer to Polarization row 599 asdm::FieldRow *fieldRow_p ; // pointer to Field row 600 601 // Tags 602 asdm::Tag antennaTag_ ; 603 asdm::Tag specWinTag_ ; 604 asdm::Tag execBlockTag_ ; 605 606 // time 607 asdm::ArrayTimeInterval timeInterval_ ; 617 608 } ; 618 609 #endif // ASAP_OLD_ASDM_READER_H
Note:
See TracChangeset
for help on using the changeset viewer.