source: trunk/src/SDFitTable.cc@ 474

Last change on this file since 474 was 468, checked in by mar637, 20 years ago

a class to transfer fit parameters.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 4.4 KB
Line 
1//#---------------------------------------------------------------------------
2//# SDFitTable.h: A wrapper for fit parameters
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:
30//#---------------------------------------------------------------------------
31
32#include "MathUtils.h"
33#include "SDFitTable.h"
34
35using namespace casa;
36using namespace asap;
37
38SDFitTable::SDFitTable(const SDFitTable& other) {
39 if (other.length() > 0) {
40 this->nfits_ = other.nfits_;
41 this->pars_ = other.pars_;
42 this->mask_ = other.mask_;
43 this->funcs_ = other.funcs_;
44 this->comps_ = other.comps_;
45 this->frameinfo_ = other.frameinfo_;
46 }
47}
48
49
50void SDFitTable::addSTLFit(const std::vector<double>& p,
51 const std::vector<bool>& m,
52 const std::vector<std::string>& f,
53 const std::vector<Int>& c,
54 const std::vector<std::string>& fi)
55{
56 pars_.push_back(p);
57 mask_.push_back(m);
58 funcs_.push_back(f);
59 comps_.push_back(c);
60 frameinfo_.push_back(fi);
61 nfits_++;
62}
63
64void SDFitTable::addFit(const Vector<Double>& p,
65 const Vector<Bool>& m,
66 const Vector<String>& f,
67 const Vector<Int>& c,
68 const Vector<String>& fi)
69{
70 std::vector<double> p1;
71 p.tovector(p1);
72 pars_.push_back(p1);
73 std::vector<bool> m1;
74 m.tovector(m1);
75 mask_.push_back(m1);
76 std::vector<string> f1;
77 f1 = mathutil::tovectorstring(f);
78 funcs_.push_back(f1);
79 std::vector<int> c1;
80 c.tovector(c1);
81 comps_.push_back(c1);
82 std::vector<string> fi1;
83 fi1 = mathutil::tovectorstring(fi);
84 frameinfo_.push_back(fi1);
85 nfits_++;
86}
87
88std::vector<double> SDFitTable::getSTLParameters(int which) const
89{
90 if (which >= nfits_)
91 return std::vector<double>();
92 return pars_[which];
93}
94
95Vector<Double> SDFitTable::getParameters(uInt which) const{
96 if (int(which) >= nfits_)
97 return Vector<Double>(std::vector<double>());
98 return Vector<Double>(pars_[which]);
99}
100
101std::vector<bool> SDFitTable::getSTLParameterMask(int which) const
102{
103 if (which >= nfits_)
104 return std::vector<bool>();
105 return mask_[which];
106}
107
108Vector<Bool> SDFitTable::getParameterMask(uInt which) const
109{
110 if (which >= nfits_)
111 return Vector<Bool>(std::vector<bool>());
112 return Vector<Bool>(mask_[which]);
113}
114
115std::vector<std::string> SDFitTable::getSTLFunctions(int which) const
116{
117 if (which >= nfits_)
118 return std::vector<std::string>();
119 return funcs_[which];
120}
121
122Vector<String> SDFitTable::getFunctions(uInt which) const
123{
124 if (int(which) >= nfits_)
125 return mathutil::toVectorString(std::vector<std::string>());
126 return mathutil::toVectorString(funcs_[which]);
127}
128
129std::vector<int> SDFitTable::getSTLComponents(int which) const
130{
131 if (which >= nfits_)
132 return std::vector<int>();
133 return comps_[which];
134}
135
136Vector<Int> SDFitTable::getComponents(uInt which) const
137{
138 if (int(which) >= nfits_)
139 return Vector<Int>(std::vector<int>());
140 return Vector<Int>(comps_[which]);
141}
142
143std::vector<std::string> SDFitTable::getSTLFrameInfo(int which) const
144{
145 if (which >= nfits_)
146 return std::vector<std::string>();
147 return frameinfo_[which];
148}
149
150Vector<String> SDFitTable::getFrameInfo(uInt which) const
151{
152 if (int(which) >= nfits_)
153 return mathutil::toVectorString(std::vector<std::string>());
154 return mathutil::toVectorString(frameinfo_[which]);
155}
156
Note: See TracBrowser for help on using the repository browser.