casacore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSPolnParse.h
Go to the documentation of this file.
1 //# MSPolnParse.h: Classes to hold results from poln grammar parseing
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_MSPOLNPARSE_H
29 #define MS_MSPOLNPARSE_H
30 
31 //# Includes
32 #include <casacore/casa/aips.h>
38 
39 namespace casacore { //# NAMESPACE CASACORE - BEGIN
40 
41 //# Forward Declarations
42 
43 
44 // <summary>
45 // Class to hold values from field grammar parser
46 // </summary>
47 
48 // <use visibility=local>
49 
50 // <reviewed reviewer="" date="" tests="">
51 // </reviewed>
52 
53 // <prerequisite>
54 //# Classes you should understand before using this one.
55 // </prerequisite>
56 
57 // <etymology>
58 // MSPolnParse is the class used to parse a polarization selection command.
59 // </etymology>
60 
61 // <synopsis>
62 //
63 // MSPolnParse is used by the parser of polarization sub-expression
64 // statements of the type [SPW:]POLN. Since this is a relatively
65 // simple expression to tokenize and parse, this parser is written
66 // without Bison or Flex. The methods of this class take an
67 // expression, and internally generate a list of the Data Description
68 // IDs that should be used to select the rows in the MS main table.
69 // The map of Polarization IDs (row numbers in the POLARIZATION
70 // sub-table) and the list of indices to be used to pick the user
71 // selected polarzation data (in the DATA columns of the MS main
72 // table) is also generated. This map is intended to be used along
73 // with the map of SPW and selected channels to apply the in-row
74 // selection (Slice on the data columns).
75 //
76 // </synopsis>
77 
78 // <motivation>
79 // It is necessary to be able to give a data selection
80 // command in ASCII. This can be used in a CLI or in the table
81 // browser to get a subset of a table or to sort a table.
82 // </motivation>
83 
84 //# <todo asof="$DATE:$">
85 //# A List of bugs, limitations, extensions or planned refinements.
86 //# </todo>
87 
88 
89 class MSPolnParse : public MSParse
90 {
91 public:
92  // Default constructor
93  MSPolnParse ();
94  // ~MSPolnParse() {cleanup();}
95 
96  // Associate the ms and the shorthand.
97  MSPolnParse (const MeasurementSet* ms);
98 
99  const TableExprNode selectFromIDList(const Vector<Int>& ddIDs);
100 
101  // Get table expression node object.
102  const TableExprNode node();
103  // static MSPolnParse* thisMSSParser;
104  void reset() {polMap_p.clear(); ddIDList_p.resize(0);}
105  void cleanup() {/*if (node_p) delete node_p;node_p=0x0;*/}
106  Int theParser(const String& command);
107  // Vector<Int>& selectedDDIDs,
108  // Matrix<Int>& selectedSpwPolnMap);
109  std::map<Int, Vector<Int> > selectedPolnMap() {return polMap_p;}
110  std::map<Int, Vector<Vector<Int> > > selectedSetupMap() {return setupMap_p;}
112 private:
114  const Vector<Int>& spwIDs, Vector<Int>& polnIDs,
115  Vector<Int>& polIndices);
117  std::map<Int, Vector<Int> >& polIndexMap,
118  Vector<Int>& polIndices,
119  Bool addToMap=False);
120  Vector<Int> getPolnIDs(const String& polSpec, Vector<Int>& polIndices);
121  Vector<Int> getPolnIndices(const Int& polnID, const Vector<Int>& polnIDList);
122  //
123  // These are the versions used in the code.
124  Vector<Int> getPolnIDsV2(const String& polSpec, Vector<Int>& polTypes);
125  Vector<Int> getMapToDDIDsV2(const String& polExpr,
126  const Vector<Int>& spwIDs,
127  Vector<Int>& polnIDs,
128  Vector<Int>& polnIndices);
131  std::map<Int, Vector<Int> > polMap_p;
132  std::map<Int, Vector<Vector<Int> > > setupMap_p;
133 
134  void setIDLists(const Int key, const Int ndx, Vector<Int>& val);
135 };
136 
137 } //# NAMESPACE CASACORE - END
138 
139 #endif
Vector< Int > ddIDList_p
Definition: MSPolnParse.h:130
int Int
Definition: aipstype.h:50
Class to hold values from an ms grammar parser.
Definition: MSParse.h:93
void reset()
static MSPolnParse* thisMSSParser;
Definition: MSPolnParse.h:104
Vector< Int > getPolnIDsV2(const String &polSpec, Vector< Int > &polTypes)
These are the versions used in the code.
TableExprNode node_p
Definition: MSPolnParse.h:129
Handle class for a table column expression tree.
Definition: ExprNode.h:156
const TableExprNode selectFromIDList(const Vector< Int > &ddIDs)
std::map< Int, Vector< Vector< Int > > > selectedSetupMap()
Definition: MSPolnParse.h:110
Vector< Int > selectedDDIDs()
Definition: MSPolnParse.h:111
const TableExprNode node()
Get table expression node object.
std::map< Int, Vector< Int > > selectedPolnMap()
Vector&lt;Int&gt;&amp; selectedDDIDs, Matrix&lt;Int&gt;&amp; selectedSpwPolnMap);.
Definition: MSPolnParse.h:109
MSPolnParse()
Default constructor.
Class to handle lookup or indexing into a MS DATA_DESC subtable.
Class to handle lookup or indexing into an MS POLARIZATION subtable.
Definition: MSPolIndex.h:83
Class to hold values from field grammar parser.
Definition: MSPolnParse.h:89
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool False
Definition: aipstype.h:44
void setIDLists(const Int key, const Int ndx, Vector< Int > &val)
A Table intended to hold astronomical data (a set of Measurements).
Vector< Int > getPolnIDs(const String &polSpec, Vector< Int > &polIndices)
void resize(size_t len, bool copyValues=false)
Definition: Vector.h:168
std::map< Int, Vector< Vector< Int > > > setupMap_p
Definition: MSPolnParse.h:132
Vector< Int > getMapToDDIDs(MSDataDescIndex &msDDNdx, MSPolarizationIndex &msPolNdx, const Vector< Int > &spwIDs, Vector< Int > &polnIDs, Vector< Int > &polIndices)
String: the storage and methods of handling collections of characters.
Definition: String.h:225
Vector< Int > getPolnIndices(const Int &polnID, const Vector< Int > &polnIDList)
Vector< Int > getMapToDDIDsV2(const String &polExpr, const Vector< Int > &spwIDs, Vector< Int > &polnIDs, Vector< Int > &polnIndices)
std::map< Int, Vector< Int > > polMap_p
Definition: MSPolnParse.h:131
Int theParser(const String &command)
MeasurementSet * ms()
Get ms object.
Vector< Int > matchPolIDsToPolTableRow(const Vector< Int > &polIds, std::map< Int, Vector< Int > > &polIndexMap, Vector< Int > &polIndices, Bool addToMap=False)