source: trunk/src/SDMathWrapper.cc@ 272

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

add reference time arg. to function 'VelocityAlignment'

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