Changeset 1924 for branches/polybatch/src
- Timestamp:
- 09/14/10 12:17:16 (14 years ago)
- Location:
- branches/polybatch/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/polybatch/src/STFit.cpp
r1000 r1924 70 70 table_.addColumn(ArrayColumnDesc<Int>("COMPONENTS")); 71 71 table_.addColumn(ArrayColumnDesc<Double>("PARAMETERS")); 72 // table_.addColumn(ArrayColumnDesc<Double>("ERRORS")); 72 73 table_.addColumn(ArrayColumnDesc<Bool>("PARMASKS")); 73 74 table_.addColumn(ArrayColumnDesc<String>("FRAMEINFO")); … … 77 78 compCol_.attach(table_,"COMPONENTS"); 78 79 parCol_.attach(table_,"PARAMETERS"); 80 // errCol_.attach(table_,"ERRORS"); 79 81 maskCol_.attach(table_,"PARMASKS"); 80 82 frameCol_.attach(table_,"FRAMEINFO"); … … 102 104 // add new row if new id 103 105 if ( !foundentry ) table_.addRow(); 106 104 107 funcCol_.put(rno, mathutil::toVectorString(fit.getFunctions())); 105 108 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 */ 107 122 maskCol_.put(rno, Vector<Bool>(fit.getParmasks())); 108 123 frameCol_.put(rno, mathutil::toVectorString(fit.getFrameinfo())); 109 124 idCol_.put(rno, resultid); 125 110 126 return resultid; 111 127 } … … 130 146 fit.setComponents(istl); 131 147 Vector<Double> dvec; 132 std::vector<double> dstl;133 148 rec.get("PARAMETERS", dvec); 149 std::vector<float> dstl(dvec.begin(), dvec.end()); 150 fit.setParameters(dstl); 151 /* 134 152 dvec.tovector(dstl); 135 153 fit.setParameters(dstl); 154 dvec.resize(); 155 rec.get("ERRORS", dvec); 156 dvec.tovector(dstl); 157 fit.setErrors(dstl); 158 */ 136 159 Vector<Bool> bvec; 137 160 std::vector<bool> bstl; -
branches/polybatch/src/STFit.h
r1353 r1924 49 49 casa::ArrayColumn<casa::Int> compCol_; 50 50 casa::ArrayColumn<casa::Double> parCol_; 51 // casa::ArrayColumn<casa::Double> errCol_; 51 52 casa::ArrayColumn<casa::Bool> maskCol_; 52 53 casa::ArrayColumn<casa::String> frameCol_; -
branches/polybatch/src/STFitEntry.cpp
r972 r1924 11 11 // 12 12 #include "STFitEntry.h" 13 #include <casa/iostream.h> 13 14 15 using namespace casa; 14 16 namespace asap { 15 17 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 */ 17 27 { 18 28 } … … 20 30 { 21 31 if ( this != &other ) { 22 this->functions_ = other.functions_;32 this->functions_ = std::vector<std::string>(); 23 33 this->components_ = other.components_; 24 34 this->parameters_ = other.parameters_; 25 this-> parmasks_ = other.parmasks_;35 this->errors_ = other.errors_; 26 36 this->frameinfo_ = other.frameinfo_; 27 37 } 28 38 } 29 39 40 STFitEntry& 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 } 30 52 31 53 STFitEntry::~STFitEntry() -
branches/polybatch/src/STFitEntry.h
r972 r1924 28 28 STFitEntry(const STFitEntry& other); 29 29 30 STFitEntry& operator=(const STFitEntry& other); 31 30 32 ~STFitEntry(); 31 33 … … 34 36 void setComponents(const std::vector<int>& c) 35 37 { components_ = c; } 36 void setParameters(const std::vector< double>& p)38 void setParameters(const std::vector<float>& p) 37 39 { parameters_ = p; } 40 void setErrors(const std::vector<float>& p) 41 { errors_ = p; } 38 42 void setParmasks(const std::vector<bool>& m) 39 43 { parmasks_ = m; } 40 44 void setFrameinfo(const std::vector<std::string>& f) 41 45 { frameinfo_ = f; } 42 43 46 std::vector<std::string> getFunctions() const { return functions_; } 44 47 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_; } 46 50 std::vector<bool> getParmasks() const { return parmasks_; } 47 51 std::vector<std::string> getFrameinfo() const { return frameinfo_; } 48 52 49 53 private: 54 50 55 std::vector<std::string> functions_; 51 56 std::vector<int> components_; 52 std::vector<double> parameters_; 57 std::vector<float> parameters_; 58 std::vector<float> errors_; 53 59 std::vector<bool> parmasks_; 54 60 std::vector<std::string> frameinfo_; -
branches/polybatch/src/STFitter.cpp
r1819 r1924 142 142 if (ncomp < 1) throw (AipsError("Need at least one gaussian to fit.")); 143 143 funcs_.resize(ncomp); 144 funcnames_.clear(); 145 funccomponents_.clear(); 144 146 for (Int k=0; k<ncomp; ++k) { 145 147 funcs_[k] = new Gaussian1D<Float>(); 148 funcnames_.push_back(expr); 149 funccomponents_.push_back(3); 146 150 } 147 151 } else if (expr == "poly") { 148 152 funcs_.resize(1); 153 funcnames_.clear(); 154 funccomponents_.clear(); 149 155 funcs_[0] = new Polynomial<Float>(ncomp); 156 funcnames_.push_back(expr); 157 funccomponents_.push_back(ncomp); 150 158 } else if (expr == "lorentz") { 151 159 if (ncomp < 1) throw (AipsError("Need at least one lorentzian to fit.")); 152 160 funcs_.resize(ncomp); 161 funcnames_.clear(); 162 funccomponents_.clear(); 153 163 for (Int k=0; k<ncomp; ++k) { 154 164 funcs_[k] = new Lorentzian1D<Float>(); 165 funcnames_.push_back(expr); 166 funccomponents_.push_back(3); 155 167 } 156 168 } else { … … 409 421 } 410 422 423 STFitEntry 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 } -
branches/polybatch/src/STFitter.h
r1391 r1924 40 40 #include <scimath/Functionals/CompoundFunction.h> 41 41 42 #include "STFitEntry.h" 43 42 44 namespace asap { 43 45 … … 69 71 70 72 std::vector<float> evaluate(int whichComp) const; 73 74 STFitEntry getFitEntry() const; 75 71 76 private: 72 77 void clear(); … … 75 80 casa::Vector<casa::Bool> m_; 76 81 casa::PtrBlock<casa::Function<casa::Float>* > funcs_; 82 std::vector<std::string> funcnames_; 83 std::vector<int> funccomponents_; 84 77 85 //Bool estimateSet_; 78 86 casa::Float chisquared_; -
branches/polybatch/src/Scantable.cpp
r1919 r1924 1750 1750 } 1751 1751 1752 void Scantable::polyBaselineBatch(const std::vector<bool>& mask, int order, int rowno) 1752 void Scantable::polyBaselineBatch(const std::vector<bool>& mask, int order) 1753 { 1754 Fitter fitter = Fitter(); 1755 for (uInt rowno=0; rowno < nrow(); ++rowno) { 1756 doPolyBaseline(mask, order, rowno, fitter); 1757 setSpectrum(fitter.getResidual(), rowno); 1758 } 1759 } 1760 1761 STFitEntry Scantable::polyBaseline(const std::vector<bool>& mask, int order, int rowno) 1753 1762 { 1754 1763 Fitter fitter = Fitter(); 1755 1764 doPolyBaseline(mask, order, rowno, fitter); 1756 1765 setSpectrum(fitter.getResidual(), rowno); 1757 } 1758 1759 void Scantable::polyBaseline(const std::vector<bool>& mask, int order, int rowno, long pars_ptr, long pars_size, long errs_ptr, long errs_size, long fmask_ptr, long fmask_size) 1760 { 1761 Fitter fitter = Fitter(); 1762 doPolyBaseline(mask, order, rowno, fitter); 1763 setSpectrum(fitter.getResidual(), rowno); 1764 1765 std::vector<float> pars = fitter.getParameters(); 1766 if (pars_size != pars.size()) { 1767 throw(AipsError("wrong pars size")); 1768 } 1769 float *ppars = reinterpret_cast<float*>(pars_ptr); 1770 for (int i = 0; i < pars_size; i++) { 1771 ppars[i] = pars[i]; 1772 } 1773 1774 std::vector<float> errs = fitter.getErrors(); 1775 if (errs_size != errs.size()) { 1776 throw(AipsError("wrong errors size")); 1777 } 1778 float *perrs = reinterpret_cast<float*>(errs_ptr); 1779 for (int i = 0; i < errs_size; i++) { 1780 perrs[i] = errs[i]; 1781 } 1782 1783 std::vector<bool> fmask = getMask(rowno); 1784 if (fmask_size != fmask.size()) { 1785 throw(AipsError("wrong fmask size")); 1786 } 1787 int *pfmask = reinterpret_cast<int*>(fmask_ptr); 1788 for (int i = 0; i < fmask_size; i++) { 1789 pfmask[i] = ((fmask[i] && mask[i]) ? 1 : 0); 1790 } 1766 return fitter.getFitEntry(); 1791 1767 } 1792 1768 -
branches/polybatch/src/Scantable.h
r1919 r1924 18 18 // AIPS++ 19 19 #include <casa/aips.h> 20 #include <casa/Containers/Record.h> 20 21 #include <casa/Arrays/MaskedArray.h> 21 22 #include <casa/BasicSL/String.h> … … 489 490 bool getFlagtraFast(int whichrow); 490 491 491 void polyBaselineBatch(const std::vector<bool>& mask, int order, int rowno); 492 void polyBaseline(const std::vector<bool>& mask, int order, int rowno, long pars_ptr, long pars_size, long errs_ptr, long errs_size, long fmask_ptr, long fmask_size); 493 492 void polyBaselineBatch(const std::vector<bool>& mask, int order); 493 STFitEntry polyBaseline(const std::vector<bool>& mask, int order, int rowno); 494 494 495 495 private: -
branches/polybatch/src/ScantableWrapper.h
r1919 r1924 19 19 #include "MathUtils.h" 20 20 #include "STFit.h" 21 #include "STFitEntry.h" 21 22 #include "Scantable.h" 22 23 #include "STCoordinate.h" … … 250 251 { table_->reshapeSpectrum( nmin, nmax ); } 251 252 252 void polyBaseline(const std::vector<bool>& mask, int order, int rowno, long pars_ptr, long pars_size, long errs_ptr, long errs_size, long fmask_ptr, long fmask_size)253 { table_->polyBaseline(mask, order, rowno, pars_ptr, pars_size, errs_ptr, errs_size, fmask_ptr, fmask_size); }254 255 void polyBaselineBatch(const std::vector<bool>& mask, int order , int rowno)256 { table_->polyBaselineBatch(mask, order , rowno); }253 STFitEntry polyBaseline(const std::vector<bool>& mask, int order, int rowno) 254 { return table_->polyBaseline(mask, order, rowno); } 255 256 void polyBaselineBatch(const std::vector<bool>& mask, int order) 257 { table_->polyBaselineBatch(mask, order); } 257 258 258 259 bool getFlagtraFast(int whichrow=0) const -
branches/polybatch/src/python_STFitEntry.cpp
r972 r1924 44 44 .def("getfixedparameters", &STFitEntry::getParmasks) 45 45 .def("getparameters", &STFitEntry::getParameters) 46 .def("geterrors", &STFitEntry::getErrors) 46 47 .def("getfunctions", &STFitEntry::getFunctions) 47 48 .def("getcomponents", &STFitEntry::getComponents) … … 49 50 .def("setfixedparameters", &STFitEntry::setParmasks) 50 51 .def("setparameters", &STFitEntry::setParameters) 52 .def("seterrors", &STFitEntry::setErrors) 51 53 .def("setfunctions", &STFitEntry::setFunctions) 52 54 .def("setcomponents", &STFitEntry::setComponents)
Note:
See TracChangeset
for help on using the changeset viewer.