casacore
Loading...
Searching...
No Matches
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: 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_MSPOLNPARSE_H
27#define MS_MSPOLNPARSE_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/ms/MSSel/MSParse.h>
32#include <casacore/ms/MeasurementSets/MSPolarization.h>
33#include <casacore/ms/MeasurementSets/MSPolColumns.h>
34#include <casacore/ms/MSSel/MSPolIndex.h>
35#include <casacore/ms/MSSel/MSDataDescIndex.h>
36
37namespace casacore { // # NAMESPACE CASACORE - BEGIN
38
39// # Forward Declarations
40
41// <summary>
42// Class to hold values from field 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// MSPolnParse is the class used to parse a polarization selection command.
56// </etymology>
57
58// <synopsis>
59//
60// MSPolnParse is used by the parser of polarization sub-expression
61// statements of the type [SPW:]POLN. Since this is a relatively
62// simple expression to tokenize and parse, this parser is written
63// without Bison or Flex. The methods of this class take an
64// expression, and internally generate a list of the Data Description
65// IDs that should be used to select the rows in the MS main table.
66// The map of Polarization IDs (row numbers in the POLARIZATION
67// sub-table) and the list of indices to be used to pick the user
68// selected polarzation data (in the DATA columns of the MS main
69// table) is also generated. This map is intended to be used along
70// with the map of SPW and selected channels to apply the in-row
71// selection (Slice on the data columns).
72//
73// </synopsis>
74
75// <motivation>
76// It is necessary to be able to give a data selection
77// command in ASCII. This can be used in a CLI or in the table
78// browser to get a subset 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 MSPolnParse : public MSParse {
86 public:
87 // Default constructor
89 // ~MSPolnParse() {cleanup();}
90
91 // Associate the ms and the shorthand.
93
95
96 // Get table expression node object.
98 // static MSPolnParse* thisMSSParser;
99 void reset() {
100 polMap_p.clear();
101 ddIDList_p.resize(0);
102 }
103 void cleanup() { /*if (node_p) delete node_p;node_p=0x0;*/ }
104 Int theParser(const String& command);
105 // Vector<Int>& selectedDDIDs,
106 // Matrix<Int>& selectedSpwPolnMap);
107 std::map<Int, Vector<Int>> selectedPolnMap() { return polMap_p; }
108 std::map<Int, Vector<Vector<Int>>> selectedSetupMap() { return setupMap_p; }
110
111 private:
113 const Vector<Int>& spwIDs, Vector<Int>& polnIDs,
114 Vector<Int>& polIndices);
116 std::map<Int, Vector<Int>>& polIndexMap,
117 Vector<Int>& polIndices, Bool addToMap = False);
118 Vector<Int> getPolnIDs(const String& polSpec, Vector<Int>& polIndices);
119 Vector<Int> getPolnIndices(const Int& polnID, const Vector<Int>& polnIDList);
120 //
121 // These are the versions used in the code.
122 Vector<Int> getPolnIDsV2(const String& polSpec, Vector<Int>& polTypes);
123 Vector<Int> getMapToDDIDsV2(const String& polExpr, const Vector<Int>& spwIDs,
124 Vector<Int>& polnIDs, Vector<Int>& polnIndices);
127 std::map<Int, Vector<Int>> polMap_p;
128 std::map<Int, Vector<Vector<Int>>> setupMap_p;
129
130 void setIDLists(const Int key, const Int ndx, Vector<Int>& val);
131};
132
133} // namespace casacore
134
135#endif
MSParse()
Default constructor for List container class.
MeasurementSet * ms()
Get ms object.
std::map< Int, Vector< Int > > selectedPolnMap()
Vector<Int>& selectedDDIDs, Matrix<Int>& selectedSpwPolnMap);.
Vector< Int > getMapToDDIDsV2(const String &polExpr, const Vector< Int > &spwIDs, Vector< Int > &polnIDs, Vector< Int > &polnIndices)
Vector< Int > ddIDList_p
const TableExprNode selectFromIDList(const Vector< Int > &ddIDs)
std::map< Int, Vector< Int > > polMap_p
TableExprNode node_p
Vector< Int > getPolnIndices(const Int &polnID, const Vector< Int > &polnIDList)
Vector< Int > getMapToDDIDs(MSDataDescIndex &msDDNdx, MSPolarizationIndex &msPolNdx, const Vector< Int > &spwIDs, Vector< Int > &polnIDs, Vector< Int > &polIndices)
Int theParser(const String &command)
Vector< Int > selectedDDIDs()
std::map< Int, Vector< Vector< Int > > > selectedSetupMap()
Vector< Int > matchPolIDsToPolTableRow(const Vector< Int > &polIds, std::map< Int, Vector< Int > > &polIndexMap, Vector< Int > &polIndices, Bool addToMap=False)
const TableExprNode node()
Get table expression node object.
void reset()
static MSPolnParse* thisMSSParser;
Definition MSPolnParse.h:99
MSPolnParse(const MeasurementSet *ms)
~MSPolnParse() {cleanup();}
Vector< Int > getPolnIDs(const String &polSpec, Vector< Int > &polIndices)
std::map< Int, Vector< Vector< Int > > > setupMap_p
void setIDLists(const Int key, const Int ndx, Vector< Int > &val)
Vector< Int > getPolnIDsV2(const String &polSpec, Vector< Int > &polTypes)
These are the versions used in the code.
MSPolnParse()
Default constructor.
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