Changeset 2435 for trunk/src


Ignore:
Timestamp:
03/15/12 15:25:45 (13 years ago)
Author:
Kana Sugimoto
Message:

New Development: Yes

JIRA Issue: Yes (CAS-2818)

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: Added methods and functions
scantable.regrid_channel, scantable._regrid_specchan (defined in python_Scantable.cpp),
Scantable::regridSpecChannel, and ScantableWrapper::regridSpecChannel

Test Programs: comming soon with sdsmooth

Put in Release Notes: No

Module(s): scantable

Description:

Enabled regridding of spectra in a scantable.

scantable.regrid_channel(width, insitu=True/False)

will do this.
width can be either in channel, frequency, or velocity unit.
verification is not available yet.


Location:
trunk/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r2433 r2435  
    18851885}
    18861886
     1887void asap::Scantable::regridSpecChannel( double dnu, int nChan )
     1888{
     1889  LogIO os( LogOrigin( "Scantable", "regridChannel()", WHERE ) ) ;
     1890  os << "Regrid abcissa with spectral resoultion " << dnu << " " << freqTable_.getUnitString() << " with channel number " << ((nChan>0)? String(nChan) : "covering band width")<< LogIO::POST ;
     1891  int freqnrow = freqTable_.table().nrow() ;
     1892  Vector<bool> firstTime( freqnrow, true ) ;
     1893  double oldincr, factor;
     1894  uInt currId;
     1895  Double refpix ;
     1896  Double refval ;
     1897  Double increment ;
     1898  for ( int irow = 0 ; irow < nrow() ; irow++ ) {
     1899    currId = mfreqidCol_(irow);
     1900    vector<double> abcissa = getAbcissa( irow ) ;
     1901    if (nChan < 0) {
     1902      int oldsize = abcissa.size() ;
     1903      double bw = (abcissa[oldsize-1]-abcissa[0]) +                     \
     1904        0.5 * (abcissa[1]-abcissa[0] + abcissa[oldsize-1]-abcissa[oldsize-2]) ;
     1905      nChan = int( ceil( abs(bw/dnu) ) ) ;
     1906    }
     1907    // actual regridding
     1908    regridChannel( nChan, dnu, irow ) ;
     1909
     1910    // update FREQUENCIES subtable
     1911    if (firstTime[currId]) {
     1912      oldincr = abcissa[1]-abcissa[0] ;
     1913      factor = dnu/oldincr ;
     1914      firstTime[currId] = false ;
     1915      freqTable_.getEntry( refpix, refval, increment, currId ) ;
     1916      /***
     1917       * need to shift refpix to 0
     1918       ***/
     1919      refval = refval - ( refpix + 0.5 * (1 - factor) ) * increment ;
     1920      refpix = 0 ;
     1921      freqTable_.setEntry( refpix, refval, increment*factor, currId ) ;
     1922      os << "ID" << currId << ": channel width (Orig) = " << oldincr << " [" << freqTable_.getUnitString() << "], scale factor = " << factor << LogIO::POST ;
     1923      os << "     frequency increment (Orig) = " << increment << "-> (New) " << increment*factor << LogIO::POST ;
     1924    }
     1925  }
     1926}
    18871927
    18881928void asap::Scantable::regridChannel( int nChan, double dnu )
  • trunk/src/Scantable.h

    r2411 r2435  
    501501  void regridChannel( int nchan, double dnu ) ;
    502502  void regridChannel( int nchan, double dnu, int irow ) ;
     503
     504  void regridSpecChannel( double dnu, int nchan=-1 ) ;
    503505
    504506  bool getFlagtraFast(casa::uInt whichrow);
  • trunk/src/ScantableWrapper.h

    r2290 r2435  
    268268  { table_->reshapeSpectrum( nmin, nmax ); }
    269269
     270  void regridSpecChannel( double dnu, int nchan )
     271  { table_->regridSpecChannel( dnu, nchan ); }
     272
    270273  void polyBaseline(const std::vector<bool>& mask, int order, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="")
    271274  { table_->polyBaseline(mask, order, getresidual, showprogress, outlog, blfile); }
  • trunk/src/python_Scantable.cpp

    r2286 r2435  
    145145         (boost::python::arg("nmin")=-1,
    146146          boost::python::arg("nmax")=-1) )
     147    .def("_regrid_specchan", &ScantableWrapper::regridSpecChannel,
     148         (boost::python::arg("nchan")=-1) )
    147149    .def("_poly_baseline", &ScantableWrapper::polyBaseline)
    148150    .def("_auto_poly_baseline", &ScantableWrapper::autoPolyBaseline)
Note: See TracChangeset for help on using the changeset viewer.