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