source: trunk/src/SDMathWrapper.cc@ 245

Last change on this file since 245 was 244, checked in by kil064, 20 years ago

Add arg 'preserve' to quotient method to preserve continuum (or not)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1//#---------------------------------------------------------------------------
2//# SDMathWrapper.cc: Wrapper classes to use CountedPtr
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
33#include "SDMathWrapper.h"
34#include "SDMath.h"
35
36
37using namespace asap;
38using namespace casa;
39
40SDMemTableWrapper SDMathWrapper::quotient(const SDMemTableWrapper& on,
41 const SDMemTableWrapper& off,
42 Bool preserveContinuum)
43{
44 SDMath sdm;
45 return SDMemTableWrapper(sdm.quotient(on.getCP(), off.getCP(), preserveContinuum));
46}
47
48
49SDMemTableWrapper SDMathWrapper::simpleBinaryOperate(const SDMemTableWrapper& left,
50 const SDMemTableWrapper& right,
51 const std::string& op)
52{
53 SDMath sdm;
54 return SDMemTableWrapper(sdm.simpleBinaryOperate(left.getCP(), right.getCP(),
55 String(op)));
56}
57
58
59void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll)
60{
61 SDMemTable* pIn = in.getPtr();
62 const uInt what = 0;
63//
64 SDMath sdm;
65 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(factor),
66 Bool(doAll), what);
67 *pIn = *pOut;
68 delete pOut;
69}
70
71SDMemTableWrapper SDMathWrapper::scale(const SDMemTableWrapper& in,
72 float factor, bool doAll)
73{
74 const CountedPtr<SDMemTable>& pIn = in.getCP();
75 const uInt what = 0;
76 SDMath sdm;
77 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn,
78 Float(factor),
79 Bool(doAll), what));
80}
81
82
83
84void SDMathWrapper::addInSitu(SDMemTableWrapper& in, float offset, bool doAll)
85{
86 SDMemTable* pIn = in.getPtr();
87 const uInt what = 1;
88//
89 SDMath sdm;
90 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(offset),
91 Bool(doAll), what);
92 *pIn = *pOut;
93 delete pOut;
94}
95
96SDMemTableWrapper SDMathWrapper::add(const SDMemTableWrapper& in,
97 float offset, bool doAll)
98{
99 const CountedPtr<SDMemTable>& pIn = in.getCP();
100 const uInt what = 1;
101 SDMath sdm;
102 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(offset),
103 Bool(doAll), what));
104}
105
106
107void SDMathWrapper::smoothInSitu(SDMemTableWrapper& in,
108 const std::string& kernel, float width,
109 bool doAll)
110{
111 SDMemTable* pIn = in.getPtr();
112 SDMath sdm;
113 SDMemTable* pOut = sdm.smooth(*pIn, String(kernel),
114 Float(width), Bool(doAll));
115 *pIn = *pOut;
116 delete pOut;
117}
118
119
120SDMemTableWrapper SDMathWrapper::smooth (const SDMemTableWrapper& in,
121 const std::string& kernel,
122 float width, bool doAll)
123{
124 const CountedPtr<SDMemTable>& pIn = in.getCP();
125 SDMath sdm;
126 return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel),
127 Float(width), Bool(doAll)));
128}
129
130
131
132void SDMathWrapper::binInSitu(SDMemTableWrapper& in, int width)
133{
134 SDMemTable* pIn = in.getPtr();
135 SDMath sdm;
136 SDMemTable* pOut = sdm.bin (*pIn, Int(width));
137 *pIn = *pOut;
138 delete pOut;
139}
140
141SDMemTableWrapper SDMathWrapper::bin (const SDMemTableWrapper& in,
142 int width)
143{
144 const CountedPtr<SDMemTable>& pIn = in.getCP();
145 SDMath sdm;
146 return CountedPtr<SDMemTable>(sdm.bin(*pIn, Int(width)));
147}
148
149
150void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in,
151 const std::vector<bool>& mask)
152{
153 SDMemTable* pIn = in.getPtr();
154 SDMath sdm;
155 Vector<Bool> tMask(mask);
156 SDMemTable* pOut = sdm.averagePol (*pIn, tMask);
157 *pIn = *pOut;
158 delete pOut;
159}
160
161SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in,
162 const std::vector<bool>& mask)
163
164{
165 const CountedPtr<SDMemTable>& pIn = in.getCP();
166 SDMath sdm;
167 Vector<Bool> tMask(mask);
168 return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, tMask));
169}
170
171
172std::vector<float> SDMathWrapper::statistic(const SDMemTableWrapper& in,
173 const std::vector<bool>& mask,
174 const std::string& which, int row)
175{
176 SDMath sdm;
177 Vector<Bool> tMask(mask);
178 return sdm.statistic(in.getCP(), tMask, String(which), Int(row));
179}
180
181
182void SDMathWrapper::convertFluxInSitu(SDMemTableWrapper& in,
183 float area, float eta, bool doAll)
184{
185 SDMemTable* pIn = in.getPtr();
186 SDMath sdm;
187 SDMemTable* pOut = sdm.convertFlux (*pIn, Float(area), Float(eta), Bool(doAll));
188 *pIn = *pOut;
189 delete pOut;
190}
191
192
193SDMemTableWrapper SDMathWrapper::convertFlux(const SDMemTableWrapper& in,
194 float area, float eta, bool doAll)
195{
196 const CountedPtr<SDMemTable>& pIn = in.getCP();
197 SDMath sdm;
198 return CountedPtr<SDMemTable>(sdm.convertFlux(*pIn, Float(area), Float(eta), Bool(doAll)));
199}
200
201
202void SDMathWrapper::gainElevationInSitu(SDMemTableWrapper& in,
203 const std::vector<float>& coeffs,
204 const string& fileName,
205 const string& method, bool doAll)
206{
207 SDMemTable* pIn = in.getPtr();
208 Vector<Float> tCoeffs(coeffs);
209 SDMath sdm;
210 SDMemTable* pOut = sdm.gainElevation(*pIn, tCoeffs, String(fileName),
211 String(method), Bool(doAll));
212 *pIn = *pOut;
213 delete pOut;
214}
215
216
217SDMemTableWrapper SDMathWrapper::gainElevation(const SDMemTableWrapper& in,
218 const std::vector<float>& coeffs,
219 const string& fileName,
220 const string& method, bool doAll)
221{
222 const CountedPtr<SDMemTable>& pIn = in.getCP();
223 Vector<Float> tCoeffs(coeffs);
224 SDMath sdm;
225 return CountedPtr<SDMemTable>(sdm.gainElevation(*pIn, tCoeffs, String(fileName),
226 String(method), Bool(doAll)));
227}
228
229void SDMathWrapper::opacityInSitu(SDMemTableWrapper& in, float tau, bool doAll)
230{
231 SDMemTable* pIn = in.getPtr();
232 SDMath sdm;
233 SDMemTable* pOut = sdm.opacity(*pIn, Float(tau), Bool(doAll));
234 *pIn = *pOut;
235 delete pOut;
236}
237
238
239SDMemTableWrapper SDMathWrapper::opacity(const SDMemTableWrapper& in,
240 float tau, bool doAll)
241{
242 const CountedPtr<SDMemTable>& pIn = in.getCP();
243 SDMath sdm;
244 return CountedPtr<SDMemTable>(sdm.opacity(*pIn, Float(tau), Bool(doAll)));
245}
246
Note: See TracBrowser for help on using the repository browser.