casacore
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>
33 #include <casacore/ms/MSSel/MSParse.h>
34 #include <casacore/casa/Containers/OrderedMap.h>
35 #include <casacore/casa/Containers/MapIO.h>
36 #include <casacore/ms/MeasurementSets/MSPolarization.h>
37 #include <casacore/ms/MeasurementSets/MSPolColumns.h>
38 #include <casacore/ms/MSSel/MSPolIndex.h>
39 #include <casacore/ms/MSSel/MSDataDescIndex.h>
40 
41 namespace casacore { //# NAMESPACE CASACORE - BEGIN
42 
43 //# Forward Declarations
44 
45 
46 // <summary>
47 // Class to hold values from field grammar parser
48 // </summary>
49 
50 // <use visibility=local>
51 
52 // <reviewed reviewer="" date="" tests="">
53 // </reviewed>
54 
55 // <prerequisite>
56 //# Classes you should understand before using this one.
57 // </prerequisite>
58 
59 // <etymology>
60 // MSPolnParse is the class used to parse a polarization selection command.
61 // </etymology>
62 
63 // <synopsis>
64 //
65 // MSPolnParse is used by the parser of polarization sub-expression
66 // statements of the type [SPW:]POLN. Since this is a relatively
67 // simple expression to tokenize and parse, this parser is written
68 // without Bison or Flex. The methods of this class take an
69 // expression, and internally generate a list of the Data Description
70 // IDs that should be used to select the rows in the MS main table.
71 // The map of Polarization IDs (row numbers in the POLARIZATION
72 // sub-table) and the list of indices to be used to pick the user
73 // selected polarzation data (in the DATA columns of the MS main
74 // table) is also generated. This map is intended to be used along
75 // with the map of SPW and selected channels to apply the in-row
76 // selection (Slice on the data columns).
77 //
78 // </synopsis>
79 
80 // <motivation>
81 // It is necessary to be able to give a data selection
82 // command in ASCII. This can be used in a CLI or in the table
83 // browser to get a subset of a table or to sort a table.
84 // </motivation>
85 
86 //# <todo asof="$DATE:$">
87 //# A List of bugs, limitations, extensions or planned refinements.
88 //# </todo>
89 
90 
91 class MSPolnParse : public MSParse
92 {
93 public:
94  // Default constructor
95  MSPolnParse ();
96  // ~MSPolnParse() {cleanup();}
97 
98  // Associate the ms and the shorthand.
99  MSPolnParse (const MeasurementSet* ms);
100 
101  const TableExprNode selectFromIDList(const Vector<Int>& ddIDs);
102 
103  // Get table expression node object.
104  const TableExprNode node();
105  // static MSPolnParse* thisMSSParser;
106  void reset() {polMap_p.clear(); ddIDList_p.resize(0);}
107  void cleanup() {/*if (node_p) delete node_p;node_p=0x0;*/}
108  Int theParser(const String& command);
109  // Vector<Int>& selectedDDIDs,
110  // Matrix<Int>& selectedSpwPolnMap);
114 private:
116  const Vector<Int>& spwIDs, Vector<Int>& polnIDs,
117  Vector<Int>& polIndices);
119  OrderedMap<Int, Vector<Int> >& polIndexMap,
120  Vector<Int>& polIndices,
121  Bool addToMap=False);
122  Vector<Int> getPolnIDs(const String& polSpec, Vector<Int>& polIndices);
123  Vector<Int> getPolnIndices(const Int& polnID, const Vector<Int>& polnIDList);
124  //
125  // These are the versions used in the code.
126  Vector<Int> getPolnIDsV2(const String& polSpec, Vector<Int>& polTypes);
127  Vector<Int> getMapToDDIDsV2(const String& polExpr,
128  const Vector<Int>& spwIDs,
129  Vector<Int>& polnIDs,
130  Vector<Int>& polnIndices);
135 
136  void setIDLists(const Int key, const Int ndx, Vector<Int>& val);
137 };
138 
139 } //# NAMESPACE CASACORE - END
140 
141 #endif
OrderedMap< Int, Vector< Int > > selectedPolnMap()
Vector<Int>& selectedDDIDs, Matrix<Int>& selectedSpwPolnMap);.
Definition: MSPolnParse.h:111
Vector< Int > ddIDList_p
Definition: MSPolnParse.h:132
int Int
Definition: aipstype.h:47
Class to hold values from an ms grammar parser.
Definition: MSParse.h:93
void reset()
static MSPolnParse* thisMSSParser;
Definition: MSPolnParse.h:106
Vector< Int > getPolnIDsV2(const String &polSpec, Vector< Int > &polTypes)
These are the versions used in the code.
TableExprNode node_p
Definition: MSPolnParse.h:131
OrderedMap< Int, Vector< Int > > polMap_p
Definition: MSPolnParse.h:133
Handle class for a table column expression tree.
Definition: ExprNode.h:578
const TableExprNode selectFromIDList(const Vector< Int > &ddIDs)
Vector< Int > selectedDDIDs()
Definition: MSPolnParse.h:113
const TableExprNode node()
Get table expression node object.
Map with keys ordered.
Definition: OrderedMap.h:42
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:91
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:39
const Bool False
Definition: aipstype.h:41
OrderedMap< Int, Vector< Vector< Int > > > selectedSetupMap()
Definition: MSPolnParse.h:112
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)
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:223
OrderedMap< Int, Vector< Vector< Int > > > setupMap_p
Definition: MSPolnParse.h:134
Vector< Int > getPolnIndices(const Int &polnID, const Vector< Int > &polnIDList)
void resize(size_t len, Bool copyValues=False)
Definition: Vector.h:171
Vector< Int > getMapToDDIDsV2(const String &polExpr, const Vector< Int > &spwIDs, Vector< Int > &polnIDs, Vector< Int > &polnIndices)
Int theParser(const String &command)
MeasurementSet * ms()
Get ms object.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
Vector< Int > matchPolIDsToPolTableRow(const Vector< Int > &polIds, OrderedMap< Int, Vector< Int > > &polIndexMap, Vector< Int > &polIndices, Bool addToMap=False)