source: trunk/src/SDMathWrapper.cc@ 225

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

add functions 'convertFluxInSitu' and 'convertFlux'

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 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{
43 SDMath sdm;
44 return SDMemTableWrapper(sdm.quotient(on.getCP(), off.getCP()));
45}
46
47
48void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll)
49{
50 SDMemTable* pIn = in.getPtr();
51 const uInt what = 0;
52//
53 SDMath sdm;
54 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(factor),
55 Bool(doAll), what);
56 *pIn = *pOut;
57 delete pOut;
58}
59
60SDMemTableWrapper SDMathWrapper::scale(const SDMemTableWrapper& in,
61 float factor, bool doAll)
62{
63 const CountedPtr<SDMemTable>& pIn = in.getCP();
64 const uInt what = 0;
65 SDMath sdm;
66 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn,
67 Float(factor),
68 Bool(doAll), what));
69}
70
71
72
73void SDMathWrapper::addInSitu(SDMemTableWrapper& in, float offset, bool doAll)
74{
75 SDMemTable* pIn = in.getPtr();
76 const uInt what = 1;
77//
78 SDMath sdm;
79 SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(offset),
80 Bool(doAll), what);
81 *pIn = *pOut;
82 delete pOut;
83}
84
85SDMemTableWrapper SDMathWrapper::add(const SDMemTableWrapper& in,
86 float offset, bool doAll)
87{
88 const CountedPtr<SDMemTable>& pIn = in.getCP();
89 const uInt what = 1;
90 SDMath sdm;
91 return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(offset),
92 Bool(doAll), what));
93}
94
95
96void SDMathWrapper::smoothInSitu(SDMemTableWrapper& in,
97 const std::string& kernel, float width,
98 bool doAll)
99{
100 SDMemTable* pIn = in.getPtr();
101 SDMath sdm;
102 SDMemTable* pOut = sdm.smooth(*pIn, String(kernel),
103 Float(width), Bool(doAll));
104 *pIn = *pOut;
105 delete pOut;
106}
107
108
109SDMemTableWrapper SDMathWrapper::smooth (const SDMemTableWrapper& in,
110 const std::string& kernel,
111 float width, bool doAll)
112{
113 const CountedPtr<SDMemTable>& pIn = in.getCP();
114 SDMath sdm;
115 return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel),
116 Float(width), Bool(doAll)));
117}
118
119
120
121void SDMathWrapper::binInSitu(SDMemTableWrapper& in, int width)
122{
123 SDMemTable* pIn = in.getPtr();
124 SDMath sdm;
125 SDMemTable* pOut = sdm.bin (*pIn, Int(width));
126 *pIn = *pOut;
127 delete pOut;
128}
129
130SDMemTableWrapper SDMathWrapper::bin (const SDMemTableWrapper& in,
131 int width)
132{
133 const CountedPtr<SDMemTable>& pIn = in.getCP();
134 SDMath sdm;
135 return CountedPtr<SDMemTable>(sdm.bin(*pIn, Int(width)));
136}
137
138
139void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in,
140 const std::vector<bool>& mask)
141{
142 SDMemTable* pIn = in.getPtr();
143 SDMath sdm;
144 SDMemTable* pOut = sdm.averagePol (*pIn, mask);
145 *pIn = *pOut;
146 delete pOut;
147}
148
149SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in,
150 const std::vector<bool>& mask)
151
152{
153 const CountedPtr<SDMemTable>& pIn = in.getCP();
154 SDMath sdm;
155 return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, mask));
156}
157
158
159std::vector<float> SDMathWrapper::statistic(const SDMemTableWrapper& in,
160 const std::vector<bool>& mask,
161 const std::string& which)
162{
163 SDMath sdm;
164 return sdm.statistic(in.getCP(), mask, which);
165}
166
167
168void SDMathWrapper::convertFluxInSitu(SDMemTableWrapper& in,
169 float area, float eta, bool doAll)
170{
171 SDMemTable* pIn = in.getPtr();
172 SDMath sdm;
173 SDMemTable* pOut = sdm.convertFlux (*pIn, Float(area), Float(eta), Bool(doAll));
174 *pIn = *pOut;
175 delete pOut;
176}
177
178
179SDMemTableWrapper SDMathWrapper::convertFlux(const SDMemTableWrapper& in,
180 float area, float eta, bool doAll)
181{
182 const CountedPtr<SDMemTable>& pIn = in.getCP();
183 SDMath sdm;
184 return CountedPtr<SDMemTable>(sdm.convertFlux(*pIn, Float(area), Float(eta), Bool(doAll)));
185}
186
Note: See TracBrowser for help on using the repository browser.