Changeset 2435
- Timestamp:
- 03/15/12 15:25:45 (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/scantable.py
r2431 r2435 2309 2309 2310 2310 @asaplog_post_dec 2311 def regrid_channel(self, width=5, plot=False, insitu=None): 2312 """\ 2313 Regrid the spectra by the specified channel width 2314 2315 Parameters: 2316 2317 width: The channel width (float) of regridded spectra 2318 in the current spectral unit. 2319 2320 plot: [NOT IMPLEMENTED YET] 2321 plot the original and the regridded spectra. 2322 In this each indivual fit has to be approved, by 2323 typing 'y' or 'n' 2324 2325 insitu: if False a new scantable is returned. 2326 Otherwise, the scaling is done in-situ 2327 The default is taken from .asaprc (False) 2328 2329 """ 2330 if insitu is None: insitu = rcParams['insitu'] 2331 varlist = vars() 2332 2333 if plot: 2334 asaplog.post() 2335 asaplog.push("Verification plot is not implemtnetd yet.") 2336 asaplog.post("WARN") 2337 2338 s = self.copy() 2339 s._regrid_specchan(width) 2340 2341 s._add_history("regrid_channel", varlist) 2342 2343 # if plot: 2344 # from asap.asapplotter import new_asaplot 2345 # theplot = new_asaplot(rcParams['plotter.gui']) 2346 # theplot.set_panels() 2347 # ylab=s._get_ordinate_label() 2348 # #theplot.palette(0,["#777777","red"]) 2349 # for r in xrange(s.nrow()): 2350 # xsm=s._getabcissa(r) 2351 # ysm=s._getspectrum(r) 2352 # xorg=orgscan._getabcissa(r) 2353 # yorg=orgscan._getspectrum(r) 2354 # theplot.clear() 2355 # theplot.hold() 2356 # theplot.set_axes('ylabel',ylab) 2357 # theplot.set_axes('xlabel',s._getabcissalabel(r)) 2358 # theplot.set_axes('title',s._getsourcename(r)) 2359 # theplot.set_line(label='Original',color="#777777") 2360 # theplot.plot(xorg,yorg) 2361 # theplot.set_line(label='Smoothed',color="red") 2362 # theplot.plot(xsm,ysm) 2363 # ### Ugly part for legend 2364 # for i in [0,1]: 2365 # theplot.subplots[0]['lines'].append( 2366 # [theplot.subplots[0]['axes'].lines[i]] 2367 # ) 2368 # theplot.release() 2369 # ### Ugly part for legend 2370 # theplot.subplots[0]['lines']=[] 2371 # res = raw_input("Accept smoothing ([y]/n): ") 2372 # if res.upper() == 'N': 2373 # s._setspectrum(yorg, r) 2374 # theplot.quit() 2375 # del theplot 2376 # del orgscan 2377 2378 if insitu: self._assign(s) 2379 else: return s 2380 2381 @asaplog_post_dec 2311 2382 def _parse_wn(self, wn): 2312 2383 if isinstance(wn, list) or isinstance(wn, tuple): -
trunk/src/Scantable.cpp
r2433 r2435 1885 1885 } 1886 1886 1887 void 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 } 1887 1927 1888 1928 void asap::Scantable::regridChannel( int nChan, double dnu ) -
trunk/src/Scantable.h
r2411 r2435 501 501 void regridChannel( int nchan, double dnu ) ; 502 502 void regridChannel( int nchan, double dnu, int irow ) ; 503 504 void regridSpecChannel( double dnu, int nchan=-1 ) ; 503 505 504 506 bool getFlagtraFast(casa::uInt whichrow); -
trunk/src/ScantableWrapper.h
r2290 r2435 268 268 { table_->reshapeSpectrum( nmin, nmax ); } 269 269 270 void regridSpecChannel( double dnu, int nchan ) 271 { table_->regridSpecChannel( dnu, nchan ); } 272 270 273 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="") 271 274 { table_->polyBaseline(mask, order, getresidual, showprogress, outlog, blfile); } -
trunk/src/python_Scantable.cpp
r2286 r2435 145 145 (boost::python::arg("nmin")=-1, 146 146 boost::python::arg("nmax")=-1) ) 147 .def("_regrid_specchan", &ScantableWrapper::regridSpecChannel, 148 (boost::python::arg("nchan")=-1) ) 147 149 .def("_poly_baseline", &ScantableWrapper::polyBaseline) 148 150 .def("_auto_poly_baseline", &ScantableWrapper::autoPolyBaseline)
Note:
See TracChangeset
for help on using the changeset viewer.