source: trunk/src/SDPol.h@ 440

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

add function SDPolUtil::stokesMask
fix error in nPol check in SDStokesENgine

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.0 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 <tables/Tables/BaseMappedArrayEngine.h>
38
39
40namespace asap {
41
42class SDPolUtil
43{
44 public:
45// Convert Q and U to polarized intensity
46 static casa::Array<casa::Float> polarizedIntensity (const casa::Array<casa::Float>& Q,
47 const casa::Array<casa::Float>& U);
48// Convert Q and U to polarized position angle (degrees)
49 static casa::Array<casa::Float> positionAngle (const casa::Array<casa::Float>& Q,
50 const casa::Array<casa::Float>& U);
51// Rotate phase of Complex correlation C3+iC4 by phase (degrees)
52 static void rotateXYPhase (casa::Array<casa::Float>& C3,
53 casa::Array<casa::Float>& C4,
54 casa::Float phase);
55
56// Get Stokes slices from the Array. Start and End should
57// already be setup to access the Array at the current cursor location
58// (beam, IF, chanells; see SDMemTable). This function will modify the asap::PolAxis
59// location to access the desired Stokes slice ("I", "Q", "U", "V")
60 static casa::Array<casa::Float> getStokesSlice (casa::Array<casa::Float>& input, const casa::IPosition& start,
61 const casa::IPosition& end, const casa::String& stokes);
62
63// Compute Circular polarization RR or LL from I and V
64 static casa::Array<casa::Float> circularPolarizationFromStokes (casa::Array<casa::Float>& I,
65 casa::Array<casa::Float>& V,
66 casa::Bool doRR);
67
68// Compute Mask for STokes parameters from raw correlation masks
69// Gets output shape right (e.g. XX,YY -> I)
70 static casa::Array<casa::Bool> stokesMask (casa::Array<casa::Bool> rawFlags,
71 casa::Bool doLinear);
72
73};
74
75
76
77class SDStokesEngine : public casa::BaseMappedArrayEngine<casa::Float, casa::Float>
78{
79 //# Make members of parent class known.
80public:
81 using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::sourceName;
82protected:
83 using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::targetName;
84 using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::table;
85 using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::roColumn;
86 using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::rwColumn;
87
88public:
89 // Construct engine. The sourveColumnName holds the XX,YY,R(XY),I(XY)
90 // correlations
91 SDStokesEngine (const casa::String& virtualColumnName,
92 const casa::String& sourceColumnName);
93
94 // Construct from a record specification as created by getmanagerSpec().
95 SDStokesEngine (const casa::Record& spec);
96
97 // Destructor is mandatory.
98 ~SDStokesEngine();
99
100 // Return the type name of the engine (i.e. its class name).
101 virtual casa::String dataManagerType() const;
102
103 // Get the name given to the engine (is the source column name).
104 virtual casa::String dataManagerName() const;
105
106 // casa::Record a casa::Record containing data manager specifications.
107 virtual casa::Record dataManagerSpec() const;
108
109 // Return the name of the class.
110 // This includes the names of the template arguments.
111 static casa::String className();
112
113 // The engine can access column cells.
114 virtual casa::Bool canAccessArrayColumnCells (casa::Bool& reask) const;
115
116 // Register the class name and the static makeObject "constructor".
117 // This will make the engine known to the table system.
118 // The automatically invoked registration function in DataManReg.cc
119 // contains SDStokesEngine
120 // Any other instantiation of this class must be registered "manually"
121 // (or added to DataManReg.cc).
122 static void registerClass();
123
124 // Non writable
125// virtual casa::Bool isWritable () const {return casa::False;}
126
127private:
128 // Copy constructor is only used by clone().
129 // (so it is made private).
130 SDStokesEngine (const SDStokesEngine&);
131
132 // Assignment is not needed and therefore forbidden
133 // (so it is made private and not implemented).
134 SDStokesEngine& operator=(const SDStokesEngine&);
135
136 // Clone the engine object.
137 DataManager* clone() const;
138
139 // Initialize the object for a new table.
140 // It defines the keywords containing the engine parameters.
141 void create (casa::uInt initialNrrow);
142
143 // Preparing consists of setting the writable switch and
144 // adding the initial number of rows in case of create.
145 // Furthermore it reads the keywords containing the engine parameters.
146 void prepare();
147
148 // Get an array in the given row.
149 void getArray (casa::uInt rownr, casa::Array<casa::Float>& array);
150
151 // Exception
152 void putArray (casa::uInt rownr, const casa::Array<casa::Float>& array);
153
154 // Compute Stokes parameters
155 void computeOnGet (casa::Array<casa::Float>& array,
156 const casa::Array<casa::Float>& target);
157
158 // Get shape
159 virtual casa::IPosition shape (casa::uInt rownr);
160
161 // Convert input to output (virtual) shape
162 casa::IPosition findOutputShape (const casa::IPosition& inputShape) const;
163
164
165public:
166 //*display 4
167 // Define the "constructor" to construct this engine when a
168 // table is read back.
169 // This "constructor" has to be registered by the user of the engine.
170 // If the engine is commonly used, its registration can be added
171 // to the registerAllCtor function in DataManReg.cc.
172 // That function gets automatically invoked by the table system.
173 static DataManager* makeObject (const casa::String& dataManagerType,
174 const casa::Record& spec);
175};
176
177} // namespace
178
179#endif
Note: See TracBrowser for help on using the repository browser.