casacore
Loading...
Searching...
No Matches
MSAntennaParse.h
Go to the documentation of this file.
1// # MSAntennaParse.h: Classes to hold results from antenna grammar parser
2// # Copyright (C) 1994,1995,1997,1998,1999,2000,2001,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 MS_MSANTENNAPARSE_H
27#define MS_MSANTENNAPARSE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/ms/MSSel/MSParse.h>
32#include <casacore/ms/MSSel/MSSelectionErrorHandler.h>
33#include <casacore/casa/Arrays/Matrix.h>
34#include <bitset>
35namespace casacore { // # NAMESPACE CASACORE - BEGIN
36
37// # Forward Declarations
38
39// <summary>
40// Class to hold values from antenna grammar parser
41// </summary>
42
43// <use visibility=local>
44
45// <reviewed reviewer="" date="" tests="">
46// </reviewed>
47
48// <prerequisite>
49// # Classes you should understand before using this one.
50// </prerequisite>
51
52// <etymology>
53// MSAntennaParse is the class used to parse a antenna command.
54// </etymology>
55
56// <synopsis>
57// MSAntennaParse is used by the parser of antenna sub-expression statements.
58// The parser is written in Bison and Flex in files MSAntennaGram.y and .l.
59// The statements in there use the routines in this file to act
60// upon a reduced rule.
61// Since multiple tables can be given (with a shorthand), the table
62// names are stored in a list. The variable names can be qualified
63// by the table name and will be looked up in the appropriate table.
64//
65// The class MSAntennaParse only contains information about a table
66// used in the table command. Global variables (like a list and a vector)
67// are used in MSAntennaParse.cc to hold further information.
68//
69// Global functions are used to operate on the information.
70// The main function is the global function msAntennaCommand.
71// It executes the given STaQL command and returns the resulting ms.
72// This is, in fact, the only function to be used by a user.
73// </synopsis>
74
75// <motivation>
76// It is necessary to be able to give a ms command in ASCII.
77// This can be used in a CLI or in the table browser to get a subset
78// of a table or to sort a table.
79// </motivation>
80
81// # <todo asof="$DATE:$">
82// # A List of bugs, limitations, extensions or planned refinements.
83// # </todo>
84
85class MSAntennaParse : public MSParse {
86 public:
87 // Define the operator types (&&&, &&, and &).
99
100 // Default constructor
102
103 // Associate the ms.
105
106 MSAntennaParse(const MSAntenna& antSubTable, const TableExprNode& ant1AsTEN,
107 const TableExprNode& ant2AsTEN);
108
113
114 // Add the given antennae selection.
116 BaselineListType baselineType = CrossOnly,
117 Bool negate = False);
118
119 // Add the given baseline selection.
120 const TableExprNode* selectAntennaIds(const Vector<Int>& antennaIds1,
121 const Vector<Int>& antennaIds2,
122 BaselineListType baselineType = CrossOnly,
123 Bool negate = False);
124
125 // Select by name or station number.
127 BaselineListType baselineType = CrossOnly,
128 Bool negate = False);
130 const Vector<String>& antenna2,
131 BaselineListType baselineType = CrossOnly,
132 Bool negate = False);
133
134 const TableExprNode* selectNameOrStation(const String& antenna1, const String& antenna2,
135 BaselineListType baselineType = CrossOnly,
136 Bool negate = False);
137
138 // Selection on baseline regex
139 const TableExprNode* selectBLRegex(const std::vector<String>& lengths, Bool negate = False);
140
141 // Selection on baseline length
142 const TableExprNode* selectLength(const std::vector<double>& lengths, Bool negate = False);
143
144 // Get a pointer to the table expression node object.
145 TableExprNode node() const { return node_p; }
146 const Vector<Int>& selectedAnt1() const { return ant1List; }
147 const Vector<Int>& selectedAnt2() const { return ant2List; }
148 const Matrix<Int>& selectedBaselines() const { return baselineList; }
149
150 // Get the factor to convert the given unit to m.
151 static double getUnitFactor(const char* unit);
152
153 void setComplexity(const ComplexityLevels& level = RESET) {
154 if (level == RESET)
155 complexity.reset();
156 else
157 complexity.set(level, True);
158 }
159 std::bitset<HIGHESTLEVEL> getComplexity() { return complexity; }
161
162 private:
163 const TableExprNode* makeBLNode(const Matrix<Bool>& match, Bool negate);
165 Bool negate = False);
168 BaselineListType baselineType = CrossOnly, Bool negate = False);
169 void makeAntennaList(Vector<Int>& antList, const Vector<Int>& thisList, Bool negate = False);
170 Bool addBaseline(const Matrix<Int>& baselist, const Int ant1, const Int ant2,
171 BaselineListType baselineType = CrossOnly);
172
173 // # Data members.
174 public:
176 static std::shared_ptr<MSSelectionErrorHandler> thisMSAErrorHandler;
177 static void cleanupErrorHandler() { thisMSAErrorHandler.reset(); }
178 std::bitset<HIGHESTLEVEL> complexity;
179
180 private:
187};
188
189} // namespace casacore
190
191#endif
std::bitset< HIGHESTLEVEL > complexity
void makeAntennaList(Vector< Int > &antList, const Vector< Int > &thisList, Bool negate=False)
const Matrix< Int > & selectedBaselines() const
static void cleanupErrorHandler()
MSAntennaParse(const MeasurementSet *ms)
Associate the ms.
const TableExprNode * selectAntennaIds(const Vector< Int > &antennaIds, BaselineListType baselineType=CrossOnly, Bool negate=False)
Add the given antennae selection.
BaselineListType
Define the operator types (&&&, &&, and &).
const TableExprNode * selectNameOrStation(const Vector< String > &antenna1, const Vector< String > &antenna2, BaselineListType baselineType=CrossOnly, Bool negate=False)
static TableExprNode column2AsTEN_p
static MSAntennaParse * thisMSAParser
const TableExprNode * selectNameOrStation(const Vector< String > &antenna, BaselineListType baselineType=CrossOnly, Bool negate=False)
Select by name or station number.
const TableExprNode * selectAntennaIds(const Vector< Int > &antennaIds1, const Vector< Int > &antennaIds2, BaselineListType baselineType=CrossOnly, Bool negate=False)
Add the given baseline selection.
const TableExprNode * setTEN(TableExprNode &condition, BaselineListType baselineType=CrossOnly, Bool negate=False)
static std::shared_ptr< MSSelectionErrorHandler > thisMSAErrorHandler
const Vector< Int > & selectedAnt1() const
void setComplexity(const ComplexityLevels &level=RESET)
const Vector< Int > & selectedAnt2() const
MSAntennaParse()
Default constructor.
Bool addBaseline(const Matrix< Int > &baselist, const Int ant1, const Int ant2, BaselineListType baselineType=CrossOnly)
static TableExprNode column1AsTEN_p
const TableExprNode * selectBLRegex(const std::vector< String > &lengths, Bool negate=False)
Selection on baseline regex.
void makeBaselineList(const Vector< Int > &a1, const Vector< Int > &a2, Matrix< Int > &b, BaselineListType baselineType=CrossOnly, Bool negate=False)
MSAntennaParse(const MSAntenna &antSubTable, const TableExprNode &ant1AsTEN, const TableExprNode &ant2AsTEN)
std::bitset< HIGHESTLEVEL > getComplexity()
static double getUnitFactor(const char *unit)
Get the factor to convert the given unit to m.
Matrix< double > getBaselineLengths()
TableExprNode node() const
Get a pointer to the table expression node object.
const TableExprNode * selectLength(const std::vector< double > &lengths, Bool negate=False)
Selection on baseline length.
const TableExprNode * selectNameOrStation(const String &antenna1, const String &antenna2, BaselineListType baselineType=CrossOnly, Bool negate=False)
const TableExprNode * makeBLNode(const Matrix< Bool > &match, Bool negate)
MSParse()
Default constructor for List container class.
MeasurementSet * ms()
Get ms object.
String: the storage and methods of handling collections of characters.
Definition String.h:355
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
int Int
Definition aipstype.h:48
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41