casacore
MSSelection.h
Go to the documentation of this file.
1 //# MSSelection.h: Class to represent a selection on an MS
2 //# Copyright (C) 1996,1997,1998,1999,2001
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 //#
27 //# $Id$
28 
29 #ifndef MS_MSSELECTION_H
30 #define MS_MSSELECTION_H
31 
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/BasicSL/String.h>
34 #include <casacore/casa/Arrays/Vector.h>
35 #include <casacore/measures/Measures/MEpoch.h>
36 #include <casacore/measures/Measures/MRadialVelocity.h>
37 #include <casacore/tables/TaQL/ExprNode.h>
38 #include <casacore/ms/MeasurementSets/MeasurementSet.h>
39 #include <casacore/casa/Arrays/Matrix.h>
40 #include <casacore/casa/Arrays/Cube.h>
41 #include <casacore/ms/MSSel/MSSelectionError.h>
42 #include <casacore/ms/MSSel/MSSelectionErrorHandler.h>
43 #include <casacore/ms/MSSel/MSSelectableTable.h>
44 #include <map>
45 
46 namespace casacore { //# NAMESPACE CASACORE - BEGIN
47 
48 // <summary>
49 // MSSelection: Class to represent a selection on an MS
50 // </summary>
51 
52 // <use visibility=export>
53 
54 // <reviewed reviewer="" date="" tests="" demos="">
55 
56 // <prerequisite>
57 // <li> <linkto class="MeasurementSet">MeasurementSet</linkto> module
58 // </prerequisite>
59 //
60 // <etymology>
61 // From "MeasurementSet" and "selection".
62 // </etymology>
63 //
64 // <synopsis>
65 // The MSSelection class represents a selection on a MeasurementSet (MS).
66 // This class is used in translating MS selections represented as
67 // selection items in the user interface, and for converting between
68 // MS selection and pure TaQL selection.
69 //
70 // The purpose of this class is to provides a simple expression based
71 // selection mechanism to both the end-user and developer wishing to
72 // perform query operations over a measurement set. This is
73 // accomplished by abstracting the TaQL interface through an
74 // adapter/translation interface which converts STaQL (Simple Table
75 // Query Language) expressions into the equivalent table expression
76 // form, reducing the knowledge necessary to perform powerful query
77 // operations directly in TaQL. It is also possible to supply pure
78 // TaQL expression(s) as sub-expressions if required. For a complete
79 // list of the STaQL interface refer to the MeasurementSet Selection Syntax document at: <a
80 // href="http://casa.nrao.edu/other_doc.shtml">Data
81 // Selection</a>
82 //
83 // The sub-expressions are interpreted in the order which they were
84 // set. The order however in not important - any dependency on the
85 // order in which the expressions are evaluated is handled internally.
86 // The result of parsing the expressions is TableExprNode (TEN). All
87 // TENs from sub-expressions are finally ANDed and the resultant TEN
88 // is used to select the rows of the MS table.
89 //
90 // </synopsis>
91 //
92 // <example>
93 // <srcblock>
94 // // Create a MS and a MS selection
95 // MeasurementSet ms(msName);
96 // MSSelection select;
97 // // Setup any sub-expressions of interest directly
98 // // (or optionally send this information through a Record)
99 // select.setFieldExpr("0,1");
100 // select.setSpwExpr(">0");
101 // // Create a table expression over a MS representing the selection
102 // TableExprNode node = select.toTableExprNode(&ms);
103 // // Optionally create a table and new MS based on this node
104 // Table tablesel(ms.tableName(), Table::Update);
105 // MeasurementSet mssel(tablesel(node, node.nrow()));
106 // </srcblock>
107 // </example>
108 //
109 // <motivation>
110 // This class is used by the MS access classes.
111 // </motivation>
112 //
113 // <todo asof="Aug/14/2009">
114 // Generalize SpwExpressions and PolnExpressions to optionally include
115 // DataDescription ID specifications.
116 // </todo>
117 
119  {
120  public:
121  enum MSExprType {NO_EXPR = 0,
137 
138  // Default null constructor, and destructor
140  virtual ~MSSelection();
141 
142  // Construct using an MS and the various selection expressions to
143  // be applied to the given MS. By default, the expressions will
144  // be parsed immediately. With mode=PARSE_LATE, the parsing will
145  // be done with a call to toTableExprNode().
147  const MSSMode& mode=PARSE_NOW,
148  const String& timeExpr="",
149  const String& antennaExpr="",
150  const String& fieldExpr="",
151  const String& spwExpr="",
152  const String& uvDistExpr="",
153  const String& taqlExpr="",
154  const String& polnExpr="",
155  const String& scanExpr="",
156  const String& arrayExpr="",
157  const String& stateExpr="",
158  const String& observationExpr="",
159  const String& feedExpr="");
160 
161  // Construct from a record representing a selection item at the
162  // CLI or user interface level. This is functionally same as the
163  // constructor above with mode=PARSE_LATE.
164  MSSelection(const Record& selectionItem);
165 
166  // Copy constructor
167  MSSelection(const MSSelection& other);
168 
169  // Assignment operator
171 
172  // Helper method for converting index vectors to expression strings
174 
175  // Helper method for converting name vectors to expression strings
177 
178  // Expression setters. The following set*Expr() methods only set
179  // the expressions. Parsing is done with a call to
180  // toTableExprNode().
181  Bool setAntennaExpr(const String& antennaExpr);
182  Bool setFieldExpr(const String& fieldExpr);
183  Bool setSpwExpr(const String& spwExpr);
184  Bool setScanExpr(const String& scanExpr);
185  Bool setArrayExpr(const String& ArrayExpr);
186  Bool setTimeExpr(const String& timeExpr);
187  Bool setUvDistExpr(const String& uvDistExpr);
188  Bool setTaQLExpr(const String& taqlExpr);
189  Bool setPolnExpr(const String& polnExpr);
190  Bool setStateExpr(const String& stateExpr);
191  Bool setObservationExpr(const String& observationExpr);
192  Bool setFeedExpr(const String& feedExpr);
193 
194  // Accessor for the various selection expressions as strings.
195  const String getExpr(const MSExprType type=NO_EXPR);
196 
197  // Accessor for result of parsing all of the selection
198  // expressions. The final TableExprNode (TEN) is the result of
199  // ANDing the TENs for the individual expressions.
201 
202  // Accessor for the list of the selected scan IDs.
203  inline Vector<Int> getScanList(const MeasurementSet* ms=NULL)
204  {getTEN(ms); return scanIDs_p;}
205 
206  // Accessor for the list of the selected observation IDs.
208  {getTEN(ms); return observationIDs_p;}
209 
210  // Accessor for the list of the selected feed1 IDs.
211  inline Vector<Int> getFeed1List(const MeasurementSet* ms=NULL)
212  {getTEN(ms); return feed1IDs_p;}
213 
214  // Accessor for the list of the selected feed2 IDs.
215  inline Vector<Int> getFeed2List(const MeasurementSet* ms=NULL)
216  {getTEN(ms); return feed2IDs_p;}
217 
218  // Similar to baselines for antennas
220  {getTEN(ms); return feedPairIDs_p;}
221 
222  // Accessor for the list of selected sub-array IDs.
224  {getTEN(ms); return arrayIDs_p;}
225 
226  // Accessor for the list of antenna-1 of the selected baselines.
227  // Antennas affected by the baseline negation operator have the
228  // antenna IDs multiplied by -1.
230  {// if (antenna1IDs_p.nelements() <= 0)
231  getTEN(ms); return antenna1IDs_p;}
232 
233  // Accessor for the list of antenna-2 of the selected baselines.
234  // Antennas affected by the baseline negation operator have the
235  // antenna IDs multiplied by -1.
237  {// if (antenna2IDs_p.nelements() <= 0)
238  getTEN(ms); return antenna2IDs_p;}
239 
240  // Accessor for the list of selected baselines. The list is a Nx2
241  // Matrix with one row per baseline containing the antenna IDs of
242  // the two antenna associated with the baseline.
243  //
244  // Baselines affected by the negation operator in the baseline
245  // selection expression are reported with one or both the antenna
246  // IDs multiplied by -1. E.g. a baseline selection expression
247  // "!1" will result in a baseline list
248  //
249  // [-1, 2],
250  // [-1, 3],
251  // [-1, 4],
252  // ....
253  //
254  // The expression "!1&10" will result in a baseline list [-1,
255  // -10]. Etc...
256  //
258  {getTEN(ms); return baselineIDs_p;}
259 
260  // Accessor for the list of selected field IDs.
261  inline Vector<Int> getFieldList(const MeasurementSet* ms=NULL)
262  {// if (fieldIDs_p.nelements() <= 0)
263  getTEN(ms); return fieldIDs_p;}
264 
265  // Accessor for the list of selected state Obs_Modes.
267  {if (stateObsModeIDs_p.nelements() <= 0) getTEN(ms); return stateObsModeIDs_p;}
268 
269  // Accessor for the list of the specified time range(s) as the
270  // start and end MJD values. The time ranges are stored as columns,
271  // i.e. the output Matrix is 2 x n_ranges.
273  {getTEN(ms); return selectedTimesList_p;}
274 
275  // Accessor for the list of the specified uv-range(s) as the start
276  // and end values in units used in the MS.
277  inline Matrix<Double> getUVList(const MeasurementSet* ms=NULL)
278  {getTEN(ms); return selectedUVRange_p;}
279 
280  // Accessor for the list of user defined units for the
281  // uv-range(s). The uv-range(s) return by getUVList is always in
282  // the units used in the MS.
284  {getTEN(ms); return selectedUVUnits_p;}
285 
286  // Accessor for the list of the selected Spectral Window IDs.
287  inline Vector<Int> getSpwList(const MeasurementSet* ms=NULL)
288  {// if (spwIDs_p.nelements() <= 0)
289  getTEN(ms); return spwIDs_p;}
290 
291  // Accessor for the table (as a nx4 Matrix) of the selected
292  // Spectral Windows and associated ranges of selected channels.
293  // Each row of the Matrix has the following elements:
294  //
295  // SpwID StartCh StopCh Step
296  //
297  // where StartCh, StopCh and Step are the first and the last
298  // selected channels and step is the step size. If no step size
299  // was supplied as part of the expression, the value of Step is
300  // replaced with the value of the defaultStep parameter. Multiple
301  // channel specifications for the same Spectral Window selection,
302  // results in multiple rows in the Matrix. If sorted is True, the
303  // rows of the output Matrix will be sorted by the SPW IDs (the
304  // entries in the first column).
306  const Int defaultStep=1,
307  const Bool sorted=False);
308 
309  //
310  // Same as getChanList, except that the channels and steps are in Hz.
311  //
313  const Bool sorted=False);
314 
315  // Accessor for the list of the selected Data Description IDs
316  // (DDID) from the polarization expression parsing. The actual
317  // selected DDIDs would be an intersection of the DDIDs selected
318  // from polarization and SPW expressions parsing (see
319  // getSPWDDIDList() below).
320  // Note that there is no guarantee that returned vector
321  // is inmight not be in sorted order.
322  inline Vector<Int> getDDIDList(const MeasurementSet* ms=NULL)
323  {if (ddIDs_p.nelements() <= 0) getTEN(ms); return ddIDs_p;}
324 
325  // Accessor for the list of the selected Data Description IDs from
326  // the SPW expression parsing. The actual
327  // selected DDIDs would be an intersection of the DDIDs selected
328  // from polarization and SPW expressions parsing (see
329  // getDDIDList() above).
330  //
331  // The actual DDIDs selected will be an intersection of the lists
332  // from getDDIDList() and getSPWDDIDList() (which can be generated
333  // using the set_intersection(Vector<Int>&, Vector<Int>&) global
334  // method in MSSelectionTool.{cc,h}).
335  inline Vector<Int> getSPWDDIDList(const MeasurementSet* ms=NULL)
336  {if (spwDDIDs_p.nelements() <= 0) getTEN(ms); return spwDDIDs_p;}
337 
338  //
339  // The key in the ordered map returned by getPolMap() is the Data
340  // Description ID (DDID). The value is a vector containing the
341  // list of in-row indices to pick out the selected polarizations
342  // (or equivalently, the list of indices for the vector in the
343  // corrType column of the POLARIZATION sub-table). These are also
344  // what the user intended (i.e., e.g. not all DD IDs due to user
345  // POL expression might be selected due to SPW expressions).
346  //
347  inline std::map<Int, Vector<Int> > getPolMap(const MeasurementSet* ms=NULL)
348  {getTEN(ms); return selectedPolMap_p;};
349 
350  //
351  // The key in the ordered map returned by getCorrMap() is the
352  // pol. in the Data Description ID (DDID) sub-table. The value is
353  // a Vector of two Vectors.
354  //
355  // The returned Map<T> has a key that maps to two vectors:
356  // Key ----> Vector1 Vector2
357  //
358  // Key : Row index in the POLARIZATION sub-table
359  //
360  // Vector1 : List of poln. indices selected from the row pointed
361  // by Key. These are the in-row indices to pick-out the
362  // desired (selected) polarization products from the
363  // selected rows of the MS (or equivalently, the list of
364  // indices for the vector in the corrType column of the
365  // POLARIZATION sub-table).
366  //
367  // Vector2 : List of selected rows from the DATA_DESCRIPTION sub-table
368  //
369  // An example: following are the sub-tables used for the example
370  // explaination below:
371  //
372  // POLARIZATION Sub-table
373  // ======================
374  // Row Poln
375  // ------------
376  // 0 RR, LL
377  // 1 RR, LR, RL, LL
378  //
379  // DATA_DESCRIPTION Sub-table
380  // ==========================
381  // Row PolnID SpwID
382  // ------------------------------
383  // 0 0 0
384  // 1 1 1
385  // 2 1 2
386  // 3 1 3
387  // 4 1 4
388  // 5 1 5
389  // 6 1 6
390  // 7 1 7
391  // 8 1 8
392  //
393  //
394  // E.g., the expression poln='LL'
395  //
396  // returns the Map:
397  //
398  // corrmap = (0, [[1], [0]]) (1, [[3], [0,1,2,3,4,5,6,7,8]] )
399  //
400  // The rows from the POLARIZATION table selected are 0 and 1, These are
401  // two keys for the two entries in the map.
402  //
403  // 1. The two vectors in map 1 are: [1] and [0]. The this reads as:
404  // From the 0th. row of the POLARIZATION table, use the indices [1]. The
405  // relevant list of associated DD rows are [0]
406  //
407  // 2. The two vectors in map 2 are: [3] and [0,1,2,3,4,5,6,7,8]. This reads as:
408  // From the 1st. row of the POLARIZATION table, use the indices [3]. The
409  // relevant list of associated DD rows are [0,1,2,3,4,5,6,7,8].
410  //
411  // For a client code:
412  //
413  // o To get a list of the DDIDs selected, iterate over all entries of the
414  // map and collate the second vector from each entry.
415  //
416  // Or, use getDDIDList().
417  //
418  // o To get the list of the selected poln. *in-row indices*, collate the
419  // first vector from each entry.
420  //
421  // o To get a list of POLARIZATION IDs selected (rows of the POLARIZATION
422  // table), make a list of all the keys of this map.
423  inline std::map<Int, Vector<Vector<Int> > > getCorrMap(const MeasurementSet* ms=NULL)
424  {getTEN(ms); return selectedSetupMap_p;};
425 
426  // Methods to convert the maps return by getChanList and
427  // getCorrMap to a list of Slice which can be directly used by
428  // Table system for in-row selection of frequency channels and
429  // polarizations.
430  void getChanSlices(Vector<Vector<Slice> >& chanslices,
431  const MeasurementSet* ms=NULL,
432  const Int defaultChanStep=1);
433 
434  void getCorrSlices(Vector<Vector<Slice> >& corrslices,
435  const MeasurementSet* ms=NULL);
436 
437 
438  // Clear sub-expression and reset priority. Default behavior is to
439  // reset all sub-expressions.
440  void clear(const MSExprType type=NO_EXPR);
441 
442  // Set all error handlers to a known state (NULL).
444 
446 
447  // Convey to the various parsers to delete the TENs they hold
448  void deleteNodes();
449 
450  // Delete error handlers (mostly the internally allocated ones).
452 
453  // Convert to TableExprNode format (C++ interface to TaQL). This
454  // is now for purely backwards compatibility and ease of use. It
455  // internally constructs the MSSelectableTable from the supplied
456  // MS and calls the generic version of toTableExprNode below
457  // (which works with MSSelectableTable object).
459 
460  // Convert to TableExprNode format (C++ interface to TaQL). The
461  // MSSelectableTable is a pure-virtual base class which provides a
462  // generic interface both to MeasurementSet and CalTable (in the
463  // synthesis module) services used in MSSelection. The actual
464  // objects used for supplying MeasurementSet or CalTable to
465  // MSSelection are MSInterface and CTInterface classes
466  // respectively. With this, MSSelection module can be used for
467  // selection on MeasurementSet or CalTable.
469 
470  // Return the selected MS. The selected MS reflects only row
471  // selections (as against in-row selections). If outMSName != "",
472  // the selected MS is also written to the disk (a shallow copy).
473  //
474  // For in-row selection, use the appropriate global function
475  // mssSetData() MSSelectionTools.h which also returns the in-row
476  // (corr/chan) slices that can be supplied to the VisIter object
477  // for on-the-fly in-row selection.
479  const String& outMSName="");
480 
481  void resetMS(const MeasurementSet& ms) {resetTEN(); ms_p=&ms;};
483 
484 
485  // The MSSelection object is designed to be re-usable object. The
486  // following reset() methods set the internal state of the object
487  // to same state as with the equivalent constructor.
488  //
489  // mode can be one of the MSSModes. MSSMode::PARSE_NOW will parse
490  // the given expressions and internally hold the final TEN
491  // (i.e. will also internally call toTableExprNode()). The
492  // internal TEN can be accessed via the getTEN() method.
493  // MSSMode::PARSE_LATER will only set the expression strings.
494  // Parsing will be done later with a call to toTableExprNode().
495  //
496  // This version, here for backward compatibility reasons,
497  // internally constructs a
498  // <linkto class="MSSelectableTable">MSSelectableTable</linkto>
499  // object and calls the reset() method below that works with
500  // MSSelectableTable.
501  void reset(const MeasurementSet& ms,
502  const MSSMode& mode = PARSE_NOW,
503  const String& timeExpr = "",
504  const String& antennaExpr = "",
505  const String& fieldExpr = "",
506  const String& spwExpr = "",
507  const String& uvDistExpr = "",
508  const String& taqlExpr = "",
509  const String& polnExpr = "",
510  const String& scanExpr = "",
511  const String& arrayExpr = "",
512  const String& stateExpr = "",
513  const String& observationExpr = "");
514 
515  // Add feedExpr; keep old signature for backwards compatibility
516  void reset2(const MeasurementSet& ms,
517  const MSSMode& mode = PARSE_NOW,
518  const String& timeExpr = "",
519  const String& antennaExpr = "",
520  const String& fieldExpr = "",
521  const String& spwExpr = "",
522  const String& uvDistExpr = "",
523  const String& taqlExpr = "",
524  const String& polnExpr = "",
525  const String& scanExpr = "",
526  const String& arrayExpr = "",
527  const String& stateExpr = "",
528  const String& observationExpr = "",
529  const String& feedExpr = "");
530 
531  // This version of reset() works with generic MSSelectableTable
532  // object. Accessing the services of the MSSelection module via
533  // this interface is recommended over the version of reset() that
534  // uses MeasurementSet.
535  void reset(MSSelectableTable& msLike,
536  const MSSMode& mode = PARSE_NOW,
537  const String& timeExpr = "",
538  const String& antennaExpr = "",
539  const String& fieldExpr = "",
540  const String& spwExpr = "",
541  const String& uvDistExpr = "",
542  const String& taqlExpr = "",
543  const String& polnExpr = "",
544  const String& scanExpr = "",
545  const String& arrayExpr = "",
546  const String& stateExpr = "",
547  const String& observationExpr = "");
548 
549  // Add feedExpr; keep old signature for backwards compatibility
550  void reset2(MSSelectableTable& msLike,
551  const MSSMode& mode = PARSE_NOW,
552  const String& timeExpr = "",
553  const String& antennaExpr = "",
554  const String& fieldExpr = "",
555  const String& spwExpr = "",
556  const String& uvDistExpr = "",
557  const String& taqlExpr = "",
558  const String& polnExpr = "",
559  const String& scanExpr = "",
560  const String& arrayExpr = "",
561  const String& stateExpr = "",
562  const String& observationExpr = "",
563  const String& feedExpr = "");
564 
565  // Set the maximum value acceptable for SCAN, OBSERVATION or
566  // SUB-ARRAY IDs. The main-table columns for these do not refere
567  // to rows of sub-tables and therefore there is no cheap way to
568  // find a valid range for these which can be used in the parsers
569  // to generate error or warning messages if a value outside the
570  // range is used in the expressions. The default maximum value
571  // for scan, observation and sub-array IDs is 1000.
572  inline void setMaxScans(const Int& n=1000) {maxScans_p=n;};
573  inline void setMaxObs(const Int& n=1000) {maxObs_p=n;};
574  inline void setMaxArray(const Int& n=1000) {maxArray_p=n;};
575 
576  // Set the error handler to be used for reporting errors while
577  // parsing the type of expression give by the first argument.
579  const Bool overRide=True);
580 
581  // Initialize the error handler. This is set the error-handler to
582  // the user supplied error handler via setErrorHandler() or to the
583  // default built-in error handler.
585 
586  // Execute the handleError() method of the error-handlers. This
587  // is called in the catch code for any exceptions emitted from any
588  // of the parsers. It is also called at the end of the
589  // parsing cycle.
591 
592  // Return the pointer to the MS used internally.
594 
595  private:
596  // Set into the order of the selection expression
598 
599  // Initialize from a Record representing a selection
600  // item from the user interface or CLI
601  void fromSelectionItem(const Record& selectionItem);
602 
603  // Check if record field exists and is not unset
604  Bool definedAndSet(const Record& inpRec, const String& fieldName);
605 
606  // Convert an MS select string to TaQL
607  // const String msToTaQL(const String& msSelect) {};
608 
611  // Selection expressions
624  // Priority
634  std::map<Int, Vector<Int> > selectedPolMap_p;
635  std::map<Int, Vector<Vector<Int> > > selectedSetupMap_p;
638  };
639 
640 } //# NAMESPACE CASACORE - END
641 
642 #endif
643 
644 
size_t nelements() const
How many elements does this array have? Product of all axis lengths.
Definition: ArrayBase.h:103
Matrix< Double > selectedUVRange_p
Definition: MSSelection.h:632
Vector< Int > getFeed2List(const MeasurementSet *ms=NULL)
Accessor for the list of the selected feed2 IDs.
Definition: MSSelection.h:215
Matrix< Int > baselineIDs_p
Definition: MSSelection.h:629
const MeasurementSet * ms_p
Definition: MSSelection.h:610
void fromSelectionItem(const Record &selectionItem)
Initialize from a Record representing a selection item from the user interface or CLI.
void resetMS(const MeasurementSet &ms)
Definition: MSSelection.h:481
Vector< Int > observationIDs_p
Definition: MSSelection.h:627
Vector< Bool > getUVUnitsList(const MeasurementSet *ms=NULL)
Accessor for the list of user defined units for the uv-range(s).
Definition: MSSelection.h:283
Vector< Int > antenna2IDs_p
Definition: MSSelection.h:626
MSSelection(const MeasurementSet &ms, const MSSMode &mode=PARSE_NOW, const String &timeExpr="", const String &antennaExpr="", const String &fieldExpr="", const String &spwExpr="", const String &uvDistExpr="", const String &taqlExpr="", const String &polnExpr="", const String &scanExpr="", const String &arrayExpr="", const String &stateExpr="", const String &observationExpr="", const String &feedExpr="")
Construct using an MS and the various selection expressions to be applied to the given MS.
Vector< Int > arrayIDs_p
Definition: MSSelection.h:626
Vector< Int > feed2IDs_p
Definition: MSSelection.h:627
void getChanSlices(Vector< Vector< Slice > > &chanslices, const MeasurementSet *ms=NULL, const Int defaultChanStep=1)
Methods to convert the maps return by getChanList and getCorrMap to a list of Slice which can be dire...
std::map< Int, Vector< Vector< Int > > > getCorrMap(const MeasurementSet *ms=NULL)
The key in the ordered map returned by getCorrMap() is the pol.
Definition: MSSelection.h:423
Vector< Int > fieldIDs_p
Definition: MSSelection.h:626
Bool setAntennaExpr(const String &antennaExpr)
Expression setters.
Bool setScanExpr(const String &scanExpr)
const MeasurementSet * getMS(MSSelectableTable *msLike)
Return the pointer to the MS used internally.
Bool setFieldExpr(const String &fieldExpr)
TableExprNode getTEN(const MeasurementSet *ms=NULL)
Accessor for result of parsing all of the selection expressions.
MSSelection()
Default null constructor, and destructor.
Vector< Int > getDDIDList(const MeasurementSet *ms=NULL)
Accessor for the list of the selected Data Description IDs (DDID) from the polarization expression pa...
Definition: MSSelection.h:322
const String getExpr(const MSExprType type=NO_EXPR)
Accessor for the various selection expressions as strings.
Bool setStateExpr(const String &stateExpr)
Matrix< Int > getFeedPairList(const MeasurementSet *ms=NULL)
Similar to baselines for antennas.
Definition: MSSelection.h:219
Bool setTimeExpr(const String &timeExpr)
void deleteErrorHandlers()
Delete error handlers (mostly the internally allocated ones).
Bool definedAndSet(const Record &inpRec, const String &fieldName)
Check if record field exists and is not unset.
Matrix< Double > getTimeList(const MeasurementSet *ms=NULL)
Accessor for the list of the specified time range(s) as the start and end MJD values.
Definition: MSSelection.h:272
Bool getSelectedMS(MeasurementSet &selectedMS, const String &outMSName="")
Return the selected MS.
void initErrorHandler(const MSExprType tye=NO_EXPR)
Initialize the error handler.
MSSelection & operator=(const MSSelection &other)
Assignment operator.
void clear(const MSExprType type=NO_EXPR)
Clear sub-expression and reset priority.
Vector< Int > getSPWDDIDList(const MeasurementSet *ms=NULL)
Accessor for the list of the selected Data Description IDs from the SPW expression parsing.
Definition: MSSelection.h:335
void deleteNodes()
Convey to the various parsers to delete the TENs they hold.
Vector< Int > ddIDs_p
Definition: MSSelection.h:627
Matrix< Double > getUVList(const MeasurementSet *ms=NULL)
Accessor for the list of the specified uv-range(s) as the start and end values in units used in the M...
Definition: MSSelection.h:277
Vector< Int > getStateObsModeList(const MeasurementSet *ms=NULL)
Accessor for the list of selected state Obs_Modes.
Definition: MSSelection.h:266
Bool setPolnExpr(const String &polnExpr)
Vector< Int > getFieldList(const MeasurementSet *ms=NULL)
Accessor for the list of selected field IDs.
Definition: MSSelection.h:261
Vector< Int > spwDDIDs_p
Definition: MSSelection.h:627
Bool setArrayExpr(const String &ArrayExpr)
void setMaxObs(const Int &n=1000)
Definition: MSSelection.h:573
void setMaxScans(const Int &n=1000)
Set the maximum value acceptable for SCAN, OBSERVATION or SUB-ARRAY IDs.
Definition: MSSelection.h:572
Bool setFeedExpr(const String &feedExpr)
Vector< Int > getFeed1List(const MeasurementSet *ms=NULL)
Accessor for the list of the selected feed1 IDs.
Definition: MSSelection.h:211
Bool exprIsNull(const MSExprType type=NO_EXPR)
Matrix< Int > getChanList(const MeasurementSet *ms=NULL, const Int defaultStep=1, const Bool sorted=False)
Accessor for the table (as a nx4 Matrix) of the selected Spectral Windows and associated ranges of se...
std::map< Int, Vector< Vector< Int > > > selectedSetupMap_p
Definition: MSSelection.h:635
Bool setOrder(MSSelection::MSExprType type)
Set into the order of the selection expression.
Vector< Int > getAntenna2List(const MeasurementSet *ms=NULL)
Accessor for the list of antenna-2 of the selected baselines.
Definition: MSSelection.h:236
void reset2(MSSelectableTable &msLike, const MSSMode &mode=PARSE_NOW, const String &timeExpr="", const String &antennaExpr="", const String &fieldExpr="", const String &spwExpr="", const String &uvDistExpr="", const String &taqlExpr="", const String &polnExpr="", const String &scanExpr="", const String &arrayExpr="", const String &stateExpr="", const String &observationExpr="", const String &feedExpr="")
Add feedExpr; keep old signature for backwards compatibility.
TableExprNode toTableExprNode(const MeasurementSet *ms)
Convert to TableExprNode format (C++ interface to TaQL).
MSSelection(const MSSelection &other)
Copy constructor.
void reset2(const MeasurementSet &ms, const MSSMode &mode=PARSE_NOW, const String &timeExpr="", const String &antennaExpr="", const String &fieldExpr="", const String &spwExpr="", const String &uvDistExpr="", const String &taqlExpr="", const String &polnExpr="", const String &scanExpr="", const String &arrayExpr="", const String &stateExpr="", const String &observationExpr="", const String &feedExpr="")
Add feedExpr; keep old signature for backwards compatibility.
Vector< Int > scanIDs_p
Definition: MSSelection.h:626
TableExprNode fullTEN_p
Convert an MS select string to TaQL const String msToTaQL(const String& msSelect) {};.
Definition: MSSelection.h:609
Vector< Int > getSpwList(const MeasurementSet *ms=NULL)
Accessor for the list of the selected Spectral Window IDs.
Definition: MSSelection.h:287
void clearErrorHandlers()
Set all error handlers to a known state (NULL).
Vector< Int > getScanList(const MeasurementSet *ms=NULL)
Accessor for the list of the selected scan IDs.
Definition: MSSelection.h:203
Matrix< Double > selectedTimesList_p
Definition: MSSelection.h:631
std::map< Int, Vector< Int > > getPolMap(const MeasurementSet *ms=NULL)
The key in the ordered map returned by getPolMap() is the Data Description ID (DDID).
Definition: MSSelection.h:347
void setMaxArray(const Int &n=1000)
Definition: MSSelection.h:574
Vector< Int > feed1IDs_p
Definition: MSSelection.h:627
Bool setObservationExpr(const String &observationExpr)
Bool setTaQLExpr(const String &taqlExpr)
Vector< Bool > selectedUVUnits_p
Definition: MSSelection.h:633
void reset(const MeasurementSet &ms, const MSSMode &mode=PARSE_NOW, const String &timeExpr="", const String &antennaExpr="", const String &fieldExpr="", const String &spwExpr="", const String &uvDistExpr="", const String &taqlExpr="", const String &polnExpr="", const String &scanExpr="", const String &arrayExpr="", const String &stateExpr="", const String &observationExpr="")
The MSSelection object is designed to be re-usable object.
String antennaExpr_p
Selection expressions.
Definition: MSSelection.h:612
static String nameExprStr(Vector< String > name)
Helper method for converting name vectors to expression strings.
Matrix< Int > getBaselineList(const MeasurementSet *ms=NULL)
Accessor for the list of selected baselines.
Definition: MSSelection.h:257
Vector< Int > antenna1IDs_p
Definition: MSSelection.h:626
Vector< Int > getSubArrayList(const MeasurementSet *ms=NULL)
Accessor for the list of selected sub-array IDs.
Definition: MSSelection.h:223
Matrix< Int > feedPairIDs_p
Definition: MSSelection.h:630
void runErrorHandler()
Execute the handleError() method of the error-handlers.
Vector< Int > getAntenna1List(const MeasurementSet *ms=NULL)
Accessor for the list of antenna-1 of the selected baselines.
Definition: MSSelection.h:229
void setErrorHandler(const MSExprType type, MSSelectionErrorHandler *mssEH, const Bool overRide=True)
Set the error handler to be used for reporting errors while parsing the type of expression give by th...
Vector< Int > stateObsModeIDs_p
Definition: MSSelection.h:627
void reset(MSSelectableTable &msLike, const MSSMode &mode=PARSE_NOW, const String &timeExpr="", const String &antennaExpr="", const String &fieldExpr="", const String &spwExpr="", const String &uvDistExpr="", const String &taqlExpr="", const String &polnExpr="", const String &scanExpr="", const String &arrayExpr="", const String &stateExpr="", const String &observationExpr="")
This version of reset() works with generic MSSelectableTable object.
std::map< Int, Vector< Int > > selectedPolMap_p
Definition: MSSelection.h:634
void getCorrSlices(Vector< Vector< Slice > > &corrslices, const MeasurementSet *ms=NULL)
Matrix< Int > chanIDs_p
Definition: MSSelection.h:628
Bool setSpwExpr(const String &spwExpr)
MSSelection(const Record &selectionItem)
Construct from a record representing a selection item at the CLI or user interface level.
Vector< Int > getObservationList(const MeasurementSet *ms=NULL)
Accessor for the list of the selected observation IDs.
Definition: MSSelection.h:207
Matrix< Double > getChanFreqList(const MeasurementSet *ms=NULL, const Bool sorted=False)
Same as getChanList, except that the channels and steps are in Hz.
TableExprNode toTableExprNode(MSSelectableTable *msLike)
Convert to TableExprNode format (C++ interface to TaQL).
static String indexExprStr(Vector< Int > index)
Helper method for converting index vectors to expression strings.
Bool setUvDistExpr(const String &uvDistExpr)
Vector< Int > exprOrder_p
Priority.
Definition: MSSelection.h:625
Vector< Int > spwIDs_p
Definition: MSSelection.h:626
String: the storage and methods of handling collections of characters.
Definition: String.h:225
this file contains all the compiler specific defines
Definition: mainpage.dox:28
const Bool False
Definition: aipstype.h:44
int Int
Definition: aipstype.h:50
bool Bool
Define the standard types used by Casacore.
Definition: aipstype.h:42
const Bool True
Definition: aipstype.h:43