source: trunk/src/STMath.h@ 1143

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

Implemented Ticket #45 as scantable.mx_quotient.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 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 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 casa::CountedPtr<Scantable>
106 unaryOperate( const casa::CountedPtr<Scantable>& in, float val,
107 const std::string& mode, bool tsys=false );
108
109 casa::CountedPtr<Scantable> autoQuotient(const casa::CountedPtr<Scantable>& in,
110 const std::string& mode = "NEAREST",
111 bool preserve = true);
112
113 casa::CountedPtr<Scantable> quotient( const casa::CountedPtr<Scantable>& on,
114 const casa::CountedPtr<Scantable>& off,
115 bool preserve = true );
116
117 casa::CountedPtr<Scantable>
118 freqSwitch( const casa::CountedPtr<Scantable>& in );
119
120 std::vector<float> statistic(const casa::CountedPtr<Scantable>& in,
121 const std::vector<bool>& mask,
122 const std::string& which);
123
124 casa::CountedPtr<Scantable> bin( const casa::CountedPtr<Scantable>& in,
125 int width=5);
126 casa::CountedPtr<Scantable>
127 resample(const casa::CountedPtr<Scantable>& in,
128 const std::string& method, float width);
129
130 casa::CountedPtr<Scantable>
131 smooth(const casa::CountedPtr<Scantable>& in, const std::string& kernel,
132 float width);
133
134 casa::CountedPtr<Scantable>
135 gainElevation(const casa::CountedPtr<Scantable>& in,
136 const std::vector<float>& coeff,
137 const std::string& fileName,
138 const std::string& method);
139 casa::CountedPtr<Scantable>
140 convertFlux(const casa::CountedPtr<Scantable>& in, float d,
141 float etaap, float jyperk);
142
143 casa::CountedPtr<Scantable> opacity(const casa::CountedPtr<Scantable>& in,
144 float tau);
145
146 casa::CountedPtr<Scantable>
147 merge(const std::vector<casa::CountedPtr<Scantable> >& in);
148
149 casa::CountedPtr<Scantable>
150 invertPhase( const casa::CountedPtr<Scantable>& in);
151
152 casa::CountedPtr<Scantable>
153 rotateXYPhase( const casa::CountedPtr<Scantable>& in, float phase);
154
155 casa::CountedPtr<Scantable>
156 rotateLinPolPhase( const casa::CountedPtr<Scantable>& in, float phase);
157
158 casa::CountedPtr<Scantable>
159 swapPolarisations(const casa::CountedPtr<Scantable>& in);
160
161 casa::CountedPtr<Scantable>
162 frequencyAlign( const casa::CountedPtr<Scantable>& in,
163 const std::string& refTime = "",
164 const std::string& method = "cubic" );
165
166 casa::CountedPtr<Scantable>
167 convertPolarisation( const casa::CountedPtr<Scantable>& in,
168 const std::string& newtype);
169
170 casa::CountedPtr<Scantable>
171 mxExtract( const casa::CountedPtr<Scantable>& in,
172 const std::string& srctype = "on");
173
174private:
175 casa::CountedPtr<Scantable> applyToPol( const casa::CountedPtr<Scantable>& in,
176 STPol::polOperation fptr,
177 casa::Float phase);
178
179 static imethod stringToIMethod(const std::string& in);
180 static WeightType stringToWeight(const std::string& in);
181
182 void scaleByVector(casa::Table& in,
183 const casa::Vector<casa::Float>& factor,
184 bool dotsys);
185
186 void scaleFromAsciiTable(casa::Table& in, const std::string& filename,
187 const std::string& method,
188 const casa::Vector<casa::Float>& xout,
189 bool dotsys);
190
191 void scaleFromTable(casa::Table& in, const casa::Table& table,
192 const std::string& method,
193 const casa::Vector<casa::Float>& xout, bool dotsys);
194
195 void convertBrightnessUnits(casa::CountedPtr<Scantable>& in,
196 bool tokelvin, float cfac);
197
198 casa::CountedPtr< Scantable >
199 getScantable(const casa::CountedPtr< Scantable >& in, bool droprows);
200
201 casa::MaskedArray<casa::Float>
202 maskedArray( const casa::Vector<casa::Float>& s,
203 const casa::Vector<casa::uChar>& f );
204 casa::Vector<casa::uChar>
205 flagsFromMA(const casa::MaskedArray<casa::Float>& ma);
206
207 bool insitu_;
208};
209
210}
211#endif
Note: See TracBrowser for help on using the repository browser.