Changeset 2225 for trunk/external-alma/asdm2ASAP/ASDMReader.cc
- Timestamp:
- 07/14/11 15:02:29 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external-alma/asdm2ASAP/ASDMReader.cc
r2220 r2225 327 327 if ( spwrows[refidx]->isMeasFreqRefExists() ) { 328 328 string mfr = CFrequencyReferenceCode::name( spwrows[refidx]->getMeasFreqRef() ) ; 329 if (mfr == "TOPO") {330 freqref = "TOPOCENT";331 } else if (mfr == "GEO") {332 freqref = "GEOCENTR";333 } else if (mfr == "BARY") {334 freqref = "BARYCENT";335 } else if (mfr == "GALACTO") {336 freqref = "GALACTOC";337 } else if (mfr == "LGROUP") {338 freqref = "LOCALGRP";339 } else if (mfr == "CMB") {340 freqref = "CMBDIPOL";341 } else if (mfr == "REST") {342 freqref = "SOURCE";343 }344 329 // if (mfr == "TOPO") { 330 // freqref = "TOPOCENT"; 331 // } else if (mfr == "GEO") { 332 // freqref = "GEOCENTR"; 333 // } else if (mfr == "BARY") { 334 // freqref = "BARYCENT"; 335 // } else if (mfr == "GALACTO") { 336 // freqref = "GALACTOC"; 337 // } else if (mfr == "LGROUP") { 338 // freqref = "LOCALGRP"; 339 // } else if (mfr == "CMB") { 340 // freqref = "CMBDIPOL"; 341 // } else if (mfr == "REST") { 342 // freqref = "SOURCE"; 343 // } 344 freqref = String( mfr ) ; 345 345 } 346 346 else { 347 347 // frequency reference is TOPOCENT by default 348 freqref = "TOPOCENT" ; 348 //freqref = "TOPOCENT" ; 349 freqref = "TOPO" ; 349 350 } 350 351 … … 977 978 } 978 979 return dir ; 980 } 981 982 void ASDMReader::getSourceDirection( unsigned int idx, 983 vector<double> &dir, 984 string &ref ) 985 { 986 dir.resize( 2 ) ; 987 dir[0] = 0.0 ; 988 dir[1] = 0.0 ; 989 ref = "J2000" ; 990 unsigned int index = dataIdList_[idx] ; 991 //ArrayTimeInterval tint( vmsData_->v_time[index]*s2d, vmsData_->v_interval[index]*s2d ) ; 992 double startSec = vmsData_->v_time[index] - 0.5 * vmsData_->v_interval[index] ; 993 ArrayTimeInterval tint( startSec*s2d, vmsData_->v_interval[index]*s2d ) ; 994 Tag ddtag( vmsData_->v_dataDescId[index], TagType::DataDescription ) ; 995 Tag spwtag = asdm_->getDataDescription().getRowByKey(ddtag)->getSpectralWindowId() ; 996 Tag ftag( vmsData_->v_fieldId[index], TagType::Field ) ; 997 FieldRow *frow = asdm_->getField().getRowByKey( ftag ) ; 998 string srcname ; 999 if ( frow->isSourceIdExists() ) { 1000 //logsink_->postLocally( LogMessage("sourceId exists",LogOrigin(className_,funcName,WHERE)) ) ; 1001 int sid = frow->getSourceId() ; 1002 SourceRow *srow = asdm_->getSource().getRowByKey( sid, tint, spwtag ) ; 1003 vector<Angle> srcdir = srow->getDirection() ; 1004 if ( srow->isDirectionCodeExists() ) { 1005 ref = CDirectionReferenceCode::toString( srow->getDirectionCode() ) ; 1006 } 1007 dir[0] = srcdir[0].get() ; 1008 dir[1] = srcdir[1].get() ; 1009 } 1010 } 1011 1012 void ASDMReader::getSourceDirection( vector<double> &dir, string &ref ) 1013 { 1014 dir.resize( 2 ) ; 1015 ref = "J2000" ; // default is J2000 1016 SourceTable &tab = asdm_->getSource() ; 1017 SourceRow *row = tab.get()[0] ; 1018 vector<Angle> dirA = row->getDirection() ; 1019 dir[0] = dirA[0].get() ; 1020 dir[1] = dirA[1].get() ; 1021 if ( row->isDirectionCodeExists() ) { 1022 ref = CDirectionReferenceCode::toString( row->getDirectionCode() ) ; 1023 } 979 1024 } 980 1025 … … 1618 1663 String funcName = "toJ2000" ; 1619 1664 1620 casa::Vector<casa::Double> azel( 2 ) ; 1665 // casa::Vector<casa::Double> azel( 2 ) ; 1666 // azel[0] = az ; 1667 // azel[1] = el ; 1668 // casa::MEpoch me( casa::Quantity( (casa::Double)mjd, "d" ), casa::MEpoch::UTC ) ; 1669 // casa::Vector<casa::Quantity> qantpos( 3 ) ; 1670 // qantpos[0] = casa::Quantity( antpos[0], "m" ) ; 1671 // qantpos[1] = casa::Quantity( antpos[1], "m" ) ; 1672 // qantpos[2] = casa::Quantity( antpos[2], "m" ) ; 1673 // casa::MPosition mp( casa::MVPosition( qantpos ), 1674 // casa::MPosition::ITRF ) ; 1675 // //ostringstream oss ; 1676 // //mp.print( oss ) ; 1677 // //logsink_->postLocally( LogMessage(oss.str(),LogOrigin(className_,funcName,WHERE)) ) ; 1678 1679 // casa::MeasFrame mf( me, mp ) ; 1680 // casa::MDirection::Convert toj2000( casa::MDirection::AZELGEO, 1681 // casa::MDirection::Ref( casa::MDirection::J2000, mf ) ) ; 1682 // casa::Vector<casa::Double> cdir = toj2000( azel ).getAngle( "rad" ).getValue() ; 1683 // //logsink_->postLocally( LogMessage("cdir = "+String::toString(cdir),LogOrigin(className_,funcName,WHERE)) ) ; 1684 // dir.resize(2) ; 1685 // dir[0] = (double)(cdir[0]) ; 1686 // dir[1] = (double)(cdir[1]) ; 1687 vector<double> azel( 2 ) ; 1621 1688 azel[0] = az ; 1622 1689 azel[1] = el ; 1623 casa::MEpoch me( casa::Quantity( (casa::Double)mjd, "d" ), casa::MEpoch::UTC ) ; 1624 casa::Vector<casa::Quantity> qantpos( 3 ) ; 1625 qantpos[0] = casa::Quantity( antpos[0], "m" ) ; 1626 qantpos[1] = casa::Quantity( antpos[1], "m" ) ; 1627 qantpos[2] = casa::Quantity( antpos[2], "m" ) ; 1628 casa::MPosition mp( casa::MVPosition( qantpos ), 1629 casa::MPosition::ITRF ) ; 1630 //ostringstream oss ; 1631 //mp.print( oss ) ; 1632 //logsink_->postLocally( LogMessage(oss.str(),LogOrigin(className_,funcName,WHERE)) ) ; 1633 1634 casa::MeasFrame mf( me, mp ) ; 1635 casa::MDirection::Convert toj2000( casa::MDirection::AZELGEO, 1636 //MDirection::Convert toj2000( MDirection::AZEL, 1637 //MDirection::Convert toj2000( MDirection::AZELSW, 1638 //MDirection::Convert toj2000( MDirection::AZELSWGEO, 1639 //MDirection::Convert toj2000( MDirection::AZELNE, 1640 //MDirection::Convert toj2000( MDirection::AZELNEGEO, 1641 casa::MDirection::Ref( casa::MDirection::J2000, mf ) ) ; 1642 casa::Vector<casa::Double> cdir = toj2000( azel ).getAngle( "rad" ).getValue() ; 1643 //logsink_->postLocally( LogMessage("cdir = "+String::toString(cdir),LogOrigin(className_,funcName,WHERE)) ) ; 1644 dir.resize(2) ; 1645 dir[0] = (double)(cdir[0]) ; 1646 dir[1] = (double)(cdir[1]) ; 1690 dir = toJ2000( azel, "AZELGEO", mjd, antpos ) ; 1691 } 1692 1693 vector<double> ASDMReader::toJ2000( vector<double> dir, 1694 casa::String dirref, 1695 double mjd, 1696 casa::Vector<casa::Double> antpos ) 1697 { 1698 casa::String funcname = "toJ2000" ; 1699 1700 vector<double> newd( dir ) ; 1701 if ( dirref != "J2000" ) { 1702 casa::MEpoch me( casa::Quantity( (casa::Double)mjd, "d" ), casa::MEpoch::UTC ) ; 1703 casa::Vector<casa::Quantity> qantpos( 3 ) ; 1704 qantpos[0] = casa::Quantity( antpos[0], "m" ) ; 1705 qantpos[1] = casa::Quantity( antpos[1], "m" ) ; 1706 qantpos[2] = casa::Quantity( antpos[2], "m" ) ; 1707 casa::MPosition mp( casa::MVPosition( qantpos ), 1708 casa::MPosition::ITRF ) ; 1709 //ostringstream oss ; 1710 //mp.print( oss ) ; 1711 //logsink_->postLocally( LogMessage(oss.str(),LogOrigin(className_,funcName,WHERE)) ) ; 1712 1713 casa::MeasFrame mf( me, mp ) ; 1714 casa::MDirection::Types dirtype ; 1715 casa::Bool b = casa::MDirection::getType( dirtype, dirref ) ; 1716 if ( b ) { 1717 casa::MDirection::Convert toj2000( dirtype, 1718 casa::MDirection::Ref( casa::MDirection::J2000, mf ) ) ; 1719 casa::Vector<casa::Double> cdir = toj2000( dir ).getAngle( "rad" ).getValue() ; 1720 //logsink_->postLocally( LogMessage("cdir = "+String::toString(cdir),LogOrigin(className_,funcName,WHERE)) ) ; 1721 newd[0] = (double)(cdir[0]) ; 1722 newd[1] = (double)(cdir[1]) ; 1723 } 1724 } 1725 return newd ; 1647 1726 } 1648 1727
Note: See TracChangeset
for help on using the changeset viewer.