source: branches/parallel/src/STMathWrapper.h@ 2203

Last change on this file since 2203 was 1907, checked in by WataruKawasaki, 14 years ago

New Development: No

JIRA Issue: Yes CAS-1937,CAS-2373

Ready to Release: Yes

Interface Changes: Yes

What Interface Changed: A new parameter 'batch' was added to

sd.scantable.poly_baseline(), while
'uselin' was removed.

Test Programs:

Put in Release Notes: Yes

Module(s): sdbaseline

Description: A faster version of sd.scantable.poly_baseline().


  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.5 KB
Line 
1//
2// C++ Interface: STMathWrapper
3//
4// Description:
5//
6//
7// Author: Malte Marquarding <Malte.Marquarding@csiro.au>, (C) 2006
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12#ifndef ASAPSTMATHWRAPPER_H
13#define ASAPSTMATHWRAPPER_H
14
15#include <vector>
16#include <string>
17
18#include <casa/Utilities/CountedPtr.h>
19
20#include "STMath.h"
21#include "Scantable.h"
22#include "ScantableWrapper.h"
23
24namespace asap {
25
26/**
27Wrapper class to handle ScantableWrapper
28
29@author Malte Marquarding
30*/
31class STMathWrapper : public STMath {
32public:
33 STMathWrapper() {;}
34 explicit STMathWrapper(bool insitu) : STMath(insitu) {;}
35
36 virtual ~STMathWrapper() {;}
37
38 ScantableWrapper
39 average( const std::vector<ScantableWrapper>& in,
40 const std::vector<bool>& mask,
41 const std::string& weight,
42 const std::string& avmode )
43 {
44 std::vector<casa::CountedPtr<Scantable> > sts;
45 for (unsigned int i=0; i<in.size(); ++i) sts.push_back(in[i].getCP());
46 return ScantableWrapper(STMath::average(sts, mask, weight, avmode));
47 }
48
49 ScantableWrapper
50 averageChannel( const ScantableWrapper& in,
51 const std::string& mode = "MEDIAN",
52 const std::string& avmode = "NONE")
53 {
54 return ScantableWrapper(STMath::averageChannel(in.getCP(), mode, avmode));
55 }
56
57 ScantableWrapper
58 averagePolarisations( const ScantableWrapper& in,
59 const std::vector<bool>& mask,
60 const std::string& weight)
61 { return ScantableWrapper(STMath::averagePolarisations(in.getCP(),mask, weight));}
62
63 ScantableWrapper
64 averageBeams( const ScantableWrapper& in,
65 const std::vector<bool>& mask,
66 const std::string& weight)
67
68 { return ScantableWrapper(STMath::averageBeams(in.getCP(),mask, weight));}
69
70 ScantableWrapper
71 unaryOperate( const ScantableWrapper& in, float val,
72 const std::string& mode, bool tsys=false )
73 { return ScantableWrapper(STMath::unaryOperate(in.getCP(), val, mode, tsys)); }
74
75 ScantableWrapper arrayOperate( const ScantableWrapper& in,
76 const std::vector<float> val,
77 const std::string& mode,
78 bool tsys=false )
79 { return ScantableWrapper(STMath::arrayOperateChannel(in.getCP(), val, mode, tsys)); }
80
81 ScantableWrapper array2dOperate( const ScantableWrapper& in,
82 const std::vector< std::vector<float> > val,
83 const std::string& mode, bool tsys=false )
84 { return ScantableWrapper(STMath::array2dOperate(in.getCP(), val, mode, tsys)); }
85
86 ScantableWrapper binaryOperate( const ScantableWrapper& left,
87 const ScantableWrapper& right,
88 const std::string& mode)
89 { return ScantableWrapper( STMath::binaryOperate( left.getCP(), right.getCP(),
90 mode ) ); }
91
92
93 ScantableWrapper autoQuotient( const ScantableWrapper& in,
94 const std::string& mode = "NEAREST",
95 bool preserve = true )
96 { return ScantableWrapper(STMath::autoQuotient(in.getCP(), mode, preserve)); }
97
98 ScantableWrapper quotient( const ScantableWrapper& on,
99 const ScantableWrapper& off,
100 bool preserve = true )
101 { return ScantableWrapper( STMath::quotient( on.getCP(), off.getCP(),
102 preserve ) ); }
103
104 ScantableWrapper dototalpower( const ScantableWrapper& calon,
105 const ScantableWrapper& caloff, casa::Float tcal= 0 )
106 { return ScantableWrapper( STMath::dototalpower( calon.getCP(), caloff.getCP(), tcal ) ); }
107
108 ScantableWrapper dosigref( const ScantableWrapper& sig,
109 const ScantableWrapper& ref,
110 int smoothref = 0, casa::Float tsysv=0.0, casa::Float tau=0.0)
111 { return ScantableWrapper( STMath::dosigref( sig.getCP(), ref.getCP(), smoothref, tsysv, tau ) ); }
112
113 ScantableWrapper donod( const ScantableWrapper& s,
114 const std::vector<int>& scans,
115 int smoothref = 0,
116 casa::Float tsysv=0.0, casa::Float tau=0.0, casa::Float tcal=0.0 )
117 { return ScantableWrapper( STMath::donod( s.getCP(), scans, smoothref, tsysv, tau, tcal ) ); }
118
119 ScantableWrapper dofs( const ScantableWrapper& s,
120 const std::vector<int>& scans,
121 int smoothref = 0,
122 casa::Float tsysv=0.0, casa::Float tau=0.0, casa::Float tcal=0.0 )
123 { return ScantableWrapper( STMath::dofs( s.getCP(), scans, smoothref, tsysv, tau, tcal ) ); }
124
125 ScantableWrapper
126 freqSwitch( const ScantableWrapper& in )
127 { return ScantableWrapper(STMath::freqSwitch(in.getCP())); }
128
129 std::vector<float> statistic(const ScantableWrapper& in,
130 const std::vector<bool>& mask,
131 const std::string& which)
132 { return STMath::statistic(in.getCP(), mask, which); }
133
134 std::vector<float> statisticRow(const ScantableWrapper& in,
135 const std::vector<bool>& mask,
136 const std::string& which,
137 int row)
138 { return STMath::statisticRow(in.getCP(), mask, which, row); }
139
140 std::vector<int> minMaxChan(const ScantableWrapper& in,
141 const std::vector<bool>& mask,
142 const std::string& which)
143 { return STMath::minMaxChan(in.getCP(), mask, which); }
144
145 ScantableWrapper bin( const ScantableWrapper& in, int width=5)
146 { return ScantableWrapper(STMath::bin(in.getCP(), width)); }
147
148 ScantableWrapper
149 resample(const ScantableWrapper& in,
150 const std::string& method, float width)
151 { return ScantableWrapper(STMath::resample(in.getCP(), method, width)); }
152
153 ScantableWrapper
154 smooth(const ScantableWrapper& in, const std::string& kernel, float width,
155 int order=2)
156 { return ScantableWrapper(STMath::smooth(in.getCP(), kernel, width, order)); }
157
158 ScantableWrapper
159 gainElevation(const ScantableWrapper& in,
160 const std::vector<float>& coeff,
161 const std::string& filename,
162 const std::string& method)
163
164 { return
165 ScantableWrapper(STMath::gainElevation(in.getCP(), coeff, filename, method)); }
166
167 ScantableWrapper
168 convertFlux(const ScantableWrapper& in, float d,
169 float etaap, float jyperk)
170 { return ScantableWrapper(STMath::convertFlux(in.getCP(), d, etaap, jyperk)); }
171
172 ScantableWrapper opacity(const ScantableWrapper& in,
173 const std::vector<float>& tau)
174 { return ScantableWrapper(STMath::opacity(in.getCP(), tau)); }
175
176 ScantableWrapper
177 merge(const std::vector<ScantableWrapper >& in)
178
179 {
180 std::vector<casa::CountedPtr<Scantable> > sts;
181 for (unsigned int i=0; i<in.size(); ++i) sts.push_back(in[i].getCP());
182 return ScantableWrapper(STMath::merge(sts)); }
183
184 ScantableWrapper rotateXYPhase( const ScantableWrapper& in, float angle)
185 { return ScantableWrapper(STMath::rotateXYPhase(in.getCP(), angle)); }
186
187 ScantableWrapper rotateLinPolPhase( const ScantableWrapper& in, float angle)
188 { return ScantableWrapper(STMath::rotateLinPolPhase(in.getCP(), angle)); }
189
190 ScantableWrapper invertPhase( const ScantableWrapper& in )
191 { return ScantableWrapper(STMath::invertPhase(in.getCP())); }
192
193 ScantableWrapper swapPolarisations( const ScantableWrapper& in )
194 { return ScantableWrapper(STMath::swapPolarisations(in.getCP())); }
195
196 ScantableWrapper frequencyAlign( const ScantableWrapper& in,
197 const std::string& refTime,
198 const std::string& method )
199 { return ScantableWrapper(STMath::frequencyAlign(in.getCP())); }
200
201 ScantableWrapper convertPolarisation( const ScantableWrapper& in,
202 const std::string& newtype )
203 { return ScantableWrapper(STMath::convertPolarisation(in.getCP(),newtype)); }
204
205 ScantableWrapper mxExtract( const ScantableWrapper& in,
206 const std::string& scantype="on" )
207 { return ScantableWrapper(STMath::mxExtract(in.getCP(),scantype)); }
208
209 ScantableWrapper lagFlag( const ScantableWrapper& in,
210 double start, double end,
211 const std::string& mode="frequency" )
212 { return ScantableWrapper(STMath::lagFlag(in.getCP(), start, end,
213 mode)); }
214
215 // test for average spectra with different channel/resolution
216 ScantableWrapper
217 new_average( const std::vector<ScantableWrapper>& in,
218 const bool& compel,
219 const std::vector<bool>& mask,
220 const std::string& weight,
221 const std::string& avmode )
222 {
223 std::vector<casa::CountedPtr<Scantable> > sts;
224 for (unsigned int i=0; i<in.size(); ++i) sts.push_back(in[i].getCP());
225 return ScantableWrapper(STMath::new_average(sts, compel, mask, weight, avmode));
226 }
227
228 // cwcal
229 ScantableWrapper cwcal( const ScantableWrapper &in,
230 const std::string calmode,
231 const std::string antname )
232 {
233 casa::CountedPtr<Scantable> tab = in.getCP() ;
234 casa::String mode( calmode ) ;
235 casa::String name( antname ) ;
236 return ScantableWrapper( STMath::cwcal( tab, mode, name ) ) ;
237 }
238 // almacal
239 ScantableWrapper almacal( const ScantableWrapper &in,
240 const std::string calmode )
241 {
242 casa::CountedPtr<Scantable> tab = in.getCP() ;
243 casa::String mode( calmode ) ;
244 return ScantableWrapper( STMath::almacal( tab, mode ) ) ;
245 }
246};
247
248}
249
250#endif
Note: See TracBrowser for help on using the repository browser.