Changeset 1932


Ignore:
Timestamp:
09/17/10 18:35:58 (14 years ago)
Author:
WataruKawasaki
Message:

New Development: No

JIRA Issue: No

Ready for Test: Yes

Interface Changes: No

What Interface Changed:

Test Programs:

Put in Release Notes: No

Module(s): poly_baseline()

Description: Malte's changes.


Location:
trunk/src
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STFit.cpp

    r1000 r1932  
    7070  table_.addColumn(ArrayColumnDesc<Int>("COMPONENTS"));
    7171  table_.addColumn(ArrayColumnDesc<Double>("PARAMETERS"));
     72  //  table_.addColumn(ArrayColumnDesc<Double>("ERRORS"));
    7273  table_.addColumn(ArrayColumnDesc<Bool>("PARMASKS"));
    7374  table_.addColumn(ArrayColumnDesc<String>("FRAMEINFO"));
     
    7778  compCol_.attach(table_,"COMPONENTS");
    7879  parCol_.attach(table_,"PARAMETERS");
     80  //  errCol_.attach(table_,"ERRORS");
    7981  maskCol_.attach(table_,"PARMASKS");
    8082  frameCol_.attach(table_,"FRAMEINFO");
     
    102104  // add new row if new id
    103105  if ( !foundentry ) table_.addRow();
     106
    104107  funcCol_.put(rno, mathutil::toVectorString(fit.getFunctions()));
    105108  compCol_.put(rno, Vector<Int>(fit.getComponents()));
    106   parCol_.put(rno, Vector<Double>(fit.getParameters()));
     109  const std::vector<float>& pvec = fit.getParameters();
     110  Vector<Double> dvec(pvec.size());
     111  for (size_t i=0; i < dvec.nelements(); ++i) {
     112    dvec[i] = Double(pvec[i]);
     113  }
     114  parCol_.put(rno, dvec);
     115  /*
     116  const std::vector<double>& evec = fit.getErrors();
     117  for (size_t i=0; i < dvec.nelements(); ++i) {
     118    dvec[i] = Double(evec[i]);
     119  }
     120  errCol_.put(rno, dvec);
     121  */
    107122  maskCol_.put(rno, Vector<Bool>(fit.getParmasks()));
    108123  frameCol_.put(rno, mathutil::toVectorString(fit.getFrameinfo()));
    109124  idCol_.put(rno, resultid);
     125
    110126  return resultid;
    111127}
     
    130146  fit.setComponents(istl);
    131147  Vector<Double> dvec;
    132   std::vector<double> dstl;
    133148  rec.get("PARAMETERS", dvec);
     149  std::vector<float> dstl(dvec.begin(), dvec.end());
     150  fit.setParameters(dstl);
     151  /*
    134152  dvec.tovector(dstl);
    135153  fit.setParameters(dstl);
     154  dvec.resize();
     155  rec.get("ERRORS", dvec);
     156  dvec.tovector(dstl);
     157  fit.setErrors(dstl);
     158  */
    136159  Vector<Bool> bvec;
    137160  std::vector<bool> bstl;
  • trunk/src/STFit.h

    r1353 r1932  
    4949  casa::ArrayColumn<casa::Int> compCol_;
    5050  casa::ArrayColumn<casa::Double> parCol_;
     51  //  casa::ArrayColumn<casa::Double> errCol_;
    5152  casa::ArrayColumn<casa::Bool> maskCol_;
    5253  casa::ArrayColumn<casa::String> frameCol_;
  • trunk/src/STFitEntry.cpp

    r972 r1932  
    1111//
    1212#include "STFitEntry.h"
     13#include <casa/iostream.h>
    1314
     15using namespace casa;
    1416namespace asap {
    1517
    16 STFitEntry::STFitEntry()
     18  STFitEntry::STFitEntry()
     19  /* :
     20    functions_( std::vector<std::string>()),
     21    components_(std::vector<int>()),
     22    parameters_(std::vector<float>()),
     23    errors_(std::vector<float>()),
     24    parmasks_(std::vector<bool>()),
     25    frameinfo_(std::vector<std::string>())
     26  */
    1727{
    1828}
     
    2030{
    2131  if ( this != &other ) {
    22     this->functions_ = other.functions_;
     32    this->functions_ = std::vector<std::string>();
    2333    this->components_ = other.components_;
    2434    this->parameters_ = other.parameters_;
    25     this->parmasks_ = other.parmasks_;
     35    this->errors_ = other.errors_;
    2636    this->frameinfo_ = other.frameinfo_;
    2737  }
    2838}
    2939
     40STFitEntry& STFitEntry::operator=(const STFitEntry& other)
     41{
     42  if ( this != &other ) {
     43    this->functions_ = other.functions_;
     44    this->components_ = other.components_;
     45    this->parameters_ = other.parameters_;
     46    this->errors_ = other.errors_;
     47    this->parmasks_ = other.parmasks_;
     48    this->frameinfo_ = other.frameinfo_;
     49  }
     50  return *this;
     51}
    3052
    3153STFitEntry::~STFitEntry()
  • trunk/src/STFitEntry.h

    r972 r1932  
    2828  STFitEntry(const STFitEntry& other);
    2929
     30  STFitEntry& operator=(const STFitEntry& other);
     31
    3032  ~STFitEntry();
    3133
     
    3436  void setComponents(const std::vector<int>& c)
    3537    { components_ = c; }
    36   void setParameters(const std::vector<double>& p)
     38  void setParameters(const std::vector<float>& p)
    3739    { parameters_ = p; }
     40  void setErrors(const std::vector<float>& p)
     41    { errors_ = p; }
    3842  void setParmasks(const std::vector<bool>& m)
    3943    { parmasks_ = m; }
    4044  void setFrameinfo(const std::vector<std::string>& f)
    4145    { frameinfo_ = f; }
    42 
    4346  std::vector<std::string> getFunctions() const { return functions_; }
    4447  std::vector<int> getComponents() const { return components_; }
    45   std::vector<double> getParameters() const { return parameters_; }
     48  std::vector<float> getParameters() const { return parameters_; }
     49  std::vector<float> getErrors() const { return errors_; }
    4650  std::vector<bool> getParmasks() const { return parmasks_; }
    4751  std::vector<std::string> getFrameinfo() const { return frameinfo_; }
    4852
    4953private:
     54
    5055  std::vector<std::string> functions_;
    5156  std::vector<int> components_;
    52   std::vector<double> parameters_;
     57  std::vector<float> parameters_;
     58  std::vector<float> errors_;
    5359  std::vector<bool> parmasks_;
    5460  std::vector<std::string> frameinfo_;
  • trunk/src/STFitter.cpp

    r1819 r1932  
    142142    if (ncomp < 1) throw (AipsError("Need at least one gaussian to fit."));
    143143    funcs_.resize(ncomp);
     144    funcnames_.clear();
     145    funccomponents_.clear();
    144146    for (Int k=0; k<ncomp; ++k) {
    145147      funcs_[k] = new Gaussian1D<Float>();
     148      funcnames_.push_back(expr);
     149      funccomponents_.push_back(3);
    146150    }
    147151  } else if (expr == "poly") {
    148152    funcs_.resize(1);
     153    funcnames_.clear();
     154    funccomponents_.clear();
    149155    funcs_[0] = new Polynomial<Float>(ncomp);
     156      funcnames_.push_back(expr);
     157      funccomponents_.push_back(ncomp);
    150158  } else if (expr == "lorentz") {
    151159    if (ncomp < 1) throw (AipsError("Need at least one lorentzian to fit."));
    152160    funcs_.resize(ncomp);
     161    funcnames_.clear();
     162    funccomponents_.clear();
    153163    for (Int k=0; k<ncomp; ++k) {
    154164      funcs_[k] = new Lorentzian1D<Float>();
     165      funcnames_.push_back(expr);
     166      funccomponents_.push_back(3);
    155167    }
    156168  } else {
     
    409421}
    410422
     423STFitEntry Fitter::getFitEntry() const
     424{
     425  STFitEntry fit;
     426  fit.setParameters(getParameters());
     427  fit.setErrors(getErrors());
     428  fit.setComponents(funccomponents_);
     429  fit.setFunctions(funcnames_);
     430  fit.setParmasks(getFixedParameters());
     431  return fit;
     432}
  • trunk/src/STFitter.h

    r1391 r1932  
    4040#include <scimath/Functionals/CompoundFunction.h>
    4141
     42#include "STFitEntry.h"
     43
    4244namespace asap {
    4345
     
    6971
    7072  std::vector<float> evaluate(int whichComp) const;
     73
     74  STFitEntry getFitEntry() const;
     75
    7176private:
    7277  void clear();
     
    7580  casa::Vector<casa::Bool> m_;
    7681  casa::PtrBlock<casa::Function<casa::Float>* > funcs_;
     82  std::vector<std::string> funcnames_;
     83  std::vector<int> funccomponents_;
     84 
    7785  //Bool estimateSet_;
    7886  casa::Float chisquared_;
Note: See TracChangeset for help on using the changeset viewer.