- Timestamp:
- 06/09/11 19:17:30 (13 years ago)
- Location:
- trunk/src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/Scantable.cpp
r2186 r2189 1817 1817 } 1818 1818 1819 void Scantable::polyBaseline(const std::vector<bool>& mask, int order, bool getResidual, bool outLogger, const std::string& blfile)1819 void Scantable::polyBaseline(const std::vector<bool>& mask, int order, bool getResidual, const std::string& progressInfo, const bool outLogger, const std::string& blfile) 1820 1820 { 1821 1821 ofstream ofs; … … 1841 1841 int nRow = nrow(); 1842 1842 std::vector<bool> chanMask; 1843 bool showProgress; 1844 int minNRow; 1845 parseProgressInfo(progressInfo, showProgress, minNRow); 1843 1846 1844 1847 for (int whichrow = 0; whichrow < nRow; ++whichrow) { … … 1847 1850 setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow); 1848 1851 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "polyBaseline()", fitter); 1849 showProgressOnTerminal(whichrow, nRow );1852 showProgressOnTerminal(whichrow, nRow, showProgress, minNRow); 1850 1853 } 1851 1854 … … 1853 1856 } 1854 1857 1855 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)1858 void Scantable::autoPolyBaseline(const std::vector<bool>& mask, int order, const std::vector<int>& edge, float threshold, int chanAvgLimit, bool getResidual, const std::string& progressInfo, const bool outLogger, const std::string& blfile) 1856 1859 { 1857 1860 ofstream ofs; … … 1880 1883 STLineFinder lineFinder = STLineFinder(); 1881 1884 lineFinder.setOptions(threshold, 3, chanAvgLimit); 1885 1886 bool showProgress; 1887 int minNRow; 1888 parseProgressInfo(progressInfo, showProgress, minNRow); 1882 1889 1883 1890 for (int whichrow = 0; whichrow < nRow; ++whichrow) { … … 1910 1917 1911 1918 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoPolyBaseline()", fitter); 1912 showProgressOnTerminal(whichrow, nRow );1919 showProgressOnTerminal(whichrow, nRow, showProgress, minNRow); 1913 1920 } 1914 1921 … … 1916 1923 } 1917 1924 1918 void Scantable::cubicSplineBaseline(const std::vector<bool>& mask, int nPiece, float thresClip, int nIterClip, bool getResidual, bool outLogger, const std::string& blfile)1925 void Scantable::cubicSplineBaseline(const std::vector<bool>& mask, int nPiece, float thresClip, int nIterClip, bool getResidual, const std::string& progressInfo, const bool outLogger, const std::string& blfile) 1919 1926 { 1920 1927 ofstream ofs; … … 1940 1947 int nRow = nrow(); 1941 1948 std::vector<bool> chanMask; 1949 bool showProgress; 1950 int minNRow; 1951 parseProgressInfo(progressInfo, showProgress, minNRow); 1942 1952 1943 1953 for (int whichrow = 0; whichrow < nRow; ++whichrow) { … … 1952 1962 1953 1963 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "cubicSplineBaseline()", pieceEdges, params); 1954 showProgressOnTerminal(whichrow, nRow );1964 showProgressOnTerminal(whichrow, nRow, showProgress, minNRow); 1955 1965 } 1956 1966 … … 1958 1968 } 1959 1969 1960 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)1970 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, const std::string& progressInfo, const bool outLogger, const std::string& blfile) 1961 1971 { 1962 1972 ofstream ofs; … … 1985 1995 STLineFinder lineFinder = STLineFinder(); 1986 1996 lineFinder.setOptions(threshold, 3, chanAvgLimit); 1997 1998 bool showProgress; 1999 int minNRow; 2000 parseProgressInfo(progressInfo, showProgress, minNRow); 1987 2001 1988 2002 for (int whichrow = 0; whichrow < nRow; ++whichrow) { … … 2021 2035 2022 2036 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoCubicSplineBaseline()", pieceEdges, params); 2023 showProgressOnTerminal(whichrow, nRow );2037 showProgressOnTerminal(whichrow, nRow, showProgress, minNRow); 2024 2038 } 2025 2039 … … 2370 2384 } 2371 2385 2372 void Scantable::sinusoidBaseline(const std::vector<bool>& mask, const bool applyFFT, const std::string& fftMethod, const std::string& fftThresh, const std::vector<int>& addNWaves, const std::vector<int>& rejectNWaves, float thresClip, int nIterClip, bool getResidual, bool outLogger, const std::string& blfile)2386 void Scantable::sinusoidBaseline(const std::vector<bool>& mask, const bool applyFFT, const std::string& fftMethod, const std::string& fftThresh, const std::vector<int>& addNWaves, const std::vector<int>& rejectNWaves, float thresClip, int nIterClip, bool getResidual, const std::string& progressInfo, const bool outLogger, const std::string& blfile) 2373 2387 { 2374 2388 ofstream ofs; … … 2395 2409 std::vector<bool> chanMask; 2396 2410 std::vector<int> nWaves; 2411 2412 bool showProgress; 2413 int minNRow; 2414 parseProgressInfo(progressInfo, showProgress, minNRow); 2397 2415 2398 2416 for (int whichrow = 0; whichrow < nRow; ++whichrow) { … … 2422 2440 2423 2441 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "sinusoidBaseline()", params); 2424 showProgressOnTerminal(whichrow, nRow );2442 showProgressOnTerminal(whichrow, nRow, showProgress, minNRow); 2425 2443 } 2426 2444 … … 2428 2446 } 2429 2447 2430 void Scantable::autoSinusoidBaseline(const std::vector<bool>& mask, const bool applyFFT, const std::string& fftMethod, const std::string& fftThresh, const std::vector<int>& addNWaves, const std::vector<int>& rejectNWaves, float thresClip, int nIterClip, const std::vector<int>& edge, float threshold, int chanAvgLimit, bool getResidual, bool outLogger, const std::string& blfile)2448 void Scantable::autoSinusoidBaseline(const std::vector<bool>& mask, const bool applyFFT, const std::string& fftMethod, const std::string& fftThresh, const std::vector<int>& addNWaves, const std::vector<int>& rejectNWaves, float thresClip, int nIterClip, const std::vector<int>& edge, float threshold, int chanAvgLimit, bool getResidual, const std::string& progressInfo, const bool outLogger, const std::string& blfile) 2431 2449 { 2432 2450 ofstream ofs; … … 2457 2475 STLineFinder lineFinder = STLineFinder(); 2458 2476 lineFinder.setOptions(threshold, 3, chanAvgLimit); 2477 2478 bool showProgress; 2479 int minNRow; 2480 parseProgressInfo(progressInfo, showProgress, minNRow); 2459 2481 2460 2482 for (int whichrow = 0; whichrow < nRow; ++whichrow) { … … 2493 2515 2494 2516 outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoSinusoidBaseline()", params); 2495 showProgressOnTerminal(whichrow, nRow );2517 showProgressOnTerminal(whichrow, nRow, showProgress, minNRow); 2496 2518 } 2497 2519 … … 2815 2837 } 2816 2838 2817 void Scantable::showProgressOnTerminal(const int nProcessed, const int nTotal, const int nTotalThreshold) 2818 { 2819 if (nTotal >= nTotalThreshold) { 2839 void Scantable::parseProgressInfo(const std::string& progressInfo, bool& showProgress, int& minNRow) 2840 { 2841 int idxDelimiter = progressInfo.find(","); 2842 if (idxDelimiter < 0) { 2843 throw(AipsError("wrong value in 'showprogress' parameter")) ; 2844 } 2845 showProgress = (progressInfo.substr(0, idxDelimiter) == "true"); 2846 std::istringstream is(progressInfo.substr(idxDelimiter+1)); 2847 is >> minNRow; 2848 } 2849 2850 void Scantable::showProgressOnTerminal(const int nProcessed, const int nTotal, const bool showProgress, const int nTotalThreshold) 2851 { 2852 if (showProgress && (nTotal >= nTotalThreshold)) { 2820 2853 int nInterval = int(floor(double(nTotal)/100.0)); 2821 2854 if (nInterval == 0) nInterval++; … … 2824 2857 printf("\x1b[31m\x1b[1m"); //set red color, highlighted 2825 2858 printf("[ 0%%]"); 2826 printf("\x1b[39m\x1b[0m"); // default attributes2859 printf("\x1b[39m\x1b[0m"); //set default attributes 2827 2860 fflush(NULL); 2828 2861 } else if (nProcessed % nInterval == 0) { 2829 printf("\r \x1b[1C"); //go to the 2nd column2862 printf("\r"); //go to the head of line 2830 2863 printf("\x1b[31m\x1b[1m"); //set red color, highlighted 2831 printf("%3d", (int)(100.0*(double(nProcessed+1))/(double(nTotal))) ); 2832 printf("\x1b[39m\x1b[0m"); //default attributes 2833 printf("\x1b[2C"); //go to the end of line 2864 printf("[%3d%%]", (int)(100.0*(double(nProcessed+1))/(double(nTotal))) ); 2865 printf("\x1b[39m\x1b[0m"); //set default attributes 2834 2866 fflush(NULL); 2835 2867 } -
trunk/src/Scantable.h
r2186 r2189 502 502 int order, 503 503 bool getResidual=true, 504 bool outLogger=false, 504 const std::string& progressInfo="true,1000", 505 const bool outLogger=false, 505 506 const std::string& blfile=""); 506 507 void autoPolyBaseline(const std::vector<bool>& mask, … … 510 511 int chanAvgLimit=1, 511 512 bool getResidual=true, 512 bool outLogger=false, 513 const std::string& progressInfo="true,1000", 514 const bool outLogger=false, 513 515 const std::string& blfile=""); 514 516 void cubicSplineBaseline(const std::vector<bool>& mask, … … 517 519 int nIterClip, 518 520 bool getResidual=true, 519 bool outLogger=false, 521 const std::string& progressInfo="true,1000", 522 const bool outLogger=false, 520 523 const std::string& blfile=""); 521 524 void autoCubicSplineBaseline(const std::vector<bool>& mask, … … 527 530 int chanAvgLimit=1, 528 531 bool getResidual=true, 529 bool outLogger=false, 532 const std::string& progressInfo="true,1000", 533 const bool outLogger=false, 530 534 const std::string& blfile=""); 531 535 void sinusoidBaseline(const std::vector<bool>& mask, … … 538 542 int nIterClip, 539 543 bool getResidual=true, 540 bool outLogger=false, 544 const std::string& progressInfo="true,1000", 545 const bool outLogger=false, 541 546 const std::string& blfile=""); 542 547 void autoSinusoidBaseline(const std::vector<bool>& mask, … … 552 557 int chanAvgLimit=1, 553 558 bool getResidual=true, 554 bool outLogger=false, 559 const std::string& progressInfo="true,1000", 560 const bool outLogger=false, 555 561 const std::string& blfile=""); 556 562 std::vector<float> execFFT(const int whichrow, … … 741 747 void outputFittingResult(bool outLogger, bool outTextFile, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, std::ofstream& ofs, const casa::String& funcName, const std::vector<int>& edge, const std::vector<float>& params); 742 748 void outputFittingResult(bool outLogger, bool outTextFile, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, std::ofstream& ofs, const casa::String& funcName, const std::vector<float>& params); 743 void showProgressOnTerminal(const int nProcessed, const int nTotal, const int nTotalThreshold=1000); 749 void parseProgressInfo(const std::string& progressInfo, bool& showProgress, int& minNRow); 750 void showProgressOnTerminal(const int nProcessed, const int nTotal, const bool showProgress=true, const int nTotalThreshold=1000); 744 751 745 752 void applyChanFlag( casa::uInt whichrow, const std::vector<bool>& msk, casa::uChar flagval); -
trunk/src/ScantableWrapper.h
r2186 r2189 264 264 { table_->reshapeSpectrum( nmin, nmax ); } 265 265 266 void polyBaseline(const std::vector<bool>& mask, int order, bool getresidual=true, bool outlog=false, const std::string& blfile="")267 { table_->polyBaseline(mask, order, getresidual, outlog, blfile); }268 269 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="")270 { table_->autoPolyBaseline(mask, order, edge, threshold, chan_avg_limit, getresidual, outlog, blfile); }271 272 void cubicSplineBaseline(const std::vector<bool>& mask, int npiece, float clipthresh, int clipniter, bool getresidual=true, bool outlog=false, const std::string& blfile="")273 { table_->cubicSplineBaseline(mask, npiece, clipthresh, clipniter, getresidual, outlog, blfile); }274 275 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="")276 { table_->autoCubicSplineBaseline(mask, npiece, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, outlog, blfile); }277 278 void sinusoidBaseline(const std::vector<bool>& mask, const bool applyfft, const std::string& fftmethod, const std::string& fftthresh, const std::vector<int>& addwn, const std::vector<int>& rejwn, float clipthresh, int clipniter, bool getresidual=true, bool outlog=false, const std::string& blfile="")279 { table_->sinusoidBaseline(mask, applyfft, fftmethod, fftthresh, addwn, rejwn, clipthresh, clipniter, getresidual, outlog, blfile); }280 281 void autoSinusoidBaseline(const std::vector<bool>& mask, const bool applyfft, const std::string& fftmethod, const std::string& fftthresh, const std::vector<int>& addwn, const std::vector<int>& rejwn, 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="")282 { table_->autoSinusoidBaseline(mask, applyfft, fftmethod, fftthresh, addwn, rejwn, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, outlog, blfile); }266 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="") 267 { table_->polyBaseline(mask, order, getresidual, showprogress, outlog, blfile); } 268 269 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, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="") 270 { table_->autoPolyBaseline(mask, order, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile); } 271 272 void cubicSplineBaseline(const std::vector<bool>& mask, int npiece, float clipthresh, int clipniter, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="") 273 { table_->cubicSplineBaseline(mask, npiece, clipthresh, clipniter, getresidual, showprogress, outlog, blfile); } 274 275 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, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="") 276 { table_->autoCubicSplineBaseline(mask, npiece, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile); } 277 278 void sinusoidBaseline(const std::vector<bool>& mask, const bool applyfft, const std::string& fftmethod, const std::string& fftthresh, const std::vector<int>& addwn, const std::vector<int>& rejwn, float clipthresh, int clipniter, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="") 279 { table_->sinusoidBaseline(mask, applyfft, fftmethod, fftthresh, addwn, rejwn, clipthresh, clipniter, getresidual, showprogress, outlog, blfile); } 280 281 void autoSinusoidBaseline(const std::vector<bool>& mask, const bool applyfft, const std::string& fftmethod, const std::string& fftthresh, const std::vector<int>& addwn, const std::vector<int>& rejwn, float clipthresh, int clipniter, const std::vector<int>& edge, float threshold=5.0, int chan_avg_limit=1, bool getresidual=true, const std::string& showprogress="true,1000", const bool outlog=false, const std::string& blfile="") 282 { table_->autoSinusoidBaseline(mask, applyfft, fftmethod, fftthresh, addwn, rejwn, clipthresh, clipniter, edge, threshold, chan_avg_limit, getresidual, showprogress, outlog, blfile); } 283 283 284 284 float getRms(const std::vector<bool>& mask, int whichrow)
Note:
See TracChangeset
for help on using the changeset viewer.