source: trunk/src/SDMathWrapper.cc@ 421

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

add perFreqID arg to function frequencyAlign

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