casacore
Loading...
Searching...
No Matches
WCLELMask.h
Go to the documentation of this file.
1// # WCLELMask.h: Class to define a mask as a LEL expression
2// # Copyright (C) 2000,2003
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 IMAGES_WCLELMASK_H
27#define IMAGES_WCLELMASK_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/images/Regions/WCRegion.h>
32#include <casacore/lattices/LRegions/RegionType.h>
33#include <casacore/coordinates/Coordinates/CoordinateSystem.h>
34#include <casacore/casa/Arrays/Vector.h>
35#include <casacore/casa/Quanta/Quantum.h>
36
37namespace casacore { // # NAMESPACE CASACORE - BEGIN
38
39// # Forward Declarations
40class LCRegion;
41class TableRecord;
42class IPosition;
43template <class T>
44class ImageExpr;
45template <class T>
46class LatticeExpr;
47class LatticeExprNode;
48
49// <summary>
50// Class to define a mask as a LEL expression
51// </summary>
52
53// <use visibility=export>
54
55// <reviewed reviewer="" date="" tests="">
56// </reviewed>
57
58// <prerequisite>
59// <li> <linkto class=WCRegion>WCRegion</linkto>
60// <li> <linkto class=ImageExpr>ImageExpr</linkto>
61// </prerequisite>
62
63// <synopsis>
64// The WCLELMask class is a specialization of class
65// <linkto class=WCRegion>WCRegion</linkto>.
66// <br>
67// It can be used to define an on-the-fly mask for an image
68// using a boolean <linkto class=LatticeExpr>LatticeExpr</linkto>.
69// The contents of the mask are calculated on the fly from the expression.
70// Thus the mask may change if the data in the image(s) used in the
71// expression change.
72// <note role=caution>
73// This mask is only persistent if constructed from an expression string.
74// When constructed from an <linkto class=ImageExpr>ImageExpr</linkto>
75// the mask is not persistent.
76// </note>
77// </synopsis>
78
79// <example>
80// </example>
81
82// <motivation>
83// Users must be able to specify a mask based on an expression.
84// </motivation>
85
86// # <todo asof="1998/05/20">
87// # <li>
88// # </todo>
89
90class WCLELMask : public WCRegion {
91 public:
93
94 // Construct from the given expression command.
95 // The command will be parsed and converted to an ImageExpr.
96 // <group>
97 explicit WCLELMask(const String& command);
98 explicit WCLELMask(const char* command);
99 // </group>
100
101 // Construct from the given image expression.
102 explicit WCLELMask(const ImageExpr<Bool>& expr);
103
104 // Construct from the given lattice expression.
105 explicit WCLELMask(const LatticeExpr<Bool>& expr);
106
107 // Construct from the given lattice expression.
108 // This constructor makes it possible to have an expression with an
109 // unknown shape (e.g. using LEL function INDEXIN).
110 // If the shape is known, the LatticeExprNode will be converted to
111 // a LatticeExpr<Bool>.
112 explicit WCLELMask(const LatticeExprNode& expr);
113
114 // Copy constructor (copy semantics).
115 WCLELMask(const WCLELMask& other);
116
117 // Destructor
118 virtual ~WCLELMask();
119
120 // Assignment (copy semantics)
122
123 // Comparison
124 virtual Bool operator==(const WCRegion& other) const;
125
126 // Clone a WCLELMask object.
127 virtual WCRegion* cloneRegion() const;
128
129 // Get the dimensionality (i.e. the number of axes).
130 virtual uInt ndim() const;
131
132 // WCLELMask cannot extend a region.
133 virtual Bool canExtend() const;
134
135 // Convert to an LCRegion using the given new coordinate system and shape.
136 // If the region has coordinates, the WCRegion implementation will
137 // be called. Otherwise the LatticeExpr is returned after checking
138 // that the shape matches.
139 virtual LCRegion* toLCRegion(const CoordinateSystem& cSys, const IPosition& latticeShape) const;
140
141 // Convert to an LCRegion using the supplied <src>CoordinateSystem</src>
142 // and shape.
143 // It checks that coordinates match and that axes are not swapped.
144 virtual LCRegion* doToLCRegion(const CoordinateSystem& cSys, const IPosition& latticeShape,
145 const IPosition& pixelAxesMap, const IPosition& outOrder) const;
146
147 // Convert the WCLELMask object to a record.
148 // The record can be used to make the object persistent.
149 // The <src>tableName</src> argument can be used by derived
150 // classes (e.g. LCPagedMask) to put very large objects.
151 virtual TableRecord toRecord(const String& tableName) const;
152
153 // Convert to a WCLELMask from a record.
154 static WCLELMask* fromRecord(const TableRecord& rec, const String& tableName);
155
156 // Returns WCLELMask
158
159 // Return region type. Returns the class name
160 virtual String type() const;
161
162 const ImageExpr<Bool>* getImageExpr() const { return itsImageExpr; }
163
164 private:
165 // Process the command.
167
168 // Initialize as a LatticeExprNode if expression's shape is unknown.
169 // Otherwise as a LatticeExpr<Bool> if coordinates are unknown.
170 // Otherwise as an ImageExpr<Bool>.
171 void init(const LatticeExprNode& expr);
172
177};
178
179} // namespace casacore
180
181#endif
String: the storage and methods of handling collections of characters.
Definition String.h:355
void init(const LatticeExprNode &expr)
Initialize as a LatticeExprNode if expression's shape is unknown.
virtual WCRegion * cloneRegion() const
Clone a WCLELMask object.
LatticeExpr< Bool > * itsLattExpr
Definition WCLELMask.h:175
virtual ~WCLELMask()
Destructor.
const ImageExpr< Bool > * getImageExpr() const
Definition WCLELMask.h:162
WCLELMask(const WCLELMask &other)
Copy constructor (copy semantics).
virtual String type() const
Return region type.
WCLELMask(const ImageExpr< Bool > &expr)
Construct from the given image expression.
WCLELMask(const LatticeExpr< Bool > &expr)
Construct from the given lattice expression.
virtual LCRegion * toLCRegion(const CoordinateSystem &cSys, const IPosition &latticeShape) const
Convert to an LCRegion using the given new coordinate system and shape.
virtual Bool canExtend() const
WCLELMask cannot extend a region.
WCLELMask & operator=(const WCLELMask &other)
Assignment (copy semantics).
static String className()
Returns WCLELMask.
virtual TableRecord toRecord(const String &tableName) const
Convert the WCLELMask object to a record.
virtual Bool operator==(const WCRegion &other) const
Comparison.
LatticeExprNode * itsLattNode
Definition WCLELMask.h:176
void processCommand()
Process the command.
ImageExpr< Bool > * itsImageExpr
Definition WCLELMask.h:174
virtual uInt ndim() const
Get the dimensionality (i.e.
virtual LCRegion * doToLCRegion(const CoordinateSystem &cSys, const IPosition &latticeShape, const IPosition &pixelAxesMap, const IPosition &outOrder) const
Convert to an LCRegion using the supplied CoordinateSystem and shape.
WCLELMask(const char *command)
WCLELMask(const String &command)
Construct from the given expression command.
static WCLELMask * fromRecord(const TableRecord &rec, const String &tableName)
Convert to a WCLELMask from a record.
WCLELMask(const LatticeExprNode &expr)
Construct from the given lattice expression.
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40