Ignore:
Timestamp:
06/09/11 19:17:30 (13 years ago)
Author:
WataruKawasaki
Message:

New Development: No

JIRA Issue: Yes CAS-3149

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: scantable.*_baseline() parameter

Test Programs:

Put in Release Notes: No

Module(s):

Description: Added two parameters 'showprogress' and 'minnrow' to scantable.*_baseline() to enable to show progress status during time-consuming processes.


File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r2186 r2189  
    18171817}
    18181818
    1819 void Scantable::polyBaseline(const std::vector<bool>& mask, int order, bool getResidual, bool outLogger, const std::string& blfile)
     1819void Scantable::polyBaseline(const std::vector<bool>& mask, int order, bool getResidual, const std::string& progressInfo, const bool outLogger, const std::string& blfile)
    18201820{
    18211821  ofstream ofs;
     
    18411841  int nRow = nrow();
    18421842  std::vector<bool> chanMask;
     1843  bool showProgress;
     1844  int minNRow;
     1845  parseProgressInfo(progressInfo, showProgress, minNRow);
    18431846
    18441847  for (int whichrow = 0; whichrow < nRow; ++whichrow) {
     
    18471850    setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow);
    18481851    outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "polyBaseline()", fitter);
    1849     showProgressOnTerminal(whichrow, nRow);
     1852    showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    18501853  }
    18511854
     
    18531856}
    18541857
    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)
     1858void 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)
    18561859{
    18571860  ofstream ofs;
     
    18801883  STLineFinder lineFinder = STLineFinder();
    18811884  lineFinder.setOptions(threshold, 3, chanAvgLimit);
     1885
     1886  bool showProgress;
     1887  int minNRow;
     1888  parseProgressInfo(progressInfo, showProgress, minNRow);
    18821889
    18831890  for (int whichrow = 0; whichrow < nRow; ++whichrow) {
     
    19101917
    19111918    outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoPolyBaseline()", fitter);
    1912     showProgressOnTerminal(whichrow, nRow);
     1919    showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    19131920  }
    19141921
     
    19161923}
    19171924
    1918 void Scantable::cubicSplineBaseline(const std::vector<bool>& mask, int nPiece, float thresClip, int nIterClip, bool getResidual, bool outLogger, const std::string& blfile)
     1925void 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)
    19191926{
    19201927  ofstream ofs;
     
    19401947  int nRow = nrow();
    19411948  std::vector<bool> chanMask;
     1949  bool showProgress;
     1950  int minNRow;
     1951  parseProgressInfo(progressInfo, showProgress, minNRow);
    19421952
    19431953  for (int whichrow = 0; whichrow < nRow; ++whichrow) {
     
    19521962
    19531963    outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "cubicSplineBaseline()", pieceEdges, params);
    1954     showProgressOnTerminal(whichrow, nRow);
     1964    showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    19551965  }
    19561966
     
    19581968}
    19591969
    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)
     1970void 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)
    19611971{
    19621972  ofstream ofs;
     
    19851995  STLineFinder lineFinder = STLineFinder();
    19861996  lineFinder.setOptions(threshold, 3, chanAvgLimit);
     1997
     1998  bool showProgress;
     1999  int minNRow;
     2000  parseProgressInfo(progressInfo, showProgress, minNRow);
    19872001
    19882002  for (int whichrow = 0; whichrow < nRow; ++whichrow) {
     
    20212035
    20222036    outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoCubicSplineBaseline()", pieceEdges, params);
    2023     showProgressOnTerminal(whichrow, nRow);
     2037    showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    20242038  }
    20252039
     
    23702384}
    23712385
    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)
     2386void 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)
    23732387{
    23742388  ofstream ofs;
     
    23952409  std::vector<bool> chanMask;
    23962410  std::vector<int> nWaves;
     2411
     2412  bool showProgress;
     2413  int minNRow;
     2414  parseProgressInfo(progressInfo, showProgress, minNRow);
    23972415
    23982416  for (int whichrow = 0; whichrow < nRow; ++whichrow) {
     
    24222440
    24232441    outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "sinusoidBaseline()", params);
    2424     showProgressOnTerminal(whichrow, nRow);
     2442    showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    24252443  }
    24262444
     
    24282446}
    24292447
    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)
     2448void 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)
    24312449{
    24322450  ofstream ofs;
     
    24572475  STLineFinder lineFinder = STLineFinder();
    24582476  lineFinder.setOptions(threshold, 3, chanAvgLimit);
     2477
     2478  bool showProgress;
     2479  int minNRow;
     2480  parseProgressInfo(progressInfo, showProgress, minNRow);
    24592481
    24602482  for (int whichrow = 0; whichrow < nRow; ++whichrow) {
     
    24932515
    24942516    outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoSinusoidBaseline()", params);
    2495     showProgressOnTerminal(whichrow, nRow);
     2517    showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    24962518  }
    24972519
     
    28152837}
    28162838
    2817 void Scantable::showProgressOnTerminal(const int nProcessed, const int nTotal, const int nTotalThreshold)
    2818 {
    2819   if (nTotal >= nTotalThreshold) {
     2839void 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
     2850void Scantable::showProgressOnTerminal(const int nProcessed, const int nTotal, const bool showProgress, const int nTotalThreshold)
     2851{
     2852  if (showProgress && (nTotal >= nTotalThreshold)) {
    28202853    int nInterval = int(floor(double(nTotal)/100.0));
    28212854    if (nInterval == 0) nInterval++;
     
    28242857      printf("\x1b[31m\x1b[1m");             //set red color, highlighted
    28252858      printf("[  0%%]");
    2826       printf("\x1b[39m\x1b[0m");             //default attributes
     2859      printf("\x1b[39m\x1b[0m");             //set default attributes
    28272860      fflush(NULL);
    28282861    } else if (nProcessed % nInterval == 0) {
    2829       printf("\r\x1b[1C");                   //go to the 2nd column
     2862      printf("\r");                          //go to the head of line
    28302863      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
    28342866      fflush(NULL);
    28352867    }
Note: See TracChangeset for help on using the changeset viewer.