casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SpectralFitter.h
Go to the documentation of this file.
1 //# SpectralCollapser.h: Header file for class SpectralCollapser
2 //# Copyright (C) 1998,1999,2000,2001,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This program is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU General Public License as published by the Free
7 //# Software Foundation; either version 2 of the License, or (at your option)
8 //# any later version.
9 //#
10 //# This program is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 //# more details.
14 //#
15 //# You should have received a copy of the GNU General Public License along
16 //# with this program; if not, write to the Free Software Foundation, Inc.,
17 //# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 
28 #ifndef IMAGEANALYSIS_SPECTRALFITTER_H
29 #define IMAGEANALYSIS_SPECTRALFITTER_H
30 
33 
34 #include <casa/namespace.h>
35 
36 namespace casacore{
37 
38 //class SpectralCoordinate;
39 class LogIO;
40 }
41 
42 namespace casa {
43 
44 template <class T> class ProfileFit1D;
45 
46 class SpectralList;
47 
49  // <summary>
50  // Does a simple fit to data in vectors. It is possible to specify weights (or errors)
51  // for each element. A single Gaussian and a polynimial of order N are the only
52  // component that can be fitted.
53  // </summary>
54 
55  // <reviewed reviewer="" date="" tests="" demos="">
56  // </reviewed>
57 
58  // <prerequisite>
59  // <li> ProfileFit1D
60  // </prerequisite>
61 
62  // <etymology>
63  // Created to fit components to spectra from the spectral profiler, hence
64  // SpectralFitter.
65  // </etymology>
66 
67  // <synopsis>
68  // </synopsis>
69 
70 public:
71  enum FitStatus {// report the status of the last fit
72  UNKNOWN, // mostly means not fit has yet been executed
75  };
76 
77  // default constructor
79 
80  // destructor
81  virtual ~SpectralFitter();
82 
83  // Parameters:
84  // <src>spcVals</src> - independent values
85  // <src>yVals</src> - dependent values
86  // <src>eVals</src> - error values
87  // <src>startVal</src> - lower boundary for independent values to be included in the fit
88  // <src>endVal</src> - upper boundary for independent values to be included in the fit
89  // <src>fitGauss</src> - fit Gaussian component
90  // <src>fitPoly</src> - fit polynomial
91  // <src>nPoly</src> - order of polynomial to be fitted
92  // <src>msg</src> - message back to the calling routine
94  const casacore::Float startVal, const casacore::Float endVal, const casacore::Bool fitGauss, const casacore::Bool fitPoly, const casacore::uInt nPoly, casacore::String &msg);
95 
96  // get the status of the last fit
98 
99  // get Chi Squared of the last fit
101 
102  // get number of iterations for the last fit
104 
105  const SpectralList &getList() const {return _fit.getList();};
106 
107  // get all values for the last fit
109 
110  // get the values in the specified data range for the last fit
112 
113  // get all residuals for the last fit
115 
116  // report on the last fit to a stream
117  casacore::String report(casacore::LogIO &os, const casacore::String &xUnit="", const casacore::String &yUnit="", const casacore::String &yPrefixUnit="") const;
118 
119 private:
121 
123 
125 
130 
132 
133  // do all necessary setup
134  void _setUp();
135 
136  // prepare the data which means give all data (independent, dependent, weights)
137  // to the fitting class
139  const casacore::Int &startIndex, const casacore::Int &endIndex, casacore::Vector<casacore::Bool> &maskVals, casacore::Vector<casacore::Double> &weightVals) const;
140 
141  // prepare the components that shall be fitted; this includes the setting
142  // of reasonable initial parameters
145 
146  // report on a list of spectral elements to a stream
147  casacore::String _report(casacore::LogIO &os, const SpectralList &list, const casacore::String &xUnit="", const casacore::String &yUnit="", const casacore::String &yPrefixUnit="") const;
148 };
149 }
150 
151 #endif
const SpectralFitter::FitStatus & getStatus()
get the status of the last fit
casacore::Vector< casacore::Double > getResidual() const
get all residuals for the last fit
int Int
Definition: aipstype.h:50
ProfileFit1D< casacore::Double > _fit
casacore::String _resultMsg
SpectralFitter()
default constructor
casacore::Vector< T > getResidual(casacore::Int which=-1, casacore::Bool fit=true) const
ostream-like interface to creating log messages.
Definition: LogIO.h:167
casacore::Double _startVal
casacore::Double getChiSquared() const
Get Chi Squared of fit.
Definition: ProfileFit1D.h:197
casacore::Bool _prepareData(const casacore::Vector< casacore::Float > &xVals, const casacore::Vector< casacore::Float > &eVals, const casacore::Int &startIndex, const casacore::Int &endIndex, casacore::Vector< casacore::Bool > &maskVals, casacore::Vector< casacore::Double > &weightVals) const
prepare the data which means give all data (independent, dependent, weights) to the fitting class ...
casacore::String report(casacore::LogIO &os, const casacore::String &xUnit="", const casacore::String &yUnit="", const casacore::String &yPrefixUnit="") const
report on the last fit to a stream
casacore::uInt _startIndex
casacore::Vector< casacore::Double > getFit() const
get all values for the last fit
virtual ~SpectralFitter()
destructor
double Double
Definition: aipstype.h:55
casacore::uInt _endIndex
casacore::Vector< T > getFit(casacore::Int which=-1) const
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
float Float
Definition: aipstype.h:54
casacore::Bool _prepareElems(const casacore::Bool fitGauss, const casacore::Bool fitPoly, const casacore::uInt nPoly, casacore::Vector< casacore::Double > &xVals, casacore::Vector< casacore::Double > &yVals, SpectralList &list)
prepare the components that shall be fitted; this includes the setting of reasonable initial paramete...
casacore::Double getNumberIterations() const
get number of iterations for the last fit
virtual casacore::Bool fit(const casacore::Vector< casacore::Float > &spcVals, const casacore::Vector< casacore::Float > &yVals, const casacore::Vector< casacore::Float > &eVals, const casacore::Float startVal, const casacore::Float endVal, const casacore::Bool fitGauss, const casacore::Bool fitPoly, const casacore::uInt nPoly, casacore::String &msg)
Parameters: spcVals - independent values yVals - dependent values eVals - error values startVal - low...
casacore::String _report(casacore::LogIO &os, const SpectralList &list, const casacore::String &xUnit="", const casacore::String &yUnit="", const casacore::String &yPrefixUnit="") const
report on a list of spectral elements to a stream
casacore::Double getNumberIterations() const
Get number of iterations for last fit.
Definition: ProfileFit1D.h:200
A set of SpectralElements.
Definition: SpectralList.h:85
FitStatus
Does a simple fit to data in vectors. It is possible to specify weights (or errors) for each element...
casacore::Double getChiSquared() const
get Chi Squared of the last fit
casacore::LogIO * _log
SpectralFitter::FitStatus _fitStatus
String: the storage and methods of handling collections of characters.
Definition: String.h:223
const SpectralList & getList(casacore::Bool fit=true) const
Recover the list of elements.
void _setUp()
do all necessary setup
unsigned int uInt
Definition: aipstype.h:51
const SpectralList & getList() const
casacore::Double _endVal
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42