MSIter.h

Classes

MSInterval -- Small helper class to specify an 'interval' comparison (full description)
MSIter -- An iterator class for MeasurementSets (full description)

class MSInterval

Interface

Public Members
static void setOffset(Double offset)
static void setInterval(Double interval)
static Int compare(const void * obj1, const void * obj2)

Description

Synopsis

Small helper class to specify an 'interval' comparison for table iteration by time interval.

Member Description

static void setOffset(Double offset)

static void setInterval(Double interval)

static Int compare(const void * obj1, const void * obj2)


class MSIter

Types

enum PolFrame

Circular = 0
Circular polarization
Linear = 1
Linear polarization

Interface

MSIter()
MSIter(const MeasurementSet& ms, const Block<Int>& sortColumns, Double timeInterval=0, Bool addDefaultSortColumns=True)
MSIter(const Block<MeasurementSet>& mss, const Block<Int>& sortColumns, Double timeInterval=0, Bool addDefaultSortColumns=True)
MSIter(const MSIter & other)
virtual ~MSIter()
MSIter & operator=(const MSIter &other)
void setInterval(Double timeInterval)
void origin()
Bool more() const
MSIter & operator++(int)
MSIter & operator++()
Table table() const
const MS& ms() const
const ROMSColumns& msColumns() const
Int msId() const
Bool newMS() const
Int arrayId() const
Bool newArray() const
Int fieldId() const
const String& fieldName() const
const String& sourceName() const
Bool newField() const
Int spectralWindowId() const
Bool newSpectralWindow() const
Int dataDescriptionId() const
Bool newDataDescriptionId() const
Int polarizationId() const
Bool newPolarizationId() const
const MDirection& phaseCenter() const
Int polFrame() const
const Vector<Double>& frequency() const
const MFrequency& frequency0() const
const MFrequency& restFrequency(Int line=0) const
const MPosition& telescopePosition() const
const Vector<SquareMatrix<Complex,2> >& CJones() const
const Matrix<Double>& receptorAngle() const
Int startChan() const
Protected Members
void construct(const Block<Int>& sortColumns, Bool addDefaultSortColumns)
void advance()
void setState()
void setMSInfo()
void setArrayInfo()
void setFeedInfo()
void setDataDescInfo()
void setFieldInfo()
Bool isSubSet(const Vector<uInt>& r1, const Vector<uInt>& r2)

Description

Prerequisite

Etymology

MSIter stands for the MeasurementSet Iterator class.

Synopsis

An MSIter is a class to traverse a MeasurementSet in various orders. It automatically adds four predefined sort columns to your selection of sort columns (see constructor) so that it can keep track of changes in frequency or polarization setup, field position and sub-array. Note that this can cause iterations to occur in a different way from what you would expect, see examples below. MSIter implements iteration by time interval for the use of e.g., calibration tasks that want to calculate solutions over some interval of time. You can iteratate over multiple MeasurementSets with this class

Example

    // The following code iterates by by ARRAY_ID, FIELD_ID, DATA_DESC_ID and
    // TIME (all implicitly added columns) and then by baseline (antenna pair),
    // in 3000s intervals.
    MeasurementSet ms("3C273XC1.ms"); 
    Block<int> sort(2);
           sort[0] = MS::ANTENNA1;
           sort[1] = MS::ANTENNA2;
    Double timeInterval = 3000;
    MSIter msIter(ms,sort,timeInteval);
    for (msIter.origin(); msIter.more(); msIter++) {
    // print out some of the iteration state
       cout << msIter.fieldId() << endl;
       cout << msIter.fieldName() << endl;
       cout << msIter.dataDescriptionId() << endl;
       cout << msIter.frequency0() << endl;
       cout << msIter.table().nrow() << endl;
       process(msIter.table()); // process the data in the current iteration
    }
    // Output shows only 1 row at a time because the table is sorted on TIME
    // first and ANTENNA1, ANTENNA2 next and each baseline occurs only once per 
    // TIME stamp. The interval has no effect in this case.
    

Example

    // The following code iterates by baseline (antenna pair), TIME, and,
    // implicitly, by ARRAY_ID, FIELD_ID and DATA_DESC_ID in 3000s
    // intervals.
    MeasurementSet ms("3C273XC1.ms"); 
    Block<int> sort(3);
           sort[0] = MS::ANTENNA1;
           sort[1] = MS::ANTENNA2;
           sort[2] = MS::TIME;
    Double timeInterval = 3000;
    MSIter msIter(ms,sort,timeInteval);
    for (msIter.origin(); msIter.more(); msIter++) {
    // print out some of the iteration state
       cout << msIter.fieldId() << endl;
       cout << msIter.fieldName() << endl;
       cout << msIter.dataDescriptionId() << endl;
       cout << msIter.frequency0() << endl;
       cout << msIter.table().nrow() << endl;
       process(msIter.table()); // process the data in the current iteration
    // Now the output shows 7 rows at a time, all with identical ANTENNA1
    // and ANTENNA2 values and TIME values within a 3000s interval.
    }
    

Motivation

This class was originally part of the VisibilityIterator class, but that class was getting too large and complicated. By splitting out the toplevel iteration into this class the code is much easier to understand. It is now also available through the ms tool.

To Do

Member Description

enum PolFrame

MSIter()

Default constructor - useful only to assign another iterator later. Use of other member functions on this object is likely to dump core.

MSIter(const MeasurementSet& ms, const Block<Int>& sortColumns, Double timeInterval=0, Bool addDefaultSortColumns=True)

Construct from MS and a Block of MS column enums specifying the iteration order, if none are specified, ARRAY_ID, FIELD_ID, DATA_DESC_ID, and TIME iteration is implicit (unless addDefaultSortColumns=False) These columns will be added first if they are not specified. An optional timeInterval can be given to iterate through chunks of time. The default interval of 0 groups all times together. Every 'chunk' of data contains all data within a certain time interval and with identical values of the other iteration columns (e.g. DATA_DESCRIPTION_ID and FIELD_ID). See the examples above for the effect of different sort orders.

MSIter(const Block<MeasurementSet>& mss, const Block<Int>& sortColumns, Double timeInterval=0, Bool addDefaultSortColumns=True)

Same as above with multiple MSs as input.

MSIter(const MSIter & other)

Copy construct. This calls the assigment operator.

virtual ~MSIter()

Destructor

MSIter & operator=(const MSIter &other)

Assigment. This will reset the iterator to the origin.

void setInterval(Double timeInterval)

Set or reset the time interval to use for iteration. You should call origin() to reset the iteration after calling this.

void origin()

Reset iterator to start of data

Bool more() const

Return False if there is no more data

MSIter & operator++(int)

Advance iterator through data

MSIter & operator++()

Table table() const

Return the current Table iteration

const MS& ms() const

Return reference to the current MS

const ROMSColumns& msColumns() const

Return reference to the current ROMSColumns

Int msId() const

Return the current MS Id (according to the order in which they appeared in the constructor)

Bool newMS() const

Return true if msId has changed since last iteration

Int arrayId() const

Return the current ArrayId

Bool newArray() const

Return True if ArrayId has changed since last iteration

Int fieldId() const

Return the current FieldId

const String& fieldName() const

Return the current Field Name

const String& sourceName() const

Return the current Source Name

Bool newField() const

Return True if FieldId/Source has changed since last iteration

Int spectralWindowId() const

Return current SpectralWindow

Bool newSpectralWindow() const

Return True if SpectralWindow has changed since last iteration

Int dataDescriptionId() const

Return current DataDescriptionId

Bool newDataDescriptionId() const

Return True if DataDescriptionId has changed since last iteration

Int polarizationId() const

Return current PolarizationId

Bool newPolarizationId() const

Return True if polarization has changed since last iteration

const MDirection& phaseCenter() const

Return the current phase center as MDirection

Int polFrame() const

Return frame for polarization (returns PolFrame enum)

const Vector<Double>& frequency() const

Return the frequencies corresponding to the DATA matrix.

const MFrequency& frequency0() const

Return frequency of first channel with reference frame as a Measure. The reference frame Epoch is that of the first row, reset it as needed for each row. The reference frame Position is the average of the antenna positions.

const MFrequency& restFrequency(Int line=0) const

Return the rest frequency of the specified line as a Measure

const MPosition& telescopePosition() const

Return the telescope position (if a known telescope) or the position of the first antenna (if unknown)

const Vector<SquareMatrix<Complex,2> >& CJones() const

Return the feed configuration/leakage matrix for feed 0 on each antenna

const Matrix<Double>& receptorAngle() const

Return the receptor angle for feed 0 on each antenna. First axis is receptor number, 2nd axis is antennaId.

Int startChan() const

Return the channel number of the first channel in the DATA. (non-zero for reference MS created by VisSet with channel selection)

void construct(const Block<Int>& sortColumns, Bool addDefaultSortColumns)

handle the construction details

void advance()

advance the iteration

void setState()

set the iteration state

void setMSInfo()

void setArrayInfo()

void setFeedInfo()

void setDataDescInfo()

void setFieldInfo()

Bool isSubSet(const Vector<uInt>& r1, const Vector<uInt>& r2)

Determine if the numbers in r1 are a sorted subset of those in r2