casacore
Public Member Functions | Protected Member Functions | Private Types | Private Attributes | Friends | List of all members
casacore::MSSelector Class Reference

More...

#include <MSSelector.h>

Public Member Functions

 MSSelector ()
 
 MSSelector (MeasurementSet &ms)
 construct from an MS, the MS will supply the range of the various parameters that can be selected on. More...
 
 MSSelector (const MSSelector &other)
 Copy constructor, this will initialize the MS with other's MS. More...
 
MSSelectoroperator= (const MSSelector &other)
 Assignment, this will initialize the MS with other's MS. More...
 
 ~MSSelector ()
 
void setMS (MeasurementSet &ms)
 Change or Set the MS this MSSelector refers to. More...
 
Bool initSelection (const Vector< Int > &dataDescIds, Bool reset=False)
 initialize the selection by specifying, optionally, the DATA_DESC_IDs. More...
 
Bool initSelection (Bool reset=False)
 As above without the data desc id argument. More...
 
Vector< IntdataDescId () const
 Return the data desc IDs selected
More...
 
Bool selectChannel (Int nChan, Int start, Int width, Int incr)
 Set the mapping from input channels in the DATA column to output channels. More...
 
Bool selectPolarization (const Vector< String > &wantedPol)
 Specify the output polarization. More...
 
Bool select (const Record &items, Bool oneBased=False)
 Select the MS based on the selections present in the input record. More...
 
Bool select (const String &msSelect)
 Select the MS based on the TaQL selection string. More...
 
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. More...
 
Bool putData (const Record &items)
 Put the data for the items provided. More...
 
Bool iterInit (const Vector< String > &columns, Double interval, rownr_t 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). More...
 
Bool iterNext ()
 Step the iterator, sets the selection to the current table iteration. More...
 
Bool iterOrigin ()
 (Re)Set the iterator to the first iteration, call this after iterInit. More...
 
Bool iterEnd ()
 End the iteration (before reaching the last iteration) and set the selection back to the state before iteration started. More...
 
rownr_t nrow () const
 Number of rows in selected table. More...
 
Table selectedTable () const
 Return the selected table. More...
 
Bool selected () const
 Return the selection status of the table. More...
 

Protected Member Functions

void getAveragedData (Array< Complex > &avData, const Array< Bool > &flag, const ArrayColumn< Complex > &col) const
 average and convert data More...
 
void getAveragedData (Array< Float > &avData, const Array< Bool > &flag, const ArrayColumn< Float > &col) const
 average and convert float data More...
 
void getAveragedData (Array< Complex > &avData, const Array< Bool > &flag, const ArrayColumn< Complex > &col, const Slicer &rowSlicer) const
 average and convert data, with row Slicer More...
 
void getAveragedData (Array< Float > &avData, const Array< Bool > &flag, const ArrayColumn< Float > &col, const Slicer &rowSlicer) const
 average and convert float data, with row Slicer More...
 
Array< BoolgetAveragedFlag (Array< Bool > &avFlag, const ArrayColumn< Bool > &col) const
 "average" flag, at present all output which has a flagged input is flagged More...
 
Array< BoolgetAveragedFlag (Array< Bool > &avFlag, const ArrayColumn< Bool > &col, const Slicer &rowSlicer) const
 "average" flag, at present all output which has a flagged input is flagged, with row Slicer More...
 
void putAveragedFlag (const Array< Bool > &avFlag, ArrayColumn< Bool > &col)
 "unaverage" flag, distribute the flags back to the channels that went into the average More...
 
Array< FloatgetWeight (const ArrayColumn< Float > &wtCol, Bool sigma=False) const
 get the weight, set sigma=True when retrieving sigma's More...
 
void makeSlicer (Int start, Int nCorr) const
 make the data slicer, pass in the first and the number of correlations to select More...
 
void reorderFlagRow (Array< Bool > &flagRow)
 reorder from 2d to 1d (removing ifr axis) More...
 
void reorderWeight (Array< Float > &weight)
 reorder from 2d to 1d (removing ifr axis) More...
 
void timeAverage (Array< Bool > &dataFlags, Array< Complex > &data, const Array< Bool > &flags, const Array< Float > &weights)
 time average the input data, return new flags More...
 
Bool checkSelection ()
 check if the data description selection has been done & do default selection if not. More...
 

Private Types

enum  {
  Amp ,
  Phase ,
  Real ,
  Imag ,
  Data ,
  nFuncType
}
 The function types. More...
 
enum  {
  Observed ,
  Corrected ,
  Model ,
  Ratio ,
  Residual ,
  ObsResidual ,
  ObsFloat ,
  nDataType
}
 The data types. More...
 

Private Attributes

MeasurementSet ms_p
 
MeasurementSet selms_p
 
MeasurementSet savems_p
 
MSItermsIter_p
 
Bool initSel_p
 
Vector< IntdataDescId_p
 
Vector< IntlastDataDescId_p
 
Vector< uIntspwId_p
 
Vector< uIntpolId_p
 
Vector< IntchanSel_p
 
Bool useSlicer_p
 
Bool haveSlicer_p
 
Slicer slicer_p
 
Slice chanSlice_p
 
Slice polSlice_p
 
Vector< IntpolIndex_p
 
Int wantedOne_p
 
Bool convert_p
 
Bool subSet_p
 
StokesConverter stokesConverter_p
 
Vector< StringpolSelection_p
 
Vector< IntifrSelection_p
 
Vector< IntifrAxis_p
 
Matrix< DoublechanFreq_p
 
Matrix< Doublebandwidth_p
 
MSDerivedValues msd_p
 
Matrix< Int64rowIndex_p
 
RowNumbers selRows_p
 
rownr_t startRow_p
 
rownr_t maxRow_p
 
Bool useIfrDefault_p
 

Friends

class MSRange
 

Detailed Description

MSSelector specifies selections on a MeasurementSet

Intended use:

Public interface

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.

Example

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);
friend class MSRange
Definition: MSSelector.h:115
int Int
Definition: aipstype.h:50

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

Definition at line 113 of file MSSelector.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

The function types.

Enumerator
Amp 
Phase 
Real 
Imag 
Data 
nFuncType 

Definition at line 292 of file MSSelector.h.

◆ anonymous enum

anonymous enum
private

The data types.

Enumerator
Observed 
Corrected 
Model 
Ratio 
Residual 
ObsResidual 
ObsFloat 
nDataType 

Definition at line 295 of file MSSelector.h.

Constructor & Destructor Documentation

◆ MSSelector() [1/3]

casacore::MSSelector::MSSelector ( )

◆ MSSelector() [2/3]

casacore::MSSelector::MSSelector ( MeasurementSet ms)
explicit

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

◆ MSSelector() [3/3]

casacore::MSSelector::MSSelector ( const MSSelector other)

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

◆ ~MSSelector()

casacore::MSSelector::~MSSelector ( )

Member Function Documentation

◆ checkSelection()

Bool casacore::MSSelector::checkSelection ( )
protected

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

Return False if the selection fails.

◆ dataDescId()

Vector< Int > casacore::MSSelector::dataDescId ( ) const
inline

Return the data desc IDs selected

Definition at line 324 of file MSSelector.h.

References dataDescId_p.

◆ getAveragedData() [1/4]

void casacore::MSSelector::getAveragedData ( Array< Complex > &  avData,
const Array< Bool > &  flag,
const ArrayColumn< Complex > &  col 
) const
protected

average and convert data

◆ getAveragedData() [2/4]

void casacore::MSSelector::getAveragedData ( Array< Complex > &  avData,
const Array< Bool > &  flag,
const ArrayColumn< Complex > &  col,
const Slicer rowSlicer 
) const
protected

average and convert data, with row Slicer

◆ getAveragedData() [3/4]

void casacore::MSSelector::getAveragedData ( Array< Float > &  avData,
const Array< Bool > &  flag,
const ArrayColumn< Float > &  col 
) const
protected

average and convert float data

◆ getAveragedData() [4/4]

void casacore::MSSelector::getAveragedData ( Array< Float > &  avData,
const Array< Bool > &  flag,
const ArrayColumn< Float > &  col,
const Slicer rowSlicer 
) const
protected

average and convert float data, with row Slicer

◆ getAveragedFlag() [1/2]

Array<Bool> casacore::MSSelector::getAveragedFlag ( Array< Bool > &  avFlag,
const ArrayColumn< Bool > &  col 
) const
protected

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

◆ getAveragedFlag() [2/2]

Array<Bool> casacore::MSSelector::getAveragedFlag ( Array< Bool > &  avFlag,
const ArrayColumn< Bool > &  col,
const Slicer rowSlicer 
) const
protected

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

◆ getData()

Record casacore::MSSelector::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.

◆ getWeight()

Array<Float> casacore::MSSelector::getWeight ( const ArrayColumn< Float > &  wtCol,
Bool  sigma = False 
) const
protected

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

◆ initSelection() [1/2]

Bool casacore::MSSelector::initSelection ( Bool  reset = False)

As above without the data desc id argument.

◆ initSelection() [2/2]

Bool casacore::MSSelector::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.

◆ iterEnd()

Bool casacore::MSSelector::iterEnd ( )

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

◆ iterInit()

Bool casacore::MSSelector::iterInit ( const Vector< String > &  columns,
Double  interval,
rownr_t  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

◆ iterNext()

Bool casacore::MSSelector::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.

◆ iterOrigin()

Bool casacore::MSSelector::iterOrigin ( )

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

◆ makeSlicer()

void casacore::MSSelector::makeSlicer ( Int  start,
Int  nCorr 
) const
protected

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

◆ nrow()

rownr_t casacore::MSSelector::nrow ( ) const
inline

Number of rows in selected table.

Definition at line 323 of file MSSelector.h.

References casacore::Table::nrow(), and selms_p.

◆ operator=()

MSSelector& casacore::MSSelector::operator= ( const MSSelector other)

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

◆ putAveragedFlag()

void casacore::MSSelector::putAveragedFlag ( const Array< Bool > &  avFlag,
ArrayColumn< Bool > &  col 
)
protected

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

◆ putData()

Bool casacore::MSSelector::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.

◆ reorderFlagRow()

void casacore::MSSelector::reorderFlagRow ( Array< Bool > &  flagRow)
protected

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

◆ reorderWeight()

void casacore::MSSelector::reorderWeight ( Array< Float > &  weight)
protected

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

◆ select() [1/2]

Bool casacore::MSSelector::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.

◆ select() [2/2]

Bool casacore::MSSelector::select ( const String msSelect)

Select the MS based on the TaQL selection string.

◆ selectChannel()

Bool casacore::MSSelector::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)

◆ selected()

Bool casacore::MSSelector::selected ( ) const
inline

Return the selection status of the table.

Definition at line 326 of file MSSelector.h.

References initSel_p.

◆ selectedTable()

Table casacore::MSSelector::selectedTable ( ) const
inline

Return the selected table.

Definition at line 325 of file MSSelector.h.

References selms_p.

◆ selectPolarization()

Bool casacore::MSSelector::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)

◆ setMS()

void casacore::MSSelector::setMS ( MeasurementSet ms)

Change or Set the MS this MSSelector refers to.

◆ timeAverage()

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

time average the input data, return new flags

Friends And Related Function Documentation

◆ MSRange

friend class MSRange
friend

Definition at line 115 of file MSSelector.h.

Member Data Documentation

◆ bandwidth_p

Matrix<Double> casacore::MSSelector::bandwidth_p
private

Definition at line 315 of file MSSelector.h.

◆ chanFreq_p

Matrix<Double> casacore::MSSelector::chanFreq_p
private

Definition at line 315 of file MSSelector.h.

◆ chanSel_p

Vector<Int> casacore::MSSelector::chanSel_p
private

Definition at line 304 of file MSSelector.h.

◆ chanSlice_p

Slice casacore::MSSelector::chanSlice_p
private

Definition at line 308 of file MSSelector.h.

◆ convert_p

Bool casacore::MSSelector::convert_p
private

Definition at line 311 of file MSSelector.h.

◆ dataDescId_p

Vector<Int> casacore::MSSelector::dataDescId_p
private

Definition at line 302 of file MSSelector.h.

Referenced by dataDescId().

◆ haveSlicer_p

Bool casacore::MSSelector::haveSlicer_p
mutableprivate

Definition at line 306 of file MSSelector.h.

◆ ifrAxis_p

Vector<Int> casacore::MSSelector::ifrAxis_p
private

Definition at line 314 of file MSSelector.h.

◆ ifrSelection_p

Vector<Int> casacore::MSSelector::ifrSelection_p
private

Definition at line 314 of file MSSelector.h.

◆ initSel_p

Bool casacore::MSSelector::initSel_p
private

Definition at line 301 of file MSSelector.h.

Referenced by selected().

◆ lastDataDescId_p

Vector<Int> casacore::MSSelector::lastDataDescId_p
private

Definition at line 302 of file MSSelector.h.

◆ maxRow_p

rownr_t casacore::MSSelector::maxRow_p
private

Definition at line 319 of file MSSelector.h.

◆ ms_p

MeasurementSet casacore::MSSelector::ms_p
private

Definition at line 297 of file MSSelector.h.

◆ msd_p

MSDerivedValues casacore::MSSelector::msd_p
private

Definition at line 316 of file MSSelector.h.

◆ msIter_p

MSIter* casacore::MSSelector::msIter_p
private

Definition at line 300 of file MSSelector.h.

◆ polId_p

Vector<uInt> casacore::MSSelector::polId_p
private

Definition at line 303 of file MSSelector.h.

◆ polIndex_p

Vector<Int> casacore::MSSelector::polIndex_p
private

Definition at line 309 of file MSSelector.h.

◆ polSelection_p

Vector<String> casacore::MSSelector::polSelection_p
private

Definition at line 313 of file MSSelector.h.

◆ polSlice_p

Slice casacore::MSSelector::polSlice_p
private

Definition at line 308 of file MSSelector.h.

◆ rowIndex_p

Matrix<Int64> casacore::MSSelector::rowIndex_p
private

Definition at line 317 of file MSSelector.h.

◆ savems_p

MeasurementSet casacore::MSSelector::savems_p
private

Definition at line 299 of file MSSelector.h.

◆ selms_p

MeasurementSet casacore::MSSelector::selms_p
private

Definition at line 298 of file MSSelector.h.

Referenced by nrow(), and selectedTable().

◆ selRows_p

RowNumbers casacore::MSSelector::selRows_p
private

Definition at line 318 of file MSSelector.h.

◆ slicer_p

Slicer casacore::MSSelector::slicer_p
mutableprivate

Definition at line 307 of file MSSelector.h.

◆ spwId_p

Vector<uInt> casacore::MSSelector::spwId_p
private

Definition at line 303 of file MSSelector.h.

◆ startRow_p

rownr_t casacore::MSSelector::startRow_p
private

Definition at line 319 of file MSSelector.h.

◆ stokesConverter_p

StokesConverter casacore::MSSelector::stokesConverter_p
private

Definition at line 312 of file MSSelector.h.

◆ subSet_p

Bool casacore::MSSelector::subSet_p
private

Definition at line 311 of file MSSelector.h.

◆ useIfrDefault_p

Bool casacore::MSSelector::useIfrDefault_p
private

Definition at line 320 of file MSSelector.h.

◆ useSlicer_p

Bool casacore::MSSelector::useSlicer_p
private

Definition at line 305 of file MSSelector.h.

◆ wantedOne_p

Int casacore::MSSelector::wantedOne_p
private

Definition at line 310 of file MSSelector.h.


The documentation for this class was generated from the following file: