casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PolOuterProduct.h
Go to the documentation of this file.
1 //# PolOuterProduct.h: Definition for PolOuterProduct
2 //# Copyright (C) 2007
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 adressed 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 //#
27 //# $Id$
28 
29 #ifndef SYNTHESIS_POLOUTERPRODUCT_H
30 #define SYNTHESIS_POLOUTERPRODUCT_H
31 
32 
33 #include <casa/Arrays/Vector.h>
34 #include <casa/Arrays/Matrix.h>
37 #include <ms/MeasurementSets/MSIter.h> // Just to get MSIter::{Linear,Circular}!
39 namespace casa{
40  // <summary>
41  // Class to encapsulate the A-Term outer product (the Mueller casacore::Matrix in feed-polarization basis)
42  // </summary>
43 
44  // <use visibility=export>
45  // <prerequisite>
46  // </prerequisite>
47  // <etymology>
48  //
49  // </etymology>
50  //
51  // <synopsis>
52  //
53  //</synopsis>
54  using namespace CFDefs;
56  {
57  public:
58  enum GenericVBPol {GPP, GPQ, GQP, GQQ, JUSTWRONGVBPOL};
59  enum CrossPolGeneric{PP, PP2Q, P2QP, P2QP2Q,
60  PQ2P, PQ, P2QQ2P, P2QQ,
61  Q2PP, Q2PP2Q, QP, QP2Q,
62  Q2PQ2P, Q2PQ, QQ2P, QQ,
63  JUSTWRONGGENERIC};
64  enum CrossPolCircular{RR, RR2L, R2LR, R2LR2L,
65  RL2R, RL, R2LL2R, R2LL,
66  L2RR, L2RR2L, LR, LR2L,
67  L2RL2R, L2RL, LL2R, LL,
68  JUSTWRONGCIRCULAR};
69  enum CrossPolLinear{XX, XX2Y, X2YX, X2YX2Y,
70  XY2X, XY, X2YY2X, X2YY,
71  Y2XX, Y2XX2Y, YX, YX2Y,
72  Y2XY2X, Y2XY, YY2X, YY,
73  JUSTWRONGLINEAR};
74  enum MuellerType {DIAGONAL=0, HYBRID, FULL};
75  //
76  //========================= Administrative Parts ==========================
77  //------------------------------------------------------------------
78  //
79  PolOuterProduct (MuellerType type=DIAGONAL) //set to diagonal which is what was originally defaulted to be.
80  {
81  polMap_p.resize(4,4);polMap_p=-1;
82  init(type);
83  };
84  //
85  //------------------------------------------------------------------
86  //
88  {
89  // assert(polMap.shape() == casacore::IPosition(2,4,4));
90 
91  polMap_p.assign(polMap);
92  init();
93  };
94  //
95  //------------------------------------------------------------------
96  //
97  virtual ~PolOuterProduct () {};
98  //
99  //============================= casacore::Functional Parts ============================
100  //------------------------------------------------------------------
101  //
102  void init(MuellerType type=DIAGONAL)
103  {
104  muellerType_p = type;
105  makeMap();
106  nelement_p=countNElements();
107  };
108  //
109  //------------------------------------------------------------------
110  //
111  void makePolMap(const casacore::Vector<CrossPolCircular>& pols);
112  //
113  //------------------------------------------------------------------
114  //
115  inline void setElement(const casacore::RigidVector<casacore::Int,2>& element,const casacore::Int& pos)
116  {polMap_p(element(0),element(1)) = pos;}
117  //
118  //------------------------------------------------------------------
119  //
120  inline void setElement(const CrossPolCircular& element, const casacore::Int& pos)
121  {casacore::RigidVector<casacore::Int,2> loc=getMuellerElement(element); setElement(loc,pos);}
122  //
123  //------------------------------------------------------------------
124  //
126  {return invIndexMap_p(element(0), element(1));};
127  //
128  //------------------------------------------------------------------
129  //
131  {return indexMap_p(element);}
132  //
133  //------------------------------------------------------------------
134  //
136  {return (polMap_p(element(0), element(1)) >= 0);};
137  //
138  //------------------------------------------------------------------
139  //
140  inline casacore::Bool isSet(const CrossPolCircular& element)
141  {return isSet(getMuellerElement(element));}
142  //
143  //------------------------------------------------------------------
144  //
146  {
147  casacore::Int n=0;
148  for (casacore::Int i=0;i<4;i++)
149  for (casacore::Int j=0;j<4;j++)
150  if (polMap_p(i,j) >= 0) n++;
151  return n;
152  }
153  //
154  //------------------------------------------------------------------
155  //
156  inline casacore::Int nelements() {return nelement_p;};
157  //
158  //------------------------------------------------------------------
159  //
161  //
162  //------------------------------------------------------------------
163  //
164  const casacore::Matrix<casacore::Int>& getPolMap() {return polMap_p;}
165  PolMapType& makePolMat(const casacore::Vector<casacore::Int>& vbPol, const casacore::Vector<casacore::Int>& vbPol2ImMap);
166  PolMapType& makePol2CFMat(const casacore::Vector<casacore::Int>& vbPol, const casacore::Vector<casacore::Int>& vbPol2ImMap);
167  PolMapType& makeConjPolMat(const casacore::Vector<casacore::Int>& vbPol, const casacore::Vector<casacore::Int>& vbPol2ImMap);
168  PolMapType& makeConjPol2CFMat(const casacore::Vector<casacore::Int>& vbPol, const casacore::Vector<casacore::Int>& vbPol2ImMap);
169  void initCFMaps(const casacore::Vector<casacore::Int>& visPol, const casacore::Vector<casacore::Int>& visPolsUsed);
170 
171  inline PolMapType& getPolMat() {return outerProduct2VBPolMap_p;};
172  inline PolMapType& getConjPolMat() {return conjOuterProduct2VBPolMap_p;};
173  inline PolMapType& getPol2CFMat() {return outerProductIndex2VBPolMap_p;};
174  inline PolMapType& getConjPol2CFMat() {return conjOuterProductIndex2VBPolMap_p;};
175  //
176  //============================= Protected Parts ============================
177  //
178  protected:
179  // casacore::LogIO& logIO() {return logIO_p;}
180  // casacore::LogIO logIO_p;
181  casacore::RigidVector<casacore::RigidVector<casacore::Int, 4>, 4> muellerRows_p, conjMuellerRows_p;
184  PolMapType outerProduct2VBPolMap_p, outerProductIndex2VBPolMap_p,
185  conjOuterProduct2VBPolMap_p, conjOuterProductIndex2VBPolMap_p, cfIndices_p;
188 
189  PolMapType& makePol2CFMat_p(const casacore::Vector<casacore::Int>& vbPol,
190  const casacore::Vector<casacore::Int>& vbPol2ImMap,
191  PolMapType& outerProdNdx2VBPolMap);
192  PolMapType& makePolMat_p(const casacore::Vector<casacore::Int>& vbPol,
193  const casacore::Vector<casacore::Int>& vbPol2ImMap,
194  PolMapType& outerProd2VBPolMap,
196 
197  virtual void makeMap()
198  {
199  //
200  // Make the (damn) mappings! Phew.
201  //
202 
204  el(0)=PP; el(1)=PP2Q; el(2)=P2QP; el(3)=P2QP2Q; muellerRows_p(GPP) = el;
205  el(0)=PQ2P; el(1)=PQ; el(2)=P2QQ2P; el(3)=P2QQ; muellerRows_p(GPQ) = el;
206  el(0)=Q2PP; el(1)=Q2PP2Q; el(2)=QP; el(3)=QP2Q; muellerRows_p(GQP) = el;
207  el(0)=Q2PQ2P; el(1)=Q2PQ; el(2)=QQ2P; el(3)=QQ; muellerRows_p(GQQ) = el;
208 
209  el(0)=QQ; el(1)=QQ2P; el(2)=Q2PQ; el(3)=Q2PQ2P; conjMuellerRows_p(GPP)=el;
210  el(0)=QP2Q; el(1)=QP; el(2)=Q2PP2Q; el(3)=Q2PP; conjMuellerRows_p(GPQ)=el;
211  el(0)=P2QQ; el(1)=P2QQ2P; el(2)=PQ; el(3)=PQ2P; conjMuellerRows_p(GQP)=el;
212  el(0)=P2QP2Q; el(1)=P2QP; el(2)=PP2Q; el(3)=PP; conjMuellerRows_p(GQQ)=el;
213 
214 
215 
216  // Pol-enum to 2-index
217  indexMap_p.resize(16);
218 
219  indexMap_p(RR) = casacore::RigidVector<casacore::Int,2>(0,0);
220  indexMap_p(RR2L) = casacore::RigidVector<casacore::Int,2>(0,1);
221  indexMap_p(R2LR) = casacore::RigidVector<casacore::Int,2>(0,2);
222  indexMap_p(R2LR2L) = casacore::RigidVector<casacore::Int,2>(0,3);
223 
224  indexMap_p(RL2R) = casacore::RigidVector<casacore::Int,2>(1,0);
225  indexMap_p(RL) = casacore::RigidVector<casacore::Int,2>(1,1);
226  indexMap_p(R2LL2R) = casacore::RigidVector<casacore::Int,2>(1,2);
227  indexMap_p(R2LL) = casacore::RigidVector<casacore::Int,2>(1,3);
228 
229  indexMap_p(L2RR) = casacore::RigidVector<casacore::Int,2>(2,0);
230  indexMap_p(L2RR2L) = casacore::RigidVector<casacore::Int,2>(2,1);
231  indexMap_p(LR) = casacore::RigidVector<casacore::Int,2>(2,2);
232  indexMap_p(LR2L) = casacore::RigidVector<casacore::Int,2>(2,3);
233 
234  indexMap_p(L2RL2R) = casacore::RigidVector<casacore::Int,2>(3,0);
235  indexMap_p(L2RL) = casacore::RigidVector<casacore::Int,2>(3,1);
236  indexMap_p(LL2R) = casacore::RigidVector<casacore::Int,2>(3,2);
237  indexMap_p(LL) = casacore::RigidVector<casacore::Int,2>(3,3);
238 
239 
240  // 2-Index to Pol-enum
241  invIndexMap_p.resize(4,4);
242 
243  invIndexMap_p(0,0)=RR; invIndexMap_p(0,1)=RR2L; invIndexMap_p(0,2)=R2LR; invIndexMap_p(0,3)=R2LR2L;
244  invIndexMap_p(1,0)=RL2R; invIndexMap_p(1,1)=RL; invIndexMap_p(1,2)=R2LL2R; invIndexMap_p(1,3)=R2LL;
245  invIndexMap_p(2,0)=L2RR; invIndexMap_p(2,1)=L2RR2L; invIndexMap_p(2,2)=LR; invIndexMap_p(2,3)=LR2L;
246  invIndexMap_p(3,0)=L2RL2R; invIndexMap_p(3,1)=L2RL; invIndexMap_p(3,2)=LL2R; invIndexMap_p(3,3)=LL;
247  };
248 
249  };
250  //
251  //------------------------------------------------------------------
252  //
256 };
257 
258 #endif
A 1-D Specialization of the Array class.
int Int
Definition: aipstype.h:50
casacore::RigidVector< casacore::Int, 2 > getMuellerElement(const CrossPolCircular &element)
casacore::Vector< casacore::RigidVector< casacore::Int, 2 > > indexMap_p
virtual Type type()
Return the type enum.
casacore::Bool isSet(const CrossPolCircular &element)
PolMapType & getPol2CFMat()
PolOuterProduct(MuellerType type=DIAGONAL)
========================= Administrative Parts ==========================
PolMapType & getPolMat()
virtual void makeMap()
PolMapType outerProductIndex2VBPolMap_p
PolOuterProduct(const casacore::Matrix< casacore::Int > &polMap)
Circular polarization.
Definition: MSIter.h:169
Fast Vector classes with fixed (templated) length.
void setElement(const casacore::RigidVector< casacore::Int, 2 > &element, const casacore::Int &pos)
const casacore::Vector< casacore::RigidVector< casacore::Int, 2 > > & getIndexMap()
void setElement(const CrossPolCircular &element, const casacore::Int &pos)
casacore::Int nelement_p
casacore::Bool isSet(const casacore::RigidVector< casacore::Int, 2 > element)
PolMapType & getConjPolMat()
casacore::Int getPolEnum(const casacore::RigidVector< casacore::Int, 2 > &element)
PolOuterProduct::GenericVBPol translateStokesToGeneric(const casacore::Int &stokes)
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
casacore::Int translateGenericToStokes(const PolOuterProduct::GenericVBPol &gPol, const casacore::MSIter::PolFrame &polFrame=casacore::MSIter::Circular)
void init(MuellerType type=DIAGONAL)
============================= casacore::Functional Parts ============================ ...
casacore::Matrix< casacore::Int > polMap_p
casacore::Int nelements()
casacore::Int countNElements()
const casacore::Matrix< casacore::Int > & getPolMap()