Ignore:
Timestamp:
03/15/12 15:25:45 (12 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.


File:
1 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 )
Note: See TracChangeset for help on using the changeset viewer.