casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Vbi2MsRow.h
Go to the documentation of this file.
1 /*
2  * Vbi2MsRow.h
3  *
4  * Created on: Aug 22, 2013
5  * Author: jjacobs
6  */
7 
8 #ifndef VBI2MSROW_H_
9 #define VBI2MSROW_H_
10 
11 #include <casa/Arrays/Array.h>
12 #include <msvis/MSVis/MsRows.h>
13 
14 // Forward Decls
15 
16 namespace casa {
17 
18 namespace vi {
19 
20 class VisBufferImpl2;
21 
22 }
23 
24 }
25 
26 namespace casa {
27 
28 namespace ms {
29 
31 
32 public:
33 
34  CachedArrayBase () : cached_p (false) {}
35  virtual ~CachedArrayBase () {}
36 
37  void clearCache () { cached_p = false;}
38 
39 protected:
40 
41  casacore::Bool isCached () const { return cached_p;}
42  void setCached () { cached_p = true;}
43 
44 private:
45 
47 };
48 
49 template <typename T>
50 class CachedPlane : public CachedArrayBase {
51 
52 public:
53 
54 typedef const casacore::Cube<T> & (casa::vi::VisBufferImpl2::* Accessor) () const;
55 
56 CachedPlane (Accessor accessor) : accessor_p (accessor) {}
57 
60 {
61  if (! isCached()){
62 
63  //cache_p.reference ((vb ->* accessor_p)().xyPlane (row)); // replace with something more efficient
64  referenceMatrix (cache_p, (vb ->* accessor_p)(), row);
65  setCached ();
66  }
67 
68  return cache_p;
69 }
70 
71 private:
72 
73  static void
75  {
77  shape.resize (2);
78 
79  // This is a bit sleazy but it seems to be helpful to performance.
80  // Assumes contiguously stored cube.
81 
82  T * storage = const_cast <T *> (& src (casacore::IPosition (3, 0, 0, row)));
83 
84  cache.takeStorage (shape, storage, casacore::SHARE);
85  }
86 
89 };
90 
91 template <typename T>
92 class CachedColumn : public CachedArrayBase {
93 
94 public:
95 
97 
98 CachedColumn (Accessor accessor) : accessor_p (accessor) {}
99 
102 {
103  if (! isCached()){
104 
105  referenceVector (cache_p, (vb ->* accessor_p)(), row);
106  setCached ();
107  }
108 
109  return cache_p;
110 }
111 
112 private:
113 
114  static void
116  {
118  shape.resize (1);
119 
120  // This is a bit sleazy but it seems to be helpful to performance.
121  // Assumes contiguously stored cube.
122 
123  T * storage = const_cast <T *> (& src (casacore::IPosition (2, 0, row)));
124 
125  cache.takeStorage (shape, storage, casacore::SHARE);
126  }
127 
130 };
131 
132 
133 class Vbi2MsRow : public MsRow {
134 
135 public:
136 
137  // Constructors
138 
139  // Constructor for read-only access.
140  // Attempt to write will throw exception.
141 
143 
144  // Constructor for read/write access
145 
147 
148  virtual ~Vbi2MsRow () {}
149 
150  void changeRow (casacore::Int row);
151  void copy (Vbi2MsRow * other,
152  const VisBufferComponents2 & componentsToCopy);
153 
154  casacore::Int antenna1 () const;
155  casacore::Int antenna2 () const;
156  casacore::Int arrayId () const;
159  casacore::Int feed1 () const;
160  casacore::Int feed2 () const;
161  casacore::Int fieldId () const;
162  casacore::Int observationId () const;
163  casacore::Int rowId () const;
164  casacore::Int processorId () const;
165  casacore::Int scanNumber () const;
166  casacore::Int stateId () const;
167  casacore::Double exposure () const;
168  casacore::Double interval () const;
169  casacore::Int spectralWindow () const;
170  casacore::Double time () const;
172 
173  void setAntenna1 (casacore::Int);
174  void setAntenna2 (casacore::Int);
175  void setArrayId (casacore::Int);
178  void setFeed1 (casacore::Int);
179  void setFeed2 (casacore::Int);
180  void setFieldId (casacore::Int);
183  void setRowId (casacore::Int);
185  void setStateId (casacore::Int);
189  void setTime (casacore::Double);
191 
193  const casacore::Double & uvw (casacore::Int i) const;
196 
197  const casacore::Complex & corrected (casacore::Int correlation, casacore::Int channel) const;
200  void setCorrected (casacore::Int correlation, casacore::Int channel, const casacore::Complex & value);
202 
203  const casacore::Complex & model (casacore::Int correlation, casacore::Int channel) const;
206  void setModel(casacore::Int correlation, casacore::Int channel, const casacore::Complex & value);
208 
209  const casacore::Complex & observed (casacore::Int correlation, casacore::Int channel) const;
212  void setObserved (casacore::Int correlation, casacore::Int channel, const casacore::Complex & value);
214 
215  const casacore::Float & singleDishData (casacore::Int correlation, casacore::Int channel) const;
218  void setSingleDishData (casacore::Int correlation, casacore::Int channel, const casacore::Float & value);
220 
221  casacore::Float sigma (casacore::Int correlation) const;
222  const casacore::Vector<casacore::Float> & sigma () const;
224  void setSigma (casacore::Int correlation, casacore::Float value);
226  casacore::Float weight (casacore::Int correlation) const;
227  const casacore::Vector<casacore::Float> & weight () const;
229  void setWeight (casacore::Int correlation, casacore::Float value);
231  casacore::Float weightSpectrum (casacore::Int correlation, casacore::Int channel) const;
236  casacore::Float sigmaSpectrum (casacore::Int correlation, casacore::Int channel) const;
241 
242  casacore::Bool isRowFlagged () const;
243  const casacore::Matrix<casacore::Bool> & flags () const;
245  casacore::Bool isFlagged (casacore::Int correlation, casacore::Int channel) const;
246 
248  void setFlags (casacore::Bool isFlagged, casacore::Int correlation, casacore::Int channel);
249 
250 protected:
251 
252  template <typename T>
253  void addToCachedArrays (T & cachedArray)
254  {
255  arrayCaches_p.push_back (& cachedArray);
256  }
257 
258  void clearArrayCaches();
260  vi::VisBufferImpl2 * getVbi () const;
261 
262 private:
263 
264  void configureArrayCaches(); // called in ctor so do not override
265 
274 
275  std::vector<CachedArrayBase *> arrayCaches_p;
276 
277 template <typename T, typename U>
278 void
279 copyIf (casacore::Bool copyThis, Vbi2MsRow * other,
280  void (Vbi2MsRow::* setter) (T),
281  U (Vbi2MsRow::* getter) () const);
282 
284 
285 };
286 
287 }
288 
289 } // end namespace casa
290 
291 
292 #endif /* VBI2MSROW_H_ */
A Vector of integers, for indexing into Array&lt;T&gt; objects.
Definition: IPosition.h:119
casacore::Int feed1() const
void copy(Vbi2MsRow *other, const VisBufferComponents2 &componentsToCopy)
void setTimeCentroid(casacore::Double)
void setProcessorId(casacore::Int)
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
const casacore::Matrix< casacore::Float > & weightSpectrum() const
virtual ~Vbi2MsRow()
Definition: Vbi2MsRow.h:148
void setFeed1(casacore::Int)
Share means that the Array will just use the pointer (no copy), however the Array will NOT delete it ...
Definition: ArrayBase.h:64
void copyIf(casacore::Bool copyThis, Vbi2MsRow *other, void(Vbi2MsRow::*setter)(T), U(Vbi2MsRow::*getter)() const)
const casacore::Matrix< casacore::Complex > & model() const
const casacore::Vector< casacore::Float > & sigma() const
const IPosition & shape() const
The length of each axis of the Matrix.
Definition: Matrix.h:295
casacore::Matrix< casacore::Float > & weightSpectrumMutable() const
casacore::Vector< T > & getCachedColumn(casa::vi::VisBufferImpl2 *vb, casacore::Int row)
Definition: Vbi2MsRow.h:101
casacore::uInt row() const
CachedPlane< casacore::Float > sigmaSpectrumCache_p
Definition: Vbi2MsRow.h:271
vi::VisBufferImpl2 * vbi2_p
Definition: Vbi2MsRow.h:283
void setScanNumber(casacore::Int)
class MsRowAttributes {
Definition: MsRows.h:131
casacore::Vector< casacore::Float > & weightMutable() const
CachedColumn(Accessor accessor)
Definition: Vbi2MsRow.h:98
casacore::Matrix< casacore::Complex > & observedMutable()
void setAntenna1(casacore::Int)
void setRowId(casacore::Int)
const IPosition & shape() const
The length of each axis of the cube.
Definition: Cube.h:292
casacore::Int correlationType() const
A 3-D Specialization of the Array class.
Vbi2MsRow(casacore::Int row, const vi::VisBufferImpl2 *vb)
Constructors.
casacore::Vector< casacore::Float > & sigmaMutable() const
void setFlags(const casacore::Matrix< casacore::Bool > &flags)
const casacore::Matrix< casacore::Complex > & observed() const
std::vector< CachedArrayBase * > arrayCaches_p
Definition: Vbi2MsRow.h:275
CachedPlane< casacore::Bool > flagCache_p
Definition: Vbi2MsRow.h:267
CachedColumn< casacore::Float > weightCache_p
Definition: Vbi2MsRow.h:272
A 2-D Specialization of the Array class.
const casacore::Vector< casacore::Float > & weight() const
void setFieldId(casacore::Int)
casacore::Int spectralWindow() const
void setSigmaSpectrum(casacore::Int correlation, casacore::Int channel, casacore::Float value)
casacore::Int fieldId() const
void setCorrelationType(casacore::Int)
void setFeed2(casacore::Int)
casacore::Matrix< casacore::Complex > & modelMutable()
const casacore::Vector< casacore::Double > uvw() const
void setSpectralWindow(casacore::Int)
void setUvw(const casacore::Vector< casacore::Double > &)
casacore::Matrix< T > & getCachedPlane(casa::vi::VisBufferImpl2 *vb, casacore::Int row)
Definition: Vbi2MsRow.h:59
static void referenceMatrix(casacore::Matrix< T > &cache, const casacore::Cube< T > &src, casacore::Int row)
Definition: Vbi2MsRow.h:74
casacore::Int feed2() const
CachedPlane< casacore::Complex > correctedCache_p
Definition: Vbi2MsRow.h:266
void setAntenna2(casacore::Int)
void setModel(casacore::Int correlation, casacore::Int channel, const casacore::Complex &value)
void setCorrected(casacore::Int correlation, casacore::Int channel, const casacore::Complex &value)
void setWeightSpectrum(casacore::Int correlation, casacore::Int channel, casacore::Float value)
casacore::Matrix< T > cache_p
Definition: Vbi2MsRow.h:88
void setWeight(casacore::Int correlation, casacore::Float value)
void setSingleDishData(casacore::Int correlation, casacore::Int channel, const casacore::Float &value)
casacore::Double exposure() const
casacore::Matrix< casacore::Float > & sigmaSpectrumMutable() const
void setExposure(casacore::Double)
casacore::Int stateId() const
casacore::Double time() const
casacore::Int arrayId() const
double Double
Definition: aipstype.h:55
void setDataDescriptionId(casacore::Int)
CachedPlane< casacore::Float > weightSpectrumCache_p
Definition: Vbi2MsRow.h:273
void setTime(casacore::Double)
CachedPlane< casacore::Complex > observedCache_p
Definition: Vbi2MsRow.h:269
const casacore::Matrix< casacore::Complex > & corrected() const
const casacore::Matrix< casacore::Float > singleDishData() const
void setStateId(casacore::Int)
const casacore::Cube< T > &(casa::vi::VisBufferImpl2::* Accessor)() const
Definition: Vbi2MsRow.h:54
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
void setRowFlag(casacore::Bool isFlagged)
float Float
Definition: aipstype.h:54
void setObservationId(casacore::Int)
casacore::Bool cached_p
Definition: Vbi2MsRow.h:46
CachedColumn< casacore::Float > sigmaCache_p
Definition: Vbi2MsRow.h:270
casacore::Int observationId() const
CachedPlane(Accessor accessor)
Definition: Vbi2MsRow.h:56
vi::VisBufferImpl2 * getVbi() const
TableExprNode shape(const TableExprNode &array)
Function operating on any scalar or array resulting in a Double array containing the shape...
Definition: ExprNode.h:1944
casacore::Int antenna1() const
casacore::Bool isRowFlagged() const
casacore::Double interval() const
casacore::Double timeCentroid() const
void setObserved(casacore::Int correlation, casacore::Int channel, const casacore::Complex &value)
casacore::Bool isCached() const
Definition: Vbi2MsRow.h:41
virtual void takeStorage(const IPosition &shape, T *storage, StorageInitPolicy policy=COPY)
Replace the data values with those in the pointer storage.
void addToCachedArrays(T &cachedArray)
Definition: Vbi2MsRow.h:253
void setInterval(casacore::Double)
casacore::Int rowId() const
casacore::Int dataDescriptionId() const
void changeRow(casacore::Int row)
casacore::Matrix< casacore::Bool > & flagsMutable()
CachedPlane< casacore::Complex > modelCache_p
Definition: Vbi2MsRow.h:268
casacore::Int scanNumber() const
void resize(uInt newSize, Bool copy=True)
Old values are copied on resize if copy==True.
virtual ~CachedArrayBase()
Definition: Vbi2MsRow.h:35
const casacore::Matrix< casacore::Float > & sigmaSpectrum() const
vi::VisBuffer2 * vb() const
static void referenceVector(casacore::Vector< T > &cache, const casacore::Matrix< T > &src, casacore::Int row)
Definition: Vbi2MsRow.h:115
casacore::Int processorId() const
void setArrayId(casacore::Int)
casacore::Int antenna2() const
This class encapsulates an enum with values corresponding to the various data components accessible v...
const casacore::Matrix< T > &(casa::vi::VisBufferImpl2::* Accessor)() const
Definition: Vbi2MsRow.h:96
VisBufferImpls encapsulate one chunk of visibility data for processing.
casacore::Bool isFlagged(casacore::Int correlation, casacore::Int channel) const
casacore::Matrix< casacore::Float > singleDishDataMutable()
const casacore::Matrix< casacore::Bool > & flags() const
casacore::Matrix< casacore::Complex > & correctedMutable()
LatticeExprNode value(const LatticeExprNode &expr)
This function returns the value of the expression without a mask.
void setSigma(casacore::Int correlation, casacore::Float value)
casacore::Vector< T > cache_p
Definition: Vbi2MsRow.h:129