MSSelector.h

Classes

MSSelector -- MSSelector specifies selections on a MeasurementSet (full description)

class MSSelector

Types

enum

Amp
Phase
Real
Imag
Data
nFuncType

enum

Observed
Corrected
Model
Ratio
Residual
ObsResidual
ObsFloat
nDataType

Interface

Public Members
MSSelector()
explicit MSSelector(MeasurementSet& ms)
MSSelector(const MSSelector& other)
MSSelector& operator=(const MSSelector& other)
~MSSelector()
void setMS(MeasurementSet& ms)
Bool initSelection(const Vector<Int>& dataDescIds, Bool reset=False)
Bool initSelection(Bool reset=False)
Vector<Int> dataDescId() const
Bool selectChannel(Int nChan, Int start, Int width, Int incr)
Bool selectPolarization(const Vector<String>& wantedPol)
Bool select(const Record& items, Bool oneBased=False)
Bool select(const String& msSelect)
Record getData(const Vector<String>& items, Bool ifrAxis, Int ifrAxisGap=0, Int inc=1, Bool average=False, Bool oneBased=False)
Bool putData(const Record& items)
Bool iterInit(const Vector<String>& columns, Double interval, Int maxRows=0, Bool addDefaultSortColumns=True)
Bool iterNext()
Bool iterOrigin()
Bool iterEnd()
Int nrow() const
Table selectedTable() const
Bool selected() const
Protected Members
void getAveragedData(Array<Complex>& avData, const Array<Bool>& flag, const ROArrayColumn<Complex>& col) const
void getAveragedData(Array<Float>& avData, const Array<Bool>& flag, const ROArrayColumn<Float>& col) const
void getAveragedData(Array<Complex>& avData, const Array<Bool>& flag, const ROArrayColumn<Complex>& col, const ROColumn & rowSlicer) const
void getAveragedData(Array<Float>& avData, const Array<Bool>& flag, const ROArrayColumn<Float>& col, const Slicer & rowSlicer) const
Array<Bool> getAveragedFlag(Array<Bool>& avFlag, const ROArrayColumn<Bool>& col) const
Array<Bool> getAveragedFlag(Array<Bool>& avFlag, const ROArrayColumn<Bool>& col, const Slicer& rowSlicer) const
void putAveragedFlag(const Array<Bool>& avFlag, ArrayColumn<Bool>& col)
Array<Float> getWeight(const ROArrayColumn<Float>& wtCol, Bool sigma=False) const
void makeSlicer(Int start, Int nCorr) const
void reorderFlagRow(Array<Bool>& flagRow)
void reorderWeight(Array<Float>& weight)
void timeAverage(Array<Bool>& dataFlags, Array<Complex>& data, const Array<Bool>& flags, const Array<Float>& weights)
Bool checkSelection()

Description

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Etymology

MSSelector's main function is selection of data from a MeasurementSet

Synopsis

This class is used to select and retrieve data from a MeasurementSet. It allows selections on e.g., time, field, spectral window (all row based), but also on channel and polarization (within a row). It can optionally do polarization conversion, spectral averaging and time averaging on the data retrieved and allows modified data to be written back to the Table. This class also provides the DO interface to the MS Iterator. The ms DO uses this class to allow these operations to be done from glish.

    MSSelector msSelector(myMS);
    // select data desc Id 1
    msSelector.initSelection(1);
    Vector<String> items(3); 
    // fill in some fields
    items(0)="field_id";
    items(1)="time";
    items(2)="num_chan";
    // get the range of values for the items specified
    MSRange msRange(msSelector.selectedTable(),msSelector.spectralWindow());
    Record range=msRange.range(items);
    //.. change the ranges as needed
    // now select with the new range
    msSelector.select(range);
    Int nchan=10, start=3, width=1, incr=2;
    msSelector.selectChannel(nchan,start,width,incr)
    // get out some data
    Vector<String> dataItems(3);
    dataItems(0)="data";
    dataItems(1)="antenna1";
    dataItems(2)="antenna2";
    Record dataRec=msSelector.getData(items);
    

Motivation

Selection from an MS is needed in various places. It makes sense to provide a uniform interface for MS selection.

Thrown Exceptions

To Do

Member Description

MSSelector()

explicit MSSelector(MeasurementSet& ms)

construct from an MS, the MS will supply the range of the various parameters that can be selected on.

MSSelector(const MSSelector& other)

Copy constructor, this will initialize the MS with other's MS

MSSelector& operator=(const MSSelector& other)

Assignment, this will initialize the MS with other's MS

~MSSelector()

void setMS(MeasurementSet& ms)

Change or Set the MS this MSSelector refers to.

Bool initSelection(const Vector<Int>& dataDescIds, Bool reset=False)

initialize the selection by specifying, optionally, the DATA_DESC_IDs. If you don't specify the dataDescIds and the data shape is constant all data is selected, if the shape does change, only the first dataDescId is selected. If you specify a number of dataDescIds and they all have the same shape, they are all selected, otherwise only the first is selected. The function returns false if the selection was limited due to changing data shape. Use the reset argument to return to the completely unselected ms.

Bool initSelection(Bool reset=False)

As above without the data desc id argument

Vector<Int> dataDescId() const

Return the data desc IDs selected

Bool selectChannel(Int nChan, Int start, Int width, Int incr)

Set the mapping from input channels in the DATA column to output channels. nChan is the number of output channels, start is the first channel to use, width specifies how wide a block of channels to average, increment specifies the start of the next block relative to the start of the current block. Note: averaging uncalibrated data should be avoided (no bandpass applied)

Bool selectPolarization(const Vector<String>& wantedPol)

Specify the output polarization. Missing input polarizations are assumed to be zero. This selection/conversion assumes that parallactic angle rotation is taken care of elsewhere (i.e., results may only be correct for CORRECTED_DATA and MODEL_DATA conversions, not for the observed DATA)

Bool select(const Record& items, Bool oneBased=False)

Select the MS based on the selections present in the input record. The format of this record is the same as that returned by range. Not all possible items can be selected on, some are quietly ignored. Correct for one-based indexing if oneBased is True.

Bool select(const String& msSelect)

Select the MS based on the TaQL selection string

Record getData(const Vector<String>& items, Bool ifrAxis, Int ifrAxisGap=0, Int inc=1, Bool average=False, Bool oneBased=False)

Return the data for the items requested, all returned values will be arrays, the last dimension of these is the table row number. The data arrays are normally 3D with axes: polarization, frequency, row. If ifrAxis is set to True, the data arrays returned will be 4D, with the data being split out along an extra interferometer axis, the axes will be: polarization, frequency, interferometer and time. Missing interferometers will be marked flagged. The order of the interferometers is that specified by the last select call. Add a (flagged) gap in the data at every antenna1 change if ifrAxisGap>0. Use inc > 1 to return data from every inc'th row. Use average=True to vector average the data along the row or time axis taking the weights column into account (use selectChannel to average channels together as well). Note that different interferometers will be averaged together if ifrAxis is False. Correct for one-based indexing if oneBased is True.

Bool putData(const Record& items)

Put the data for the items provided. Note that only fields corresponding to actual table columns can be put (i.e., no AMPLITUDEs, IFR_NUMBERs etc) The data will need to have the correct shape for the column and a last dimension matching the number of selected rows (or last two dimensions matching times and interferometers, for data retrieved with ifraxis=T) Channel selection is supported, but the width parameter has to be 1.

Bool iterInit(const Vector<String>& columns, Double interval, Int maxRows=0, Bool addDefaultSortColumns=True)

Set up an iterator, iterating over the specified columns, with optional time interval and maximum number of rows to return at once (the default of zero returns all rows). To keep MSIter from adding the default sort columns, specify addDefaultSortColumns=False

Bool iterNext()

Step the iterator, sets the selection to the current table iteration. Returns false if there is no more data and sets the selection back to the state before iteration started.

Bool iterOrigin()

(Re)Set the iterator to the first iteration, call this after iterInit.

Bool iterEnd()

/ End the iteration (before reaching the last iteration) and set the selection back to the state before iteration started.

Int nrow() const

Number of rows in selected table

Table selectedTable() const

Return the selected table

Bool selected() const

Return the selection status of the table

void getAveragedData(Array<Complex>& avData, const Array<Bool>& flag, const ROArrayColumn<Complex>& col) const

average and convert data

void getAveragedData(Array<Float>& avData, const Array<Bool>& flag, const ROArrayColumn<Float>& col) const

average and convert float data

void getAveragedData(Array<Complex>& avData, const Array<Bool>& flag, const ROArrayColumn<Complex>& col, const ROColumn & rowSlicer) const

average and convert data, with row Slicer

void getAveragedData(Array<Float>& avData, const Array<Bool>& flag, const ROArrayColumn<Float>& col, const Slicer & rowSlicer) const

average and convert float data, with row Slicer

Array<Bool> getAveragedFlag(Array<Bool>& avFlag, const ROArrayColumn<Bool>& col) const

"average" flag, at present all output which has a flagged input is flagged

Array<Bool> getAveragedFlag(Array<Bool>& avFlag, const ROArrayColumn<Bool>& col, const Slicer& rowSlicer) const

"average" flag, at present all output which has a flagged input is flagged, with row Slicer

void putAveragedFlag(const Array<Bool>& avFlag, ArrayColumn<Bool>& col)

"unaverage" flag, distribute the flags back to the channels that went into the average

Array<Float> getWeight(const ROArrayColumn<Float>& wtCol, Bool sigma=False) const

get the weight, set sigma=True when retrieving sigma's

void makeSlicer(Int start, Int nCorr) const

make the data slicer, pass in the first and the number of correlations to select

void reorderFlagRow(Array<Bool>& flagRow)

reorder from 2d to 1d (removing ifr axis)

void reorderWeight(Array<Float>& weight)

reorder from 2d to 1d (removing ifr axis)

void timeAverage(Array<Bool>& dataFlags, Array<Complex>& data, const Array<Bool>& flags, const Array<Float>& weights)

time average the input data, return new flags

Bool checkSelection()

check if the data description selection has been done & do default selection if not. Return False if the selection fails.

enum

The function types

enum

The data types