//#--------------------------------------------------------------------------- //# Fitter.h: A Fitter class for spectra //#--------------------------------------------------------------------------- //# Copyright (C) 2004 //# ATNF //# //# This program is free software; you can redistribute it and/or modify it //# under the terms of the GNU General Public License as published by the Free //# Software Foundation; either version 2 of the License, or (at your option) //# any later version. //# //# This program is distributed in the hope that it will be useful, but //# WITHOUT ANY WARRANTY; without even the implied warranty of //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General //# Public License for more details. //# //# You should have received a copy of the GNU General Public License along //# with this program; if not, write to the Free Software Foundation, Inc., //# 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning this software should be addressed as follows: //# Internet email: Malte.Marquarding@csiro.au //# Postal address: Malte Marquarding, //# Australia Telescope National Facility, //# P.O. Box 76, //# Epping, NSW, 2121, //# AUSTRALIA //# //# $Id: STFitter.h 3106 2016-10-04 07:20:50Z TakeshiNakazato $ //#--------------------------------------------------------------------------- #ifndef STFITTER_H #define STFITTER_H #include #include #include #include #include #include #include #include "STFitEntry.h" namespace asap { class Fitter { public: Fitter(); virtual ~Fitter(); // allowed "gauss" and "poly". ncomp is either numvber of gaussions // or order of the polynomial bool setExpression(const std::string& expr, int ncomp=1); bool setData(std::vector absc, std::vector spec, std::vector mask); bool setParameters(std::vector params); bool setFixedParameters(std::vector fixed); void addConstraint(const std::vector& constraint); std::vector getResidual() const; std::vector getFit() const; std::vector getParameters() const; std::vector getFixedParameters() const; std::vector getEstimate() const; std::vector getErrors() const; float getChisquared() const; void reset(); bool fit(); // Fit via linear method bool lfit(); bool computeEstimate(); std::vector evaluate(int whichComp) const; STFitEntry getFitEntry() const; private: void clear(); void applyConstraints(casacore::GenericL2Fit& fitter); casacore::Vector x_; casacore::Vector y_; casacore::Vector m_; casacore::PtrBlock* > funcs_; std::vector funcnames_; std::vector funccomponents_; //Bool estimateSet_; casacore::Float chisquared_; casacore::Vector parameters_; casacore::Vector fixedpar_; std::vector > constraints_; casacore::Vector error_; casacore::Vector thefit_; casacore::Vector residual_; casacore::Vector estimate_; }; } // namespace #endif