source: branches/Release-1-fixes/src/SDMathWrapper.cc@ 3037

Last change on this file since 3037 was 502, checked in by kil064, 20 years ago

add function rotateLinPolPhase

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.9 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 Bool doTSys = True;
46 return SDMemTableWrapper(sdm.binaryOperate(on.getCP(), off.getCP(),
47 String("QUOTIENT"), preserveContinuum, doTSys));
48}
49
50
51SDMemTableWrapper SDMathWrapper::binaryOperate(const SDMemTableWrapper& left,
52 const SDMemTableWrapper& right,
53 const std::string& op, bool doTSys)
54{
55 SDMath sdm;
56 return SDMemTableWrapper(sdm.binaryOperate(left.getCP(), right.getCP(),
57 String(op), False, Bool(doTSys)));
58}
59
60
61void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll, bool doTSys)
62{
63 SDMemTable* pIn = in.getPtr();
64 const uInt what = 0;
65//
66 SDMath sdm;
67 SDMemTable* pOut = sdm.unaryOperate (*pIn, Float(factor),
68 Bool(doAll), what, Bool(doTSys));
69 *pIn = *pOut;
70 delete pOut;
71}
72
73SDMemTableWrapper SDMathWrapper::scale(const SDMemTableWrapper& in,
74 float factor, bool doAll, bool doTSys)
75{
76 const CountedPtr<SDMemTable>& pIn = in.getCP();
77 const uInt what = 0;
78 SDMath sdm;
79 return CountedPtr<SDMemTable>(sdm.unaryOperate(*pIn, Float(factor), Bool(doAll),
80 what, Bool (doTSys)));
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 Bool doTSys = False;
91 SDMemTable* pOut = sdm.unaryOperate (*pIn, Float(offset),
92 Bool(doAll), what, doTSys);
93 *pIn = *pOut;
94 delete pOut;
95}
96
97SDMemTableWrapper SDMathWrapper::add(const SDMemTableWrapper& in,
98 float offset, bool doAll)
99{
100 const CountedPtr<SDMemTable>& pIn = in.getCP();
101 const uInt what = 1;
102 SDMath sdm;
103 Bool doTSys = False;
104 return CountedPtr<SDMemTable>(sdm.unaryOperate(*pIn, Float(offset),
105 Bool(doAll), what, doTSys));
106}
107
108
109void SDMathWrapper::smoothInSitu(SDMemTableWrapper& in,
110 const std::string& kernel, float width,
111 bool doAll)
112{
113 SDMemTable* pIn = in.getPtr();
114 SDMath sdm;
115 SDMemTable* pOut = sdm.smooth(*pIn, String(kernel),
116 Float(width), Bool(doAll));
117 *pIn = *pOut;
118 delete pOut;
119}
120
121
122SDMemTableWrapper SDMathWrapper::smooth (const SDMemTableWrapper& in,
123 const std::string& kernel,
124 float width, bool doAll)
125{
126 const CountedPtr<SDMemTable>& pIn = in.getCP();
127 SDMath sdm;
128 return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel),
129 Float(width), Bool(doAll)));
130}
131
132
133
134void SDMathWrapper::binInSitu(SDMemTableWrapper& in, int width)
135{
136 SDMemTable* pIn = in.getPtr();
137 SDMath sdm;
138 SDMemTable* pOut = sdm.bin (*pIn, Int(width));
139 *pIn = *pOut;
140 delete pOut;
141}
142
143SDMemTableWrapper SDMathWrapper::bin (const SDMemTableWrapper& in,
144 int width)
145{
146 const CountedPtr<SDMemTable>& pIn = in.getCP();
147 SDMath sdm;
148 return CountedPtr<SDMemTable>(sdm.bin(*pIn, Int(width)));
149}
150
151void SDMathWrapper::resampleInSitu(SDMemTableWrapper& in, const std::string& method,
152 float width)
153{
154 SDMemTable* pIn = in.getPtr();
155 SDMath sdm;
156 SDMemTable* pOut = sdm.resample(*pIn, String(method), Float(width));
157 *pIn = *pOut;
158 delete pOut;
159}
160
161SDMemTableWrapper SDMathWrapper::resample (const SDMemTableWrapper& in,
162 const std::string& method, float width)
163{
164 const CountedPtr<SDMemTable>& pIn = in.getCP();
165 SDMath sdm;
166 return CountedPtr<SDMemTable>(sdm.resample(*pIn, String(method), Float(width)));
167}
168
169
170void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in,
171 const std::vector<bool>& mask,
172 const std::string& weightStr)
173{
174 SDMemTable* pIn = in.getPtr();
175 SDMath sdm;
176 Vector<Bool> tMask(mask);
177 SDMemTable* pOut = sdm.averagePol (*pIn, tMask, String(weightStr));
178 *pIn = *pOut;
179 delete pOut;
180}
181
182SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in,
183 const std::vector<bool>& mask,
184 const std::string& weightStr)
185{
186 const CountedPtr<SDMemTable>& pIn = in.getCP();
187 SDMath sdm;
188 Vector<Bool> tMask(mask);
189 return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, tMask, String(weightStr)));
190}
191
192
193std::vector<float> SDMathWrapper::statistic(const SDMemTableWrapper& in,
194 const std::vector<bool>& mask,
195 const std::string& which, int row)
196{
197 SDMath sdm;
198 Vector<Bool> tMask(mask);
199 return sdm.statistic(in.getCP(), tMask, String(which), Int(row));
200}
201
202
203void SDMathWrapper::convertFluxInSitu(SDMemTableWrapper& in, float D,
204 float eta, float JyPerK, bool doAll)
205{
206 SDMemTable* pIn = in.getPtr();
207 SDMath sdm;
208 SDMemTable* pOut = sdm.convertFlux (*pIn, Float(D), Float(eta), Float(JyPerK), Bool(doAll));
209 *pIn = *pOut;
210 delete pOut;
211}
212
213
214SDMemTableWrapper SDMathWrapper::convertFlux(const SDMemTableWrapper& in, float D, float eta,
215 float JyPerK, bool doAll)
216{
217 const CountedPtr<SDMemTable>& pIn = in.getCP();
218 SDMath sdm;
219 return CountedPtr<SDMemTable>(sdm.convertFlux(*pIn, Float(D), Float(eta), Float(JyPerK), Bool(doAll)));
220}
221
222
223void SDMathWrapper::gainElevationInSitu(SDMemTableWrapper& in,
224 const std::vector<float>& coeffs,
225 const string& fileName,
226 const string& method, bool doAll)
227{
228 SDMemTable* pIn = in.getPtr();
229 Vector<Float> tCoeffs(coeffs);
230 SDMath sdm;
231 SDMemTable* pOut = sdm.gainElevation(*pIn, tCoeffs, String(fileName),
232 String(method), Bool(doAll));
233 *pIn = *pOut;
234 delete pOut;
235}
236
237
238SDMemTableWrapper SDMathWrapper::gainElevation(const SDMemTableWrapper& in,
239 const std::vector<float>& coeffs,
240 const string& fileName,
241 const string& method, bool doAll)
242{
243 const CountedPtr<SDMemTable>& pIn = in.getCP();
244 Vector<Float> tCoeffs(coeffs);
245 SDMath sdm;
246 return CountedPtr<SDMemTable>(sdm.gainElevation(*pIn, tCoeffs, String(fileName),
247 String(method), Bool(doAll)));
248}
249
250void SDMathWrapper::frequencyAlignmentInSitu (SDMemTableWrapper& in, const std::string& refTime,
251 const std::string& method, bool perFreqID)
252{
253 SDMemTable* pIn = in.getPtr();
254 SDMath sdm;
255 SDMemTable* pOut = sdm.frequencyAlignment(*pIn, String(refTime), String(method),
256 Bool(perFreqID));
257 *pIn = *pOut;
258 delete pOut;
259}
260
261
262SDMemTableWrapper SDMathWrapper::frequencyAlignment (const SDMemTableWrapper& in,
263 const std::string& refTime,
264 const std::string& method,
265 bool perFreqID)
266{
267 const CountedPtr<SDMemTable>& pIn = in.getCP();
268 SDMath sdm;
269 return CountedPtr<SDMemTable>(sdm.frequencyAlignment(*pIn, String(refTime),
270 String(method), Bool(perFreqID)));
271}
272
273void SDMathWrapper::rotateXYPhaseInSitu(SDMemTableWrapper& in, float angle, bool doAll)
274{
275 SDMemTable* pIn = in.getPtr();
276 SDMath sdm;
277 sdm.rotateXYPhase(*pIn, Float(angle), Bool(doAll));
278}
279
280
281void SDMathWrapper::rotateLinPolPhaseInSitu(SDMemTableWrapper& in, float angle, bool doAll)
282{
283 SDMemTable* pIn = in.getPtr();
284 SDMath sdm;
285 sdm.rotateLinPolPhase(*pIn, Float(angle), Bool(doAll));
286}
287
288
289
290
291void SDMathWrapper::opacityInSitu(SDMemTableWrapper& in, float tau, bool doAll)
292{
293 SDMemTable* pIn = in.getPtr();
294 SDMath sdm;
295 SDMemTable* pOut = sdm.opacity(*pIn, Float(tau), Bool(doAll));
296 *pIn = *pOut;
297 delete pOut;
298}
299
300
301SDMemTableWrapper SDMathWrapper::opacity(const SDMemTableWrapper& in,
302 float tau, bool doAll)
303{
304 const CountedPtr<SDMemTable>& pIn = in.getCP();
305 SDMath sdm;
306 return CountedPtr<SDMemTable>(sdm.opacity(*pIn, Float(tau), Bool(doAll)));
307}
308
Note: See TracBrowser for help on using the repository browser.