source: trunk/src/SDMathWrapper.cc @ 227

Last change on this file since 227 was 227, checked in by kil064, 19 years ago

add gain-elevation correction capability

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.1 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,
41                                          const SDMemTableWrapper& off)
42{
[170]43    SDMath sdm;
44    return SDMemTableWrapper(sdm.quotient(on.getCP(), off.getCP()));
[169]45}
46
47
[170]48void SDMathWrapper::scaleInSitu(SDMemTableWrapper& in, float factor, bool doAll)
[169]49{
50  SDMemTable* pIn = in.getPtr();
51  const uInt what = 0;
[170]52//
53  SDMath sdm;
[209]54  SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(factor),
55                                        Bool(doAll), what);
[169]56  *pIn = *pOut;
57   delete pOut;
58}
59
60SDMemTableWrapper SDMathWrapper::scale(const SDMemTableWrapper& in,
[170]61                          float factor, bool doAll)
[169]62{
63  const CountedPtr<SDMemTable>& pIn = in.getCP();
64  const uInt what = 0;
[170]65  SDMath sdm;
[209]66  return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn,
67                                                  Float(factor),
68                                                  Bool(doAll), what));
[169]69}
70
71
72
[170]73void SDMathWrapper::addInSitu(SDMemTableWrapper& in, float offset, bool doAll)
[169]74{
75  SDMemTable* pIn = in.getPtr();
76  const uInt what = 1;
[170]77//
78  SDMath sdm;
[209]79  SDMemTable* pOut = sdm.simpleOperate (*pIn, Float(offset),
80                                        Bool(doAll), what);
[169]81  *pIn = *pOut;
82   delete pOut;
83}
84
85SDMemTableWrapper SDMathWrapper::add(const SDMemTableWrapper& in,
[170]86                                     float offset, bool doAll)
[169]87{
88  const CountedPtr<SDMemTable>& pIn = in.getCP();
89  const uInt what = 1;
[170]90  SDMath sdm;
[209]91  return CountedPtr<SDMemTable>(sdm.simpleOperate(*pIn, Float(offset),
92                                                  Bool(doAll), what));
[169]93}
94
[178]95
[209]96void SDMathWrapper::smoothInSitu(SDMemTableWrapper& in,
97                                 const std::string& kernel, float width,
98                                 bool doAll)
[171]99{
100  SDMemTable* pIn = in.getPtr();
101  SDMath sdm;
[209]102  SDMemTable* pOut = sdm.smooth(*pIn, String(kernel),
103                                Float(width), Bool(doAll));
[171]104  *pIn = *pOut;
105   delete pOut;
106}
[169]107
[178]108
[209]109SDMemTableWrapper SDMathWrapper::smooth (const SDMemTableWrapper& in,
110                                         const std::string& kernel,
[178]111                                         float width, bool doAll)
[169]112{
[171]113  const CountedPtr<SDMemTable>& pIn = in.getCP();
[170]114  SDMath sdm;
[209]115  return CountedPtr<SDMemTable>(sdm.smooth(*pIn, String(kernel),
116                                           Float(width), Bool(doAll)));
[169]117}
118
119
[171]120
[169]121void SDMathWrapper::binInSitu(SDMemTableWrapper& in, int width)
122{
123  SDMemTable* pIn = in.getPtr();
[170]124  SDMath sdm;
125  SDMemTable* pOut = sdm.bin (*pIn, Int(width));
[169]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();
[170]134  SDMath sdm;
135  return CountedPtr<SDMemTable>(sdm.bin(*pIn, Int(width)));
[169]136}
137
138
[209]139void SDMathWrapper::averagePolInSitu(SDMemTableWrapper& in,
140                                     const std::vector<bool>& mask)
[169]141{
142  SDMemTable* pIn = in.getPtr();
[170]143  SDMath sdm;
144  SDMemTable* pOut = sdm.averagePol (*pIn, mask);
[169]145  *pIn = *pOut;
146   delete pOut;
147}
148
[209]149SDMemTableWrapper SDMathWrapper::averagePol (const SDMemTableWrapper& in,
150                                             const std::vector<bool>& mask)
[169]151
152{
153  const CountedPtr<SDMemTable>& pIn = in.getCP();
[170]154  SDMath sdm;
155  return CountedPtr<SDMemTable>(sdm.averagePol(*pIn, mask));
[169]156}
157
158
159std::vector<float> SDMathWrapper::statistic(const SDMemTableWrapper& in,
160                                            const std::vector<bool>& mask,
161                                            const std::string& which)
162{
[170]163  SDMath sdm;
[227]164  return sdm.statistic(in.getCP(), mask, String(which));
[169]165}
[222]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
[227]187
188void SDMathWrapper::gainElevationInSitu(SDMemTableWrapper& in, const string& fileName,
189                                        const string& method, bool doAll)
190{
191  SDMemTable* pIn = in.getPtr();
192  SDMath sdm;
193  SDMemTable* pOut = sdm.gainElevation(*pIn, String(fileName), String(method), Bool(doAll));
194  *pIn = *pOut;
195  delete pOut;
196}
197
198
199SDMemTableWrapper SDMathWrapper::gainElevation(const SDMemTableWrapper& in,
200                                               const string& fileName,
201                                               const string& method, bool doAll)
202{
203  const CountedPtr<SDMemTable>& pIn = in.getCP();
204  SDMath sdm;
205  return CountedPtr<SDMemTable>(sdm.gainElevation(*pIn, String(fileName),
206                                                  String(method), Bool(doAll)));
207}
208
Note: See TracBrowser for help on using the repository browser.