source: trunk/src/SDPol.h @ 437

Last change on this file since 437 was 437, checked in by kil064, 19 years ago

make it work for nPol=1,2 or 4

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.8 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
69
70
71class SDStokesEngine : public casa::BaseMappedArrayEngine<casa::Float, casa::Float>
72{
73  //# Make members of parent class known.
74public:
75  using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::sourceName;
76protected:
77  using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::targetName;
78  using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::table;
79  using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::roColumn;
80  using casa::BaseMappedArrayEngine<casa::Float,casa::Float>::rwColumn;
81
82public:
83    // Construct engine.  The sourveColumnName holds the XX,YY,R(XY),I(XY)
84    // correlations
85    SDStokesEngine (const casa::String& virtualColumnName,
86               const casa::String& sourceColumnName);
87
88    // Construct from a record specification as created by getmanagerSpec().
89    SDStokesEngine (const casa::Record& spec);
90
91    // Destructor is mandatory.
92    ~SDStokesEngine();
93
94    // Return the type name of the engine (i.e. its class name).
95    virtual casa::String dataManagerType() const;
96
97    // Get the name given to the engine (is the source column name).
98    virtual casa::String dataManagerName() const;
99 
100    // casa::Record a casa::Record containing data manager specifications.
101    virtual casa::Record dataManagerSpec() const;
102
103    // Return the name of the class.
104    // This includes the names of the template arguments.
105    static casa::String className();
106
107   // The engine can access column cells.
108    virtual casa::Bool canAccessArrayColumnCells (casa::Bool& reask) const;
109
110    // Register the class name and the static makeObject "constructor".
111    // This will make the engine known to the table system.
112    // The automatically invoked registration function in DataManReg.cc
113    // contains SDStokesEngine
114    // Any other instantiation of this class must be registered "manually"
115    // (or added to DataManReg.cc).
116    static void registerClass();
117
118    // Non writable
119    virtual casa::Bool isWritable () const {return casa::False;}
120
121private:
122    // Copy constructor is only used by clone().
123    // (so it is made private).
124    SDStokesEngine (const SDStokesEngine&);
125
126    // Assignment is not needed and therefore forbidden
127    // (so it is made private and not implemented).
128    SDStokesEngine& operator=(const SDStokesEngine&);
129
130    // Clone the engine object.
131    DataManager* clone() const;
132
133    // Initialize the object for a new table.
134    // It defines the keywords containing the engine parameters.
135    void create (casa::uInt initialNrrow);
136
137    // Preparing consists of setting the writable switch and
138    // adding the initial number of rows in case of create.
139    // Furthermore it reads the keywords containing the engine parameters.
140    void prepare();
141
142    // Get an array in the given row.
143    void getArray (casa::uInt rownr, casa::Array<casa::Float>& array);
144
145    // Exception
146    void putArray (casa::uInt rownr, const casa::Array<casa::Float>& array);
147
148    // Compute Stokes parameters
149    void computeOnGet (casa::Array<casa::Float>& array,
150                     const casa::Array<casa::Float>& target);
151
152    // Get shape
153    virtual casa::IPosition shape (casa::uInt rownr);
154
155    // Convert input to output (virtual) shape
156    casa::IPosition findOutputShape (const casa::IPosition& inputShape) const;
157
158
159public:
160    //*display 4
161    // Define the "constructor" to construct this engine when a
162    // table is read back.
163    // This "constructor" has to be registered by the user of the engine.
164    // If the engine is commonly used, its registration can be added
165    // to the registerAllCtor function in DataManReg.cc.
166    // That function gets automatically invoked by the table system.
167    static DataManager* makeObject (const casa::String& dataManagerType,
168                                    const casa::Record& spec);
169};
170
171} // namespace
172
173#endif
Note: See TracBrowser for help on using the repository browser.