source: trunk/src/STFitter.h@ 2059

Last change on this file since 2059 was 1932, checked in by WataruKawasaki, 14 years ago

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.


  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.1 KB
Line 
1//#---------------------------------------------------------------------------
2//# Fitter.h: A Fitter class for spectra
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//# Internet email: Malte.Marquarding@csiro.au
23//# Postal address: Malte Marquarding,
24//# Australia Telescope National Facility,
25//# P.O. Box 76,
26//# Epping, NSW, 2121,
27//# AUSTRALIA
28//#
29//# $Id: STFitter.h 1932 2010-09-17 08:35:58Z WataruKawasaki $
30//#---------------------------------------------------------------------------
31#ifndef STFITTER_H
32#define STFITTER_H
33
34#include <string>
35#include <vector>
36
37#include <casa/Arrays/Vector.h>
38#include <casa/Containers/Block.h>
39#include <scimath/Functionals/Function.h>
40#include <scimath/Functionals/CompoundFunction.h>
41
42#include "STFitEntry.h"
43
44namespace asap {
45
46class Fitter {
47public:
48 Fitter();
49 virtual ~Fitter();
50 // allowed "gauss" and "poly". ncomp is either numvber of gaussions
51 // or order of the polynomial
52 bool setExpression(const std::string& expr, int ncomp=1);
53 bool setData(std::vector<float> absc, std::vector<float> spec,
54 std::vector<bool> mask);
55 bool setParameters(std::vector<float> params);
56 bool setFixedParameters(std::vector<bool> fixed);
57
58 std::vector<float> getResidual() const;
59 std::vector<float> getFit() const;
60 std::vector<float> getParameters() const;
61 std::vector<bool> getFixedParameters() const;
62
63 std::vector<float> getEstimate() const;
64 std::vector<float> getErrors() const;
65 float getChisquared() const;
66 void reset();
67 bool fit();
68 // Fit via linear method
69 bool lfit();
70 bool computeEstimate();
71
72 std::vector<float> evaluate(int whichComp) const;
73
74 STFitEntry getFitEntry() const;
75
76private:
77 void clear();
78 casa::Vector<casa::Float> x_;
79 casa::Vector<casa::Float> y_;
80 casa::Vector<casa::Bool> m_;
81 casa::PtrBlock<casa::Function<casa::Float>* > funcs_;
82 std::vector<std::string> funcnames_;
83 std::vector<int> funccomponents_;
84
85 //Bool estimateSet_;
86 casa::Float chisquared_;
87 casa::Vector<casa::Float> parameters_;
88 casa::Vector<casa::Bool> fixedpar_;
89
90 casa::Vector<casa::Float> error_;
91 casa::Vector<casa::Float> thefit_;
92 casa::Vector<casa::Float> residual_;
93 casa::Vector<casa::Float> estimate_;
94};
95
96} // namespace
97
98#endif
Note: See TracBrowser for help on using the repository browser.