casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PolAverageTVI.h
Go to the documentation of this file.
1 //# PolAverageTVI.h: Transforming VI for polarization averaging
2 //# Copyright (C) 1996,1997,1998,1999,2000,2001,2002,2003
3 //# Associated Universities, Inc. Washington DC, USA.
4 //#
5 //# This library is free software; you can redistribute it and/or modify it
6 //# under the terms of the GNU Library General Public License as published by
7 //# the Free Software Foundation; either version 2 of the License, or (at your
8 //# option) any later version.
9 //#
10 //# This library is distributed in the hope that it will be useful, but WITHOUT
11 //# ANY WARRANTY; without even the Implied warranty of MERCHANTABILITY or
12 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13 //# License for more details.
14 //#
15 //# You should have received a copy of the GNU Library General Public License
16 //# along with this library; if not, write to the Free Software Foundation,
17 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18 //#
19 //# Correspondence concerning AIPS++ should be addressed as follows:
20 //# Internet email: aips2-request@nrao.edu.
21 //# Postal address: AIPS++ Project Office
22 //# National Radio Astronomy Observatory
23 //# 520 Edgemont Road
24 //# Charlottesville, VA 22903-2475 USA
25 //#
26 //# $Id: $
27 
28 #ifndef _MSVIS_POLAVERAGINGTVI_H_
29 #define _MSVIS_POLAVERAGINGTVI_H_
30 
31 #include <casacore/casa/aips.h>
35 
36 #include <map>
37 #include <vector>
38 
41 
42 namespace casacore {
43 
44 template<typename T> class Vector;
45 }
46 
47 namespace casa { //# NAMESPACE CASA - BEGIN
48 
49 namespace vi { // # NAMESPACE VI - BEGIN
50 
51 //# forward decl
52 
53 class VisBuffer2;
54 
55 class ChannelSelector;
56 class ChannelSelectorCache;
58 class SpectralWindowChannelsCache;
59 class SpectralWindowChannels;
60 class SubtableColumns;
61 
63 
64 // <summary>
65 // PolAverageTVI
66 // </summary>
67 
68 // <use visibility=export>
69 
70 // <reviewed reviewer="" date="yyyy/mm/dd" tests="" demos="">
71 // </reviewed>
72 
73 // <prerequisite>
74 // <li> <linkto class="MSIter">MSIter</linkto>
75 // <li> <linkto class="casacore::MeasurementSet">casacore::MeasurementSet</linkto>
76 // <li> <linkto class="VisSet">VisSet</linkto>
77 // </prerequisite>
78 //
79 // <etymology>
80 // PolAverageTVI
81 // </etymology>
82 //
83 // <synopsis>
84 //
85 // </synopsis>
86 //
87 // <example>
88 // <code>
89 // //
90 // </code>
91 // </example>
92 //
93 // <motivation>
94 //
95 // </motivation>
96 //
97 // <thrown>
98 // <li>
99 // <li>
100 // </thrown>
101 //
102 // <todo asof="1997/05/30">
103 // <li> cleanup the currently dual interface for visibilities and flags
104 // <li> sort out what to do with weights when interpolating
105 // </todo>
106 
108 
109 public:
110 
111  // Destructor
112 
113  virtual ~PolAverageTVI();
114 
115  // Report the the ViImplementation type
116  // (should be specialized in child classes)
117  virtual casacore::String ViiType() const {
118  return casacore::String("PolAverage( ") + getVii()->ViiType() + " )";
119  }
120 
121  // Methods to control and monitor subchunk iteration
122 
123  virtual void origin();
124  virtual void next();
125 
126  // Override the following methods to always return Stokes::I
127  virtual void corrType(casacore::Vector<casacore::Int> & corrTypes) const;
131 
132  // POLARIZATION table will have additional entry nPolarizationIds() should
133  // return original number plus one
134  // NB: nDataDescriptionIds() will not be affected
135  virtual casacore::Int nPolarizationIds() const {
137  }
138 
139  // Polarization Id will point to the new row to be added (to the end)
140  virtual casacore::Int polarizationId() const {
141  return nPolarizationIds() - 1;
142  }
143 
144  // Return row flag
145 
146  virtual void flagRow (casacore::Vector<casacore::Bool> & rowflags) const;
147 
148  // Return flag for each polarization, channel and row
149 
150  virtual void flag(casacore::Cube<casacore::Bool> & flags) const;
151 
152  // Return flag for each channel & row
153 
154  virtual void flag(casacore::Matrix<casacore::Bool> & flags) const;
155 
156  // Return feed configuration matrix for specified antenna
157  // Must fail
158  virtual void jonesC(
160 
161  // Return sigma
162 
163  virtual void sigma(casacore::Matrix<casacore::Float> & sigmat) const;
164 
165  // Return the visibilities as found in the casacore::MS, casacore::Cube (npol,nchan,nrow).
166 
167  virtual void visibilityCorrected(
169  virtual void visibilityModel(casacore::Cube<casacore::Complex> & vis) const;
170  virtual void visibilityObserved(
172 
173  // Return FLOAT_DATA as a casacore::Cube (npol, nchan, nrow) if found in the MS.
174 
175  virtual void floatData(casacore::Cube<casacore::Float> & fcube) const;
176 
177  // Return the shape of the visibility Cube
178 
179  virtual casacore::IPosition visibilityShape() const;
180 
181  // Return weight
182  // TODO
183 
184  virtual void weight(casacore::Matrix<casacore::Float> & wtmat) const;
185 
186  // Return weightspectrum (a weight for each channel)
187  // TODO
188 
189  virtual void weightSpectrum(casacore::Cube<casacore::Float> & wtsp) const;
190  virtual void sigmaSpectrum(casacore::Cube<casacore::Float> & wtsp) const;
191 
192  // Return imaging weight (a weight for each channel)
193  // virtual casacore::Matrix<casacore::Float> & imagingWeight (casacore::Matrix<casacore::Float> & wt) const;
194 
195  virtual const VisImagingWeight & getImagingWeightGenerator() const;
196 
197 protected:
198 
199  // Constructor
200 
201  PolAverageTVI(ViImplementation2 * inputVi);
202 
203  // transform data (DATA, CORRECTED_DATA, MODEL_DATA, FLOAT_DATA)
204  virtual void transformComplexData(
205  casacore::Cube<casacore::Complex> const &dataIn,
206  casacore::Cube<casacore::Bool> const &flagIn,
207  casacore::Cube<casacore::Complex> &dataOut) const = 0;
208  virtual void transformFloatData(casacore::Cube<casacore::Float> const &dataIn,
209  casacore::Cube<casacore::Bool> const &flagIn,
210  casacore::Cube<casacore::Float> &dataOut) const = 0;
211 
212  // transform weight (WEIGHT, WEIGHT_SPECTRUM)
213  // TODO
214  virtual void transformWeight(casacore::Array<casacore::Float> const &weightIn,
215  casacore::Array<casacore::Float> &weightOut) const = 0;
216 
217  // Flags (per ms, per data description) whether transformation must be executed or not
218  // condition:
219  //
220  // 1. if polarization type is neither Linear nor Circular, do not transform
221  // 2. if visibility only contain one polarization component, do not transform
222  // 3. if visibility contains cross-polarization (XY, YX, RL, LR), do not
223  // take into account it
224  //
225 // casacore::Vector<Vector<Bool> > doTransform_;
227 
228  // List of polarization ids that points either (XX,YY) or (RR,LL)
229 // Vector<Vector<uInt> > polId0;
230 // Vector<Vector<uInt> > polId1;
232 
233 private:
234 
235  // Properly fill doTransform_, polId0_, and polId1_ based on current MS
236  void configurePolAverage();
237 
238  // Reconfigure if necessary
240  if (isNewMs()) {
242  }
243  }
244 
245  // warn if current dd is inappropriate for polarization averaging
246  void warnIfNoTransform();
247 
249 };
250 
252 public:
255 
256  // Report the the ViImplementation type
257  // (should be specialized in child classes)
258  virtual casacore::String ViiType() const {
259  return casacore::String("GeometricPolAverage( ") + getVii()->ViiType()
260  + " )";
261  }
262 
263  // transform data (DATA, CORRECTED_DATA, MODEL_DATA, FLOAT_DATA)
264  virtual void transformComplexData(
265  casacore::Cube<casacore::Complex> const &dataIn,
266  casacore::Cube<casacore::Bool> const &flagIn,
267  casacore::Cube<casacore::Complex> &dataOut) const;
268  virtual void transformFloatData(casacore::Cube<casacore::Float> const &dataIn,
269  casacore::Cube<casacore::Bool> const &flagIn,
270  casacore::Cube<casacore::Float> &dataOut) const;
271 
272  // transform weight (WEIGHT, WEIGHT_SPECTRUM)
273  // TODO
274  virtual void transformWeight(casacore::Array<casacore::Float> const &weightIn,
275  casacore::Array<casacore::Float> &weightOut) const;
276 
277 protected:
278 
279  template<class T>
280  void transformData(casacore::Cube<T> const &dataIn,
281  casacore::Cube<casacore::Bool> const &flagIn,
282  casacore::Int pid0,
283  casacore::Int pid1,
284  casacore::Cube<T> &dataOut) const;
285 };
286 
288 public:
291 
292  // Report the the ViImplementation type
293  // (should be specialized in child classes)
294  virtual casacore::String ViiType() const {
295  return casacore::String("StokesPolAverage( ") + getVii()->ViiType() + " )";
296  }
297 
298  // transform data (DATA, CORRECTED_DATA, MODEL_DATA, FLOAT_DATA)
299  virtual void transformComplexData(
300  casacore::Cube<casacore::Complex> const &dataIn,
301  casacore::Cube<casacore::Bool> const &flagIn,
302  casacore::Cube<casacore::Complex> &dataOut) const;
303  virtual void transformFloatData(casacore::Cube<casacore::Float> const &dataIn,
304  casacore::Cube<casacore::Bool> const &flagIn,
305  casacore::Cube<casacore::Float> &dataOut) const;
306 
307  // transform weight (WEIGHT, WEIGHT_SPECTRUM)
308  // TODO
309  virtual void transformWeight(casacore::Array<casacore::Float> const &weightIn,
310  casacore::Array<casacore::Float> &weightOut) const;
311 
312 protected:
313 
314  template<class T>
315  void transformData(casacore::Cube<T> const &dataIn,
316  casacore::Cube<casacore::Bool> const &flagIn,
317  casacore::Int pid0,
318  casacore::Int pid1,
319  casacore::Cube<T> &dataOut) const;
320 };
321 
322 // <summary>
323 // A factory for generating ViImplementation2 for polarization averaging.
324 // </summary>
325 //
326 // <use visibility=export>
327 //
328 // <prerequisite>
329 // <li> <linkto class="VisibilityIterator2:description">VisibilityIterator2</linkto>
330 // </prerequisite>
331 //
332 // <etymology>
333 // Factory for layered ViImplementation2 construction
334 // </etymology>
335 //
336 // <synopsis>
337 // PolAverageVi2Factory
338 // </synopsis>
339 //
340 // <motivation>
341 //
342 // </motivation>
343 //
344 // <example>
345 //
346 // </example>
347 
349 
350 public:
351  // Constructor
352  PolAverageVi2Factory(casacore::Record const &configuration,
353  ViImplementation2 *inputVII);
354  PolAverageVi2Factory(casacore::Record const &configuration,
355  casacore::MeasurementSet const *ms, SortColumns const sortColumns,
356  casacore::Double timeInterval, casacore::Bool isWritable);
357 
358  // Destructor
360 
361  ViImplementation2 * createVi() const;
362 
363 private:
366  };
367 
369  casacore::Record const &configuration) {
370  if (configuration.isDefined("mode")) {
371  casacore::String mode = configuration.asString("mode");
372  mode.downcase();
373  if (mode == "geometric") {
374  return AveragingMode::GEOMETRIC;
375  } else if (mode == "stokes") {
376  return AveragingMode::STOKES;
377  } else if (mode == "default") {
378  return AveragingMode::DEFAULT;
379  } else {
380  return AveragingMode::NUM_MODES;
381  }
382  }
383  return AveragingMode::DEFAULT;
384  }
385 
387 
389 };
390 
392 
393 public:
394  PolAverageTVILayerFactory(casacore::Record const &configuration);
396  }
397  ;
398 
399 protected:
400 
402 
404 
405 };
406 
407 } //# NAMESPACE VI - END
408 
409 } //# NAMESPACE CASA - END
410 
411 #endif // _MSVIS_POLAVERAGINGTVI_H_
412 
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
virtual ~PolAverageTVI()
Destructor.
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
std::vector< double > Vector
Definition: ds9context.h:24
ViImplementation2 * createInstance(ViImplementation2 *vii0) const
Make a ViImplementation with another as input Must be specialized for each type.
Object to hold type of imaging weight scheme to be used on the fly and to provide facilities to do th...
void transformData(casacore::Cube< T > const &dataIn, casacore::Cube< casacore::Bool > const &flagIn, casacore::Int pid0, casacore::Int pid1, casacore::Cube< T > &dataOut) const
ViImplementation2 * createVi() const
static AveragingMode GetAverageModeFromConfig(casacore::Record const &configuration)
virtual void transformFloatData(casacore::Cube< casacore::Float > const &dataIn, casacore::Cube< casacore::Bool > const &flagIn, casacore::Cube< casacore::Float > &dataOut) const
virtual void jonesC(casacore::Vector< casacore::SquareMatrix< casacore::Complex, 2 > > &cjones) const
Return feed configuration matrix for specified antenna Must fail.
virtual casacore::Int nPolarizationIds() const override
A factory for generating ViImplementation2 for polarization averaging.
virtual casacore::String ViiType() const
Report the the ViImplementation type (should be specialized in child classes)
virtual casacore::String ViiType() const
Report the the ViImplementation type (should be specialized in child classes)
virtual void visibilityModel(casacore::Cube< casacore::Complex > &vis) const
ViImplementation2 * inputVII_p
PolAverageVi2Factory(casacore::Record const &configuration, ViImplementation2 *inputVII)
Constructor.
virtual casacore::Int polarizationId() const
Polarization Id will point to the new row to be added (to the end)
PolAverageTVI(ViImplementation2 *inputVi)
Constructor.
PolAverageTVILayerFactory(casacore::Record const &configuration)
virtual casacore::IPosition visibilityShape() const
Return the shape of the visibility Cube.
virtual void floatData(casacore::Cube< casacore::Float > &fcube) const
Return FLOAT_DATA as a casacore::Cube (npol, nchan, nrow) if found in the MS.
casacore::Vector< casacore::Int > polId1_
virtual void sigmaSpectrum(casacore::Cube< casacore::Float > &wtsp) const
Return sgimaspectrum (a sigma for each channel)
StokesPolAverageTVI(ViImplementation2 *inputVi)
virtual casacore::Int nPolarizationIds() const
POLARIZATION table will have additional entry nPolarizationIds() should return original number plus o...
virtual void weightSpectrum(casacore::Cube< casacore::Float > &wtsp) const
Return weightspectrum (a weight for each channel) TODO.
virtual casacore::Vector< casacore::Stokes::StokesTypes > getCorrelationTypesSelected() const
Fast Square Matrix class with fixed (templated) size.
casacore::Vector< casacore::Bool > doTransform_
Flags (per ms, per data description) whether transformation must be executed or not condition: ...
double Double
Definition: aipstype.h:55
void configurePolAverage()
Properly fill doTransform_, polId0_, and polId1_ based on current MS.
virtual void corrType(casacore::Vector< casacore::Int > &corrTypes) const
Override the following methods to always return Stokes::I.
virtual void transformWeight(casacore::Array< casacore::Float > const &weightIn, casacore::Array< casacore::Float > &weightOut) const =0
transform weight (WEIGHT, WEIGHT_SPECTRUM) TODO
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
virtual void transformComplexData(casacore::Cube< casacore::Complex > const &dataIn, casacore::Cube< casacore::Bool > const &flagIn, casacore::Cube< casacore::Complex > &dataOut) const
transform data (DATA, CORRECTED_DATA, MODEL_DATA, FLOAT_DATA)
virtual casacore::Vector< casacore::Stokes::StokesTypes > getCorrelationTypesDefined() const
Bool isDefined(const String &fieldName) const
Test if a field name exists.
void reconfigurePolAverageIfNecessary()
Reconfigure if necessary.
VisibilityIterator2 iterates through one or more readonly MeasurementSets.
virtual void transformFloatData(casacore::Cube< casacore::Float > const &dataIn, casacore::Cube< casacore::Bool > const &flagIn, casacore::Cube< casacore::Float > &dataOut) const
casacore::Vector< casacore::Vector< casacore::Slice > > ChannelSlicer
Definition: PolAverageTVI.h:56
virtual void origin()
Methods to control and monitor subchunk iteration.
virtual void sigma(casacore::Matrix< casacore::Float > &sigmat) const
Return sigma.
A Table intended to hold astronomical data (a set of Measurements).
void transformData(casacore::Cube< T > const &dataIn, casacore::Cube< casacore::Bool > const &flagIn, casacore::Int pid0, casacore::Int pid1, casacore::Cube< T > &dataOut) const
virtual void weight(casacore::Matrix< casacore::Float > &wtmat) const
Return weight TODO.
virtual void visibilityCorrected(casacore::Cube< casacore::Complex > &vis) const
Return the visibilities as found in the casacore::MS, casacore::Cube (npol,nchan,nrow).
virtual void transformComplexData(casacore::Cube< casacore::Complex > const &dataIn, casacore::Cube< casacore::Bool > const &flagIn, casacore::Cube< casacore::Complex > &dataOut) const
transform data (DATA, CORRECTED_DATA, MODEL_DATA, FLOAT_DATA)
VisibilityIterator2 iterates through one or more readonly MeasurementSets.
virtual void flag(casacore::Cube< casacore::Bool > &flags) const
Return flag for each polarization, channel and row.
const String & asString(const RecordFieldId &) const
virtual casacore::String ViiType() const =0
Report the the ViImplementation type.
virtual void transformComplexData(casacore::Cube< casacore::Complex > const &dataIn, casacore::Cube< casacore::Bool > const &flagIn, casacore::Cube< casacore::Complex > &dataOut) const =0
transform data (DATA, CORRECTED_DATA, MODEL_DATA, FLOAT_DATA)
virtual casacore::String ViiType() const
Report the the ViImplementation type (should be specialized in child classes)
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual void transformWeight(casacore::Array< casacore::Float > const &weightIn, casacore::Array< casacore::Float > &weightOut) const
transform weight (WEIGHT, WEIGHT_SPECTRUM) TODO
GeometricPolAverageTVI(ViImplementation2 *inputVi)
virtual void flagRow(casacore::Vector< casacore::Bool > &rowflags) const
Return row flag.
virtual casacore::Bool isNewMs() const override
void warnIfNoTransform()
warn if current dd is inappropriate for polarization averaging
virtual void transformFloatData(casacore::Cube< casacore::Float > const &dataIn, casacore::Cube< casacore::Bool > const &flagIn, casacore::Cube< casacore::Float > &dataOut) const =0
virtual const VisImagingWeight & getImagingWeightGenerator() const
Return imaging weight (a weight for each channel) virtual casacore::Matrix&lt;casacore::Float&gt; &amp; imaging...
virtual casacore::Vector< casacore::Int > getCorrelations() const
virtual void transformWeight(casacore::Array< casacore::Float > const &weightIn, casacore::Array< casacore::Float > &weightOut) const
transform weight (WEIGHT, WEIGHT_SPECTRUM) TODO
void downcase()
internal transformation to lowercase of String
virtual void visibilityObserved(casacore::Cube< casacore::Complex > &vis) const
casacore::Vector< casacore::Int > polId0_
List of polarization ids that points either (XX,YY) or (RR,LL) Vector&lt;Vector&lt;uInt&gt; &gt; polId0; Vector&lt;V...
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42