MSSelection.h

Go to the documentation of this file.
00001 //# MSSelection.h: Class to represent a selection on an MS
00002 //# Copyright (C) 1996,1997,1998,1999,2001
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 //#
00027 //# $Id$
00028 
00029 #ifndef MS_MSSELECTION_H
00030 #define MS_MSSELECTION_H
00031 
00032 #include <casacore/casa/aips.h>
00033 #include <casacore/casa/BasicSL/String.h>
00034 #include <casacore/casa/Arrays/Vector.h>
00035 #include <casacore/measures/Measures/MEpoch.h>
00036 #include <casacore/measures/Measures/MRadialVelocity.h>
00037 #include <casacore/tables/TaQL/ExprNode.h>
00038 #include <casacore/ms/MeasurementSets/MeasurementSet.h>
00039 #include <casacore/casa/Arrays/Matrix.h>
00040 #include <casacore/casa/Arrays/Cube.h>
00041 #include <casacore/ms/MSSel/MSSelectionError.h>
00042 #include <casacore/ms/MSSel/MSSelectionErrorHandler.h>
00043 #include <casacore/ms/MSSel/MSSelectableTable.h>
00044 #include <casacore/casa/Containers/OrderedMap.h>
00045 #include <casacore/casa/Containers/MapIO.h>
00046 namespace casacore { //# NAMESPACE CASACORE - BEGIN
00047 
00048 // <summary> 
00049 // MSSelection: Class to represent a selection on an MS
00050 // </summary>
00051 
00052 // <use visibility=export>
00053 
00054 // <reviewed reviewer="" date="" tests="" demos="">
00055 
00056 // <prerequisite>
00057 //   <li> <linkto class="MeasurementSet">MeasurementSet</linkto> module
00058 // </prerequisite>
00059 //
00060 // <etymology>
00061 // From "MeasurementSet" and "selection".
00062 // </etymology>
00063 //
00064 // <synopsis>
00065 // The MSSelection class represents a selection on a MeasurementSet (MS).
00066 // This class is used in translating MS selections represented as
00067 // selection items in the user interface, and for converting between
00068 // MS selection and pure TaQL selection.
00069 //
00070 // The purpose of this class is to provides a simple expression based
00071 // selection mechanism to both the end-user and developer wishing to
00072 // perform query operations over a measurement set.  This is
00073 // accomplished by abstracting the TaQL interface through an
00074 // adapter/translation interface which converts STaQL (Simple Table
00075 // Query Language) expressions into the equivalent table expression
00076 // form, reducing the knowledge necessary to perform powerful query
00077 // operations directly in TaQL.  It is also possible to supply pure
00078 // TaQL expression(s) as sub-expressions if required. For a complete
00079 // list of the STaQL interface refer to the MeasurementSet Selection Syntax document at: <a
00080 // href="http://casa.nrao.edu/other_doc.shtml">Data
00081 // Selection</a>
00082 //
00083 // The sub-expressions are interpreted in the order which they were
00084 // set.  The order however in not important - any dependency on the
00085 // order in which the expressions are evaluated is handled internally.
00086 // The result of parsing the expressions is TableExprNode (TEN).  All
00087 // TENs from sub-expressions are finally ANDed and the resultant TEN
00088 // is used to select the rows of the MS table.
00089 //
00090 // </synopsis>
00091 //
00092 // <example>
00093 // <srcblock>
00094 // // Create a MS and a MS selection
00095 // MeasurementSet ms(msName);
00096 // MSSelection select;
00097 // // Setup any sub-expressions of interest directly
00098 // // (or optionally send this information through a Record)
00099 // select.setFieldExpr("0,1");
00100 // select.setSpwExpr(">0");
00101 // // Create a table expression over a MS representing the selection
00102 // TableExprNode node = select.toTableExprNode(&ms);
00103 // // Optionally create a table and new MS based on this node
00104 // Table tablesel(ms.tableName(), Table::Update);
00105 // MeasurementSet mssel(tablesel(node, node.nrow()));
00106 // </srcblock>
00107 // </example>
00108 //
00109 // <motivation>
00110 // This class is used by the MS access classes.
00111 // </motivation>
00112 //
00113 // <todo asof="Aug/14/2009">
00114 // Generalize SpwExpressions and PolnExpressions to optionally include
00115 // DataDescription ID specifications.
00116 // </todo>
00117 
00118   class MSSelection
00119   {
00120   public:
00121     enum MSExprType {NO_EXPR = 0,
00122                      ANTENNA_EXPR,
00123                      CORR_EXPR,
00124                      FIELD_EXPR,
00125                      SPW_EXPR,
00126                      SCAN_EXPR,
00127                      ARRAY_EXPR,
00128                      TIME_EXPR,
00129                      UVDIST_EXPR,
00130                      POLN_EXPR,
00131                      STATE_EXPR,
00132                      OBSERVATION_EXPR,
00133                      FEED_EXPR,
00134                      TAQL_EXPR,
00135                      MAX_EXPR = TAQL_EXPR};
00136     enum MSSMode {PARSE_NOW=0, PARSE_LATE};
00137 
00138     // Default null constructor, and destructor
00139     MSSelection();
00140     virtual ~MSSelection();
00141     
00142     // Construct using an MS and the various selection expressions to
00143     // be applied to the given MS.  By default, the expressions will
00144     // be parsed immediately.  With mode=PARSE_LATE, the parsing will
00145     // be done with a call to toTableExprNode().
00146     MSSelection(const MeasurementSet& ms,
00147                 const MSSMode& mode=PARSE_NOW,
00148                 const String& timeExpr="",
00149                 const String& antennaExpr="",
00150                 const String& fieldExpr="",
00151                 const String& spwExpr="",
00152                 const String& uvDistExpr="",
00153                 const String& taqlExpr="",
00154                 const String& polnExpr="",
00155                 const String& scanExpr="",
00156                 const String& arrayExpr="",
00157                 const String& stateExpr="",
00158                 const String& observationExpr="",
00159                 const String& feedExpr="");
00160     
00161     // Construct from a record representing a selection item at the
00162     // CLI or user interface level.  This is functionally same as the
00163     // constructor above with mode=PARSE_LATE.
00164     MSSelection(const Record& selectionItem);
00165     
00166     // Copy constructor
00167     MSSelection(const MSSelection& other);
00168     
00169     // Assignment operator
00170     MSSelection& operator=(const MSSelection& other);
00171     
00172     // Helper method for converting index vectors to expression strings
00173     static String indexExprStr(Vector<Int> index);
00174     
00175     // Helper method for converting name vectors to expression strings
00176     static String nameExprStr(Vector<String> name);
00177     
00178     // Expression setters.  The following set*Expr() methods only set
00179     // the expressions.  Parsing is done with a call to
00180     // toTableExprNode().
00181     Bool setAntennaExpr(const String& antennaExpr);
00182     Bool setFieldExpr(const String& fieldExpr);
00183     Bool setSpwExpr(const String& spwExpr);
00184     Bool setScanExpr(const String& scanExpr);
00185     Bool setArrayExpr(const String& ArrayExpr);
00186     Bool setTimeExpr(const String& timeExpr);
00187     Bool setUvDistExpr(const String& uvDistExpr);
00188     Bool setTaQLExpr(const String& taqlExpr);
00189     Bool setPolnExpr(const String& polnExpr);
00190     Bool setStateExpr(const String& stateExpr);
00191     Bool setObservationExpr(const String& observationExpr);
00192     Bool setFeedExpr(const String& feedExpr);
00193 
00194     // Accessor for the various selection expressions as strings.
00195     const String getExpr(const MSExprType type=NO_EXPR);
00196     
00197     // Accessor for result of parsing all of the selection
00198     // expressions.  The final TableExprNode (TEN) is the result of
00199     // ANDing the TENs for the individual expressions.
00200     TableExprNode getTEN(const MeasurementSet*ms = NULL);
00201 
00202     // Accessor for the list of the selected scan IDs.
00203     inline Vector<Int> getScanList(const MeasurementSet* ms=NULL) 
00204     {getTEN(ms); return scanIDs_p;}
00205 
00206     // Accessor for the list of the selected observation IDs.
00207     inline Vector<Int> getObservationList(const MeasurementSet* ms=NULL) 
00208     {getTEN(ms); return observationIDs_p;}
00209 
00210     // Accessor for the list of the selected feed1 IDs.
00211     inline Vector<Int> getFeed1List(const MeasurementSet* ms=NULL) 
00212     {getTEN(ms); return feed1IDs_p;}
00213 
00214     // Accessor for the list of the selected feed2 IDs.
00215     inline Vector<Int> getFeed2List(const MeasurementSet* ms=NULL) 
00216     {getTEN(ms); return feed2IDs_p;}
00217 
00218     // Similar to baselines for antennas
00219     inline Matrix<Int> getFeedPairList(const MeasurementSet* ms=NULL) 
00220     {getTEN(ms); return feedPairIDs_p;}
00221     
00222     // Accessor for the list of selected sub-array IDs.
00223     inline Vector<Int> getSubArrayList(const MeasurementSet* ms=NULL) 
00224     {getTEN(ms); return arrayIDs_p;}
00225     
00226     // Accessor for the list of antenna-1 of the selected baselines.
00227     // Antennas affected by the baseline negation operator have the
00228     // antenna IDs multiplied by -1.
00229     inline Vector<Int> getAntenna1List(const MeasurementSet* ms=NULL) 
00230     {// if (antenna1IDs_p.nelements() <= 0) 
00231         getTEN(ms); return antenna1IDs_p;}
00232     
00233     // Accessor for the list of antenna-2 of the selected baselines.
00234     // Antennas affected by the baseline negation operator have the
00235     // antenna IDs multiplied by -1.
00236     inline Vector<Int> getAntenna2List(const MeasurementSet* ms=NULL) 
00237     {// if (antenna2IDs_p.nelements() <= 0) 
00238         getTEN(ms); return antenna2IDs_p;}
00239     
00240     // Accessor for the list of selected baselines.  The list is a Nx2
00241     // Matrix with one row per baseline containing the antenna IDs of
00242     // the two antenna associated with the baseline.
00243     //
00244     // Baselines affected by the negation operator in the baseline
00245     // selection expression are reported with one or both the antenna
00246     // IDs multiplied by -1.  E.g. a baseline selection expression
00247     // "!1" will result in a baseline list
00248     //
00249     // [-1, 2],
00250     // [-1, 3],
00251     // [-1, 4],
00252     // ....
00253     //
00254     // The expression "!1&10" will result in a baseline list [-1,
00255     // -10].  Etc...
00256     //
00257     inline Matrix<Int> getBaselineList(const MeasurementSet* ms=NULL) 
00258     {getTEN(ms); return baselineIDs_p;}
00259     
00260     // Accessor for the list of selected field IDs.
00261     inline Vector<Int> getFieldList(const MeasurementSet* ms=NULL) 
00262     {// if (fieldIDs_p.nelements() <= 0) 
00263         getTEN(ms); return fieldIDs_p;}
00264 
00265     // Accessor for the list of selected state Obs_Modes.
00266     inline Vector<Int> getStateObsModeList(const MeasurementSet* ms=NULL) 
00267     {if (stateObsModeIDs_p.nelements() <= 0) getTEN(ms); return stateObsModeIDs_p;}
00268     
00269     // Accessor for the list of the specified time range(s) as the
00270     // start and end MJD values.  The time ranges are stored as columns,
00271     // i.e. the output Matrix is 2 x n_ranges.
00272     inline Matrix<Double> getTimeList(const MeasurementSet* ms=NULL)
00273     {getTEN(ms); return selectedTimesList_p;}
00274     
00275     // Accessor for the list of the specified uv-range(s) as the start
00276     // and end values in units used in the MS.
00277     inline Matrix<Double> getUVList(const MeasurementSet* ms=NULL) 
00278     {getTEN(ms); return selectedUVRange_p;}
00279     
00280     // Accessor for the list of user defined units for the
00281     // uv-range(s).  The uv-range(s) return by getUVList is always in
00282     // the units used in the MS.
00283     inline Vector<Bool> getUVUnitsList(const MeasurementSet* ms=NULL) 
00284     {getTEN(ms); return selectedUVUnits_p;}
00285 
00286     // Accessor for the list of the selected Spectral Window IDs.
00287     inline Vector<Int> getSpwList(const MeasurementSet* ms=NULL) 
00288     {// if (spwIDs_p.nelements() <= 0) 
00289         getTEN(ms); return spwIDs_p;}
00290     
00291     // Accessor for the table (as a nx4 Matrix) of the selected
00292     // Spectral Windows and associated ranges of selected channels.
00293     // Each row of the Matrix has the following elements:
00294     //
00295     //    SpwID StartCh StopCh Step
00296     //
00297     // where StartCh, StopCh and Step are the first and the last
00298     // selected channels and step is the step size.  If no step size
00299     // was supplied as part of the expression, the value of Step is
00300     // replaced with the value of the defaultStep parameter. Multiple
00301     // channel specifications for the same Spectral Window selection,
00302     // results in multiple rows in the Matrix. If sorted is True, the
00303     // rows of the output Matrix will be sorted by the SPW IDs (the
00304     // entries in the first column).
00305     Matrix<Int> getChanList(const MeasurementSet* ms=NULL, 
00306                             const Int defaultStep=1,
00307                             const Bool sorted=False);
00308 
00309     //
00310     // Same as getChanList, except that the channels and steps are in Hz.
00311     //    
00312     Matrix<Double> getChanFreqList(const MeasurementSet* ms=NULL, 
00313                                    const Bool sorted=False);
00314 
00315     // Accessor for the list of the selected Data Description IDs
00316     // (DDID) from the polarization expression parsing.  The actual
00317     // selected DDIDs would be an intersection of the DDIDs selected
00318     // from polarization and SPW expressions parsing (see
00319     // getSPWDDIDList() below).
00320     inline Vector<Int> getDDIDList(const MeasurementSet* ms=NULL) 
00321     {if (ddIDs_p.nelements() <= 0) getTEN(ms); return ddIDs_p;}
00322 
00323     // Accessor for the list of the selected Data Description IDs from
00324     // the SPW expression parsing.  The actual
00325     // selected DDIDs would be an intersection of the DDIDs selected
00326     // from polarization and SPW expressions parsing (see
00327     // getDDIDList() above).
00328     //
00329     // The actual DDIDs selected will be an intersection of the lists
00330     // from getDDIDList() and getSPWDDIDList() (which can be generated
00331     // using the set_intersection(Vector<Int>&, Vector<Int>&) global
00332     // method in MSSelectionTool.{cc,h}).
00333     inline Vector<Int> getSPWDDIDList(const MeasurementSet* ms=NULL) 
00334     {if (spwDDIDs_p.nelements() <= 0) getTEN(ms); return spwDDIDs_p;}
00335 
00336     //
00337     // The key in the ordered map returned by getPolMap() is the Data
00338     // Description ID (DDID). The value is a vector containing the
00339     // list of in-row indices to pick out the selected polarizations
00340     // (or equivalently, the list of indices for the vector in the
00341     // corrType column of the POLARIZATION sub-table). These are also
00342     // what the user intended (i.e., e.g. not all DD IDs due to user
00343     // POL expression might be selected due to SPW expressions).
00344     //
00345     inline OrderedMap<Int, Vector<Int> > getPolMap(const MeasurementSet* ms=NULL) 
00346     {getTEN(ms); return selectedPolMap_p;};
00347 
00348     //
00349     // The key in the ordered map returned by getCorrMap() is the
00350     // pol. in the Data Description ID (DDID) sub-table.  The value is
00351     // a Vector of two Vectors.
00352     //
00353     // The returned Map<T> has a key that maps to two vectors:
00354     // Key  ---->    Vector1               Vector2
00355     //
00356     // Key : Row index in the POLARIZATION sub-table
00357     //
00358     // Vector1 : List of poln. indices selected from the row pointed
00359     //           by Key.  These are the in-row indices to pick-out the
00360     //           desired (selected) polarization products from the
00361     //           selected rows of the MS (or equivalently, the list of
00362     //           indices for the vector in the corrType column of the
00363     //           POLARIZATION sub-table).
00364     //
00365     // Vector2 : List of selected rows from the DATA_DESCRIPTION sub-table 
00366     //
00367     // An example: following are the sub-tables used for the example
00368     // explaination below:
00369     //
00370     // POLARIZATION Sub-table
00371     // ======================
00372     // Row    Poln
00373     // ------------
00374     // 0         RR, LL
00375     // 1         RR, LR, RL, LL
00376     //
00377     // DATA_DESCRIPTION Sub-table
00378     // ==========================
00379     // Row      PolnID         SpwID
00380     // ------------------------------
00381     // 0          0              0
00382     // 1          1              1
00383     // 2          1              2
00384     // 3          1              3
00385     // 4          1              4
00386     // 5          1              5
00387     // 6          1              6
00388     // 7          1              7
00389     // 8          1              8
00390     //
00391     //
00392     // E.g., the expression poln='LL'
00393     //
00394     // returns the Map:
00395     //
00396     // corrmap = (0, [[1], [0]]) (1, [[3], [0,1,2,3,4,5,6,7,8]] )
00397     //
00398     // The rows from the POLARIZATION table selected are 0 and 1,  These are
00399     // two keys for the two entries in the map.
00400     //
00401     //  1. The two vectors in map 1 are:  [1] and [0].  The this reads as:
00402     //      From the 0th. row of the POLARIZATION table, use the indices [1].  The
00403     //      relevant list of associated DD rows are [0]
00404     //
00405     //  2. The two vectors in map 2 are:  [3] and  [0,1,2,3,4,5,6,7,8].  This reads as:
00406     //       From the 1st. row of the POLARIZATION table, use the indices [3].  The
00407     //       relevant list of associated DD rows are [0,1,2,3,4,5,6,7,8].
00408     //
00409     // For a client code:
00410     //
00411     // o To get a list of the DDIDs selected, iterate over all entries of the
00412     //   map and collate the second vector from each entry.
00413     //
00414     //        Or, use getDDIDList().
00415     //
00416     // o To get the list of the selected poln. *in-row indices*, collate the
00417     //   first vector from each entry.
00418     //
00419     // o To get a list of POLARIZATION IDs selected (rows of the POLARIZATION
00420     //   table), make a list of all the keys of this map.
00421     inline OrderedMap<Int, Vector<Vector<Int> > > getCorrMap(const MeasurementSet* ms=NULL) 
00422     {getTEN(ms); return selectedSetupMap_p;};
00423 
00424     // Methods to convert the maps return by getChanList and
00425     // getCorrMap to a list of Slice which can be directly used by
00426     // Table system for in-row selection of frequency channels and
00427     // polarizations.
00428     void getChanSlices(Vector<Vector<Slice> >& chanslices, 
00429                        const MeasurementSet* ms=NULL, 
00430                        const Int defaultChanStep=1);
00431 
00432     void getCorrSlices(Vector<Vector<Slice> >& corrslices,
00433                        const MeasurementSet* ms=NULL);
00434     
00435     
00436     // Clear sub-expression and reset priority.  Default behavior is to
00437     // reset all sub-expressions.
00438     void clear(const MSExprType type=NO_EXPR);
00439     
00440     // Set all error handlers to a known state (NULL).
00441     void clearErrorHandlers();
00442 
00443     Bool exprIsNull(const MSExprType type=NO_EXPR);
00444     
00445     // Convey to the various parsers to delete the TENs they hold
00446     void deleteNodes();
00447 
00448     // Delete error handlers (mostly the internally allocated ones).
00449     void deleteErrorHandlers();
00450 
00451     // Convert to TableExprNode format (C++ interface to TaQL).  This
00452     // is now for purely backwards compatibility and ease of use.  It
00453     // internally constructs the MSSelectableTable from the supplied
00454     // MS and calls the generic version of toTableExprNode below
00455     // (which works with MSSelectableTable object).
00456     TableExprNode toTableExprNode(const MeasurementSet* ms);
00457 
00458     // Convert to TableExprNode format (C++ interface to TaQL).  The
00459     // MSSelectableTable is a pure-virtual base class which provides a
00460     // generic interface both to MeasurementSet and CalTable (in the
00461     // synthesis module) services used in MSSelection.  The actual
00462     // objects used for supplying MeasurementSet or CalTable to
00463     // MSSelection are MSInterface and CTInterface classes
00464     // respectively.  With this, MSSelection module can be used for
00465     // selection on MeasurementSet or CalTable.
00466     TableExprNode toTableExprNode(MSSelectableTable* msLike);
00467     
00468     // Return the selected MS.  The selected MS reflects only row
00469     // selections (as against in-row selections).  If outMSName != "",
00470     // the selected MS is also written to the disk (a shallow copy).
00471     //
00472     // For in-row selection, use the appropriate global function
00473     // mssSetData() MSSelectionTools.h which also returns the in-row
00474     // (corr/chan) slices that can be supplied to the VisIter object
00475     // for on-the-fly in-row selection.
00476     Bool getSelectedMS(MeasurementSet& selectedMS,
00477                        const String& outMSName="");
00478     
00479     void resetMS(const MeasurementSet& ms) {resetTEN(); ms_p=&ms;};
00480     void resetTEN() {fullTEN_p=TableExprNode();};
00481     
00482     
00483     // The MSSelection object is designed to be re-usable object.  The
00484     // following reset() methods set the internal state of the object
00485     // to same state as with the equivalent constructor.
00486     //
00487     // mode can be one of the MSSModes.  MSSMode::PARSE_NOW will parse
00488     // the given expressions and internally hold the final TEN
00489     // (i.e. will also internally call toTableExprNode()).  The
00490     // internal TEN can be accessed via the getTEN() method.
00491     // MSSMode::PARSE_LATER will only set the expression strings.
00492     // Parsing will be done later with a call to toTableExprNode().
00493     //
00494     // This version, here for backward compatibility reasons,
00495     // internally constructs a
00496     // <linkto class="MSSelectableTable">MSSelectableTable</linkto>
00497     // object and calls the reset() method below that works with
00498     // MSSelectableTable.
00499     void reset(const MeasurementSet& ms,
00500                const MSSMode& mode           = PARSE_NOW,
00501                const String& timeExpr        = "",
00502                const String& antennaExpr     = "",
00503                const String& fieldExpr       = "",
00504                const String& spwExpr         = "",
00505                const String& uvDistExpr      = "",
00506                const String& taqlExpr        = "",
00507                const String& polnExpr        = "",
00508                const String& scanExpr        = "",
00509                const String& arrayExpr       = "",
00510                const String& stateExpr       = "",
00511                const String& observationExpr = "");
00512 
00513     // Add feedExpr; keep old signature for backwards compatibility
00514     void reset2(const MeasurementSet& ms,
00515                const MSSMode& mode           = PARSE_NOW,
00516                const String& timeExpr        = "",
00517                const String& antennaExpr     = "",
00518                const String& fieldExpr       = "",
00519                const String& spwExpr         = "",
00520                const String& uvDistExpr      = "",
00521                const String& taqlExpr        = "",
00522                const String& polnExpr        = "",
00523                const String& scanExpr        = "",
00524                const String& arrayExpr       = "",
00525                const String& stateExpr       = "",
00526                const String& observationExpr = "",
00527                const String& feedExpr        = "");
00528 
00529     // This version of reset() works with generic MSSelectableTable
00530     // object.  Accessing the services of the MSSelection module via
00531     // this interface is recommended over the version of reset() that
00532     // uses MeasurementSet.
00533     void reset(MSSelectableTable& msLike,
00534                const MSSMode& mode           = PARSE_NOW,
00535                const String& timeExpr        = "",
00536                const String& antennaExpr     = "",
00537                const String& fieldExpr       = "",
00538                const String& spwExpr         = "",
00539                const String& uvDistExpr      = "",
00540                const String& taqlExpr        = "",
00541                const String& polnExpr        = "",
00542                const String& scanExpr        = "",
00543                const String& arrayExpr       = "",
00544                const String& stateExpr       = "",
00545                const String& observationExpr = "");
00546 
00547     // Add feedExpr; keep old signature for backwards compatibility
00548     void reset2(MSSelectableTable& msLike,
00549                const MSSMode& mode           = PARSE_NOW,
00550                const String& timeExpr        = "",
00551                const String& antennaExpr     = "",
00552                const String& fieldExpr       = "",
00553                const String& spwExpr         = "",
00554                const String& uvDistExpr      = "",
00555                const String& taqlExpr        = "",
00556                const String& polnExpr        = "",
00557                const String& scanExpr        = "",
00558                const String& arrayExpr       = "",
00559                const String& stateExpr       = "",
00560                const String& observationExpr = "",
00561                const String& feedExpr        = "");
00562 
00563     // Set the maximum value acceptable for SCAN, OBSERVATION or
00564     // SUB-ARRAY IDs. The main-table columns for these do not refere
00565     // to rows of sub-tables and therefore there is no cheap way to
00566     // find a valid range for these which can be used in the parsers
00567     // to generate error or warning messages if a value outside the
00568     // range is used in the expressions.  The default maximum value
00569     // for scan, observation and sub-array IDs is 1000.
00570     inline void setMaxScans(const Int& n=1000) {maxScans_p=n;};
00571     inline void setMaxObs(const Int& n=1000)   {maxObs_p=n;};
00572     inline void setMaxArray(const Int& n=1000) {maxArray_p=n;};
00573     
00574     // Set the error handler to be used for reporting errors while
00575     // parsing the type of expression give by the first argument.
00576     void setErrorHandler(const MSExprType type, MSSelectionErrorHandler* mssEH,
00577                          const Bool overRide=True);
00578     
00579     // Initialize the error handler.  This is set the error-handler to
00580     // the user supplied error handler via setErrorHandler() or to the
00581     // default built-in error handler.
00582     void initErrorHandler(const MSExprType tye=NO_EXPR);
00583 
00584     // Execute the handleError() method of the error-handlers.  This
00585     // is called in the catch code for any exceptions emitted from any
00586     // of the parsers. It is also called at the end of the
00587     // parsing cycle.
00588     void runErrorHandler();
00589 
00590     // Return the pointer to the MS used internally.
00591     const MeasurementSet* getMS(MSSelectableTable* msLike);
00592 
00593   private:
00594     // Set into the order of the selection expression
00595     Bool setOrder(MSSelection::MSExprType type);
00596     
00597     // Initialize from a Record representing a selection
00598     // item from the user interface or CLI
00599     void fromSelectionItem(const Record& selectionItem);
00600     
00601     // Check if record field exists and is not unset
00602     Bool definedAndSet(const Record& inpRec, const String& fieldName);
00603     
00604     // Convert an MS select string to TaQL
00605     //   const String msToTaQL(const String& msSelect) {};
00606     
00607     TableExprNode fullTEN_p;
00608     const MeasurementSet *ms_p;
00609     // Selection expressions
00610     String antennaExpr_p;
00611     String fieldExpr_p;
00612     String spwExpr_p;
00613     String scanExpr_p;
00614     String arrayExpr_p;
00615     String timeExpr_p;
00616     String uvDistExpr_p;
00617     String polnExpr_p;
00618     String taqlExpr_p;
00619     String stateExpr_p;
00620     String observationExpr_p;
00621     String feedExpr_p;
00622     // Priority
00623     Vector<Int> exprOrder_p;
00624     Vector<Int> antenna1IDs_p,antenna2IDs_p,fieldIDs_p, spwIDs_p, scanIDs_p, arrayIDs_p,
00625       ddIDs_p,stateObsModeIDs_p, observationIDs_p, spwDDIDs_p, feed1IDs_p, feed2IDs_p;
00626     Matrix<Int> chanIDs_p;
00627     Matrix<Int> baselineIDs_p;
00628     Matrix<Int> feedPairIDs_p;
00629     Matrix<Double> selectedTimesList_p;
00630     Matrix<Double> selectedUVRange_p;
00631     Vector<Bool> selectedUVUnits_p;
00632     OrderedMap<Int, Vector<Int> > selectedPolMap_p;
00633     OrderedMap<Int, Vector<Vector<Int> > > selectedSetupMap_p;
00634     Int maxScans_p, maxObs_p, maxArray_p;
00635     Bool isMS_p,toTENCalled_p;
00636   };
00637   
00638 } //# NAMESPACE CASACORE - END
00639 
00640 #endif
00641 
00642 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1