Changeset 2754


Ignore:
Timestamp:
01/31/13 13:14:27 (12 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CSV-2532 (may be related to CSV-1908 and CSV-2161)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: In tool level, added parameter 'freq_tolsr' to

scantable constructor and function sd.splitant.

Test Programs: test_sdsave, test_importasdm_sd

Put in Release Notes: Yes

Module(s): Module Names change impacts.

Description: Describe your changes here...

In importing MS to Scantable, frequency frame information is
imported as is by default, i.e., base frame in Scantable is
TOPO for ALMA data, which is forcibly converted to LSRK with
wrong time and direction reference.

Some functions have a boolean parameter 'freq_tolsr' that controls
the above behavior. If freq_tolsr is False (default), frequency
is imported as is, while frequency is converted to LSRK (wrongly)
when it is True.


Location:
trunk
Files:
7 edited

Legend:

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

    r2710 r2754  
    2626    antennaId_( -1 ),
    2727    antennaName_( "" ),
    28     className_("ASDMFiller")
     28    className_("ASDMFiller"),
     29    freqToLsr_(False)
    2930{
    3031  reader_ = new ASDMReader() ;
     
    5253  antennaId_ = reader_->getAntennaId() ;
    5354  antennaName_ = reader_->getAntennaName() ;
     55
     56  if (rec.isDefined("asdm")) {
     57    Record asdmrec = rec.asRecord("asdm") ;
     58    if (asdmrec.isDefined("freq_tolsr")) {
     59      freqToLsr_ = asdmrec.asBool("freq_tolsr");
     60    }
     61  }
     62  logsink_->postLocally(LogMessage("freqToLsr_ = "+String(freqToLsr_?"True":"False"), LogOrigin(className_, funcName, WHERE)));
    5463
    5564  //logsink_->postLocally( LogMessage("antennaId_ = "+String::toString(antennaId_),LogOrigin(className_,funcName,WHERE)) ) ;
     
    7281  MFrequency::Types freqFrame = MFrequency::LSRK ;
    7382  table_->frequencies().setFrame( freqFrame, false ) ;
    74   table_->frequencies().setFrame( freqFrame, true ) ;
     83  if ( freqToLsr_ ) {
     84    table_->frequencies().setFrame( freqFrame, true ) ;
     85  }
     86  else {
     87    string baseFrame = reader_->getFrame() ;
     88    table_->frequencies().setFrame( baseFrame, true ) ;
     89  }
    7590  //logsink_->postLocally( LogMessage("sFreqFrame = "+sFreqFrame,LogOrigin(className_,funcName,WHERE)) ) ;
    7691 
     
    615630  //logsink_->postLocally( LogMessage("freqref = "+freqref,LogOrigin(className_,funcName,WHERE)) ) ;
    616631  casa::Double newf = freq ;
    617   if ( freqref != "LSRK" ) {
     632  if ( freqToLsr_ && freqref != "LSRK" ) {
    618633    MEpoch me( Quantum<casa::Double>( utc, Unit("d") ), MEpoch::UTC ) ;
    619634    Vector< Quantum<casa::Double> > antposQ( 3 ) ;
  • trunk/external-alma/asdm2ASAP/ASDMFiller.h

    r2225 r2754  
    102102
    103103  casa::String className_ ;
     104  casa::Bool freqToLsr_ ;
    104105
    105106} ;
  • trunk/external-alma/asdm2ASAP/asdm2ASAP.cc

    r2273 r2754  
    4949  inp.create( "srt", "all", "spectral resolution mode: all|fr(full resolution)|ca(channel average)|bw(baseband wide)|fr+ca|fr+bw|ca+bw", "String" ) ;
    5050  inp.create( "logfile", "", "logger output", "String" ) ;
     51  inp.create( "freq-tolsr", "False", "Convert frequency frame to LSRK or not: True|False", "Bool" ) ;
    5152  inp.readArguments( argc, argv ) ;
    5253
     
    6061  string resolutionType = inp.getString( "srt" ) ;
    6162  string logfile = inp.getString( "logfile" ) ;
     63  Bool freqToLsr = inp.getBool( "freq-tolsr" ) ;
    6264   
    6365  int numApc = 1 ;
     
    112114    asdmRec.define( "sampling", timeSampling ) ;
    113115    asdmRec.define( "srt", resolutionType ) ;
     116    asdmRec.define( "freq_tolsr", freqToLsr ) ;
    114117    if ( reg.match( antenna.c_str(), antenna.size() ) != String::npos ) {
    115118      // antenna is specifiec as id
  • trunk/python/asapmath.py

    r2646 r2754  
    949949
    950950@asaplog_post_dec
    951 def splitant(filename, outprefix='',overwrite=False):
     951def splitant(filename, outprefix='',overwrite=False, getpt=True, freq_tolsr=False):
    952952    """
    953953    Split Measurement set by antenna name, save data as a scantables,
     
    963963                    The default False is to return with warning
    964964                    without writing the output. USE WITH CARE.
     965       getpt        Whether to import direction from MS/POINTING
     966                    table or not. Default is True (import direction).
     967       freq_tolsr   Whether to convert frequency frame information
     968                    to LSRK or not. Default is False (import as is).
    965969
    966970    """
     
    10081012        tb.open(tablename=filename,nomodify=True)
    10091013        tbsel=tb.query('ANTENNA1 == %s && ANTENNA2 == %s'%(antid,antid),tmpname)
    1010         scan=scantable(tmpname,average=False,getpt=True,antenna=int(antid))
     1014        scan=scantable(tmpname,average=False,antenna=int(antid),getpt=getpt,freq_tolsr=freq_tolsr,)
    10111015        outname=prefix+antnames[antid]+'.asap'
    10121016        scan.save(outname,format='ASAP',overwrite=overwrite)
  • trunk/python/scantable.py

    r2753 r2754  
    209209                          Default (false) is taken from rc file.
    210210
     211            getpt:        Whether to import direction from MS/POINTING
     212                          table properly or not.
     213                          This is effective only when filename is MS.
     214                          The default (True) is to import direction
     215                          from MS/POINTING.
     216
     217            freq_tolsr:   Whether to convert frequency frame information
     218                          to LSRK or not.
     219                          This is effective only when filename is MS.
     220                          The default (False) is to import frequency
     221                          as is.
     222                         
    211223        """
    212224        if average is None:
  • trunk/src/MSFiller.cpp

    r2746 r2754  
    257257  MSFillerVisitor(const Table &from, Scantable &to)
    258258    : BaseMSFillerVisitor(from),
    259       scantable( to )
     259      scantable(to),
     260      freqToLsr_(False)
    260261  {
    261262    antennaId = 0 ;
     
    712713    sysCalTsysCol.attach( sctab, tsysCol ) ;
    713714  }
     715  void setFreqToLsr(Bool b) { freqToLsr_ = b; }
    714716  STHeader getHeader() { return header ; }
    715717  uInt getNumBeam() { return nbeam ; }
     
    816818    MFrequency::Types freqRef = MFrequency::castType( measFreqRef ) ;
    817819    //freqref = MFrequency::showType( freqRef ) ;
    818     freqref = "LSRK" ;
     820    //freqref = "LSRK" ;
     821    freqref = "TOPO";
    819822    Quantum<Double> q ;
    820823    getScalarQuant( "TOTAL_BANDWIDTH", spwId, spwtab, q ) ;
     
    842845    if ( even )
    843846      refval = 0.5 * ( refval + qa[refchan+1].getValue( "Hz" ) ) ;
    844     if ( freqRef != MFrequency::LSRK ) {
     847    if ( freqToLsr_ && freqRef != MFrequency::LSRK ) {
     848      //cout << "do conversion to LSRK" << endl;
    845849      MeasFrame mframe( me, mp, md ) ;
    846850      MFrequency::Convert tolsr( freqRef, MFrequency::Ref( MFrequency::LSRK, mframe ) ) ;
     
    13141318  //String tsysCol;
    13151319  //String tcalCol;
     1320  Bool freqToLsr_;
    13161321
    13171322  // MS subtables
     
    15851590    antennaStr_(""),
    15861591    getPt_( True ),
     1592    freqToLsr_( False ),
    15871593    isFloatData_( False ),
    15881594    isData_( False ),
     
    16311637      antenna_ = 0 ;
    16321638    }
     1639    if ( msrec.isDefined( "freq_tolsr" ) ) {
     1640      freqToLsr_ = msrec.asBool( "freq_tolsr" ) ;
     1641    }
    16331642  }
    16341643
     
    16491658
    16501659  os_ << "Parsing MS options" << endl ;
    1651   os_ << "   getPt = " << getPt_ << endl ;
     1660  os_ << "   getPt = " << (getPt_ ? "True" : "False") << endl ;
    16521661  os_ << "   antenna = " << antenna_ << endl ;
    1653   os_ << "   antennaStr = " << antennaStr_ << LogIO::POST ;
     1662  os_ << "   antennaStr = " << antennaStr_ << endl ;
     1663  os_ << "   freqToLsr = " << (freqToLsr_  ? "True" : "False") << LogIO::POST;
    16541664
    16551665  mstable_ = MeasurementSet( (*tmpMS)( tmpMS->col("ANTENNA1") == antenna_
     
    17451755  string freqFrame = "LSRK" ;
    17461756  table_->frequencies().setFrame( freqFrame ) ;
    1747   table_->frequencies().setFrame( freqFrame, True ) ;
     1757  if ( freqToLsr_ ) {
     1758    table_->frequencies().setFrame( freqFrame, True ) ;
     1759  }
     1760  else {
     1761    string baseFrame = frameFromSpwTable() ;
     1762    table_->frequencies().setFrame( baseFrame, True ) ;
     1763  }
    17481764
    17491765  // SUBTABLES: WEATHER
     
    17911807    if ( isSysCal_ )
    17921808      myVisitor.setSysCalRecord( tcalrec_ ) ;
     1809    myVisitor.setFreqToLsr( freqToLsr_ ) ;
    17931810   
    17941811    //double t2 = mathutil::gettimeofday_sec() ;
     
    21592176}
    21602177
     2178string MSFiller::frameFromSpwTable()
     2179{
     2180  string frameString;
     2181  Table tab = mstable_.spectralWindow();
     2182  ROScalarColumn<Int> mfrCol(tab, "MEAS_FREQ_REF");
     2183  Vector<Int> mfr = mfrCol.getColumn();
     2184  if (allEQ(mfr,mfr[0])) {
     2185    frameString = MFrequency::showType(mfr[0]);
     2186    //cout << "all rows have same frame: " << frameString << endl;
     2187  }
     2188  else {
     2189    mfrCol.attach(tab, "NUM_CHAN");
     2190    for (uInt i = 0; i < tab.nrow(); i++) {
     2191      if (mfrCol(i) != 4) {
     2192        frameString = MFrequency::showType(mfr[i]);
     2193        break;
     2194      }
     2195    }
     2196    if (frameString.size() == 0) {
     2197      frameString = "TOPO";
     2198    }
     2199  }
     2200
     2201  //cout << "frameString = " << frameString << endl;
     2202
     2203  return frameString;
     2204}
     2205
    21612206};
  • trunk/src/MSFiller.h

    r2744 r2754  
    156156  void initHeader( STHeader &header ) ;
    157157
     158  // get base frame from SPECTRAL_WINDOW table
     159  std::string frameFromSpwTable();
     160
    158161  CountedPtr<Scantable> table_ ;
    159162  MeasurementSet mstable_ ;
     
    162165  String antennaStr_ ;
    163166  Bool getPt_ ;
     167  Bool freqToLsr_ ;
    164168
    165169  Bool isFloatData_ ;
Note: See TracChangeset for help on using the changeset viewer.