source: trunk/src/SDPol.h@ 447

Last change on this file since 447 was 446, checked in by kil064, 20 years ago

add function convertStokes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1//#---------------------------------------------------------------------------
2//# SDPol.h: Polarimetric processing
3//#---------------------------------------------------------------------------
4//# Copyright (C) 2004
5//# ATNF
6//#
7//# This program is free software; you can redistribute it and/or modify it
8//# under the terms of the GNU General Public License as published by the Free
9//# Software Foundation; either version 2 of the License, or (at your option)
10//# any later version.
11//#
12//# This program is distributed in the hope that it will be useful, but
13//# WITHOUT ANY WARRANTY; without even the implied warranty of
14//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15//# Public License for more details.
16//#
17//# You should have received a copy of the GNU General Public License along
18//# with this program; if not, write to the Free Software Foundation, Inc.,
19//# 675 Massachusetts Ave, Cambridge, MA 02139, USA.
20//#
21//# Correspondence concerning this software should be addressed as follows:
22//# Internet email: Malte.Marquarding@csiro.au
23//# Postal address: Malte Marquarding,
24//# Australia Telescope National Facility,
25//# P.O. Box 76,
26//# Epping, NSW, 2121,
27//# AUSTRALIA
28//#
29//# $Id:
30//#---------------------------------------------------------------------------
31#ifndef SDPOL_H
32#define SDPOL_H
33
34//# Includes
35#include <casa/aips.h>
36#include <casa/Arrays/Array.h>
37#include <measures/Measures/Stokes.h>
38#include <tables/Tables/BaseMappedArrayEngine.h>
39
40
41namespace asap {
42
43class SDPolUtil
44{
45 public:
46// Convert Q and U to polarized intensity
47 static casa::Array<casa::Float> polarizedIntensity (const casa::Array<casa::Float>& Q,
48 const casa::Array<casa::Float>& U);
49// Convert Q and U to polarized position angle (degrees)
50 static casa::Array<casa::Float> positionAngle (const casa::Array<casa::Float>& Q,
51 const casa::Array<casa::Float>& U);
52// Rotate phase of Complex correlation C3+iC4 by phase (degrees)
53 static void rotateXYPhase (casa::Array<casa::Float>& C3,
54 casa::Array<casa::Float>& C4,
55 casa::Float phase);
56
57// Get Stokes slices from the Array. Start and End should
58// already be setup to access the Array at the current cursor location
59// (beam, IF, chanells; see SDMemTable). This function will modify the asap::PolAxis
60// location to access the desired Stokes slice ("I", "Q", "U", "V")
61 static casa::Array<casa::Float> getStokesSlice (casa::Array<casa::Float>& input, const casa::IPosition& start,
62 const casa::IPosition& end, const casa::String& stokes);
63
64// Compute Circular polarization RR or LL from I and V
65 static casa::Array<casa::Float> circularPolarizationFromStokes (casa::Array<casa::Float>& I,
66 casa::Array<casa::Float>& V,
67 casa::Bool doRR);
68
69// Compute Mask for STokes parameters from raw correlation masks
70// Gets output shape right (e.g. XX,YY -> I)
71 static casa::Array<casa::Bool> stokesMask (casa::Array<casa::Bool> rawFlags,
72 casa::Bool doLinear);
73
74// Find the Stokes type for the given polarization axis (0,1,2,3)
75// You can ask for STokes or raw correltions (linear or circular)
76 static casa::Stokes::StokesTypes convertStokes(casa::Int val, casa::Bool toStokes,
77 casa::Bool linear);
78};
79
80
81
82class SDStokesEngine : public casa::BaseMappedArrayEngine<casa::Float, casa::Float>
83{
84 //# Make members of parent class known.
85public:
86 using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::sourceName;
87protected:
88 using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::targetName;
89 using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::table;
90 using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::roColumn;
91 using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::rwColumn;
92
93public:
94 // Construct engine. The sourveColumnName holds the XX,YY,R(XY),I(XY)
95 // correlations
96 SDStokesEngine (const casa::String& virtualColumnName,
97 const casa::String& sourceColumnName);
98
99 // Construct from a record specification as created by getmanagerSpec().
100 SDStokesEngine (const casa::Record& spec);
101
102 // Destructor is mandatory.
103 ~SDStokesEngine();
104
105 // Return the type name of the engine (i.e. its class name).
106 virtual casa::String dataManagerType() const;
107
108 // Get the name given to the engine (is the source column name).
109 virtual casa::String dataManagerName() const;
110
111 // casa::Record a casa::Record containing data manager specifications.
112 virtual casa::Record dataManagerSpec() const;
113
114 // Return the name of the class.
115 // This includes the names of the template arguments.
116 static casa::String className();
117
118 // The engine can access column cells.
119 virtual casa::Bool canAccessArrayColumnCells (casa::Bool& reask) const;
120
121 // Register the class name and the static makeObject "constructor".
122 // This will make the engine known to the table system.
123 // The automatically invoked registration function in DataManReg.cc
124 // contains SDStokesEngine
125 // Any other instantiation of this class must be registered "manually"
126 // (or added to DataManReg.cc).
127 static void registerClass();
128
129 // Non writable
130// virtual casa::Bool isWritable () const {return casa::False;}
131
132private:
133 // Copy constructor is only used by clone().
134 // (so it is made private).
135 SDStokesEngine (const SDStokesEngine&);
136
137 // Assignment is not needed and therefore forbidden
138 // (so it is made private and not implemented).
139 SDStokesEngine& operator=(const SDStokesEngine&);
140
141 // Clone the engine object.
142 DataManager* clone() const;
143
144 // Initialize the object for a new table.
145 // It defines the keywords containing the engine parameters.
146 void create (casa::uInt initialNrrow);
147
148 // Preparing consists of setting the writable switch and
149 // adding the initial number of rows in case of create.
150 // Furthermore it reads the keywords containing the engine parameters.
151 void prepare();
152
153 // Get an array in the given row.
154 void getArray (casa::uInt rownr, casa::Array<casa::Float>& array);
155
156 // Exception
157 void putArray (casa::uInt rownr, const casa::Array<casa::Float>& array);
158
159 // Compute Stokes parameters
160 void computeOnGet (casa::Array<casa::Float>& array,
161 const casa::Array<casa::Float>& target);
162
163 // Get shape
164 virtual casa::IPosition shape (casa::uInt rownr);
165
166 // Convert input to output (virtual) shape
167 casa::IPosition findOutputShape (const casa::IPosition& inputShape) const;
168
169
170public:
171 //*display 4
172 // Define the "constructor" to construct this engine when a
173 // table is read back.
174 // This "constructor" has to be registered by the user of the engine.
175 // If the engine is commonly used, its registration can be added
176 // to the registerAllCtor function in DataManReg.cc.
177 // That function gets automatically invoked by the table system.
178 static DataManager* makeObject (const casa::String& dataManagerType,
179 const casa::Record& spec);
180};
181
182} // namespace
183
184#endif
Note: See TracBrowser for help on using the repository browser.