Ignore:
Timestamp:
07/14/11 15:02:29 (13 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-1913

Ready for Test: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes/No?

Module(s): Module Names change impacts.

Description: Describe your changes here...

Frequency is stored as LSRK value although raw frequency value is
in arbitrary frequency frame.
Also, direction is stored as J2000 value independently of original
direction reference code.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/external-alma/asdm2ASAP/ASDMFiller.cc

    r2220 r2225  
    77#include <measures/Measures/MDirection.h>
    88#include <measures/Measures/MCDirection.h>
     9#include <measures/Measures/MFrequency.h>
     10#include <measures/Measures/MCFrequency.h>
    911#include <measures/Measures/MeasFrame.h>
    1012#include <measures/Measures/MeasConvert.h>
     
    5153  antennaName_ = reader_->getAntennaName() ;
    5254
    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)) ) ;
    5557
    5658  return status ;
     
    8284  uInt numConfigDescId = configDescIdList.size() ;
    8385
    84   //logsink->postLocally( LogMessage("configDescIdList = "+String::toString(configDescIdList),LogOrigin(className_,funcName,WHERE)) ) ;
     86  //logsink_->postLocally( LogMessage("configDescIdList = "+String::toString(configDescIdList),LogOrigin(className_,funcName,WHERE)) ) ;
    8587
    8688  // get field list
     
    8890  uInt numFieldId = fieldIdList.size() ;
    8991
    90   //logsink->postLocally( LogMessage("fieldIdList = "+String::toString(fieldIdList),LogOrigin(className_,funcName,WHERE)) ) ;
     92  //logsink_->postLocally( LogMessage("fieldIdList = "+String::toString(fieldIdList),LogOrigin(className_,funcName,WHERE)) ) ;
    9193
    9294  // BEAMNO is always 0 since ALMA antenna is single beam
     
    187189          string fieldname = reader_->getFieldName( idata ) ;
    188190          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 ) ;
    190195          vector<double> srcProperMotion = reader_->getSourceProperMotion( idata ) ;
    191196          double sysVel = reader_->getSysVel( idata ) ;
     
    343348                       hdr.poltype ) ;
    344349
     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
    345375  setHeader( hdr ) ;
    346376}
     
    498528  azel[0] = az ;
    499529  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
     546Vector<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 ;
    513571}
    514572
     
    525583  return ftype ;
    526584}
     585
     586casa::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}
Note: See TracChangeset for help on using the changeset viewer.