casa  5.7.0-16
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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: 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 
28 #ifndef MS_MSANTENNAPARSE_H
29 #define MS_MSANTENNAPARSE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
36 #include <bitset>
37 namespace casacore { //# NAMESPACE CASACORE - BEGIN
38 
39  //# Forward Declarations
40 
41  // <summary>
42  // Class to hold values from antenna grammar parser
43  // </summary>
44 
45  // <use visibility=local>
46 
47  // <reviewed reviewer="" date="" tests="">
48  // </reviewed>
49 
50  // <prerequisite>
51  //# Classes you should understand before using this one.
52  // </prerequisite>
53 
54  // <etymology>
55  // MSAntennaParse is the class used to parse a antenna command.
56  // </etymology>
57 
58  // <synopsis>
59  // MSAntennaParse is used by the parser of antenna sub-expression statements.
60  // The parser is written in Bison and Flex in files MSAntennaGram.y and .l.
61  // The statements in there use the routines in this file to act
62  // upon a reduced rule.
63  // Since multiple tables can be given (with a shorthand), the table
64  // names are stored in a list. The variable names can be qualified
65  // by the table name and will be looked up in the appropriate table.
66  //
67  // The class MSAntennaParse only contains information about a table
68  // used in the table command. Global variables (like a list and a vector)
69  // are used in MSAntennaParse.cc to hold further information.
70  //
71  // Global functions are used to operate on the information.
72  // The main function is the global function msAntennaCommand.
73  // It executes the given STaQL command and returns the resulting ms.
74  // This is, in fact, the only function to be used by a user.
75  // </synopsis>
76 
77  // <motivation>
78  // It is necessary to be able to give a ms command in ASCII.
79  // This can be used in a CLI or in the table browser to get a subset
80  // of a table or to sort a table.
81  // </motivation>
82 
83  //# <todo asof="$DATE:$">
84  //# A List of bugs, limitations, extensions or planned refinements.
85  //# </todo>
86 
87 
88  class MSAntennaParse : public MSParse
89  {
90 
91  public:
92  // Define the operator types (&&&, &&, and &).
95 
96  // Default constructor
98 
99  // Associate the ms.
101 
102  MSAntennaParse (const MSAntenna& antSubTable,
103  const TableExprNode& ant1AsTEN, const TableExprNode& ant2AsTEN);
104 
106 
107  // Add the given antennae selection.
108  const TableExprNode* selectAntennaIds(const Vector<Int>& antennaIds,
109  BaselineListType baselineType=CrossOnly,
110  Bool negate=False);
111 
112  // Add the given baseline selection.
113  const TableExprNode* selectAntennaIds(const Vector<Int>& antennaIds1,
114  const Vector<Int>& antennaIds2,
115  BaselineListType baselineType=CrossOnly,
116  Bool negate=False);
117 
118  // Select by name or station number.
119  const TableExprNode* selectNameOrStation(const Vector<String>& antenna,
120  BaselineListType baselineType=CrossOnly,
121  Bool negate=False);
122  const TableExprNode* selectNameOrStation(const Vector<String>& antenna1,
123  const Vector<String>& antenna2,
124  BaselineListType baselineType=CrossOnly,
125  Bool negate=False);
126 
127  const TableExprNode* selectNameOrStation(const String& antenna1,
128  const String& antenna2,
129  BaselineListType baselineType=CrossOnly,
130  Bool negate=False);
131 
132  // Selection on baseline regex
133  const TableExprNode* selectBLRegex(const std::vector<String>& lengths,
134  Bool negate=False);
135 
136  // Selection on baseline length
137  const TableExprNode* selectLength(const std::vector<double>& lengths,
138  Bool negate=False);
139 
140  // Get a pointer to the table expression node object.
142  { return node_p; }
143  const Vector<Int>& selectedAnt1() const
144  { return ant1List; }
145  const Vector<Int>& selectedAnt2() const
146  { return ant2List; }
148  { return baselineList; }
149 
150  // Get the factor to convert the given unit to m.
151  static double getUnitFactor (const char* unit);
152 
154  {if (level==RESET) complexity.reset(); else complexity.set(level,True);}
155  std::bitset<HIGHESTLEVEL> getComplexity() {return complexity;}
157  private:
158  const TableExprNode* makeBLNode (const Matrix<Bool>& match,
159  Bool negate);
160  const TableExprNode* setTEN(TableExprNode& condition,
161  BaselineListType baselineType=CrossOnly,
162  Bool negate=False);
164  void makeBaselineList(const Vector<Int>&a1, const Vector<Int>&a2, Matrix<Int>&b,
165  BaselineListType baselineType=CrossOnly,
166  Bool negate=False);
167  void makeAntennaList(Vector<Int>& antList,const Vector<Int>& thisList,
168  Bool negate=False);
169  Bool addBaseline(const Matrix<Int>& baselist,
170  const Int ant1, const Int ant2,
171  BaselineListType baselineType=CrossOnly);
172 
173  //# Data members.
174  public:
177  static void cleanupErrorHandler() {thisMSAErrorHandler.reset();}
178  std::bitset<HIGHESTLEVEL> complexity;
179  private:
186  };
187 
188 } //# NAMESPACE CASACORE - END
189 
190 #endif
static double getUnitFactor(const char *unit)
Get the factor to convert the given unit to m.
int Int
Definition: aipstype.h:50
Class to hold values from an ms grammar parser.
Definition: MSParse.h:93
Handle class for a table column expression tree.
Definition: ExprNode.h:155
const TableExprNode * setTEN(TableExprNode &condition, BaselineListType baselineType=CrossOnly, Bool negate=False)
static MSAntennaParse * thisMSAParser
const TableExprNode * selectBLRegex(const std::vector< String > &lengths, Bool negate=False)
Selection on baseline regex.
Class to hold values from antenna grammar parser.
const Vector< Int > & selectedAnt2() const
static void cleanupErrorHandler()
void setComplexity(const ComplexityLevels &level=RESET)
const Matrix< Int > & selectedBaselines() const
A Table intended to hold a MeasurementSet ANTENNA table.
Definition: MSAntenna.h:79
static CountedPtr< MSSelectionErrorHandler > thisMSAErrorHandler
Bool addBaseline(const Matrix< Int > &baselist, const Int ant1, const Int ant2, BaselineListType baselineType=CrossOnly)
void makeAntennaList(Vector< Int > &antList, const Vector< Int > &thisList, Bool negate=False)
std::bitset< HIGHESTLEVEL > complexity
Referenced counted pointer for constant data.
Definition: VisModelData.h:42
const TableExprNode * makeBLNode(const Matrix< Bool > &match, Bool negate)
std::bitset< HIGHESTLEVEL > getComplexity()
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const TableExprNode * selectLength(const std::vector< double > &lengths, Bool negate=False)
Selection on baseline length.
const TableExprNode * selectAntennaIds(const Vector< Int > &antennaIds, BaselineListType baselineType=CrossOnly, Bool negate=False)
Add the given antennae selection.
const Bool False
Definition: aipstype.h:44
TableExprNode node() const
Get a pointer to the table expression node object.
BaselineListType
Define the operator types (&amp;&amp;&amp;, &amp;&amp;, and &amp;).
A Table intended to hold astronomical data (a set of Measurements).
void makeBaselineList(const Vector< Int > &a1, const Vector< Int > &a2, Matrix< Int > &b, BaselineListType baselineType=CrossOnly, Bool negate=False)
Matrix< double > getBaselineLengths()
MSAntennaParse()
Default constructor.
const TableExprNode * selectNameOrStation(const Vector< String > &antenna, BaselineListType baselineType=CrossOnly, Bool negate=False)
Select by name or station number.
String: the storage and methods of handling collections of characters.
Definition: String.h:223
static TableExprNode column1AsTEN_p
const Vector< Int > & selectedAnt1() const
MeasurementSet * ms()
Get ms object.
const Bool True
Definition: aipstype.h:43
static TableExprNode column2AsTEN_p
#define casacore
&lt;X11/Intrinsic.h&gt; #defines true, false, casacore::Bool, and String.
Definition: X11Intrinsic.h:42