Changeset 2641 for trunk/src


Ignore:
Timestamp:
08/10/12 20:49:54 (12 years ago)
Author:
WataruKawasaki
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: Yes

What Interface Changed: parameter of tool functions

Test Programs:

Put in Release Notes: No

Module(s): sd.scantable

Description: added a new parameter csvformat.


Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/Scantable.cpp

    r2595 r2641  
    24892489    bool hasSameNchan = true;
    24902490    bool outTextFile = false;
     2491    bool csvFormat = false;
    24912492
    24922493    if (blfile != "") {
    2493       ofs.open(blfile.c_str(), ios::out | ios::app);
     2494      csvFormat = (blfile.substr(0, 1) == "T");
     2495      ofs.open(blfile.substr(1).c_str(), ios::out | ios::app);
    24942496      if (ofs) outTextFile = true;
    24952497    }
     
    25152517      fitBaseline(chanMask, whichrow, fitter);
    25162518      setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow);
    2517       outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "polyBaseline()", fitter);
     2519      outputFittingResult(outLogger, outTextFile, csvFormat, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "polyBaseline()", fitter);
    25182520      showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    25192521    }
     
    25332535    bool hasSameNchan = true;
    25342536    bool outTextFile = false;
     2537    bool csvFormat = false;
    25352538
    25362539    if (blfile != "") {
    2537       ofs.open(blfile.c_str(), ios::out | ios::app);
     2540      csvFormat = (blfile.substr(0, 1) == "T");
     2541      ofs.open(blfile.substr(1).c_str(), ios::out | ios::app);
    25382542      if (ofs) outTextFile = true;
    25392543    }
     
    25872591      setSpectrum((getResidual ? fitter.getResidual() : fitter.getFit()), whichrow);
    25882592
    2589       outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoPolyBaseline()", fitter);
     2593      outputFittingResult(outLogger, outTextFile, csvFormat, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoPolyBaseline()", fitter);
    25902594      showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    25912595    }
     
    26002604void 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)
    26012605{
    2602   /*************/
    2603   //clock_t totTimeStart, totTimeEnd, blTimeStart, blTimeEnd, ioTimeStart, ioTimeEnd;
     2606  /*************
    26042607  double totTimeStart, totTimeEnd, blTimeStart, blTimeEnd, ioTimeStart, ioTimeEnd, msTimeStart, msTimeEnd, seTimeStart, seTimeEnd, otTimeStart, otTimeEnd, prTimeStart, prTimeEnd;
    26052608  double elapseMs = 0.0;
     
    26092612  double elapseBl = 0.0;
    26102613  double elapseIo = 0.0;
    2611   //totTimeStart = clock();
    26122614  totTimeStart = mathutil::gettimeofday_sec();
    2613   /*************/
     2615  *************/
    26142616
    26152617  try {
     
    26182620    bool hasSameNchan = true;
    26192621    bool outTextFile = false;
     2622    bool csvFormat = false;
    26202623
    26212624    if (blfile != "") {
    2622       ofs.open(blfile.c_str(), ios::out | ios::app);
     2625      csvFormat = (blfile.substr(0, 1) == "T");
     2626      ofs.open(blfile.substr(1).c_str(), ios::out | ios::app);
    26232627      if (ofs) outTextFile = true;
    26242628    }
     
    26432647    //--------------------------------
    26442648    for (int whichrow = 0; whichrow < nRow; ++whichrow) {
    2645       /******************/
    2646       //ioTimeStart = clock();
     2649      /******************
    26472650      ioTimeStart = mathutil::gettimeofday_sec();
    2648       /**/
     2651      **/
    26492652      std::vector<float> sp = getSpectrum(whichrow);
    2650       /**/
    2651       //ioTimeEnd = clock();
     2653      /**
    26522654      ioTimeEnd = mathutil::gettimeofday_sec();
    26532655      elapseIo += (double)(ioTimeEnd - ioTimeStart);
    2654 
    2655       //blTimeStart = clock();
    26562656      msTimeStart = mathutil::gettimeofday_sec();
    2657       /******************/
     2657      ******************/
    26582658
    26592659      chanMask = getCompositeChanMask(whichrow, mask);
    26602660
    2661       /**/
     2661      /**
    26622662      msTimeEnd = mathutil::gettimeofday_sec();
    26632663      elapseMs += (double)(msTimeEnd - msTimeStart);
    26642664      blTimeStart = mathutil::gettimeofday_sec();
    2665       /**/
     2665      **/
    26662666
    26672667      //fitBaseline(chanMask, whichrow, fitter);
     
    26722672      std::vector<float> res = doCubicSplineFitting(sp, chanMask, nPiece, pieceEdges, params, nClipped, thresClip, nIterClip, getResidual);
    26732673
    2674       /**/
     2674      /**
    26752675      blTimeEnd = mathutil::gettimeofday_sec();
    26762676      elapseBl += (double)(blTimeEnd - blTimeStart);
    26772677      seTimeStart = mathutil::gettimeofday_sec();
    2678       /**/
     2678      **/
    26792679
    26802680
     
    26822682      //
    26832683
    2684       /**/
     2684      /**
    26852685      seTimeEnd = mathutil::gettimeofday_sec();
    26862686      elapseSe += (double)(seTimeEnd - seTimeStart);
    26872687      otTimeStart = mathutil::gettimeofday_sec();
    2688       /**/
    2689 
    2690       outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "cubicSplineBaseline()", pieceEdges, params, nClipped);
    2691 
    2692       /**/
     2688      **/
     2689
     2690      outputFittingResult(outLogger, outTextFile, csvFormat, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "cubicSplineBaseline()", pieceEdges, params, nClipped);
     2691
     2692      /**
    26932693      otTimeEnd = mathutil::gettimeofday_sec();
    26942694      elapseOt += (double)(otTimeEnd - otTimeStart);
    26952695      prTimeStart = mathutil::gettimeofday_sec();
    2696       /**/
     2696      **/
    26972697
    26982698      showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    26992699
    2700       /******************/
    2701       //blTimeEnd = clock();
     2700      /******************
    27022701      prTimeEnd = mathutil::gettimeofday_sec();
    27032702      elapsePr += (double)(prTimeEnd - prTimeStart);
    2704       /******************/
     2703      ******************/
    27052704    }
    27062705    //--------------------------------
     
    27112710    throw;
    27122711  }
    2713   /***************/
    2714   //totTimeEnd = clock();
     2712  /***************
    27152713  totTimeEnd = mathutil::gettimeofday_sec();
    2716   //std::cout << "io    : " << elapseIo/CLOCKS_PER_SEC << " (sec.)" << endl;
    2717   //std::cout << "bl    : " << elapseBl/CLOCKS_PER_SEC << " (sec.)" << endl;
    2718   //std::cout << "total : " << (double)(totTimeEnd - totTimeStart)/CLOCKS_PER_SEC << " (sec.)" << endl;
    27192714  std::cout << "io    : " << elapseIo << " (sec.)" << endl;
    27202715  std::cout << "ms    : " << elapseMs << " (sec.)" << endl;
     
    27242719  std::cout << "pr    : " << elapsePr << " (sec.)" << endl;
    27252720  std::cout << "total : " << (double)(totTimeEnd - totTimeStart) << " (sec.)" << endl;
    2726   /***************/
     2721  ***************/
    27272722}
    27282723
    27292724void 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)
    27302725{
    2731   /*************
    2732   clock_t totTimeStart, totTimeEnd, blTimeStart, blTimeEnd, ioTimeStart, ioTimeEnd;
    2733   double elapseBl = 0.0;
    2734   double elapseIo = 0.0;
    2735   totTimeStart = clock();
    2736   *************/
    2737 
    27382726  try {
    27392727    ofstream ofs;
     
    27412729    bool hasSameNchan = true;
    27422730    bool outTextFile = false;
     2731    bool csvFormat = false;
    27432732
    27442733    if (blfile != "") {
    2745       ofs.open(blfile.c_str(), ios::out | ios::app);
     2734      csvFormat = (blfile.substr(0, 1) == "T");
     2735      ofs.open(blfile.substr(1).c_str(), ios::out | ios::app);
    27462736      if (ofs) outTextFile = true;
    27472737    }
     
    27682758
    27692759    for (int whichrow = 0; whichrow < nRow; ++whichrow) {
    2770       /******************
    2771       ioTimeStart = clock();
    2772       */
    27732760      std::vector<float> sp = getSpectrum(whichrow);
    2774       /*
    2775       ioTimeEnd = clock();
    2776       elapseIo += (double)(ioTimeEnd - ioTimeStart);
    2777 
    2778       blTimeStart = clock();
    2779       ******************/
    27802761
    27812762      //-------------------------------------------------------
     
    27972778        throw(AipsError("Wrong length of edge element"));
    27982779      }
    2799       lineFinder.setData(getSpectrum(whichrow));
     2780      //lineFinder.setData(getSpectrum(whichrow));
     2781      lineFinder.setData(sp);
    28002782      lineFinder.findLines(getCompositeChanMask(whichrow, mask), currentEdge, whichrow);
    28012783      chanMask = lineFinder.getMask();
     
    28122794      //
    28132795
    2814       outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoCubicSplineBaseline()", pieceEdges, params, nClipped);
     2796      outputFittingResult(outLogger, outTextFile, csvFormat, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoCubicSplineBaseline()", pieceEdges, params, nClipped);
    28152797      showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    2816 
    2817       /******************
    2818       blTimeEnd = clock();
    2819       elapseBl += (double)(blTimeEnd - blTimeStart);
    2820       ******************/
    2821 
    28222798    }
    28232799
     
    28272803    throw;
    28282804  }
    2829 
    2830   /***************
    2831   totTimeEnd = clock();
    2832   std::cout << "io    : " << elapseIo/CLOCKS_PER_SEC << " (sec.)" << endl;
    2833   std::cout << "bl    : " << elapseBl/CLOCKS_PER_SEC << " (sec.)" << endl;
    2834   std::cout << "total : " << (double)(totTimeEnd - totTimeStart)/CLOCKS_PER_SEC << " (sec.)" << endl;
    2835   ***************/
    28362805}
    28372806
     
    32683237    bool hasSameNchan = true;
    32693238    bool outTextFile = false;
     3239    bool csvFormat = false;
    32703240
    32713241    if (blfile != "") {
    3272       ofs.open(blfile.c_str(), ios::out | ios::app);
     3242      csvFormat = (blfile.substr(0, 1) == "T");
     3243      ofs.open(blfile.substr(1).c_str(), ios::out | ios::app);
    32733244      if (ofs) outTextFile = true;
    32743245    }
     
    33203291      //
    33213292
    3322       outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "sinusoidBaseline()", params, nClipped);
     3293      outputFittingResult(outLogger, outTextFile, csvFormat, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "sinusoidBaseline()", params, nClipped);
    33233294      showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    33243295    }
     
    33383309    bool hasSameNchan = true;
    33393310    bool outTextFile = false;
     3311    bool csvFormat = false;
    33403312
    33413313    if (blfile != "") {
    3342       ofs.open(blfile.c_str(), ios::out | ios::app);
     3314      csvFormat = (blfile.substr(0, 1) == "T");
     3315      ofs.open(blfile.substr(1).c_str(), ios::out | ios::app);
    33433316      if (ofs) outTextFile = true;
    33443317    }
     
    34013374      //
    34023375
    3403       outputFittingResult(outLogger, outTextFile, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoSinusoidBaseline()", params, nClipped);
     3376      outputFittingResult(outLogger, outTextFile, csvFormat, chanMask, whichrow, coordInfo, hasSameNchan, ofs, "autoSinusoidBaseline()", params, nClipped);
    34043377      showProgressOnTerminal(whichrow, nRow, showProgress, minNRow);
    34053378    }
     
    37053678
    37063679/* for poly. the variations of outputFittingResult() should be merged into one eventually (2011/3/10 WK)  */
    3707 void Scantable::outputFittingResult(bool outLogger, bool outTextFile, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, ofstream& ofs, const casa::String& funcName, Fitter& fitter)
     3680void Scantable::outputFittingResult(bool outLogger, bool outTextFile, bool csvFormat, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, ofstream& ofs, const casa::String& funcName, Fitter& fitter)
    37083681{
    37093682  if (outLogger || outTextFile) {
     
    37153688    if (outLogger) {
    37163689      LogIO ols(LogOrigin("Scantable", funcName, WHERE));
    3717       ols << formatBaselineParams(params, fixed, rms, -1, masklist, whichrow, false) << LogIO::POST ;
     3690      ols << formatBaselineParams(params, fixed, rms, -1, masklist, whichrow, false, csvFormat) << LogIO::POST ;
    37183691    }
    37193692    if (outTextFile) {
    3720       ofs << formatBaselineParams(params, fixed, rms, -1, masklist, whichrow, true) << flush;
     3693      ofs << formatBaselineParams(params, fixed, rms, -1, masklist, whichrow, true, csvFormat) << flush;
    37213694    }
    37223695  }
     
    37243697
    37253698/* for cspline. will be merged once cspline is available in fitter (2011/3/10 WK) */
    3726 void Scantable::outputFittingResult(bool outLogger, bool outTextFile, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, ofstream& ofs, const casa::String& funcName, const std::vector<int>& edge, const std::vector<float>& params, const int nClipped)
     3699void Scantable::outputFittingResult(bool outLogger, bool outTextFile, bool csvFormat, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, ofstream& ofs, const casa::String& funcName, const std::vector<int>& edge, const std::vector<float>& params, const int nClipped)
    37273700{
    37283701  if (outLogger || outTextFile) {
     
    37503723    if (outLogger) {
    37513724      LogIO ols(LogOrigin("Scantable", funcName, WHERE));
    3752       ols << formatPiecewiseBaselineParams(edge, params, fixed, rms, nClipped, masklist, whichrow, false) << LogIO::POST ;
     3725      ols << formatPiecewiseBaselineParams(edge, params, fixed, rms, nClipped, masklist, whichrow, false, csvFormat) << LogIO::POST ;
    37533726    }
    37543727    if (outTextFile) {
    3755       ofs << formatPiecewiseBaselineParams(edge, params, fixed, rms, nClipped, masklist, whichrow, true);// << flush;
     3728      ofs << formatPiecewiseBaselineParams(edge, params, fixed, rms, nClipped, masklist, whichrow, true, csvFormat) << flush;
    37563729    }
    37573730
     
    37663739
    37673740/* for sinusoid. will be merged once sinusoid is available in fitter (2011/3/10 WK) */
    3768 void Scantable::outputFittingResult(bool outLogger, bool outTextFile, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, ofstream& ofs, const casa::String& funcName, const std::vector<float>& params, const int nClipped)
     3741void Scantable::outputFittingResult(bool outLogger, bool outTextFile, bool csvFormat, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, ofstream& ofs, const casa::String& funcName, const std::vector<float>& params, const int nClipped)
    37693742{
    37703743  if (outLogger || outTextFile) {
     
    37763749    if (outLogger) {
    37773750      LogIO ols(LogOrigin("Scantable", funcName, WHERE));
    3778       ols << formatBaselineParams(params, fixed, rms, nClipped, masklist, whichrow, false) << LogIO::POST ;
     3751      ols << formatBaselineParams(params, fixed, rms, nClipped, masklist, whichrow, false, csvFormat) << LogIO::POST ;
    37793752    }
    37803753    if (outTextFile) {
    3781       ofs << formatBaselineParams(params, fixed, rms, nClipped, masklist, whichrow, true) << flush;
     3754      ofs << formatBaselineParams(params, fixed, rms, nClipped, masklist, whichrow, true, csvFormat) << flush;
    37823755    }
    37833756  }
     
    39023875
    39033876
    3904 std::string Scantable::formatBaselineParamsHeader(int whichrow, const std::string& masklist, bool verbose) const
    3905 {
    3906   ostringstream oss;
    3907 
     3877std::string Scantable::formatBaselineParamsHeader(int whichrow, const std::string& masklist, bool verbose, bool csvformat) const
     3878{
    39083879  if (verbose) {
    3909     oss <<  " Scan[" << getScan(whichrow)  << "]";
    3910     oss <<  " Beam[" << getBeam(whichrow)  << "]";
    3911     oss <<    " IF[" << getIF(whichrow)    << "]";
    3912     oss <<   " Pol[" << getPol(whichrow)   << "]";
    3913     oss << " Cycle[" << getCycle(whichrow) << "]: " << endl;
    3914     oss << "Fitter range = " << masklist << endl;
    3915     oss << "Baseline parameters" << endl;
     3880    ostringstream oss;
     3881
     3882    if (csvformat) {
     3883      oss << getScan(whichrow)  << ",";
     3884      oss << getBeam(whichrow)  << ",";
     3885      oss << getIF(whichrow)    << ",";
     3886      oss << getPol(whichrow)   << ",";
     3887      oss << getCycle(whichrow) << ",";
     3888      String commaReplacedMasklist = masklist;
     3889      string::size_type pos = 0;
     3890      while (pos = commaReplacedMasklist.find(","), pos != string::npos) {
     3891        commaReplacedMasklist.replace(pos, 1, ";");
     3892        pos++;
     3893      }
     3894      oss << commaReplacedMasklist << ",";
     3895    } else {
     3896      oss <<  " Scan[" << getScan(whichrow)  << "]";
     3897      oss <<  " Beam[" << getBeam(whichrow)  << "]";
     3898      oss <<    " IF[" << getIF(whichrow)    << "]";
     3899      oss <<   " Pol[" << getPol(whichrow)   << "]";
     3900      oss << " Cycle[" << getCycle(whichrow) << "]: " << endl;
     3901      oss << "Fitter range = " << masklist << endl;
     3902      oss << "Baseline parameters" << endl;
     3903    }
    39163904    oss << flush;
    3917   }
    3918 
    3919   return String(oss);
    3920 }
    3921 
    3922 std::string Scantable::formatBaselineParamsFooter(float rms, int nClipped, bool verbose) const
    3923 {
    3924   ostringstream oss;
    3925 
     3905
     3906    return String(oss);
     3907  }
     3908
     3909  return "";
     3910}
     3911
     3912std::string Scantable::formatBaselineParamsFooter(float rms, int nClipped, bool verbose, bool csvformat) const
     3913{
    39263914  if (verbose) {
    3927     oss << "Results of baseline fit" << endl;
    3928     oss << "  rms = " << setprecision(6) << rms << endl;
    3929     if (nClipped >= 0) {
    3930       oss << "  Number of clipped channels = " << nClipped << endl;
    3931     }
    3932     for (int i = 0; i < 60; ++i) {
    3933       oss << "-";
     3915    ostringstream oss;
     3916
     3917    if (csvformat) {
     3918      oss << rms << ",";
     3919      if (nClipped >= 0) {
     3920        oss << nClipped;
     3921      }
     3922    } else {
     3923      oss << endl;
     3924      oss << "Results of baseline fit" << endl;
     3925      oss << "  rms = " << setprecision(6) << rms << endl;
     3926      if (nClipped >= 0) {
     3927        oss << "  Number of clipped channels = " << nClipped << endl;
     3928      }
     3929      for (int i = 0; i < 60; ++i) {
     3930        oss << "-";
     3931      }
    39343932    }
    39353933    oss << endl;
    39363934    oss << flush;
    3937   }
    3938 
    3939   return String(oss);
     3935
     3936    return String(oss);
     3937  }
     3938
     3939  return "";
    39403940}
    39413941
     
    39473947                                            int whichrow,
    39483948                                            bool verbose,
     3949                                            bool csvformat,
    39493950                                            int start, int count,
    39503951                                            bool resetparamid) const
     
    39573958
    39583959    ostringstream oss;
    3959     oss << formatBaselineParamsHeader(whichrow, masklist, verbose);
     3960    oss << formatBaselineParamsHeader(whichrow, masklist, verbose, csvformat);
    39603961
    39613962    if (start < 0) start = 0;
     
    39703971      }
    39713972      std::string sFix = ((fixed.size() > 0) && (fixed[i]) && verbose) ? "(fixed)" : "";
    3972       oss << "  p" << (i+paramidoffset) << sFix << "= " << right << setw(13) << setprecision(6) << params[i];
    3973     }
    3974 
    3975     oss << endl;
    3976     oss << formatBaselineParamsFooter(rms, nClipped, verbose);
     3973      if (csvformat) {
     3974        oss << params[i] << sFix;
     3975      } else {
     3976        oss << "  p" << (i+paramidoffset) << sFix << "= " << right << setw(13) << setprecision(6) << params[i];
     3977      }
     3978    }
     3979
     3980    if (csvformat) {
     3981      oss << ",";
     3982    }
     3983    oss << formatBaselineParamsFooter(rms, nClipped, verbose, csvformat);
    39773984
    39783985    return String(oss);
     
    39813988}
    39823989
    3983   std::string Scantable::formatPiecewiseBaselineParams(const std::vector<int>& ranges, const std::vector<float>& params, const std::vector<bool>& fixed, float rms, int nClipped, const std::string& masklist, int whichrow, bool verbose) const
     3990std::string Scantable::formatPiecewiseBaselineParams(const std::vector<int>& ranges, const std::vector<float>& params, const std::vector<bool>& fixed, float rms, int nClipped, const std::string& masklist, int whichrow, bool verbose, bool csvformat) const
    39843991{
    39853992  int nOutParam = (int)(params.size());
     
    39893996    return("  Not fitted");
    39903997  } else if (nPiece < 0) {
    3991     return formatBaselineParams(params, fixed, rms, nClipped, masklist, whichrow, verbose);
     3998    return formatBaselineParams(params, fixed, rms, nClipped, masklist, whichrow, verbose, csvformat);
    39923999  } else if (nPiece < 1) {
    39934000    return("  Bad count of the piece edge info");
     
    39994006
    40004007    ostringstream oss;
    4001     oss << formatBaselineParamsHeader(whichrow, masklist, verbose);
    4002 
    4003     stringstream ss;
    4004     ss << ranges[nPiece] << flush;
    4005     int wRange = ss.str().size() * 2 + 5;
    4006 
    4007     for (int i = 0; i < nPiece; ++i) {
    4008       ss.str("");
    4009       ss << "  [" << ranges[i] << "," << (ranges[i+1]-1) << "]";
    4010       oss << left << setw(wRange) << ss.str();
    4011       oss << formatBaselineParams(params, fixed, rms, 0, masklist, whichrow, false, i*nParam, nParam, true);
    4012     }
    4013 
    4014     oss << formatBaselineParamsFooter(rms, nClipped, verbose);
     4008    oss << formatBaselineParamsHeader(whichrow, masklist, verbose, csvformat);
     4009
     4010    if (csvformat) {
     4011      for (int i = 0; i < nPiece; ++i) {
     4012        oss << ranges[i] << "," << (ranges[i+1]-1) << ",";
     4013        oss << formatBaselineParams(params, fixed, rms, 0, masklist, whichrow, false, csvformat, i*nParam, nParam, true);
     4014      }
     4015    } else {
     4016      stringstream ss;
     4017      ss << ranges[nPiece] << flush;
     4018      int wRange = ss.str().size() * 2 + 5;
     4019
     4020      for (int i = 0; i < nPiece; ++i) {
     4021        ss.str("");
     4022        ss << "  [" << ranges[i] << "," << (ranges[i+1]-1) << "]";
     4023        oss << left << setw(wRange) << ss.str();
     4024        oss << formatBaselineParams(params, fixed, rms, 0, masklist, whichrow, false, csvformat, i*nParam, nParam, true);
     4025        oss << endl;
     4026      }
     4027    }
     4028
     4029    oss << formatBaselineParamsFooter(rms, nClipped, verbose, csvformat);
    40154030
    40164031    return String(oss);
  • trunk/src/Scantable.h

    r2595 r2641  
    580580                                   int whichrow,
    581581                                   bool verbose=false,
     582                                   bool csvformat=false,
    582583                                   int start=-1,
    583584                                   int count=-1,
     
    590591                                            const std::string& masklist,
    591592                                            int whichrow,
    592                                             bool verbose=false) const;
     593                                            bool verbose=false,
     594                                            bool csvformat=false) const;
    593595  std::vector<uint> getMoleculeIdColumnData() const;
    594596  void setMoleculeIdColumnData(const std::vector<uint>& molids);
     
    757759                                bool verbose=false);
    758760  std::vector<int> getMaskEdgeIndices(const std::vector<bool>& mask);
    759   std::string formatBaselineParamsHeader(int whichrow, const std::string& masklist, bool verbose) const;
    760   std::string formatBaselineParamsFooter(float rms, int nClipped, bool verbose) const;
     761  std::string formatBaselineParamsHeader(int whichrow, const std::string& masklist, bool verbose, bool csvformat) const;
     762  std::string formatBaselineParamsFooter(float rms, int nClipped, bool verbose, bool csvformat) const;
    761763  std::vector<bool> getCompositeChanMask(int whichrow, const std::vector<bool>& inMask);
    762764  //std::vector<bool> getCompositeChanMask(int whichrow, const std::vector<bool>& inMask, const std::vector<int>& edge, const int minEdgeSize, STLineFinder& lineFinder);
    763   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, Fitter& fitter);
    764   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, const int nClipped);
    765   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, const int nClipped);
     765  void outputFittingResult(bool outLogger, bool outTextFile, bool csvFormat, const std::vector<bool>& chanMask, int whichrow, const casa::String& coordInfo, bool hasSameNchan, std::ofstream& ofs, const casa::String& funcName, Fitter& fitter);
     766  void outputFittingResult(bool outLogger, bool outTextFile, bool csvFormat, 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, const int nClipped);
     767  void outputFittingResult(bool outLogger, bool outTextFile, bool csvFormat, 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, const int nClipped);
    766768  void parseProgressInfo(const std::string& progressInfo, bool& showProgress, int& minNRow);
    767769  void showProgressOnTerminal(const int nProcessed, const int nTotal, const bool showProgress=true, const int nTotalThreshold=1000);
  • trunk/src/ScantableWrapper.h

    r2591 r2641  
    298298  { return table_->getRms(mask, whichrow); }
    299299
    300   std::string formatBaselineParams(const std::vector<float>& params, const std::vector<bool>& fixed, float rms, const std::string& masklist, int whichrow, bool verbose=false)
    301   { return table_->formatBaselineParams(params, fixed, rms, -1, masklist, whichrow, verbose); }
    302 
    303   std::string formatPiecewiseBaselineParams(const std::vector<int>& ranges, const std::vector<float>& params, const std::vector<bool>& fixed, float rms, const std::string& masklist, int whichrow, bool verbose=false)
    304   { return table_->formatPiecewiseBaselineParams(ranges, params, fixed, rms, -1, masklist, whichrow, verbose); }
     300  std::string formatBaselineParams(const std::vector<float>& params, const std::vector<bool>& fixed, float rms, const std::string& masklist, int whichrow, bool verbose=false, bool csvformat=false)
     301  { return table_->formatBaselineParams(params, fixed, rms, -1, masklist, whichrow, verbose, csvformat); }
     302
     303  std::string formatPiecewiseBaselineParams(const std::vector<int>& ranges, const std::vector<float>& params, const std::vector<bool>& fixed, float rms, const std::string& masklist, int whichrow, bool verbose=false, bool csvformat=false)
     304  { return table_->formatPiecewiseBaselineParams(ranges, params, fixed, rms, -1, masklist, whichrow, verbose, csvformat); }
    305305
    306306  bool getFlagtraFast(int whichrow=0) const
Note: See TracChangeset for help on using the changeset viewer.