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