source: branches/Release2.1.2/src/STMath.h@ 2903

Last change on this file since 2903 was 1310, checked in by mar637, 18 years ago

merge from trunk, to get binary operator changes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.8 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 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 mask 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 casa::CountedPtr<Scantable>
135 freqSwitch( const casa::CountedPtr<Scantable>& in );
136
137 std::vector<float> statistic(const casa::CountedPtr<Scantable>& in,
138 const std::vector<bool>& mask,
139 const std::string& which);
140
141 casa::CountedPtr<Scantable> bin( const casa::CountedPtr<Scantable>& in,
142 int width=5);
143 casa::CountedPtr<Scantable>
144 resample(const casa::CountedPtr<Scantable>& in,
145 const std::string& method, float width);
146
147 casa::CountedPtr<Scantable>
148 smooth(const casa::CountedPtr<Scantable>& in, const std::string& kernel,
149 float width);
150
151 casa::CountedPtr<Scantable>
152 gainElevation(const casa::CountedPtr<Scantable>& in,
153 const std::vector<float>& coeff,
154 const std::string& fileName,
155 const std::string& method);
156 casa::CountedPtr<Scantable>
157 convertFlux(const casa::CountedPtr<Scantable>& in, float d,
158 float etaap, float jyperk);
159
160 casa::CountedPtr<Scantable> opacity(const casa::CountedPtr<Scantable>& in,
161 float tau);
162
163 casa::CountedPtr<Scantable>
164 merge(const std::vector<casa::CountedPtr<Scantable> >& in);
165
166 casa::CountedPtr<Scantable>
167 invertPhase( const casa::CountedPtr<Scantable>& in);
168
169 casa::CountedPtr<Scantable>
170 rotateXYPhase( const casa::CountedPtr<Scantable>& in, float phase);
171
172 casa::CountedPtr<Scantable>
173 rotateLinPolPhase( const casa::CountedPtr<Scantable>& in, float phase);
174
175 casa::CountedPtr<Scantable>
176 swapPolarisations(const casa::CountedPtr<Scantable>& in);
177
178 casa::CountedPtr<Scantable>
179 frequencyAlign( const casa::CountedPtr<Scantable>& in,
180 const std::string& refTime = "",
181 const std::string& method = "cubic" );
182
183 casa::CountedPtr<Scantable>
184 convertPolarisation( const casa::CountedPtr<Scantable>& in,
185 const std::string& newtype);
186
187 casa::CountedPtr<Scantable>
188 mxExtract( const casa::CountedPtr<Scantable>& in,
189 const std::string& srctype = "on");
190
191 /**
192 * "hard" flag the data, this flags everything selected in setSelection()
193 * @param frequency the frequency to remove
194 * @param width the number of lags to flag left to the side of the frequency
195 */
196 casa::CountedPtr<Scantable>
197 lagFlag( const casa::CountedPtr<Scantable>& in, double frequency,
198 double width);
199
200private:
201 casa::CountedPtr<Scantable> applyToPol( const casa::CountedPtr<Scantable>& in,
202 STPol::polOperation fptr,
203 casa::Float phase);
204
205 static imethod stringToIMethod(const std::string& in);
206 static WeightType stringToWeight(const std::string& in);
207
208 void scaleByVector(casa::Table& in,
209 const casa::Vector<casa::Float>& factor,
210 bool dotsys);
211
212 void scaleFromAsciiTable(casa::Table& in, const std::string& filename,
213 const std::string& method,
214 const casa::Vector<casa::Float>& xout,
215 bool dotsys);
216
217 void scaleFromTable(casa::Table& in, const casa::Table& table,
218 const std::string& method,
219 const casa::Vector<casa::Float>& xout, bool dotsys);
220
221 void convertBrightnessUnits(casa::CountedPtr<Scantable>& in,
222 bool tokelvin, float cfac);
223
224 casa::CountedPtr< Scantable >
225 getScantable(const casa::CountedPtr< Scantable >& in, bool droprows);
226
227 casa::MaskedArray<casa::Float>
228 maskedArray( const casa::Vector<casa::Float>& s,
229 const casa::Vector<casa::uChar>& f );
230 casa::Vector<casa::uChar>
231 flagsFromMA(const casa::MaskedArray<casa::Float>& ma);
232
233 bool insitu_;
234};
235
236}
237#endif
Note: See TracBrowser for help on using the repository browser.