casa
$Rev:20696$
|
00001 //# MSAntennaParse.h: Classes to hold results from antenna grammar parser 00002 //# Copyright (C) 1994,1995,1997,1998,1999,2000,2001,2003 00003 //# Associated Universities, Inc. Washington DC, USA. 00004 //# 00005 //# This library is free software; you can redistribute it and/or modify it 00006 //# under the terms of the GNU Library General Public License as published by 00007 //# the Free Software Foundation; either version 2 of the License, or (at your 00008 //# option) any later version. 00009 //# 00010 //# This library is distributed in the hope that it will be useful, but WITHOUT 00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00012 //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00013 //# License for more details. 00014 //# 00015 //# You should have received a copy of the GNU Library General Public License 00016 //# along with this library; if not, write to the Free Software Foundation, 00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. 00018 //# 00019 //# Correspondence concerning AIPS++ should be addressed as follows: 00020 //# Internet email: aips2-request@nrao.edu. 00021 //# Postal address: AIPS++ Project Office 00022 //# National Radio Astronomy Observatory 00023 //# 520 Edgemont Road 00024 //# Charlottesville, VA 22903-2475 USA 00025 //# 00026 //# $Id: MSAntennaParse.h 20934 2010-08-17 09:16:24Z gervandiepen $ 00027 00028 #ifndef MS_MSANTENNAPARSE_H 00029 #define MS_MSANTENNAPARSE_H 00030 00031 //# Includes 00032 #include <ms/MeasurementSets/MSParse.h> 00033 #include <ms/MeasurementSets/MSSelectionErrorHandler.h> 00034 #include <casa/Arrays/Matrix.h> 00035 #include <bitset> 00036 namespace casa { //# NAMESPACE CASA - BEGIN 00037 00038 //# Forward Declarations 00039 00040 // <summary> 00041 // Class to hold values from antenna grammar parser 00042 // </summary> 00043 00044 // <use visibility=local> 00045 00046 // <reviewed reviewer="" date="" tests=""> 00047 // </reviewed> 00048 00049 // <prerequisite> 00050 //# Classes you should understand before using this one. 00051 // </prerequisite> 00052 00053 // <etymology> 00054 // MSAntennaParse is the class used to parse a antenna command. 00055 // </etymology> 00056 00057 // <synopsis> 00058 // MSAntennaParse is used by the parser of antenna sub-expression statements. 00059 // The parser is written in Bison and Flex in files MSAntennaGram.y and .l. 00060 // The statements in there use the routines in this file to act 00061 // upon a reduced rule. 00062 // Since multiple tables can be given (with a shorthand), the table 00063 // names are stored in a list. The variable names can be qualified 00064 // by the table name and will be looked up in the appropriate table. 00065 // 00066 // The class MSAntennaParse only contains information about a table 00067 // used in the table command. Global variables (like a list and a vector) 00068 // are used in MSAntennaParse.cc to hold further information. 00069 // 00070 // Global functions are used to operate on the information. 00071 // The main function is the global function msAntennaCommand. 00072 // It executes the given STaQL command and returns the resulting ms. 00073 // This is, in fact, the only function to be used by a user. 00074 // </synopsis> 00075 00076 // <motivation> 00077 // It is necessary to be able to give a ms command in ASCII. 00078 // This can be used in a CLI or in the table browser to get a subset 00079 // of a table or to sort a table. 00080 // </motivation> 00081 00082 //# <todo asof="$DATE:$"> 00083 //# A List of bugs, limitations, extensions or planned refinements. 00084 //# </todo> 00085 00086 00087 class MSAntennaParse : public MSParse 00088 { 00089 00090 public: 00091 // Define the operator types (&&&, &&, and &). 00092 enum BaselineListType {AutoCorrOnly=0, AutoCorrAlso, CrossOnly}; 00093 enum ComplexityLevels {RESET=0,ANTREGEX,ANTLIST,STATIONREGEX, STATIONLIST, ANTATSTATIONLIST, BASELINELIST,HIGHESTLEVEL}; 00094 00095 // Default constructor 00096 MSAntennaParse(); 00097 00098 // Associate the ms. 00099 MSAntennaParse (const MeasurementSet* ms); 00100 00101 MSAntennaParse (const MSAntenna& antSubTable, 00102 const TableExprNode& ant1AsTEN, const TableExprNode& ant2AsTEN); 00103 00104 ~MSAntennaParse() {column1AsTEN_p=TableExprNode();column2AsTEN_p=TableExprNode();}; 00105 00106 // Add the given antennae selection. 00107 const TableExprNode* selectAntennaIds(const Vector<Int>& antennaIds, 00108 BaselineListType baselineType=CrossOnly, 00109 Bool negate=False); 00110 00111 // Add the given baseline selection. 00112 const TableExprNode* selectAntennaIds(const Vector<Int>& antennaIds1, 00113 const Vector<Int>& antennaIds2, 00114 BaselineListType baselineType=CrossOnly, 00115 Bool negate=False); 00116 00117 // Select by name or station number. 00118 const TableExprNode* selectNameOrStation(const Vector<String>& antenna, 00119 BaselineListType baselineType=CrossOnly, 00120 Bool negate=False); 00121 const TableExprNode* selectNameOrStation(const Vector<String>& antenna1, 00122 const Vector<String>& antenna2, 00123 BaselineListType baselineType=CrossOnly, 00124 Bool negate=False); 00125 00126 const TableExprNode* selectNameOrStation(const String& antenna1, 00127 const String& antenna2, 00128 BaselineListType baselineType=CrossOnly, 00129 Bool negate=False); 00130 00131 // Selection on baseline length 00132 const TableExprNode* selectLength(const std::vector<double>& lengths, 00133 Bool negate=False); 00134 00135 // Get a pointer to the table expression node object. 00136 TableExprNode node() const 00137 { return node_p; } 00138 const Vector<Int>& selectedAnt1() const 00139 { return ant1List; } 00140 const Vector<Int>& selectedAnt2() const 00141 { return ant2List; } 00142 const Matrix<Int>& selectedBaselines() const 00143 { return baselineList; } 00144 00145 // Get the factor to convert the given unit to m. 00146 static double getUnitFactor (const char* unit); 00147 00148 void setComplexity(const ComplexityLevels& level=RESET) 00149 {if (level==RESET) complexity.reset(); else complexity.set(level,True);}; 00150 std::bitset<HIGHESTLEVEL> getComplexity() {return complexity;}; 00151 MSAntenna& subTable() {return msSubTable_p;} 00152 private: 00153 const TableExprNode* setTEN(TableExprNode& condition, 00154 BaselineListType baselineType=CrossOnly, 00155 Bool negate=False); 00156 Matrix<double> getBaselineLengths(); 00157 void makeBaselineList(const Vector<Int>&a1, const Vector<Int>&a2, Matrix<Int>&b, 00158 BaselineListType baselineType=CrossOnly, 00159 Bool negate=False); 00160 void makeAntennaList(Vector<Int>& antList,const Vector<Int>& thisList, 00161 Bool negate=False); 00162 Bool addBaseline(const Matrix<Int>& baselist, 00163 const Int ant1, const Int ant2, 00164 BaselineListType baselineType=CrossOnly); 00165 00166 //# Data members. 00167 public: 00168 static MSAntennaParse* thisMSAParser; 00169 static MSSelectionErrorHandler* thisMSAErrorHandler; 00170 std::bitset<HIGHESTLEVEL> complexity; 00171 private: 00172 TableExprNode node_p; 00173 const String colName1, colName2; 00174 Vector<Int> ant1List, ant2List; 00175 Matrix<Int> baselineList; 00176 MSAntenna msSubTable_p; 00177 static TableExprNode column1AsTEN_p,column2AsTEN_p; 00178 }; 00179 00180 } //# NAMESPACE CASA - END 00181 00182 #endif