MSAntennaParse.h

Go to the documentation of this file.
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$
00027 
00028 #ifndef MS_MSANTENNAPARSE_H
00029 #define MS_MSANTENNAPARSE_H
00030 
00031 //# Includes
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/ms/MSSel/MSParse.h>
00034 #include <casacore/ms/MSSel/MSSelectionErrorHandler.h>
00035 #include <casacore/casa/Arrays/Matrix.h>
00036 #include <bitset>
00037 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00038   
00039   //# Forward Declarations
00040   
00041   // <summary>
00042   // Class to hold values from antenna grammar parser
00043   // </summary>
00044   
00045   // <use visibility=local>
00046   
00047   // <reviewed reviewer="" date="" tests="">
00048   // </reviewed>
00049   
00050   // <prerequisite>
00051   //# Classes you should understand before using this one.
00052   // </prerequisite>
00053   
00054   // <etymology>
00055   // MSAntennaParse is the class used to parse a antenna command.
00056   // </etymology>
00057   
00058   // <synopsis>
00059   // MSAntennaParse is used by the parser of antenna sub-expression statements.
00060   // The parser is written in Bison and Flex in files MSAntennaGram.y and .l.
00061   // The statements in there use the routines in this file to act
00062   // upon a reduced rule.
00063   // Since multiple tables can be given (with a shorthand), the table
00064   // names are stored in a list. The variable names can be qualified
00065   // by the table name and will be looked up in the appropriate table.
00066   //
00067   // The class MSAntennaParse only contains information about a table
00068   // used in the table command. Global variables (like a list and a vector)
00069   // are used in MSAntennaParse.cc to hold further information.
00070   //
00071   // Global functions are used to operate on the information.
00072   // The main function is the global function msAntennaCommand.
00073   // It executes the given STaQL command and returns the resulting ms.
00074   // This is, in fact, the only function to be used by a user.
00075   // </synopsis>
00076   
00077   // <motivation>
00078   // It is necessary to be able to give a ms command in ASCII.
00079   // This can be used in a CLI or in the table browser to get a subset
00080   // of a table or to sort a table.
00081   // </motivation>
00082   
00083   //# <todo asof="$DATE:$">
00084   //# A List of bugs, limitations, extensions or planned refinements.
00085   //# </todo>
00086   
00087   
00088   class MSAntennaParse : public MSParse
00089   {
00090     
00091   public:
00092     // Define the operator types (&&&, &&, and &).
00093     enum BaselineListType {AutoCorrOnly=0, AutoCorrAlso, CrossOnly};
00094     enum ComplexityLevels {RESET=0,ANTREGEX,ANTLIST,STATIONREGEX, STATIONLIST, ANTATSTATIONLIST, BASELINELIST,HIGHESTLEVEL};
00095 
00096     // Default constructor
00097     MSAntennaParse();
00098     
00099     // Associate the ms.
00100     MSAntennaParse (const MeasurementSet* ms);
00101 
00102     MSAntennaParse (const MSAntenna& antSubTable, 
00103                     const TableExprNode& ant1AsTEN, const TableExprNode& ant2AsTEN);
00104 
00105     ~MSAntennaParse() {column1AsTEN_p=TableExprNode();column2AsTEN_p=TableExprNode();}
00106 
00107     // Add the given antennae selection.
00108     const TableExprNode* selectAntennaIds(const Vector<Int>& antennaIds, 
00109                                           BaselineListType baselineType=CrossOnly,
00110                                           Bool negate=False);
00111 
00112     // Add the given baseline selection.
00113     const TableExprNode* selectAntennaIds(const Vector<Int>& antennaIds1,
00114                                           const Vector<Int>& antennaIds2, 
00115                                           BaselineListType baselineType=CrossOnly,
00116                                           Bool negate=False);
00117 
00118     // Select by name or station number.
00119     const TableExprNode* selectNameOrStation(const Vector<String>& antenna,
00120                                              BaselineListType baselineType=CrossOnly,
00121                                              Bool negate=False);
00122     const TableExprNode* selectNameOrStation(const Vector<String>& antenna1,
00123                                              const Vector<String>& antenna2, 
00124                                              BaselineListType baselineType=CrossOnly,
00125                                              Bool negate=False);
00126 
00127     const TableExprNode* selectNameOrStation(const String& antenna1,
00128                                              const String& antenna2, 
00129                                              BaselineListType baselineType=CrossOnly,
00130                                              Bool negate=False);
00131     
00132     // Selection on baseline regex
00133     const TableExprNode* selectBLRegex(const std::vector<String>& lengths,
00134                                        Bool negate=False);
00135 
00136     // Selection on baseline length
00137     const TableExprNode* selectLength(const std::vector<double>& lengths,
00138                                       Bool negate=False);
00139 
00140     // Get a pointer to the table expression node object.
00141     TableExprNode node() const
00142       { return node_p; }
00143     const Vector<Int>& selectedAnt1() const
00144       { return ant1List; }
00145     const Vector<Int>& selectedAnt2() const
00146       { return ant2List; }
00147     const Matrix<Int>& selectedBaselines() const
00148       { return baselineList; }
00149 
00150     // Get the factor to convert the given unit to m.
00151     static double getUnitFactor (const char* unit);
00152     
00153     void setComplexity(const ComplexityLevels& level=RESET) 
00154     {if (level==RESET) complexity.reset(); else complexity.set(level,True);}
00155     std::bitset<HIGHESTLEVEL> getComplexity() {return complexity;}
00156     MSAntenna& subTable() {return msSubTable_p;}
00157   private:
00158     const TableExprNode* makeBLNode (const Matrix<Bool>& match,
00159                                      Bool negate);
00160     const TableExprNode* setTEN(TableExprNode& condition, 
00161                                 BaselineListType baselineType=CrossOnly,
00162                                 Bool negate=False);
00163     Matrix<double> getBaselineLengths();
00164     void makeBaselineList(const Vector<Int>&a1, const Vector<Int>&a2, Matrix<Int>&b, 
00165                           BaselineListType baselineType=CrossOnly,
00166                           Bool negate=False);
00167     void makeAntennaList(Vector<Int>& antList,const Vector<Int>& thisList,
00168                          Bool negate=False);
00169     Bool addBaseline(const Matrix<Int>& baselist,
00170                      const Int ant1, const Int ant2, 
00171                      BaselineListType baselineType=CrossOnly);
00172 
00173     //# Data members.
00174   public:
00175     static MSAntennaParse* thisMSAParser;
00176     static MSSelectionErrorHandler* thisMSAErrorHandler;
00177     static void cleanupErrorHandler() {if (thisMSAErrorHandler) delete thisMSAErrorHandler;thisMSAErrorHandler=0x0;}
00178     std::bitset<HIGHESTLEVEL> complexity;
00179   private:
00180     TableExprNode node_p;
00181     const String colName1, colName2;
00182     Vector<Int> ant1List, ant2List;
00183     Matrix<Int> baselineList;
00184     MSAntenna msSubTable_p;
00185     static TableExprNode column1AsTEN_p,column2AsTEN_p;
00186   };
00187   
00188 } //# NAMESPACE CASACORE - END
00189 
00190 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1