casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ChannelAverageTVI.h
Go to the documentation of this file.
1 //# ChannelAverageTVI.h: This file contains the interface definition of the MSTransformManager class.
2 //#
3 //# CASA - Common Astronomy Software Applications (http://casa.nrao.edu/)
4 //# Copyright (C) Associated Universities, Inc. Washington DC, USA 2011, All rights reserved.
5 //# Copyright (C) European Southern Observatory, 2011, All rights reserved.
6 //#
7 //# This library is free software; you can redistribute it and/or
8 //# modify it under the terms of the GNU Lesser General Public
9 //# License as published by the Free software Foundation; either
10 //# version 2.1 of the License, or (at your option) any later version.
11 //#
12 //# This library is distributed in the hope that it will be useful,
13 //# but WITHOUT ANY WARRANTY, without even the implied warranty of
14 //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 //# Lesser General Public License for more details.
16 //#
17 //# You should have received a copy of the GNU Lesser General Public
18 //# License along with this library; if not, write to the Free Software
19 //# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 //# MA 02111-1307 USA
21 //# $Id: $
22 
23 #ifndef ChannelAverageTVI_H_
24 #define ChannelAverageTVI_H_
25 
26 // Base class
28 
29 //#define REPORT_TIMING
30 
31 namespace casa { //# NAMESPACE CASA - BEGIN
32 
33 namespace vi { //# NAMESPACE VI - BEGIN
34 
36 // ChannelAverageTVI class
38 
39 class ChannelAverageTVI : public FreqAxisTVI
40 {
41 
42 public:
43 
44  ChannelAverageTVI(ViImplementation2 * inputVii, const casacore::Record &configuration);
45  // Report the the ViImplementation type
46  virtual casacore::String ViiType() const { return casacore::String("ChannelAverage( ")+getVii()->ViiType()+" )"; };
47 
48 #ifdef _OPENMP
49  virtual void originChunks(casacore::Bool forceRewind) {
50  Tfl_=Tws_=Tss_=Tcd_=Tmd_=Tchave_=0.0; getVii()->originChunks(forceRewind); }
51  #ifdef REPORT_TIMING
52  virtual ~ChannelAverageTVI() {
53  cout << "ChannelAverageTVI: " << endl
54  << " T_flagCube =" << Tfl_ << endl
55  << " T_weightSpectrum =" << Tws_ << endl
56  << " T_sigmaSpectrum =" << Tss_ << endl
57  << " T_visibilityCorrected =" << Tcd_ << endl
58  << " T_visibilityModel =" << Tmd_ << endl
59  << " T_total =" << Tfl_+Tws_+Tss_+Tcd_+Tmd_
60  << endl;
61  }
62  #endif
63 #endif
64 
65  void flag(casacore::Cube<casacore::Bool>& flagCube) const;
66  void floatData (casacore::Cube<casacore::Float> & vis) const;
70  void weightSpectrum(casacore::Cube<casacore::Float> &weightSp) const;
71  void sigmaSpectrum (casacore::Cube<casacore::Float> &sigmaSp) const;
72 
73  casacore::Bool weightSpectrumExists () const {return true;}
74  casacore::Bool sigmaSpectrumExists () const {return true;}
75 
77  casacore::Int spectralWindowId, casacore::Int msId) const;
78 
79 
81 
82 protected:
83 
84  void propagateChanAvgFlags (const casacore::Cube<casacore::Bool> &avgFlagCube, casacore::Cube<casacore::Bool> &expandedFlagCube);
86  void initialize();
87 
89  mutable std::map<casacore::Int,casacore::uInt > spwChanbinMap_p; // Must be accessed from const methods
90 
91 #ifdef _OPENMP
92  mutable casacore::Double Tfl_,Tws_,Tcd_,Tmd_,Tss_,Tchave_;
93 #endif
94 };
95 
97 // ChannelAverageTVIFactory class
99 
100 class ChannelAverageTVIFactory : public ViFactory
101 {
102 
103 public:
104 
106  ViImplementation2 *inputVII);
107 
108 protected:
109 
110  vi::ViImplementation2 * createVi () const;
111 
114 };
115 
117 // ChannelAverageTVILayerFactory class (for _recursive_ layering)
119 
121 {
122 
123 public:
124 
126 
128 
129 protected:
130 
131 
132  virtual ViImplementation2 * createInstance(ViImplementation2* vii0) const;
133 
135 
136 };
137 
139 // ChannelAverageTransformEngine class
141 
142 
143 template<class T> class ChannelAverageKernel; // Forward declaration
144 
145 template<class T> class ChannelAverageTransformEngine : public FreqAxisTransformEngine2<T>
146 {
147 
150 
151 public:
152 
154  DataCubeMap *inputData,
155  DataCubeMap *outputData,
156  casacore::uInt width);
157 
158  // package transformation of all corr,row spectra in the in/outputData_p
159  // gmoellen (2017Mar06)
160  void transformAll();
161 
162  void transform();
163 
164 protected:
165 
167  // This member has to be a pointer, otherwise there
168  // are compile time problems due to the fact that
169  // it is a pure virtual class.
171 };
172 
174 // ChannelAverageKernel class
176 
177 template<class T> class ChannelAverageKernel
178 {
179 
180 public:
181 
182  virtual void kernel(DataCubeMap *inputData,
183  DataCubeMap *outputData,
184  casacore::uInt startInputPos,
185  casacore::uInt outputPos,
186  casacore::uInt width) = 0;
187 };
188 
190 // PlainChannelAverageKernel class
191 // (numerical averaging, ignoring flags)
193 
194 template<class T> class PlainChannelAverageKernel : public ChannelAverageKernel<T>
195 {
196 
197 public:
198 
199  void kernel( DataCubeMap *inputData,
200  DataCubeMap *outputData,
201  casacore::uInt startInputPos,
202  casacore::uInt outputPos,
203  casacore::uInt width);
204 
205 };
206 
208 // FlaggedChannelAverageKernel class
209 // (numerical averaging, respecting flags)
211 
212 template<class T> class FlaggedChannelAverageKernel : public ChannelAverageKernel<T>
213 {
214 
215 public:
216 
217  void kernel(DataCubeMap *inputData,
218  DataCubeMap *outputData,
219  casacore::uInt startInputPos,
220  casacore::uInt outputPos,
221  casacore::uInt width);
222 };
223 
225 // WeightedChannelAverageKernel class
226 // (weighted averaging, respecting flags)
228 
229 template<class T> class WeightedChannelAverageKernel : public ChannelAverageKernel<T>
230 {
231 
232 public:
233 
234  void kernel(DataCubeMap *inputData,
235  DataCubeMap *outputData,
236  casacore::uInt startInputPos,
237  casacore::uInt outputPos,
238  casacore::uInt width);
239 };
240 
242 // LogicalANDKernel class
244 
245 template<class T> class LogicalANDKernel : public ChannelAverageKernel<T>
246 {
247 
248 public:
249 
250  void kernel(DataCubeMap *inputData,
251  DataCubeMap *outputData,
252  casacore::uInt startInputPos,
253  casacore::uInt outputPos,
254  casacore::uInt width);
255 };
256 
258 // ChannelAccumulationKernel class
259 // (numerical accumulation, respecting flags)
261 
262 template<class T> class ChannelAccumulationKernel : public ChannelAverageKernel<T>
263 {
264 
265 public:
266 
267  void kernel(DataCubeMap *inputData,
268  DataCubeMap *outputData,
269  casacore::uInt startInputPos,
270  casacore::uInt outputPos,
271  casacore::uInt width);
272 };
273 
274 } //# NAMESPACE VI - END
275 
276 } //# NAMESPACE CASA - END
277 
278 #endif /* ChannelAverageTVI_H_ */
279 
casacore::Bool sigmaSpectrumExists() const
Determine whether SIGMA_SPECTRUM exists.
void propagateChanAvgFlags(const casacore::Cube< casacore::Bool > &avgFlagCube, casacore::Cube< casacore::Bool > &expandedFlagCube)
int Int
Definition: aipstype.h:50
vi::ViImplementation2 * createVi() const
casacore::Vector< casacore::Int > chanbin_p
ChannelAverageTVIFactory(casacore::Record &configuration, ViImplementation2 *inputVII)
virtual void time(casacore::Vector< double > &t) const override
Return MJD midpoint of interval.
void writeFlag(const casacore::Cube< casacore::Bool > &flag)
Write/modify the flags in the data.
void weightSpectrum(casacore::Cube< casacore::Float > &weightSp) const
Return weightspectrum (a weight for each channel)
casacore::Bool parseConfiguration(const casacore::Record &configuration)
std::map< casacore::Int, casacore::uInt > spwChanbinMap_p
ChannelAverageTVILayerFactory(casacore::Record &configuration)
void flag(casacore::Cube< casacore::Bool > &flagCube) const
Return flag for each polarization, channel and row.
void transformAll()
package transformation of all corr,row spectra in the in/outputData_p gmoellen (2017Mar06) ...
ChannelAverageKernel< T > * chanAvgKernel_p
This member has to be a pointer, otherwise there are compile time problems due to the fact that it is...
ChannelAverageTransformEngine(ChannelAverageKernel< T > *kernel, DataCubeMap *inputData, DataCubeMap *outputData, casacore::uInt width)
double Double
Definition: aipstype.h:55
void kernel(DataCubeMap *inputData, DataCubeMap *outputData, casacore::uInt startInputPos, casacore::uInt outputPos, casacore::uInt width)
virtual ViImplementation2 * createInstance(ViImplementation2 *vii0) const
Make a ViImplementation with another as input Must be specialized for each type.
A hierarchical collection of named fields of various types.
Definition: Record.h:180
ViImplementation2 * getVii() const
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void visibilityCorrected(casacore::Cube< casacore::Complex > &vis) const
Return the visibilities as found in the casacore::MS, casacore::Cube (npol,nchan,nrow).
void floatData(casacore::Cube< casacore::Float > &vis) const
Return FLOAT_DATA as a casacore::Cube (npol, nchan, nrow) if found in the MS.
void visibilityObserved(casacore::Cube< casacore::Complex > &vis) const
virtual void originChunks(casacore::Bool forceRewind=false) override
Methods to control chunk iterator.
void kernel(DataCubeMap *inputData, DataCubeMap *outputData, casacore::uInt startInputPos, casacore::uInt outputPos, casacore::uInt width)
void kernel(DataCubeMap *inputData, DataCubeMap *outputData, casacore::uInt startInputPos, casacore::uInt outputPos, casacore::uInt width)
VisibilityIterator2 iterates through one or more readonly MeasurementSets.
virtual casacore::String ViiType() const =0
Report the the ViImplementation type.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
void sigmaSpectrum(casacore::Cube< casacore::Float > &sigmaSp) const
Return sgimaspectrum (a sigma for each channel)
casacore::Vector< casacore::Double > getFrequencies(casacore::Double time, casacore::Int frameOfReference, casacore::Int spectralWindowId, casacore::Int msId) const
void visibilityModel(casacore::Cube< casacore::Complex > &vis) const
virtual void kernel(DataCubeMap *inputData, DataCubeMap *outputData, casacore::uInt startInputPos, casacore::uInt outputPos, casacore::uInt width)=0
ChannelAverageTVI(ViImplementation2 *inputVii, const casacore::Record &configuration)
virtual casacore::String ViiType() const
Report the the ViImplementation type.
virtual casacore::Int msId() const override
reference to actual ms in interator
virtual void originChunks(casacore::Bool forceRewind=false)=0
Methods to control chunk iterator.
void kernel(DataCubeMap *inputData, DataCubeMap *outputData, casacore::uInt startInputPos, casacore::uInt outputPos, casacore::uInt width)
unsigned int uInt
Definition: aipstype.h:51
casacore::Bool weightSpectrumExists() const
Determine whether WEIGHT_SPECTRUM exists.
void kernel(DataCubeMap *inputData, DataCubeMap *outputData, casacore::uInt startInputPos, casacore::uInt outputPos, casacore::uInt width)