MSSelection.h

Classes

MSSelection -- MSSelection: Class to represent a selection on an MS (full description)

class MSSelection

Types

enum MSExprType

NO_EXPR = 0
ANTENNA_EXPR
CORR_EXPR
FIELD_EXPR
SPW_EXPR
SCAN_EXPR
TIME_EXPR
UVDIST_EXPR
TAQL_EXPR

Interface

Public Members
MSSelection()
virtual ~MSSelection()
MSSelection(const Record& selectionItem)
MSSelection(const MSSelection& other)
MSSelection& operator=(const MSSelection& other)
static String indexExprStr(Vector<Int> index)
static String nameExprStr(Vector<String> name)
Bool setAntennaExpr(const String& antennaExpr)
Bool setCorrExpr(const String& corrExpr)
Bool setFieldExpr(const String& fieldExpr)
Bool setSpwExpr(const String& spwExpr)
Bool setScanExpr(const String& scanExpr)
Bool setTimeExpr(const String& timeExpr)
Bool setUvDistExpr(const String& uvDistExpr)
Bool setTaQLExpr(const String& taqlExpr)
void clear(void)
TableExprNode toTableExprNode(const MeasurementSet* ms)
Private Members
Bool setOrder(MSSelection::MSExprType type)
void fromSelectionItem(const Record& selectionItem)
Bool definedAndSet(const Record& inpRec, const String& fieldName)

Description

Prerequisite

Etymology

From "MeasurementSet" and "selection".

Synopsis

The MSSelection class represents a selection on a MeasurementSet (MS). This class is used in translating MS selections represented as selection items in the user interface, and for converting between MS selection and pure TaQL selection.

The purpose of this class is to provides a simple expression based selection mechanism to both the end-user and developer wishing to perform query operations over a measurement set. This is accomplished by abstracting the TaQL interface through an adapter/translation interface which converts STaQL (Simple Table Query Language) expressions into the equivalent table expression form, reducing the knowledge necessary to perform powerful query operations directly in TaQL.

The subexpressions available for performing a selection are as follows (a detailed syntax for each expression is also given below):

    antenna - Antenna STaQL expression
      antenna=ANTENNA.INDEX
      antenna='ANTENNA.NAME'
      antenna='ANTENNA.STATION'
      antenna=ANTENNA.INDEX : POL
      antenna=ANTENNA.INDEX : FEED POL
      antenna=ANTENNA.INDEX & ANTENNA.INDEX
      antenna=( ANTENNA.INDEX , ANTENNA.INDEX )
      antenna=( ANTENNA.INDEX - ANTENNA.INDEX )
      antenna=ANTENNA.INDEX & ANTENNA.INDEX : POL
      antenna=ANTENNA.INDEX : POL & ANTENNA.INDEX
      antenna=ANTENNA.INDEX : POL & ANTENNA.INDEX : POL
      antenna=( ANTENNA.INDEX , ANTENNA.INDEX ) : POL
      antenna=( ANTENNA.INDEX - ANTENNA.INDEX ) : POL
      antenna=ANTENNA.INDEX & *
      antenna=ANTENNA.NAME & *
      antenna=ANTENNA.NAME *
      antenna=[antennaexpr], [...]
    corr    - Correlator STaQL expression
      corr='RR'
      corr='RL'
      corr='LR'
      corr='LL'
      corr='XX'
      corr='XY'
      corr='YX'
      corr='YY'
      corr='I'
      corr='Q'
      corr='U'
      corr='V'
      corr='P'
      corr='Q'
      corr=[correxpr], [...]
    field   - Field STaQL expression
      field=FIELD.INDEX
      field='FIELD.NAME'
      field='FIELD.CODE'
      field='SOURCE.NAME'
      field='SOURCE.CODE'
      field=< FIELD.INDEX
      field=> FIELD.INDEX
      field=FIELD.INDEX - FIELD.INDEX
      field=FIELD.NAME *
      field=* FIELD.NAME
      field=[fieldexpr], [...]
    spw     - SPW STaQL expression
      spw=SPW.INDEX
      spw=SPW.NAME
      spw=SPW.INDEX : VALUE / VALUE / VALUE / VALUE
      spw=SPW.INDEX : VALUE - VALUE
      spw=SPW.INDEX : VALUE - VALUE UNIT
      spw=SPW.INDEX : ( VALUE , VALUE , ... )
      spw=SPW.INDEX : ( VALUE , VALUE , ... ) UNIT
      spw=[spwexpr], [...]
    scan    - Scan STaQL expression
      =SCAN.INDEX
      =SCAN.INDEX - SCAN.INDEX
      =[scanexpr], [...]
    time    - Time STaQL expression
      time='YYYY/MM/DD/HH:MM:SS.sss'
      time='ddd/HH:MM:SS.sss'
      time='< YYYY/MM/DD/HH:MM:SS.sss'
      time='> YYYY/MM/DD/HH:MM:SS.sss'
      time='YYYY/MM/DD/HH:MM:SS.sss - YYYY/MM/DD/HH:MM:SS.sss'
      time='YYYY[/MM][/DD][/HH][:MM][:SS][.sss]'
      time='ddd[/HH][:MM][:SS][.sss]'
      time=[timeexpr], [...]
    uvdist  - UV Distribution STaQL expression
      uvdist='< VALUE UNIT'
      uvdist='> VALUE UNIT'
      uvdist='VALUE - VALUE UNIT'
      uvdist='VALUE UNIT : PERCENTAGE %'
      uvdist=[uvdistexpr], [range]
    taql    - TaQL expression
      taql=[taqlexpr]
The subexpressions are interpreted in the order which they were set, with an AND between the results of each subexpression.

For a complete list of the STaQL interface refer to: Data Selection

Example

    // Create a MS and a MS selection
    MeasurementSet ms(msName);
    MSSelection select;
    // Setup any subexpressions of interest directly
    // (or optionally send this information through a Record)
    select.setFieldExpr("0,1");
    select.setSpwExpr(">0");
    // Create a table expression over a MS representing the selection
    TableExprNode node = select.toTableExprNode(&ms);
    // Optionally create a table and new MS based on this node
    Table tablesel(ms.tableName(), Table::Update);
    MeasurementSet mssel(tablesel(node, node.nrow()));
    

Motivation

This class is used by the MS access classes.

To Do

Member Description

enum MSExprType

MSSelection()

Default null constructor, and destructor

virtual ~MSSelection()

MSSelection(const Record& selectionItem)

Construct from a record representing a selection item at the CLI or user interface level.

MSSelection(const MSSelection& other)

Copy constructor

MSSelection& operator=(const MSSelection& other)

Assignment operator

static String indexExprStr(Vector<Int> index)

Helper method for converting index vectors to expression strings

static String nameExprStr(Vector<String> name)

Helper method for converting name vectors to expression strings

Bool setAntennaExpr(const String& antennaExpr)

Expression accessors

Bool setCorrExpr(const String& corrExpr)

Bool setFieldExpr(const String& fieldExpr)

Bool setSpwExpr(const String& spwExpr)

Bool setScanExpr(const String& scanExpr)

Bool setTimeExpr(const String& timeExpr)

Bool setUvDistExpr(const String& uvDistExpr)

Bool setTaQLExpr(const String& taqlExpr)

void clear(void)

Clear all subexpression and reset priority

TableExprNode toTableExprNode(const MeasurementSet* ms)

Convert to TableExprNode format (C++ interface to TaQL)

Bool setOrder(MSSelection::MSExprType type)

Set into the order of the selection expression

void fromSelectionItem(const Record& selectionItem)

Initialize from a Record representing a selection item from the user interface or CLI

Bool definedAndSet(const Record& inpRec, const String& fieldName)

Check if record field exists and is not unset