Changeset 2189 for trunk/src


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.


Location:
trunk/src
Files:
3 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    }
  • trunk/src/Scantable.h

    r2186 r2189  
    502502                    int order,
    503503                    bool getResidual=true,
    504                     bool outLogger=false,
     504                    const std::string& progressInfo="true,1000",
     505                    const bool outLogger=false,
    505506                    const std::string& blfile="");
    506507  void autoPolyBaseline(const std::vector<bool>& mask,
     
    510511                        int chanAvgLimit=1,
    511512                        bool getResidual=true,
    512                         bool outLogger=false,
     513                        const std::string& progressInfo="true,1000",
     514                        const bool outLogger=false,
    513515                        const std::string& blfile="");
    514516  void cubicSplineBaseline(const std::vector<bool>& mask,
     
    517519                           int nIterClip,
    518520                           bool getResidual=true,
    519                            bool outLogger=false,
     521                           const std::string& progressInfo="true,1000",
     522                           const bool outLogger=false,
    520523                           const std::string& blfile="");
    521524  void autoCubicSplineBaseline(const std::vector<bool>& mask,
     
    527530                               int chanAvgLimit=1,
    528531                               bool getResidual=true,
    529                                bool outLogger=false,
     532                               const std::string& progressInfo="true,1000",
     533                               const bool outLogger=false,
    530534                               const std::string& blfile="");
    531535  void sinusoidBaseline(const std::vector<bool>& mask,
     
    538542                        int nIterClip,
    539543                        bool getResidual=true,
    540                         bool outLogger=false,
     544                        const std::string& progressInfo="true,1000",
     545                        const bool outLogger=false,
    541546                        const std::string& blfile="");
    542547  void autoSinusoidBaseline(const std::vector<bool>& mask,
     
    552557                            int chanAvgLimit=1,
    553558                            bool getResidual=true,
    554                             bool outLogger=false,
     559                            const std::string& progressInfo="true,1000",
     560                            const bool outLogger=false,
    555561                            const std::string& blfile="");
    556562  std::vector<float> execFFT(const int whichrow,
     
    741747  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);
    742748  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);
    744751
    745752  void applyChanFlag( casa::uInt whichrow, const std::vector<bool>& msk, casa::uChar flagval);
  • trunk/src/ScantableWrapper.h

    r2186 r2189  
    264264  { table_->reshapeSpectrum( nmin, nmax ); }
    265265
    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); }
    283283
    284284  float getRms(const std::vector<bool>& mask, int whichrow)
Note: See TracChangeset for help on using the changeset viewer.