Changeset 2095
- Timestamp:
- 04/01/11 21:43:18 (14 years ago)
- Location:
- branches/casa-prerelease/pre-asap
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/casa-prerelease/pre-asap
-
branches/casa-prerelease/pre-asap/Makefile
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/casa-prerelease/pre-asap/SConstruct
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/casa-prerelease/pre-asap/apps
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/casa-prerelease/pre-asap/external-alma
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/casa-prerelease/pre-asap/external-alma/atnf/pks/pks_maths.cc
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/casa-prerelease/pre-asap/getsvnrev.sh
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/casa-prerelease/pre-asap/python
- Property svn:mergeinfo changed
/trunk/python merged: 2094
- Property svn:mergeinfo changed
-
branches/casa-prerelease/pre-asap/python/scantable.py
r2082 r2095 2073 2073 clipthresh=None, clipniter=None, plot=None, getresidual=None, outlog=None, blfile=None): 2074 2074 """\ 2075 Return a scan which has been baselined (all rows) bysinusoidal functions.2075 Return a scan which has been baselined (all rows) with sinusoidal functions. 2076 2076 Parameters: 2077 2077 insitu: If False a new scantable is returned. … … 2166 2166 chan_avg_limit=None, plot=None, getresidual=None, outlog=None, blfile=None): 2167 2167 """\ 2168 Return a scan which has been baselined (all rows) by cubic spline 2169 function (piecewise cubic polynomial). 2168 Return a scan which has been baselined (all rows) with sinusoidal functions. 2170 2169 Spectral lines are detected first using linefinder and masked out 2171 2170 to avoid them affecting the baseline solution. … … 2309 2308 2310 2309 @asaplog_post_dec 2311 def cspline_baseline(self, insitu=None, mask=None, npiece=None, clipthresh=None, clipniter=None, plot=None, outlog=None, blfile=None): 2310 def cspline_baseline(self, insitu=None, mask=None, npiece=None, 2311 clipthresh=None, clipniter=None, plot=None, getresidual=None, outlog=None, blfile=None): 2312 2312 """\ 2313 2313 Return a scan which has been baselined (all rows) by cubic spline function (piecewise cubic polynomial). … … 2324 2324 indivual fit has to be approved, by typing 'y' 2325 2325 or 'n' 2326 getresidual:if False, returns best-fit values instead of 2327 residual. (default is True) 2326 2328 outlog: Output the coefficients of the best-fit 2327 2329 function to logger (default is False) … … 2350 2352 nchan = workscan.nchan() 2351 2353 2352 if mask is None: mask = [True for i in xrange(nchan)] 2353 if npiece is None: npiece = 2 2354 if clipthresh is None: clipthresh = 3.0 2355 if clipniter is None: clipniter = 1 2356 if plot is None: plot = False 2357 if outlog is None: outlog = False 2358 if blfile is None: blfile = "" 2354 if mask is None: mask = [True for i in xrange(nchan)] 2355 if npiece is None: npiece = 2 2356 if clipthresh is None: clipthresh = 3.0 2357 if clipniter is None: clipniter = 1 2358 if plot is None: plot = False 2359 if getresidual is None: getresidual = True 2360 if outlog is None: outlog = False 2361 if blfile is None: blfile = "" 2359 2362 2360 2363 outblfile = (blfile != "") and os.path.exists(os.path.expanduser(os.path.expandvars(blfile))) … … 2362 2365 try: 2363 2366 #CURRENTLY, PLOT=true UNAVAILABLE UNTIL cubic spline fitting is implemented as a fitter method. 2364 workscan._cspline_baseline(mask, npiece, clipthresh, clipniter, outlog, blfile)2367 workscan._cspline_baseline(mask, npiece, clipthresh, clipniter, getresidual, outlog, blfile) 2365 2368 2366 2369 workscan._add_history("cspline_baseline", varlist) … … 2383 2386 def auto_cspline_baseline(self, insitu=None, mask=None, npiece=None, clipthresh=None, 2384 2387 clipniter=None, edge=None, threshold=None, 2385 chan_avg_limit=None, plot=None, outlog=None, blfile=None):2388 chan_avg_limit=None, getresidual=None, plot=None, outlog=None, blfile=None): 2386 2389 """\ 2387 2390 Return a scan which has been baselined (all rows) by cubic spline … … 2423 2426 indivual fit has to be approved, by typing 'y' 2424 2427 or 'n' 2428 getresidual:if False, returns best-fit values instead of 2429 residual. (default is True) 2425 2430 outlog: Output the coefficients of the best-fit 2426 2431 function to logger (default is False) … … 2447 2452 nchan = workscan.nchan() 2448 2453 2449 if mask is None: mask= [True for i in xrange(nchan)]2450 if npiece is None: npiece= 22451 if clipthresh is None: clipthresh= 3.02452 if clipniter is None: clipniter= 12453 if edge is None: edge= (0, 0)2454 if threshold is None: threshold= 32454 if mask is None: mask = [True for i in xrange(nchan)] 2455 if npiece is None: npiece = 2 2456 if clipthresh is None: clipthresh = 3.0 2457 if clipniter is None: clipniter = 1 2458 if edge is None: edge = (0, 0) 2459 if threshold is None: threshold = 3 2455 2460 if chan_avg_limit is None: chan_avg_limit = 1 2456 if plot is None: plot = False 2457 if outlog is None: outlog = False 2458 if blfile is None: blfile = "" 2461 if plot is None: plot = False 2462 if getresidual is None: getresidual = True 2463 if outlog is None: outlog = False 2464 if blfile is None: blfile = "" 2459 2465 2460 2466 outblfile = (blfile != "") and os.path.exists(os.path.expanduser(os.path.expandvars(blfile))) … … 2491 2497 curedge += edge[i] 2492 2498 2493 workscan._auto_cspline_baseline(mask, npiece, clipthresh, clipniter, curedge, threshold, chan_avg_limit, outlog, blfile)2499 workscan._auto_cspline_baseline(mask, npiece, clipthresh, clipniter, curedge, threshold, chan_avg_limit, getresidual, outlog, blfile) 2494 2500 2495 2501 workscan._add_history("auto_cspline_baseline", varlist) … … 2511 2517 2512 2518 @asaplog_post_dec 2513 def poly_baseline(self, insitu=None, mask=None, order=None, plot=None, outlog=None, blfile=None):2519 def poly_baseline(self, insitu=None, mask=None, order=None, plot=None, getresidual=None, outlog=None, blfile=None): 2514 2520 """\ 2515 2521 Return a scan which has been baselined (all rows) by a polynomial. … … 2523 2529 indivual fit has to be approved, by typing 'y' 2524 2530 or 'n' 2531 getresidual:if False, returns best-fit values instead of 2532 residual. (default is True) 2525 2533 outlog: Output the coefficients of the best-fit 2526 2534 function to logger (default is False) … … 2545 2553 nchan = workscan.nchan() 2546 2554 2547 if mask is None: mask = [True for i in xrange(nchan)] 2548 if order is None: order = 0 2549 if plot is None: plot = False 2550 if outlog is None: outlog = False 2551 if blfile is None: blfile = "" 2555 if mask is None: mask = [True for i in xrange(nchan)] 2556 if order is None: order = 0 2557 if plot is None: plot = False 2558 if getresidual is None: getresidual = True 2559 if outlog is None: outlog = False 2560 if blfile is None: blfile = "" 2552 2561 2553 2562 outblfile = (blfile != "") and os.path.exists(os.path.expanduser(os.path.expandvars(blfile))) … … 2579 2588 masklist = workscan.get_masklist(f.mask, row=r, silent=True) 2580 2589 #workscan._append_blinfo(blpars, masklist, f.mask) 2581 workscan._setspectrum( f.fitter.getresidual(), r)2590 workscan._setspectrum((f.fitter.getresidual() if getresidual else f.fitter.getfit()), r) 2582 2591 2583 2592 if outblfile: … … 2591 2600 if outblfile: blf.close() 2592 2601 else: 2593 workscan._poly_baseline(mask, order, outlog, blfile)2602 workscan._poly_baseline(mask, order, getresidual, outlog, blfile) 2594 2603 2595 2604 workscan._add_history("poly_baseline", varlist) … … 2611 2620 2612 2621 def auto_poly_baseline(self, insitu=None, mask=None, order=None, edge=None, threshold=None, 2613 chan_avg_limit=None, plot=None, outlog=None, blfile=None):2622 chan_avg_limit=None, plot=None, getresidual=None, outlog=None, blfile=None): 2614 2623 """\ 2615 2624 Return a scan which has been baselined (all rows) by a polynomial. … … 2647 2656 indivual fit has to be approved, by typing 'y' 2648 2657 or 'n' 2658 getresidual:if False, returns best-fit values instead of 2659 residual. (default is True) 2649 2660 outlog: Output the coefficients of the best-fit 2650 2661 function to logger (default is False) … … 2667 2678 nchan = workscan.nchan() 2668 2679 2669 if mask is None: mask= [True for i in xrange(nchan)]2670 if order is None: order= 02671 if edge is None: edge= (0, 0)2672 if threshold is None: threshold= 32680 if mask is None: mask = [True for i in xrange(nchan)] 2681 if order is None: order = 0 2682 if edge is None: edge = (0, 0) 2683 if threshold is None: threshold = 3 2673 2684 if chan_avg_limit is None: chan_avg_limit = 1 2674 if plot is None: plot = False 2675 if outlog is None: outlog = False 2676 if blfile is None: blfile = "" 2685 if plot is None: plot = False 2686 if getresidual is None: getresidual = True 2687 if outlog is None: outlog = False 2688 if blfile is None: blfile = "" 2677 2689 2678 2690 outblfile = (blfile != "") and os.path.exists(os.path.expanduser(os.path.expandvars(blfile))) … … 2741 2753 masklist = workscan.get_masklist(f.mask, row=r, silent=True) 2742 2754 #workscan._append_blinfo(blpars, masklist, f.mask) 2743 workscan._setspectrum( f.fitter.getresidual(), r)2755 workscan._setspectrum((f.fitter.getresidual() if getresidual else f.fitter.getfit()), r) 2744 2756 2745 2757 if outblfile: … … 2759 2771 curedge += edge[i] 2760 2772 2761 workscan._auto_poly_baseline(mask, order, curedge, threshold, chan_avg_limit, outlog, blfile)2773 workscan._auto_poly_baseline(mask, order, curedge, threshold, chan_avg_limit, getresidual, outlog, blfile) 2762 2774 2763 2775 workscan._add_history("auto_poly_baseline", varlist) -
branches/casa-prerelease/pre-asap/src
- Property svn:mergeinfo changed
/trunk/src merged: 2094
- Property svn:mergeinfo changed
-
branches/casa-prerelease/pre-asap/src/SConscript
- Property svn:mergeinfo changed (with no actual effect on merging)
-
branches/casa-prerelease/pre-asap/src/Scantable.cpp
r2082 r2095 1761 1761 } 1762 1762 1763 void Scantable::polyBaseline(const std::vector<bool>& mask, int order, bool outLogger, const std::string& blfile)1763 void Scantable::polyBaseline(const std::vector<bool>& mask, int order, bool getResidual, bool outLogger, const std::string& blfile) 1764 1764 { 1765 1765 ofstream ofs; … … 1789 1789 chanMask = getCompositeChanMask(whichrow, mask); 1790 1790 fitBaseline(chanMask, whichrow, fitter); 1791 setSpectrum( fitter.getResidual(), whichrow);1791 setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow); 1792 1792 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "polyBaseline()", fitter); 1793 1793 } … … 1796 1796 } 1797 1797 1798 void Scantable::autoPolyBaseline(const std::vector<bool>& mask, int order, const std::vector<int>& edge, float threshold, int chanAvgLimit, bool outLogger, const std::string& blfile)1798 void Scantable::autoPolyBaseline(const std::vector<bool>& mask, int order, const std::vector<int>& edge, float threshold, int chanAvgLimit, bool getResidual, bool outLogger, const std::string& blfile) 1799 1799 { 1800 1800 ofstream ofs; … … 1850 1850 1851 1851 fitBaseline(chanMask, whichrow, fitter); 1852 setSpectrum( fitter.getResidual(), whichrow);1852 setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow); 1853 1853 1854 1854 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoPolyBaseline()", fitter); … … 1858 1858 } 1859 1859 1860 void Scantable::cubicSplineBaseline(const std::vector<bool>& mask, int nPiece, float thresClip, int nIterClip, bool outLogger, const std::string& blfile)1860 void Scantable::cubicSplineBaseline(const std::vector<bool>& mask, int nPiece, float thresClip, int nIterClip, bool getResidual, bool outLogger, const std::string& blfile) 1861 1861 { 1862 1862 ofstream ofs; … … 1886 1886 chanMask = getCompositeChanMask(whichrow, mask); 1887 1887 //fitBaseline(chanMask, whichrow, fitter); 1888 //setSpectrum( fitter.getResidual(), whichrow);1888 //setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow); 1889 1889 std::vector<int> pieceEdges; 1890 1890 std::vector<float> params; 1891 std::vector<float> res = doCubicSplineFitting(getSpectrum(whichrow), chanMask, nPiece, pieceEdges, params, thresClip, nIterClip, true);1891 std::vector<float> res = doCubicSplineFitting(getSpectrum(whichrow), chanMask, nPiece, pieceEdges, params, thresClip, nIterClip, getResidual); 1892 1892 setSpectrum(res, whichrow); 1893 1893 // … … 1899 1899 } 1900 1900 1901 void Scantable::autoCubicSplineBaseline(const std::vector<bool>& mask, int nPiece, float thresClip, int nIterClip, const std::vector<int>& edge, float threshold, int chanAvgLimit, bool outLogger, const std::string& blfile)1901 void Scantable::autoCubicSplineBaseline(const std::vector<bool>& mask, int nPiece, float thresClip, int nIterClip, const std::vector<int>& edge, float threshold, int chanAvgLimit, bool getResidual, bool outLogger, const std::string& blfile) 1902 1902 { 1903 1903 ofstream ofs; … … 1954 1954 1955 1955 //fitBaseline(chanMask, whichrow, fitter); 1956 //setSpectrum( fitter.getResidual(), whichrow);1956 //setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow); 1957 1957 std::vector<int> pieceEdges; 1958 1958 std::vector<float> params; 1959 std::vector<float> res = doCubicSplineFitting(getSpectrum(whichrow), chanMask, nPiece, pieceEdges, params, thresClip, nIterClip, true);1959 std::vector<float> res = doCubicSplineFitting(getSpectrum(whichrow), chanMask, nPiece, pieceEdges, params, thresClip, nIterClip, getResidual); 1960 1960 setSpectrum(res, whichrow); 1961 1961 // … … 1973 1973 } 1974 1974 if (nPiece < 1) { 1975 throw(AipsError(" wrong number of the sections for fitting"));1975 throw(AipsError("number of the sections must be one or more")); 1976 1976 } 1977 1977 … … 2215 2215 chanMask = getCompositeChanMask(whichrow, mask); 2216 2216 //fitBaseline(chanMask, whichrow, fitter); 2217 //setSpectrum( fitter.getResidual(), whichrow);2217 //setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow); 2218 2218 std::vector<float> params; 2219 //std::vector<float> res = doSinusoidFitting(getSpectrum(whichrow), chanMask, nWaves, params, thresClip, nIterClip, true);2220 2219 std::vector<float> res = doSinusoidFitting(getSpectrum(whichrow), chanMask, nWaves, maxWaveLength, params, thresClip, nIterClip, getResidual); 2221 2220 setSpectrum(res, whichrow); … … 2283 2282 2284 2283 //fitBaseline(chanMask, whichrow, fitter); 2285 //setSpectrum( fitter.getResidual(), whichrow);2284 //setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow); 2286 2285 std::vector<float> params; 2287 2286 std::vector<float> res = doSinusoidFitting(getSpectrum(whichrow), chanMask, nWaves, maxWaveLength, params, thresClip, nIterClip, getResidual); … … 2335 2334 2336 2335 const double PI = 6.0 * asin(0.5); // PI (= 3.141592653...) 2337 double baseXFactor = 2.0*PI/(double)maxWaveLength/(double)(nChan-1); //the denominator (nChan-1) should be changed to (xdata[nChan-1]-xdata[0]) for accepting x-values given in velocity or frequency when this function is moved to fitter. 2336 double baseXFactor = 2.0*PI/(double)maxWaveLength/(double)(nChan-1); //the denominator (nChan-1) should be changed to (xdata[nChan-1]-xdata[0]) for accepting x-values given in velocity or frequency when this function is moved to fitter. (2011/03/30 WK) 2338 2337 2339 2338 // xArray : contains elemental values for computing the least-square matrix. … … 2635 2634 2636 2635 if (verbose) { 2637 for (int i = 0; i < 60; ++i) {2638 oss << "-";2639 }2640 oss << endl;2641 2636 oss << " Scan[" << getScan(whichrow) << "]"; 2642 2637 oss << " Beam[" << getBeam(whichrow) << "]"; … … 2659 2654 oss << "Results of baseline fit" << endl; 2660 2655 oss << " rms = " << setprecision(6) << rms << endl; 2656 for (int i = 0; i < 60; ++i) { 2657 oss << "-"; 2658 } 2659 oss << flush; 2661 2660 } 2662 2661 -
branches/casa-prerelease/pre-asap/src/Scantable.h
r2082 r2095 497 497 void polyBaseline(const std::vector<bool>& mask, 498 498 int order, 499 bool getResidual=true, 499 500 bool outLogger=false, 500 501 const std::string& blfile=""); … … 504 505 float threshold=3.0, 505 506 int chanAvgLimit=1, 507 bool getResidual=true, 506 508 bool outLogger=false, 507 509 const std::string& blfile=""); … … 510 512 float thresClip, 511 513 int nIterClip, 514 bool getResidual=true, 512 515 bool outLogger=false, 513 516 const std::string& blfile=""); … … 519 522 float threshold=3.0, 520 523 int chanAvgLimit=1, 524 bool getResidual=true, 521 525 bool outLogger=false, 522 526 const std::string& blfile=""); … … 679 683 float thresClip=3.0, 680 684 int nIterClip=1, 681 bool getResidual= false);685 bool getResidual=true); 682 686 std::vector<float> doSinusoidFitting(const std::vector<float>& data, 683 687 const std::vector<bool>& mask, … … 687 691 float thresClip=3.0, 688 692 int nIterClip=1, 689 bool getResidual= false);693 bool getResidual=true); 690 694 bool hasSameNchanOverIFs(); 691 695 std::string getMaskRangeList(const std::vector<bool>& mask, -
branches/casa-prerelease/pre-asap/src/ScantableWrapper.h
r2082 r2095 257 257 { table_->reshapeSpectrum( nmin, nmax ); } 258 258 259 void polyBaseline(const std::vector<bool>& mask, int order, bool outlog=false, const std::string& blfile="")260 { table_->polyBaseline(mask, order, outlog, blfile); }261 262 void autoPolyBaseline(const std::vector<bool>& mask, int order, const std::vector<int>& edge, float threshold=5.0, int chan_avg_limit=1, bool outlog=false, const std::string& blfile="")263 { table_->autoPolyBaseline(mask, order, edge, threshold, chan_avg_limit, outlog, blfile); }264 265 void cubicSplineBaseline(const std::vector<bool>& mask, int npiece, float clipthresh, int clipniter, bool outlog=false, const std::string& blfile="")266 { table_->cubicSplineBaseline(mask, npiece, clipthresh, clipniter, outlog, blfile); }267 268 void autoCubicSplineBaseline(const std::vector<bool>& mask, int npiece, float clipthresh, int clipniter, const std::vector<int>& edge, float threshold=5.0, int chan_avg_limit=1, bool outlog=false, const std::string& blfile="")269 { table_->autoCubicSplineBaseline(mask, npiece, clipthresh, clipniter, edge, threshold, chan_avg_limit, outlog, blfile); }259 void polyBaseline(const std::vector<bool>& mask, int order, bool getresidual=true, bool outlog=false, const std::string& blfile="") 260 { table_->polyBaseline(mask, order, getresidual, outlog, blfile); } 261 262 void autoPolyBaseline(const std::vector<bool>& mask, int order, const std::vector<int>& edge, float threshold=5.0, int chan_avg_limit=1, bool getresidual=true, bool outlog=false, const std::string& blfile="") 263 { table_->autoPolyBaseline(mask, order, edge, threshold, chan_avg_limit, getresidual, outlog, blfile); } 264 265 void cubicSplineBaseline(const std::vector<bool>& mask, int npiece, float clipthresh, int clipniter, bool getresidual=true, bool outlog=false, const std::string& blfile="") 266 { table_->cubicSplineBaseline(mask, npiece, clipthresh, clipniter, getresidual, outlog, blfile); } 267 268 void autoCubicSplineBaseline(const std::vector<bool>& mask, int npiece, float clipthresh, int clipniter, const std::vector<int>& edge, float threshold=5.0, int chan_avg_limit=1, bool getresidual=true, bool outlog=false, const std::string& blfile="") 269 { table_->autoCubicSplineBaseline(mask, npiece, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, outlog, blfile); } 270 270 271 271 void sinusoidBaseline(const std::vector<bool>& mask, const std::vector<int>& nwave, float maxwavelength, float clipthresh, int clipniter, bool getresidual=true, bool outlog=false, const std::string& blfile="")
Note:
See TracChangeset
for help on using the changeset viewer.