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