- Timestamp:
- 10/15/12 15:52:38 (12 years ago)
- Location:
- trunk/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/STFitter.cpp
r2580 r2666 80 80 y_.resize(); 81 81 m_.resize(); 82 constraints_.clear(); 82 83 } 83 84 … … 294 295 } 295 296 297 void Fitter::addConstraint(const std::vector<float>& constraint) 298 { 299 if (funcs_.nelements() == 0) 300 throw (AipsError("Function not yet set.")); 301 constraints_.push_back(constraint); 302 303 } 304 305 void Fitter::applyConstraints(GenericL2Fit<Float>& fitter) 306 { 307 std::vector<std::vector<float> >::const_iterator it; 308 for (it = constraints_.begin(); it != constraints_.end(); ++it) { 309 Vector<Float> tmp(*it); 310 fitter.addConstraint(tmp(Slice(0,tmp.nelements()-1)), 311 tmp(tmp.nelements()-1)); 312 } 313 } 314 296 315 bool Fitter::setFixedParameters(std::vector<bool> fixed) 297 316 { … … 377 396 // Convergence criterium 378 397 fitter.setCriteria(0.001); 398 applyConstraints(fitter); 379 399 380 400 // Fit … … 397 417 chisquared_ = fitter.getChi2(); 398 418 399 // residual_.resize();400 // residual_ = y_;401 // fitter.residual(residual_,x_);402 419 // use fitter.residual(model=True) to get the model 403 420 thefit_.resize(x_.nelements()); 404 421 fitter.residual(thefit_,x_,True); 405 // residual = data - model406 422 residual_.resize(x_.nelements()); 407 423 residual_ = y_ - thefit_ ; … … 419 435 420 436 fitter.setFunction(func); 421 //fitter.setMaxIter(50+n*10); 422 // Convergence criterium 423 //fitter.setCriteria(0.001); 424 425 // Fit 426 // Vector<Float> sigma(x_.nelements()); 427 // sigma = 1.0; 437 applyConstraints(fitter); 428 438 429 439 parameters_.resize(); 430 // parameters_ = fitter.fit(x_, y_, sigma, &m_);431 440 parameters_ = fitter.fit(x_, y_, &m_); 432 441 std::vector<float> ps; … … 439 448 chisquared_ = fitter.getChi2(); 440 449 441 // residual_.resize();442 // residual_ = y_;443 // fitter.residual(residual_,x_);444 // use fitter.residual(model=True) to get the model445 450 thefit_.resize(x_.nelements()); 446 451 fitter.residual(thefit_,x_,True); 447 // residual = data - model448 452 residual_.resize(x_.nelements()); 449 453 residual_ = y_ - thefit_ ; -
trunk/src/STFitter.h
r1932 r2666 39 39 #include <scimath/Functionals/Function.h> 40 40 #include <scimath/Functionals/CompoundFunction.h> 41 #include <scimath/Fitting/GenericL2Fit.h> 42 41 43 42 44 #include "STFitEntry.h" 45 43 46 44 47 namespace asap { … … 55 58 bool setParameters(std::vector<float> params); 56 59 bool setFixedParameters(std::vector<bool> fixed); 60 void addConstraint(const std::vector<float>& constraint); 57 61 58 62 std::vector<float> getResidual() const; … … 76 80 private: 77 81 void clear(); 82 void applyConstraints(casa::GenericL2Fit<casa::Float>& fitter); 78 83 casa::Vector<casa::Float> x_; 79 84 casa::Vector<casa::Float> y_; … … 87 92 casa::Vector<casa::Float> parameters_; 88 93 casa::Vector<casa::Bool> fixedpar_; 94 std::vector<std::vector<float> > constraints_; 89 95 90 96 casa::Vector<casa::Float> error_; -
trunk/src/STLineFinder.h
r2580 r2666 48 48 #include "ScantableWrapper.h" 49 49 #include "Scantable.h" 50 #include "STFitter.h"51 50 52 51 namespace asap { -
trunk/src/Scantable.cpp
r2658 r2666 71 71 #include "STPolStokes.h" 72 72 #include "STUpgrade.h" 73 #include "STFitter.h" 73 74 #include "Scantable.h" 74 75 -
trunk/src/Scantable.h
r2658 r2666 43 43 #include "STFit.h" 44 44 #include "STFitEntry.h" 45 #include "STFitter.h"45 //#include "STFitter.h" 46 46 #include "STFocus.h" 47 47 #include "STFrequencies.h" … … 55 55 56 56 namespace asap { 57 58 class Fitter; 57 59 58 60 /** -
trunk/src/python_Fitter.cpp
r1391 r2666 49 49 .def("getparameters", &Fitter::getParameters) 50 50 .def("setparameters", &Fitter::setParameters) 51 .def("addconstraint", &Fitter::addConstraint) 51 52 .def("getestimate", &Fitter::getEstimate) 52 53 .def("estimate", &Fitter::computeEstimate) -
trunk/src/python_asap.cpp
r2658 r2666 124 124 casa::pyrap::register_convert_casa_valueholder(); 125 125 casa::pyrap::register_convert_casa_record(); 126 126 127 #endif 127 128 }
Note:
See TracChangeset
for help on using the changeset viewer.