00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef SYNTHESIS_TRANSFORM2_POLOUTERPRODUCT_H
00030 #define SYNTHESIS_TRANSFORM2_POLOUTERPRODUCT_H
00031
00032
00033 #include <casa/Arrays/Vector.h>
00034 #include <casa/Arrays/Matrix.h>
00035 #include <scimath/Mathematics/RigidVector.h>
00036 #include <coordinates/Coordinates/StokesCoordinate.h>
00037 #include <ms/MeasurementSets/MSIter.h>
00038 #include <synthesis/TransformMachines2/CFDefs.h>
00039 namespace casa{
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 namespace refim{
00055 using namespace CFDefs;
00056 class PolOuterProduct
00057 {
00058 public:
00059 enum GenericVBPol {GPP, GPQ, GQP, GQQ, JUSTWRONGVBPOL};
00060 enum CrossPolGeneric{PP, PP2Q, P2QP, P2QP2Q,
00061 PQ2P, PQ, P2QQ2P, P2QQ,
00062 Q2PP, Q2PP2Q, QP, QP2Q,
00063 Q2PQ2P, Q2PQ, QQ2P, QQ,
00064 JUSTWRONGGENERIC};
00065 enum CrossPolCircular{RR, RR2L, R2LR, R2LR2L,
00066 RL2R, RL, R2LL2R, R2LL,
00067 L2RR, L2RR2L, LR, LR2L,
00068 L2RL2R, L2RL, LL2R, LL,
00069 JUSTWRONGCIRCULAR};
00070 enum CrossPolLinear{XX, XX2Y, X2YX, X2YX2Y,
00071 XY2X, XY, X2YY2X, X2YY,
00072 Y2XX, Y2XX2Y, YX, YX2Y,
00073 Y2XY2X, Y2XY, YY2X, YY,
00074 JUSTWRONGLINEAR};
00075 enum MuellerType {DIAGONAL=0, HYBRID, FULL};
00076
00077
00078
00079
00080 PolOuterProduct (MuellerType type=FULL)
00081 {
00082 polMap_p.resize(4,4);polMap_p=-1;
00083 init(type);
00084 };
00085
00086
00087
00088 PolOuterProduct (const Matrix<Int>& polMap)
00089 {
00090
00091
00092 polMap_p.assign(polMap);
00093 init();
00094 };
00095
00096
00097
00098 virtual ~PolOuterProduct () {};
00099
00100
00101
00102
00103 void init(MuellerType type=DIAGONAL)
00104 {
00105 muellerType_p = type;
00106 makeMap();
00107 nelement_p=countNElements();
00108 };
00109
00110
00111
00112 void makePolMap(const Vector<CrossPolCircular>& pols);
00113
00114
00115
00116 inline void setElement(const RigidVector<Int,2>& element,const Int& pos)
00117 {polMap_p(element(0),element(1)) = pos;}
00118
00119
00120
00121 inline void setElement(const CrossPolCircular& element, const Int& pos)
00122 {RigidVector<Int,2> loc=getMuellerElement(element); setElement(loc,pos);}
00123
00124
00125
00126 inline Int getPolEnum(const RigidVector<Int, 2>& element)
00127 {return invIndexMap_p(element(0), element(1));};
00128
00129
00130
00131 inline RigidVector<Int,2> getMuellerElement(const CrossPolCircular& element)
00132 {return indexMap_p(element);}
00133
00134
00135
00136 inline Bool isSet(const RigidVector<Int,2> element)
00137 {return (polMap_p(element(0), element(1)) >= 0);};
00138
00139
00140
00141 inline Bool isSet(const CrossPolCircular& element)
00142 {return isSet(getMuellerElement(element));}
00143
00144
00145
00146 inline Int countNElements()
00147 {
00148 Int n=0;
00149 for (Int i=0;i<4;i++)
00150 for (Int j=0;j<4;j++)
00151 if (polMap_p(i,j) >= 0) n++;
00152 return n;
00153 }
00154
00155
00156
00157 inline Int nelements() {return nelement_p;};
00158
00159
00160
00161 const Vector<RigidVector<Int,2> >& getIndexMap() {return indexMap_p;};
00162
00163
00164
00165 const Matrix<Int>& getPolMap() {return polMap_p;}
00166 PolMapType& makePolMat(const Vector<Int>& vbPol, const Vector<Int>& vbPol2ImMap);
00167 PolMapType& makePol2CFMat(const Vector<Int>& vbPol, const Vector<Int>& vbPol2ImMap);
00168 PolMapType& makeConjPolMat(const Vector<Int>& vbPol, const Vector<Int>& vbPol2ImMap);
00169 PolMapType& makeConjPol2CFMat(const Vector<Int>& vbPol, const Vector<Int>& vbPol2ImMap);
00170 void initCFMaps(const Vector<Int>& visPol, const Vector<Int>& visPolsUsed);
00171
00172 inline PolMapType& getPolMat() {return outerProduct2VBPolMap_p;};
00173 inline PolMapType& getConjPolMat() {return conjOuterProduct2VBPolMap_p;};
00174 inline PolMapType& getPol2CFMat() {return outerProductIndex2VBPolMap_p;};
00175 inline PolMapType& getConjPol2CFMat() {return conjOuterProductIndex2VBPolMap_p;};
00176
00177
00178
00179 protected:
00180
00181
00182 RigidVector<RigidVector<Int, 4>, 4> muellerRows_p, conjMuellerRows_p;
00183 Matrix<Int> polMap_p, invIndexMap_p;
00184 Vector<RigidVector<Int,2> > indexMap_p;
00185 PolMapType outerProduct2VBPolMap_p, outerProductIndex2VBPolMap_p,
00186 conjOuterProduct2VBPolMap_p, conjOuterProductIndex2VBPolMap_p, cfIndices_p;
00187 MuellerType muellerType_p;
00188 Int nelement_p;
00189
00190 PolMapType& makePol2CFMat_p(const Vector<Int>& vbPol,
00191 const Vector<Int>& vbPol2ImMap,
00192 PolMapType& outerProdNdx2VBPolMap);
00193 PolMapType& makePolMat_p(const Vector<Int>& vbPol,
00194 const Vector<Int>& vbPol2ImMap,
00195 PolMapType& outerProd2VBPolMap,
00196 RigidVector<RigidVector<Int, 4>, 4>& mRows);
00197
00198 virtual void makeMap()
00199 {
00200
00201
00202
00203
00204 RigidVector<Int,4> el;
00205 el(0)=PP; el(1)=PP2Q; el(2)=P2QP; el(3)=P2QP2Q; muellerRows_p(GPP) = el;
00206 el(0)=PQ2P; el(1)=PQ; el(2)=P2QQ2P; el(3)=P2QQ; muellerRows_p(GPQ) = el;
00207 el(0)=Q2PP; el(1)=Q2PP2Q; el(2)=QP; el(3)=QP2Q; muellerRows_p(GQP) = el;
00208 el(0)=Q2PQ2P; el(1)=Q2PQ; el(2)=QQ2P; el(3)=QQ; muellerRows_p(GQQ) = el;
00209
00210 el(0)=QQ; el(1)=QQ2P; el(2)=Q2PQ; el(3)=Q2PQ2P; conjMuellerRows_p(GPP)=el;
00211 el(0)=QP2Q; el(1)=QP; el(2)=Q2PP2Q; el(3)=Q2PP; conjMuellerRows_p(GPQ)=el;
00212 el(0)=P2QQ; el(1)=P2QQ2P; el(2)=PQ; el(3)=PQ2P; conjMuellerRows_p(GQP)=el;
00213 el(0)=P2QP2Q; el(1)=P2QP; el(2)=PP2Q; el(3)=PP; conjMuellerRows_p(GQQ)=el;
00214
00215
00216
00217
00218 indexMap_p.resize(16);
00219
00220 indexMap_p(RR) = RigidVector<Int,2>(0,0);
00221 indexMap_p(RR2L) = RigidVector<Int,2>(0,1);
00222 indexMap_p(R2LR) = RigidVector<Int,2>(0,2);
00223 indexMap_p(R2LR2L) = RigidVector<Int,2>(0,3);
00224
00225 indexMap_p(RL2R) = RigidVector<Int,2>(1,0);
00226 indexMap_p(RL) = RigidVector<Int,2>(1,1);
00227 indexMap_p(R2LL2R) = RigidVector<Int,2>(1,2);
00228 indexMap_p(R2LL) = RigidVector<Int,2>(1,3);
00229
00230 indexMap_p(L2RR) = RigidVector<Int,2>(2,0);
00231 indexMap_p(L2RR2L) = RigidVector<Int,2>(2,1);
00232 indexMap_p(LR) = RigidVector<Int,2>(2,2);
00233 indexMap_p(LR2L) = RigidVector<Int,2>(2,3);
00234
00235 indexMap_p(L2RL2R) = RigidVector<Int,2>(3,0);
00236 indexMap_p(L2RL) = RigidVector<Int,2>(3,1);
00237 indexMap_p(LL2R) = RigidVector<Int,2>(3,2);
00238 indexMap_p(LL) = RigidVector<Int,2>(3,3);
00239
00240
00241
00242 invIndexMap_p.resize(4,4);
00243
00244 invIndexMap_p(0,0)=RR; invIndexMap_p(0,1)=RR2L; invIndexMap_p(0,2)=R2LR; invIndexMap_p(0,3)=R2LR2L;
00245 invIndexMap_p(1,0)=RL2R; invIndexMap_p(1,1)=RL; invIndexMap_p(1,2)=R2LL2R; invIndexMap_p(1,3)=R2LL;
00246 invIndexMap_p(2,0)=L2RR; invIndexMap_p(2,1)=L2RR2L; invIndexMap_p(2,2)=LR; invIndexMap_p(2,3)=LR2L;
00247 invIndexMap_p(3,0)=L2RL2R; invIndexMap_p(3,1)=L2RL; invIndexMap_p(3,2)=LL2R; invIndexMap_p(3,3)=LL;
00248 };
00249 };
00250
00251
00252
00253 PolOuterProduct::GenericVBPol translateStokesToGeneric(const Int& stokes) ;
00254 Int translateGenericToStokes2(const PolOuterProduct::GenericVBPol& gPol,
00255 const MSIter::PolFrame& polFrame=MSIter::Circular);
00256 };
00257 };
00258 #endif