Changeset 2225 for trunk/external-alma/asdm2ASAP
- Timestamp:
- 07/14/11 15:02:29 (13 years ago)
- Location:
- trunk/external-alma/asdm2ASAP
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/external-alma/asdm2ASAP/ASDMFiller.cc
r2220 r2225 7 7 #include <measures/Measures/MDirection.h> 8 8 #include <measures/Measures/MCDirection.h> 9 #include <measures/Measures/MFrequency.h> 10 #include <measures/Measures/MCFrequency.h> 9 11 #include <measures/Measures/MeasFrame.h> 10 12 #include <measures/Measures/MeasConvert.h> … … 51 53 antennaName_ = reader_->getAntennaName() ; 52 54 53 //logsink ->postLocally( LogMessage("antennaId_ = "+String::toString(antennaId_),LogOrigin(className_,funcName,WHERE)) ) ;54 //logsink ->postLocally( LogMessage("antennaName_ = "+antennaName_,LogOrigin(className_,funcName,WHERE)) ) ;55 //logsink_->postLocally( LogMessage("antennaId_ = "+String::toString(antennaId_),LogOrigin(className_,funcName,WHERE)) ) ; 56 //logsink_->postLocally( LogMessage("antennaName_ = "+antennaName_,LogOrigin(className_,funcName,WHERE)) ) ; 55 57 56 58 return status ; … … 82 84 uInt numConfigDescId = configDescIdList.size() ; 83 85 84 //logsink ->postLocally( LogMessage("configDescIdList = "+String::toString(configDescIdList),LogOrigin(className_,funcName,WHERE)) ) ;86 //logsink_->postLocally( LogMessage("configDescIdList = "+String::toString(configDescIdList),LogOrigin(className_,funcName,WHERE)) ) ; 85 87 86 88 // get field list … … 88 90 uInt numFieldId = fieldIdList.size() ; 89 91 90 //logsink ->postLocally( LogMessage("fieldIdList = "+String::toString(fieldIdList),LogOrigin(className_,funcName,WHERE)) ) ;92 //logsink_->postLocally( LogMessage("fieldIdList = "+String::toString(fieldIdList),LogOrigin(className_,funcName,WHERE)) ) ; 91 93 92 94 // BEAMNO is always 0 since ALMA antenna is single beam … … 187 189 string fieldname = reader_->getFieldName( idata ) ; 188 190 int srctype = reader_->getSrcType( scanno, subscanno ) ; 189 vector<double> srcDirection = reader_->getSourceDirection( idata ) ; 191 //vector<double> srcDirection = reader_->getSourceDirection( idata ) ; 192 vector<double> srcDirection ; 193 string srcDirRef ; 194 reader_->getSourceDirection( idata, srcDirection, srcDirRef ) ; 190 195 vector<double> srcProperMotion = reader_->getSourceProperMotion( idata ) ; 191 196 double sysVel = reader_->getSysVel( idata ) ; … … 343 348 hdr.poltype ) ; 344 349 350 if ( hdr.freqref != "LSRK" ) { 351 // String freqref ; 352 // if (hdr.freqref == "TOPOCENT") { 353 // freqref = "TOPO"; 354 // } else if (hdr.freqref == "GEOCENTR") { 355 // freqref = "GEO"; 356 // } else if (hdr.freqref == "BARYCENT") { 357 // freqref = "BARY"; 358 // } else if (hdr.freqref == "GALACTOC") { 359 // freqref = "GALACTO"; 360 // } else if (hdr.freqref == "LOCALGRP") { 361 // freqref = "LGROUP"; 362 // } else if (hdr.freqref == "CMBDIPOL") { 363 // freqref = "CMB"; 364 // } else if (hdr.freqref == "SOURCE") { 365 // freqref = "REST"; 366 // } 367 vector<double> sdir ; 368 string ref ; 369 reader_->getSourceDirection( sdir, ref ) ; 370 Vector<casa::Double> sourceDir( sdir ) ; 371 hdr.reffreq = toLSRK( hdr.reffreq, hdr.freqref, hdr.utc, hdr.antennaposition, sdir, String(ref) ) ; 372 hdr.freqref = "LSRK" ; 373 } 374 345 375 setHeader( hdr ) ; 346 376 } … … 498 528 azel[0] = az ; 499 529 azel[1] = el ; 500 MEpoch me( Quantity( mjd, "d" ), MEpoch::UTC ) ; 501 Vector<Quantity> qantpos( 3 ) ; 502 qantpos[0] = Quantity( antpos[0], "m" ) ; 503 qantpos[1] = Quantity( antpos[1], "m" ) ; 504 qantpos[2] = Quantity( antpos[2], "m" ) ; 505 MPosition mp( MVPosition( qantpos ), 506 MPosition::ITRF ) ; 507 // mp.print( os_.output() ) ; 508 MeasFrame mf( me, mp ) ; 509 MDirection::Convert toj2000( MDirection::AZELGEO, 510 MDirection::Ref( MDirection::J2000, mf ) ) ; 511 dir = toj2000( azel ).getAngle( "rad" ).getValue() ; 512 //logsink->postLocally( LogMessage("dir = "+String::toString(dir),LogOrigin(className_,funcName,WHERE)) ) ; 530 // MEpoch me( Quantity( mjd, "d" ), MEpoch::UTC ) ; 531 // Vector<Quantity> qantpos( 3 ) ; 532 // qantpos[0] = Quantity( antpos[0], "m" ) ; 533 // qantpos[1] = Quantity( antpos[1], "m" ) ; 534 // qantpos[2] = Quantity( antpos[2], "m" ) ; 535 // MPosition mp( MVPosition( qantpos ), 536 // MPosition::ITRF ) ; 537 // // mp.print( os_.output() ) ; 538 // MeasFrame mf( me, mp ) ; 539 // MDirection::Convert toj2000( MDirection::AZELGEO, 540 // MDirection::Ref( MDirection::J2000, mf ) ) ; 541 // dir = toj2000( azel ).getAngle( "rad" ).getValue() ; 542 dir = toJ2000( azel, "AZELGEO", mjd, antpos ) ; 543 //logsink_->postLocally( LogMessage("dir = "+String::toString(dir),LogOrigin(className_,funcName,WHERE)) ) ; 544 } 545 546 Vector<casa::Double> ASDMFiller::toJ2000( Vector<casa::Double> dir, 547 String dirref, 548 casa::Double mjd, 549 Vector<casa::Double> antpos ) 550 { 551 Vector<casa::Double> newd( dir ) ; 552 if ( dirref != "J2000" ) { 553 MEpoch me( Quantity( mjd, "d" ), MEpoch::UTC ) ; 554 Vector<Quantity> qantpos( 3 ) ; 555 qantpos[0] = Quantity( antpos[0], "m" ) ; 556 qantpos[1] = Quantity( antpos[1], "m" ) ; 557 qantpos[2] = Quantity( antpos[2], "m" ) ; 558 MPosition mp( MVPosition( qantpos ), 559 MPosition::ITRF ) ; 560 // mp.print( os_.output() ) ; 561 MeasFrame mf( me, mp ) ; 562 MDirection::Types dirtype ; 563 Bool b = MDirection::getType( dirtype, dirref ) ; 564 if ( b ) { 565 MDirection::Convert toj2000( dirtype, 566 MDirection::Ref( MDirection::J2000, mf ) ) ; 567 newd = toj2000( dir ).getAngle( "rad" ).getValue() ; 568 } 569 } 570 return newd ; 513 571 } 514 572 … … 525 583 return ftype ; 526 584 } 585 586 casa::Double ASDMFiller::toLSRK( casa::Double freq, 587 String freqref, 588 casa::Double utc, 589 Vector<casa::Double> antpos, 590 Vector<casa::Double> dir, 591 String dirref ) 592 { 593 String funcName = "toLSRK" ; 594 595 //logsink_->postLocally( LogMessage("freqref = "+freqref,LogOrigin(className_,funcName,WHERE)) ) ; 596 casa::Double newf = freq ; 597 if ( freqref != "LSRK" ) { 598 MEpoch me( Quantum<casa::Double>( utc, Unit("d") ), MEpoch::UTC ) ; 599 Vector< Quantum<casa::Double> > antposQ( 3 ) ; 600 for ( int i = 0 ; i < 3 ; i++ ) 601 antposQ[i] = Quantum<casa::Double>( antpos[i], Unit("m") ) ; 602 MPosition mp( antposQ, MPosition::ITRF ) ; 603 MDirection::Types dirtype ; 604 Bool b = MDirection::getType( dirtype, dirref ) ; 605 if ( !b ) 606 dirtype = MDirection::J2000 ; 607 MDirection md( Quantum<casa::Double>( dir[0], Unit("rad") ), 608 Quantum<casa::Double>( dir[1], Unit("rad") ), 609 dirtype ) ; 610 MeasFrame mf( me, mp, md ) ; 611 MFrequency::Types freqtype ; 612 b = MFrequency::getType( freqtype, freqref ) ; 613 if ( !b ) 614 freqtype = MFrequency::TOPO ; 615 MFrequency::Convert tolsr( freqtype, 616 MFrequency::Ref( MFrequency::LSRK, mf ) ) ; 617 newf = tolsr( Quantum<casa::Double>( freq, Unit("Hz") ) ).get( "Hz" ).getValue() ; 618 //logsink_->postLocally( LogMessage("freq = "+String::toString(freq)+", newf = "+String::toString(newf),LogOrigin(className_,funcName,WHERE)) ) ; 619 } 620 return newf ; 621 } -
trunk/external-alma/asdm2ASAP/ASDMFiller.h
r2218 r2225 74 74 casa::Vector<casa::Double> antpos ) ; 75 75 76 // to J2000 77 casa::Vector<casa::Double> toJ2000( casa::Vector<casa::Double> dir, 78 casa::String dirref, 79 casa::Double mjd, 80 casa::Vector<casa::Double> antpos ) ; 81 76 82 // get frequency frame enum value from string 77 83 casa::MFrequency::Types toFrameType( std::string &s ) ; 84 85 // to LSRK 86 // utc must be UTC time in "d" (day) 87 // antpos must be ITRF value in "m" 88 casa::Double toLSRK( casa::Double freq, 89 casa::String freqref, 90 casa::Double utc, 91 casa::Vector<casa::Double> antpos, 92 casa::Vector<casa::Double> dir, 93 casa::String dirref ) ; 78 94 79 95 casa::CountedPtr<ASDMReader> reader_ ; -
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 -
trunk/external-alma/asdm2ASAP/ASDMReader.h
r2220 r2225 237 237 **/ 238 238 std::vector<double> getSourceDirection( unsigned int idx ) ; 239 void getSourceDirection( unsigned int idx, 240 std::vector<double> &dir, 241 std::string &ref ) ; 242 243 /** 244 * get source direction with reference 245 * 246 * @param dir source direction 247 * @param reference frame 248 * @param idx for Source table 249 **/ 250 void getSourceDirection( std::vector<double> &dir, std::string &ref ) ; 239 251 240 252 /** … … 496 508 casa::Vector<casa::Double> antpos ) ; 497 509 510 /** 511 * to J2000 512 * 513 * @param dir pointing direction 514 * @param dirref direction reference 515 * @param mjd reference time 516 * @param antpos antenna position vector 517 * @return new direction 518 **/ 519 std::vector<double> toJ2000( std::vector<double> dir, 520 casa::String dirref, 521 double mjd, 522 casa::Vector<casa::Double> antpos ) ; 498 523 /** 499 524 * get nIF
Note:
See TracChangeset
for help on using the changeset viewer.