source: branches/alma/src/STMath.h@ 1556

Last change on this file since 1556 was 1516, checked in by Kana Sugimoto, 16 years ago

New Development: No

JIRA Issue: Yes (CAS-1079)

Ready to Release: Yes

Interface Changes: Yes

What Interface Changed: Changed names of functions

  1. (NEW) std::vector<int> asap::python::stmath::_minmaxchan (OLD) std::vector<int> asap::python::stmath::_minmaxpos @python_STMath.cpp
  2. (NEW) std::vector<int> STMathWrapper::minMaxChan (OLD) std::vector<int> STMathWrapper::minMaxPos @STMathWrapper.h
  3. (NEW) std::vector<int> STMath::minMaxChan (OLD) std::vector<int> STMath::minMaxPos @STMath.h & .cpp

Test Programs:

Run scantable.stats() with the parameter stat='min_abc' or 'max_abc',
and you(ll get min/max value with its position.
Notice that parameter names to select in scantable.stats() are also changed.

Put in Release Notes: No

Module(s): scantable.stats()

Description:

The names of functions are changed from rev. 1514.

These modifications are to return min/max value with its
position (channel/frequency/velocity) by running scantable.stats().

Diagram:
scantable.stats() ->asap::python::stmath::_minmaxchan
-> STMathWrapper::minMaxChan -> STMath::minMaxChan() -> mathutil::minMaxPos()
-> casa::minMax (@casacore/casa/casa/Arrays/MaskArrMath.tcc)


  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.9 KB
Line 
1//
2// C++ Interface: STMath
3//
4// Description:
5//
6//
7// Author: Malte Marquarding <asap@atnf.csiro.au>, (C) 2006
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
12#ifndef ASAPSTMATH_H
13#define ASAPSTMATH_H
14
15#include <string>
16#include <map>
17
18#include <casa/aips.h>
19#include <casa/Utilities/CountedPtr.h>
20#include <casa/BasicSL/String.h>
21#include <casa/Arrays/Vector.h>
22#include <scimath/Mathematics/InterpolateArray1D.h>
23
24#include "Scantable.h"
25#include "STDefs.h"
26#include "STPol.h"
27#include "Logger.h"
28
29namespace asap {
30
31/**
32 * Mathmatical operations on Scantable objects
33 * @author Malte Marquarding
34*/
35class STMath : private Logger {
36public:
37 // typedef for long method name
38 typedef casa::InterpolateArray1D<casa::Double,
39 casa::Float>::InterpolationMethod imethod;
40
41 // typedef for std::map
42 typedef std::map<std::string, imethod> imap;
43
44/**
45 * whether to operate on the given Scantable or return a new one
46 * @param insitu the toggle for this behaviour
47 */
48 explicit STMath(bool insitu=true);
49
50 virtual ~STMath();
51
52 /**
53 * get the currnt @attr inistu_ state
54 */
55 bool insitu() const { return insitu_;};
56
57 /**
58 * set the currnt @attr inistu state
59 * @param b the new state
60 */
61 void setInsitu(bool b) { insitu_ = b; };
62
63
64 /**
65 * average a vector of Scantables
66 * @param in the vector of Scantables to average
67 * @param an optional mask to apply on specific weights
68 * @param weight weighting scheme
69 * @param avmode the mode ov averaging. Per "SCAN" or "ALL".
70 * @return a casa::CountedPtr<Scantable> which either holds a new Scantable
71 * or returns the imput pointer.
72 */
73 casa::CountedPtr<Scantable>
74 average( const std::vector<casa::CountedPtr<Scantable> >& in,
75 const std::vector<bool>& mask = std::vector<bool>(),
76 const std::string& weight = "NONE",
77 const std::string& avmode = "SCAN");
78
79 /**
80 * median average a vector of Scantables. See also STMath::average
81 * @param in the Scantable to average
82 * @param mode the averaging mode. Currently only "MEDIAN"
83 * @param avmode the mode ov averaging. Per "SCAN" or "ALL".
84 * @return a casa::CountedPtr<Scantable> which either holds a new Scantable
85 * or returns the imput pointer.
86 */
87 casa::CountedPtr<Scantable>
88 averageChannel( const casa::CountedPtr<Scantable> & in,
89 const std::string& mode = "MEDIAN",
90 const std::string& avmode = "SCAN");
91
92 /**
93 * Average polarisations together. really only useful if only linears are
94 * available.
95 * @param in the input Scantable
96 * @param mask an optional mask if weight allows one
97 * @param weight weighting scheme
98 * @return
99 */
100 casa::CountedPtr< Scantable >
101 averagePolarisations( const casa::CountedPtr< Scantable > & in,
102 const std::vector<bool>& mask,
103 const std::string& weight );
104
105 /**
106 * Average beams together.
107 * @param in the input Scantable
108 * @param mask an optional mask if weight allows one
109 * @param weight weighting scheme
110 * @return
111 */
112 casa::CountedPtr< Scantable >
113 averageBeams( const casa::CountedPtr< Scantable > & in,
114 const std::vector<bool>& mask,
115 const std::string& weight );
116
117 casa::CountedPtr<Scantable>
118 unaryOperate( const casa::CountedPtr<Scantable>& in, float val,
119 const std::string& mode, bool tsys=false );
120
121 casa::CountedPtr<Scantable>
122 binaryOperate( const casa::CountedPtr<Scantable>& left,
123 const casa::CountedPtr<Scantable>& right,
124 const std::string& mode);
125
126 casa::CountedPtr<Scantable> autoQuotient(const casa::CountedPtr<Scantable>& in,
127 const std::string& mode = "NEAREST",
128 bool preserve = true);
129
130 casa::CountedPtr<Scantable> quotient( const casa::CountedPtr<Scantable>& on,
131 const casa::CountedPtr<Scantable>& off,
132 bool preserve = true );
133
134 /**
135 * Calibrate total power scans (translated from GBTIDL)
136 * @param calon uncalibrated Scantable with CAL noise signal
137 * @param caloff uncalibrated Scantable with no CAL signal
138 * @param tcal optional scalar Tcal, CAL temperature (K)
139 * @return casa::CountedPtr<Scantable> which holds a calibrated Scantable
140 * (spectrum - average of the two CAL on and off spectra;
141 * tsys - mean Tsys = <caloff>*Tcal/<calon-caloff> + Tcal/2)
142 */
143 casa::CountedPtr<Scantable> dototalpower( const casa::CountedPtr<Scantable>& calon,
144 const casa::CountedPtr<Scantable>& caloff,
145 casa::Float tcal=1.0 );
146
147 /**
148 * Combine signal and reference scans (translated from GBTIDL)
149 * @param sig Scantable which contains signal scans
150 * @param ref Scantable which contains reference scans
151 * @param smoothref optional Boxcar smooth width of the reference scans
152 * default: no smoothing (=1)
153 * @param tsysv optional scalar Tsys value at the zenith, required to
154 * set tau, as well
155 * @param tau optional scalar Tau value
156 * @return casa::CountedPtr<Scantable> which holds combined scans
157 * (spectrum = (sig-ref)/ref * Tsys )
158 */
159 casa::CountedPtr<Scantable> dosigref( const casa::CountedPtr<Scantable>& sig,
160 const casa::CountedPtr<Scantable>& ref,
161 int smoothref=1,
162 casa::Float tsysv=0.0,
163 casa::Float tau=0.0 );
164
165 /**
166 * Calibrate GBT Nod scan pairs (translated from GBTIDL)
167 * @param s Scantable which contains Nod scans
168 * @param scans Vector of scan numbers
169 * @param smoothref optional Boxcar smooth width of the reference scans
170 * @param tsysv optional scalar Tsys value at the zenith, required to
171 * set tau, as well
172 * @param tau optional scalar Tau value
173 * @param tcal optional scalar Tcal, CAL temperature (K)
174 * @return casa::CountedPtr<Scantable> which holds calibrated scans
175 */
176 casa::CountedPtr<Scantable> donod( const casa::CountedPtr<Scantable>& s,
177 const std::vector<int>& scans,
178 int smoothref=1,
179 casa::Float tsysv=0.0,
180 casa::Float tau=0.0,
181 casa::Float tcal=0.0 );
182
183 /**
184 * Calibrate frequency switched scans (translated from GBTIDL)
185 * @param s Scantable which contains frequency switched scans
186 * @param scans Vector of scan numbers
187 * @param smoothref optional Boxcar smooth width of the reference scans
188 * @param tsysv optional scalar Tsys value at the zenith, required to
189 * set tau, as well
190 * @param tau optional scalar Tau value
191 * @param tcal optional scalar Tcal, CAL temperature (K)
192 * @return casa::CountedPtr<Scantable> which holds calibrated scans
193 */
194 casa::CountedPtr<Scantable> dofs( const casa::CountedPtr<Scantable>& s,
195 const std::vector<int>& scans,
196 int smoothref=1,
197 casa::Float tsysv=0.0,
198 casa::Float tau=0.0,
199 casa::Float tcal=0.0 );
200
201
202 casa::CountedPtr<Scantable>
203 freqSwitch( const casa::CountedPtr<Scantable>& in );
204
205 std::vector<float> statistic(const casa::CountedPtr<Scantable>& in,
206 const std::vector<bool>& mask,
207 const std::string& which);
208
209 std::vector< int > minMaxChan(const casa::CountedPtr<Scantable>& in,
210 const std::vector<bool>& mask,
211 const std::string& which);
212
213 casa::CountedPtr<Scantable> bin( const casa::CountedPtr<Scantable>& in,
214 int width=5);
215 casa::CountedPtr<Scantable>
216 resample(const casa::CountedPtr<Scantable>& in,
217 const std::string& method, float width);
218
219 casa::CountedPtr<Scantable>
220 smooth(const casa::CountedPtr<Scantable>& in, const std::string& kernel,
221 float width);
222
223 casa::CountedPtr<Scantable>
224 gainElevation(const casa::CountedPtr<Scantable>& in,
225 const std::vector<float>& coeff,
226 const std::string& fileName,
227 const std::string& method);
228 casa::CountedPtr<Scantable>
229 convertFlux(const casa::CountedPtr<Scantable>& in, float d,
230 float etaap, float jyperk);
231
232 casa::CountedPtr<Scantable> opacity(const casa::CountedPtr<Scantable>& in,
233 float tau);
234
235 casa::CountedPtr<Scantable>
236 merge(const std::vector<casa::CountedPtr<Scantable> >& in);
237
238 casa::CountedPtr<Scantable>
239 invertPhase( const casa::CountedPtr<Scantable>& in);
240
241 casa::CountedPtr<Scantable>
242 rotateXYPhase( const casa::CountedPtr<Scantable>& in, float phase);
243
244 casa::CountedPtr<Scantable>
245 rotateLinPolPhase( const casa::CountedPtr<Scantable>& in, float phase);
246
247 casa::CountedPtr<Scantable>
248 swapPolarisations(const casa::CountedPtr<Scantable>& in);
249
250 casa::CountedPtr<Scantable>
251 frequencyAlign( const casa::CountedPtr<Scantable>& in,
252 const std::string& refTime = "",
253 const std::string& method = "cubic" );
254
255 casa::CountedPtr<Scantable>
256 convertPolarisation( const casa::CountedPtr<Scantable>& in,
257 const std::string& newtype);
258
259 casa::CountedPtr<Scantable>
260 mxExtract( const casa::CountedPtr<Scantable>& in,
261 const std::string& srctype = "on");
262
263 /**
264 * "hard" flag the data, this flags everything selected in setSelection()
265 * @param frequency the frequency to remove
266 * @param width the number of lags to flag left to the side of the frequency
267 */
268 casa::CountedPtr<Scantable>
269 lagFlag( const casa::CountedPtr<Scantable>& in, double frequency,
270 double width);
271
272 // test for average spectra with different channel/resolution
273 casa::CountedPtr<Scantable>
274 new_average( const std::vector<casa::CountedPtr<Scantable> >& in,
275 const bool& compel,
276 const std::vector<bool>& mask = std::vector<bool>(),
277 const std::string& weight = "NONE",
278 const std::string& avmode = "SCAN" )
279 throw (casa::AipsError) ;
280
281
282private:
283 casa::CountedPtr<Scantable> applyToPol( const casa::CountedPtr<Scantable>& in,
284 STPol::polOperation fptr,
285 casa::Float phase);
286
287 static imethod stringToIMethod(const std::string& in);
288 static WeightType stringToWeight(const std::string& in);
289
290 void scaleByVector(casa::Table& in,
291 const casa::Vector<casa::Float>& factor,
292 bool dotsys);
293
294 void scaleFromAsciiTable(casa::Table& in, const std::string& filename,
295 const std::string& method,
296 const casa::Vector<casa::Float>& xout,
297 bool dotsys);
298
299 void scaleFromTable(casa::Table& in, const casa::Table& table,
300 const std::string& method,
301 const casa::Vector<casa::Float>& xout, bool dotsys);
302
303 void convertBrightnessUnits(casa::CountedPtr<Scantable>& in,
304 bool tokelvin, float cfac);
305
306 casa::CountedPtr< Scantable >
307 smoothOther( const casa::CountedPtr< Scantable >& in,
308 const std::string& kernel,
309 float width );
310
311 casa::CountedPtr< Scantable >
312 getScantable(const casa::CountedPtr< Scantable >& in, bool droprows);
313
314 casa::MaskedArray<casa::Float>
315 maskedArray( const casa::Vector<casa::Float>& s,
316 const casa::Vector<casa::uChar>& f );
317 casa::Vector<casa::uChar>
318 flagsFromMA(const casa::MaskedArray<casa::Float>& ma);
319
320 bool insitu_;
321};
322
323}
324#endif
Note: See TracBrowser for help on using the repository browser.