casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
StokesConverter.h
Go to the documentation of this file.
1 //# StokesConverter.h: convert any set of polarizations into any other one
2 //# Copyright (C) 1997,2001
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 //#
27 //# $Id$
28 
29 #ifndef MS_STOKESCONVERTER_H
30 #define MS_STOKESCONVERTER_H
31 
32 #include <casacore/casa/aips.h>
37 
38 namespace casacore { //# NAMESPACE CASACORE - BEGIN
39 
40 // <summary>
41 // StokesConverter converts any set of polarizations into any other one
42 // </summary>
43 
44 // <use visibility=export>
45 
46 // <reviewed reviewer="" date="yyyy/mm/dd" tests="tStokesConverter" demos="">
47 // </reviewed>
48 
49 // <prerequisite>
50 // <li> <a href="StokesConverter.html"> Stokes </a>
51 // </prerequisite>
52 //
53 // <etymology>
54 // StokesConverter is a class that converts Stokes Parameters
55 // </etymology>
56 //
57 // <synopsis>
58 // This class is used to convert polarizations from one system to
59 // another.
60 // First the conversion wanted is specified and then large blocks of data
61 // can be converted.
62 // <example>
63 // <srcblock>
64 // // create converter
65 // StokesConverter sc;
66 // Vector<Int> out(7),in(4);
67 // // set the input polarizations
68 // in(0)=Stokes::RR;
69 // in(1)=Stokes::LL;
70 // in(2)=Stokes::RL;
71 // in(3)=Stokes::LR;
72 // // set the required output
73 // out(0)=Stokes::I;
74 // out(1)=Stokes::Q;
75 // out(2)=Stokes::U;
76 // out(3)=Stokes::V;
77 // out(4)=Stokes::Ptotal;
78 // out(5)=Stokes::Pangle;
79 // out(6)=Stokes::PFlinear;
80 // // initialize the conversion engine
81 // sc.setConversion(out,in);
82 // // set up some test data
83 // Vector<Complex> datain(4),dataout(7);
84 // datain(0)=1.0;
85 // datain(1)=0.9;
86 // datain(2)=0.3;
87 // datain(3)=0.2;
88 // // convert the data
89 // sc.convert(dataout,datain);
90 // </srcblock>
91 // </example>
92 // </synopsis>
93 //
94 // <motivation>
95 // Polarization conversion is needed in various places. It makes sense to
96 // provide all conversion in one place.
97 // </motivation>
98 //
99 // <thrown>
100 // <li>
101 // <li>
102 // </thrown>
103 //
104 // <todo asof="1997/10/09">
105 // <li> cope with incomplete input polarizations sensibly
106 // <li> decide what to do about factor 2 between I and RR/LL,XX/YY etc.
107 // </todo>
108 
110 {
111 public:
112 
113  // default constructor, does not set up a conversion
114  StokesConverter();
115 
116  // Set up a conversion from in to out.
117  // The in and out vectors contain a list of polarization present/wanted
118  // in that order. The in vector should match the data to convert.
119  // (CORR_TYPE column in SPECTRAL_WINDOW table contains this info)
120  // The rescale option will correct for crosscorrelation data that
121  // has been scaled to the level Stokes I (common practice
122  // in radioastronomy: even though officially I=XX+YY, in practice
123  // we need to do I=(XX+YY)/2, set rescale to True to do the latter).
124  StokesConverter(const Vector<Int>& out, const Vector<Int>& in,
125  Bool rescale=False);
126 
127  // desctructor
129 
130  // Copy constructor
131  StokesConverter(const StokesConverter& other);
132 
133  // Assignment,
135 
136  // Change or Set the conversion. Arguments are the same as for
137  // constructor above.
138  void setConversion(const Vector<Int>& out, const Vector<Int>& in,
139  Bool rescale = False);
140 
141  // convert data, first dimension of input must match
142  // that of the input conversion vector used to set up the conversion.
143  // Output is resized as needed.
144  void convert(Array<Complex>& out, const Array<Complex>& in) const;
145 
146  // convert flags, first dimension of input must match
147  // that of the input conversion vector used to set up the conversion.
148  // Output is resized as needed. All output depending on a flagged input
149  // will be flagged.
150  void convert(Array<Bool>& out, const Array<Bool>& in) const;
151 
152  // convert weights, first dimension of input must match
153  // that of the input conversion vector used to set up the conversion.
154  // Output is resized as needed.
155  // Set sigma to True when converting sigma's using this routine.
156  void convert(Array<Float>& out, const Array<Float>& in,
157  Bool sigma=False) const;
158 
159  // invert flags, first dimension of input must match
160  // that of the output conversion vector used to set up the conversion.
161  // Output is resized as needed. All output depending on a flagged input
162  // will be flagged. This does the inverse operation of convert, allowing
163  // flagging of converted data to be transferred back to the original data.
164  void invert(Array<Bool>& out, const Array<Bool>& in) const;
165 
166 protected:
167 
168  // initialize the polarization conversion matrix
169  void initConvMatrix();
170 
171 private:
174  //# mutable because operator Matrix(Slice,Slice) doesn't have const version
181 };
182 
183 
184 } //# NAMESPACE CASACORE - END
185 
186 #endif
StokesConverter & operator=(const StokesConverter &other)
Assignment,.
void convert(Array< Complex > &out, const Array< Complex > &in) const
convert data, first dimension of input must match that of the input conversion vector used to set up ...
StokesConverter converts any set of polarizations into any other one.
StokesConverter()
default constructor, does not set up a conversion
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
~StokesConverter()
desctructor
void setConversion(const Vector< Int > &out, const Vector< Int > &in, Bool rescale=False)
Change or Set the conversion.
const Bool False
Definition: aipstype.h:44
Matrix< Complex > conv_p
Matrix< Complex > polConv_p
void initConvMatrix()
initialize the polarization conversion matrix
void invert(Array< Bool > &out, const Array< Bool > &in) const
invert flags, first dimension of input must match that of the output conversion vector used to set up...
Matrix< Complex > iquvConv_p