casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DDMapper.h
Go to the documentation of this file.
1 //# DDMapper.h: this defines DDMapper
2 //# Copyright (C) 2000,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 //# $Id$
27 #ifndef FLAGGING_DDMAPPER_H
28 #define FLAGGING_DDMAPPER_H
29 
30 #include <casa/Arrays/Vector.h>
31 #include <casa/Arrays/Cube.h>
32 #include <casa/Exceptions/Error.h>
34 
35 namespace casa { //# NAMESPACE CASA - BEGIN
36 
37 // <summary>
38 // Abstract Derived casacore::Data Mapper class
39 // </summary>
40 
41 // <use visibility=local>
42 
43 // <reviewed reviewer="" date="" tests="" demos="">
44 // </reviewed>
45 
46 // <synopsis>
47 // The DDMapper class defines an interface for mapping complex visibilities
48 // into casacore::Float derived values. DDMappers are used by several flagging
49 // agents.
50 // </synopsis>
51 //
52 // <motivation>
53 // A lot of algorithms are expressed in terms of some real value
54 // derived from a set of visibilities (i.e., |XX|, |XX|-|YY|, etc.). The
55 // DDMapper hierarchy provides a uniform interface for deriving such values.
56 // </motivation>
57 //
58 // <todo asof="2001/04/16">
59 // <li> add this feature
60 // </todo>
61 
62 class DDMapper
63 {
64 protected:
66  casacore::uShort corrmask; // mask of affected correlations
67 
68 public:
69  DDMapper () { valid=false; }
70  virtual ~DDMapper () {};
71 
72  // Given a vector of correlation types, recomputes internal indices.
73  // returns true if all indices were found successfully.
74  virtual casacore::Bool reset ( const casacore::Vector<casacore::Int> &corr ) =0;
75 
76  // Maps a slice of visibilities at (*,ich,irow) from the given
77  // viscube into a the derived value.
79 
80  // Returns the "mask" of correlations which are used by this mapper.
81  // by this mapper. Bit "i" is set if corr. "i" is used.
82  casacore::uShort corrMask () const { return corrmask; }
83 
84  // Returns true if given correlations is masked
85  casacore::Bool masked (casacore::uInt icorr) const { return (corrmask&(1<<icorr)) != 0; }
86 
87  // Tells if mapper is valid
88  casacore::Bool isValid () { return valid; }
89 };
90 
91 // <summary>
92 // DDDummy: dummy mapper, throws an excpetion if any methods are called
93 // </summary>
94 // <use visibility=local>
95 class DDDummy : public DDMapper
96 {
97 public:
98  DDDummy ();
99  ~DDDummy ();
100 
101  virtual void puke () const
102  { throw(casacore::AipsError("Uninitialized DDMapper used")); }
103 
105  { puke(); return false; }
107  { puke(); return 0.; }
108 
109 };
110 
111 // <summary>
112 // DDFunc: maps correlation A into func(A)
113 // </summary>
114 // <use visibility=local>
115 class DDFunc : public DDMapper
116 {
117 public:
119 
120  DDFunc ( FuncSignature fsig,const casacore::String &corr );
121  ~DDFunc() {};
122 
123  virtual casacore::Bool reset ( const casacore::Vector<casacore::Int> &corr );
125 
126 // Define these functions, because using std::real/imag in getFunction
127 // matches multiple functions.
128  static casacore::Float real (const casacore::Complex&);
129  static casacore::Float imag (const casacore::Complex&);
130 
131 // Static function to map a function name into a function pointer
132 // Functions currently recognized: ABS ARG NORM RE IM
134 
135 // Static function to map string expression into a DDMapper
136 // Possible syntax is:
137 // <FUNC> <CC>
138 // SUM <FUNC> <CC> <CC>
139 // DIFF <FUNC> <CC> <CC>
140 // <FUNC> SUM <CC> <CC>
141 // <FUNC> DIFF <CC> <CC>
142  static DDMapper * getMapper ( casacore::String &desc,const casacore::Vector<casacore::String> &expr,casacore::Bool throw_excp=false );
143 
144 protected:
148 };
149 
150 // <summary>
151 // DDSumFunc: maps two correlations A and B into func(A)+func(B)
152 // </summary>
153 // <use visibility=local>
154 class DDSumFunc : public DDFunc
155 {
156 public:
157  DDSumFunc ( FuncSignature fsig,const casacore::String &corr1,const casacore::String &corr2 );
158  virtual ~DDSumFunc() {};
159 
160  virtual casacore::Bool reset ( const casacore::Vector<casacore::Int> &corr );
162 
163 protected:
166 };
167 
168 // <summary>
169 // DDFuncSum: maps two correlations A and B into func(A+B)
170 // </summary>
171 // <use visibility=local>
172 class DDFuncSum : public DDSumFunc
173 {
174 public:
175  DDFuncSum ( FuncSignature fsig,const casacore::String &corr1,const casacore::String &corr2 );
176  virtual ~DDFuncSum() {};
177 
179 };
180 
181 // <summary>
182 // DDFuncDiff: maps two correlations A and B into func(A-B)
183 // </summary>
184 // <use visibility=local>
185 class DDFuncDiff : public DDSumFunc
186 {
187 public:
188  DDFuncDiff ( FuncSignature fsig,const casacore::String &corr1,const casacore::String &corr2 );
189  virtual ~DDFuncDiff() {};
190 
192 };
193 
194 // <summary>
195 // DDDiffFunc: maps two correlations A and B into func(A)-func(B)
196 // </summary>
197 // <use visibility=local>
198 class DDDiffFunc : public DDSumFunc
199 {
200 public:
201  DDDiffFunc ( FuncSignature fsig,const casacore::String &corr1,const casacore::String &corr2 );
202  virtual ~DDDiffFunc() {};
203 
205 };
206 
207 // helper function to split an expression into elements
209 
210 
211 } //# NAMESPACE CASA - END
212 
213 #endif
virtual casacore::Float map(const casacore::Cube< casacore::Complex > &vis, casacore::uInt ich, casacore::uInt irow) const
Maps a slice of visibilities at (*,ich,irow) from the given viscube into a the derived value...
int Int
Definition: aipstype.h:50
static FuncSignature getFunction(const casacore::String &name)
Static function to map a function name into a function pointer Functions currently recognized: ABS AR...
virtual ~DDFuncDiff()
Definition: DDMapper.h:189
DDFuncDiff(FuncSignature fsig, const casacore::String &corr1, const casacore::String &corr2)
virtual casacore::Float map(const casacore::Cube< casacore::Complex > &vis, casacore::uInt ich, casacore::uInt irow) const
Maps a slice of visibilities at (*,ich,irow) from the given viscube into a the derived value...
casacore::uShort corrmask
Definition: DDMapper.h:66
DDFunc(FuncSignature fsig, const casacore::String &corr)
virtual casacore::Bool reset(const casacore::Vector< casacore::Int > &corr)
Given a vector of correlation types, recomputes internal indices.
Abstract Derived casacore::Data Mapper class.
Definition: DDMapper.h:62
DDDiffFunc(FuncSignature fsig, const casacore::String &corr1, const casacore::String &corr2)
virtual casacore::Float map(const casacore::Cube< casacore::Complex > &vis, casacore::uInt ich, casacore::uInt irow) const
Maps a slice of visibilities at (*,ich,irow) from the given viscube into a the derived value...
casacore::Bool isValid()
Tells if mapper is valid.
Definition: DDMapper.h:88
DDFuncSum: maps two correlations A and B into func(A+B)
Definition: DDMapper.h:172
FuncSignature func
Definition: DDMapper.h:147
DDDummy: dummy mapper, throws an excpetion if any methods are called.
Definition: DDMapper.h:95
casacore::Vector< casacore::String > splitExpression(const casacore::Vector< casacore::String > &expr0)
helper function to split an expression into elements
DDDiffFunc: maps two correlations A and B into func(A)-func(B)
Definition: DDMapper.h:198
casacore::Stokes::StokesTypes corrtype2
Definition: DDMapper.h:165
casacore::Int icorr
Definition: DDMapper.h:145
ABSTRACT CLASSES Abstract class for colors Any implementation of color should be able to provide a hexadecimal form of the if a human readable name(i.e."black").In many places throughout the plotter
virtual casacore::Bool reset(const casacore::Vector< casacore::Int > &)
Given a vector of correlation types, recomputes internal indices.
Definition: DDMapper.h:104
static casacore::Float imag(const casacore::Complex &)
StokesTypes
The Stokes types are defined by this enum.
Definition: Stokes.h:66
virtual casacore::Bool reset(const casacore::Vector< casacore::Int > &corr)=0
Given a vector of correlation types, recomputes internal indices.
casacore::Stokes::StokesTypes corrtype
Definition: DDMapper.h:146
virtual ~DDMapper()
Definition: DDMapper.h:70
DDFunc: maps correlation A into func(A)
Definition: DDMapper.h:115
virtual casacore::Float map(const casacore::Cube< casacore::Complex > &vis, casacore::uInt ich, casacore::uInt irow) const
Maps a slice of visibilities at (*,ich,irow) from the given viscube into a the derived value...
virtual casacore::Float map(const casacore::Cube< casacore::Complex > &, casacore::uInt, casacore::uInt) const
Maps a slice of visibilities at (*,ich,irow) from the given viscube into a the derived value...
Definition: DDMapper.h:106
DDFuncDiff: maps two correlations A and B into func(A-B)
Definition: DDMapper.h:185
casacore::Bool masked(casacore::uInt icorr) const
Returns true if given correlations is masked.
Definition: DDMapper.h:85
virtual ~DDDiffFunc()
Definition: DDMapper.h:202
casacore::Bool valid
Definition: DDMapper.h:65
casacore::uShort corrMask() const
Returns the &quot;mask&quot; of correlations which are used by this mapper.
Definition: DDMapper.h:82
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
virtual void puke() const
Definition: DDMapper.h:101
virtual ~DDFuncSum()
Definition: DDMapper.h:176
casacore::Int icorr2
Definition: DDMapper.h:164
float Float
Definition: aipstype.h:54
virtual casacore::Float map(const casacore::Cube< casacore::Complex > &vis, casacore::uInt ich, casacore::uInt irow) const =0
Maps a slice of visibilities at (*,ich,irow) from the given viscube into a the derived value...
DDSumFunc: maps two correlations A and B into func(A)+func(B)
Definition: DDMapper.h:154
DDFuncSum(FuncSignature fsig, const casacore::String &corr1, const casacore::String &corr2)
casacore::Float(* FuncSignature)(const casacore::Complex &)
Definition: DDMapper.h:118
Base class for all Casacore library errors.
Definition: Error.h:134
virtual casacore::Bool reset(const casacore::Vector< casacore::Int > &corr)
Given a vector of correlation types, recomputes internal indices.
DDSumFunc(FuncSignature fsig, const casacore::String &corr1, const casacore::String &corr2)
virtual ~DDSumFunc()
Definition: DDMapper.h:158
String: the storage and methods of handling collections of characters.
Definition: String.h:223
virtual casacore::Float map(const casacore::Cube< casacore::Complex > &vis, casacore::uInt ich, casacore::uInt irow) const
Maps a slice of visibilities at (*,ich,irow) from the given viscube into a the derived value...
static DDMapper * getMapper(casacore::String &desc, const casacore::Vector< casacore::String > &expr, casacore::Bool throw_excp=false)
Static function to map string expression into a DDMapper Possible syntax is: &lt;FUNC&gt; &lt;CC&gt; SUM &lt;FUNC&gt; &lt;...
static casacore::Float real(const casacore::Complex &)
Define these functions, because using std::real/imag in getFunction matches multiple functions...
unsigned int uInt
Definition: aipstype.h:51
unsigned short uShort
Definition: aipstype.h:49