casacore
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>
33 #include <casacore/ms/MSSel/MSParse.h>
34 #include <casacore/ms/MSSel/MSSelectionErrorHandler.h>
35 #include <casacore/casa/Arrays/Matrix.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.
120  BaselineListType baselineType=CrossOnly,
121  Bool negate=False);
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);
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
Referenced counted pointer for constant data.
Definition: CountedPtr.h:81
std::bitset< HIGHESTLEVEL > complexity
void makeAntennaList(Vector< Int > &antList, const Vector< Int > &thisList, Bool negate=False)
std::bitset< HIGHESTLEVEL > getComplexity()
static void cleanupErrorHandler()
MSAntennaParse(const MeasurementSet *ms)
Associate the ms.
const Vector< Int > & selectedAnt1() const
BaselineListType
Define the operator types (&&&, &&, and &).
static TableExprNode column2AsTEN_p
static MSAntennaParse * thisMSAParser
const TableExprNode * setTEN(TableExprNode &condition, BaselineListType baselineType=CrossOnly, Bool negate=False)
const TableExprNode * selectAntennaIds(const Vector< Int > &antennaIds1, const Vector< Int > &antennaIds2, BaselineListType baselineType=CrossOnly, Bool negate=False)
Add the given baseline selection.
const TableExprNode * selectNameOrStation(const Vector< String > &antenna1, const Vector< String > &antenna2, BaselineListType baselineType=CrossOnly, Bool negate=False)
const TableExprNode * makeBLNode(const Matrix< Bool > &match, Bool negate)
const Vector< Int > & selectedAnt2() const
void setComplexity(const ComplexityLevels &level=RESET)
const TableExprNode * selectNameOrStation(const Vector< String > &antenna, BaselineListType baselineType=CrossOnly, Bool negate=False)
Select by name or station number.
MSAntennaParse()
Default constructor.
const TableExprNode * selectLength(const std::vector< double > &lengths, Bool negate=False)
Selection on baseline length.
Bool addBaseline(const Matrix< Int > &baselist, const Int ant1, const Int ant2, BaselineListType baselineType=CrossOnly)
static TableExprNode column1AsTEN_p
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)
const TableExprNode * selectBLRegex(const std::vector< String > &lengths, Bool negate=False)
Selection on baseline regex.
static double getUnitFactor(const char *unit)
Get the factor to convert the given unit to m.
TableExprNode node() const
Get a pointer to the table expression node object.
const TableExprNode * selectNameOrStation(const String &antenna1, const String &antenna2, BaselineListType baselineType=CrossOnly, Bool negate=False)
Matrix< double > getBaselineLengths()
static CountedPtr< MSSelectionErrorHandler > thisMSAErrorHandler
const TableExprNode * selectAntennaIds(const Vector< Int > &antennaIds, BaselineListType baselineType=CrossOnly, Bool negate=False)
Add the given antennae selection.
const Matrix< Int > & selectedBaselines() const
MeasurementSet * ms()
Get ms object.
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43