[91] | 1 | //#---------------------------------------------------------------------------
|
---|
| 2 | //# SDFitter.h: A Fitter class for spectra
|
---|
| 3 | //#---------------------------------------------------------------------------
|
---|
| 4 | //# Copyright (C) 2004
|
---|
| 5 | //# Malte Marquarding, 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:
|
---|
| 30 | //#---------------------------------------------------------------------------
|
---|
| 31 | #ifndef SDFITTER_H
|
---|
| 32 | #define SDFITTER_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 | namespace asap {
|
---|
| 43 |
|
---|
| 44 | class SDFitter {
|
---|
| 45 | public:
|
---|
| 46 | SDFitter();
|
---|
| 47 | virtual ~SDFitter();
|
---|
| 48 | // allowed "gauss" and "poly". ncomp is either numvber of gaussions
|
---|
| 49 | // or order of the polynomial
|
---|
| 50 | bool setExpression(const std::string& expr, int ncomp=1);
|
---|
| 51 | bool setData(std::vector<float> absc, std::vector<float> spec,
|
---|
| 52 | std::vector<bool> mask);
|
---|
| 53 | bool setParameters(std::vector<float> params);
|
---|
| 54 | bool setFixedParameters(std::vector<bool> fixed);
|
---|
| 55 |
|
---|
| 56 | std::vector<float> getResidual() const;
|
---|
| 57 | std::vector<float> getFit() const;
|
---|
| 58 | std::vector<float> getParameters() const;
|
---|
| 59 | std::vector<bool> getFixedParameters() const;
|
---|
| 60 |
|
---|
| 61 | std::vector<float> getEstimate() const;
|
---|
| 62 | std::vector<float> getErrors() const;
|
---|
| 63 | float getChisquared() const;
|
---|
| 64 | void reset();
|
---|
| 65 | bool fit();
|
---|
| 66 | bool computeEstimate();
|
---|
| 67 | //std::vector<float> getEstimate() const;
|
---|
| 68 | private:
|
---|
| 69 | void clear();
|
---|
| 70 | Vector<Float> x_;
|
---|
| 71 | Vector<Float> y_;
|
---|
| 72 | Vector<Bool> m_;
|
---|
| 73 | PtrBlock<Function<Float>* > funcs_;
|
---|
| 74 | CompoundFunction<Float> cfunc_;
|
---|
| 75 | //Bool estimateSet_;
|
---|
| 76 | Float chisquared_;
|
---|
| 77 | Vector<Float> parameters_;
|
---|
| 78 | Vector<Bool> fixedpar_;
|
---|
| 79 |
|
---|
| 80 | Vector<Float> error_;
|
---|
| 81 | Vector<Float> thefit_;
|
---|
| 82 | Vector<Float> residual_;
|
---|
| 83 | Vector<Float> estimate_;
|
---|
| 84 | };
|
---|
| 85 |
|
---|
| 86 | } // namespace
|
---|
| 87 |
|
---|
| 88 | #endif
|
---|