casacore::MSIter Class Reference

An iterator class for MeasurementSets. More...

#include <MSIter.h>

List of all members.

Public Types

enum  PolFrame {
  Circular,
  Linear
}

Public Member Functions

 MSIter ()
 Default constructor - useful only to assign another iterator later.
 MSIter (const MeasurementSet &ms, const Block< Int > &sortColumns, Double timeInterval=0, Bool addDefaultSortColumns=True, Bool storeSorted=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.
 MSIter (const Block< MeasurementSet > &mss, const Block< Int > &sortColumns, Double timeInterval=0, Bool addDefaultSortColumns=True, Bool storeSorted=True)
 Same as above with multiple MSs as input.
 MSIter (const MSIter &other)
 Copy construct.
virtual ~MSIter ()
 Destructor.
MSIteroperator= (const MSIter &other)
 Assigment.
void setInterval (Double timeInterval)
 Set or reset the time interval to use for iteration.
void origin ()
 Reset iterator to start of data.
Bool more () const
 Return False if there is no more data.
MSIteroperator++ (int)
 Advance iterator through data.
MSIteroperator++ ()
Table table () const
 Return the current Table iteration.
const MSms () const
 Return reference to the current MS.
const ROMSColumnsmsColumns () 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 StringfieldName () const
 Return the current Field Name.
const StringsourceName () 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 MDirectionphaseCenter () 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 MFrequencyfrequency0 () const
 Return frequency of first channel with reference frame as a Measure.
const MFrequencyrestFrequency (Int line=0) const
 Return the rest frequency of the specified line as a Measure.
const MPositiontelescopePosition () 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 TODO: CJonesAll can be used instead of this method in all instances.
const Matrix< SquareMatrix
< Complex, 2 > > & 
CJonesAll () const
 Return the feed configuration/leakage matrix for all feeds and antennae First axis is antennaId, 2nd axis is feedId.
const Matrix< Double > & receptorAngle () const
 Return the receptor angle for feed 0 on each antenna.
const Cube< Double > & receptorAngles () const
 Return the receptor angles for all feeds and antennae First axis is a receptor number, 2nd axis is antennaId, 3rd axis is feedId.
Int startChan () const
 Return the channel number of the first channel in the DATA.
const Vector< String > & antennaMounts () const
 Return a string mount identifier for each antenna.
const Cube< RigidVector
< Double, 2 > > & 
getBeamOffsets () const
 Return a cube containing pairs of coordinate offset for each receptor of each feed (values are in radians, coordinate system is fixed with antenna and is the same as used to define the BEAM_OFFSET parameter in the feed table).
Bool allBeamOffsetsZero () const
 True if all elements of the cube returned by getBeamOffsets are zero.
void getSpwInFreqRange (Block< Vector< Int > > &spw, Block< Vector< Int > > &start, Block< Vector< Int > > &nchan, Double freqStart, Double freqEnd, Double freqStep)
 Get the spw, start and nchan for all the ms's is this msiter that match the frequecy "freqstart-freqStep" and "freqEnd+freqStep" range.
Int numMS () const
 Get the number of actual ms's associated wth this iterator.
const MSms (const uInt n) const
 Get a reference to the nth ms in the list of ms associated with this iterator.

Protected Member Functions

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.

Protected Attributes

MSIterThis
Block< MeasurementSetbms_p
PtrBlock< TableIterator * > tabIter_p
Block< BooltabIterAtStart_p
Int nMS_p
ROMSColumnsmsc_p
Table curTable_p
Int curMS_p
Int lastMS_p
Int curArray_p
Int lastArray_p
Int curSource_p
String curFieldName_p
String curSourceName_p
Int curField_p
Int lastField_p
Int curSpectralWindow_p
Int lastSpectralWindow_p
Int curPolarizationId_p
Int lastPolarizationId_p
Int curDataDescId_p
Int lastDataDescId_p
Bool more_p
Bool newMS_p
Bool newArray_p
Bool newField_p
Bool newSpectralWindow_p
Bool newPolarizationId_p
Bool newDataDescId_p
Bool preselected_p
Bool timeDepFeed_p
Bool spwDepFeed_p
Bool checkFeed_p
Int startChan_p
Bool storeSorted_p
 Globally control disk storage of SORTED_TABLE.
Double interval_p
 time selection
Block< IntpreselectedChanStart_p
 channel selection
Block< IntpreselectednChan_p
ScalarColumn< IntcolArray_p
 columns
ScalarColumn< IntcolDataDesc_p
ScalarColumn< IntcolField_p
MDirection phaseCenter_p
 cache for access functions
Matrix< DoublereceptorAnglesFeed0_p
Cube< DoublereceptorAngles_p
 temporary retained for compatibility contain actually a reference to the first plane of receptorAngles_p
Vector< SquareMatrix< Complex, 2 > > CJonesFeed0_p
Matrix< SquareMatrix< Complex, 2 > > CJones_p
 similar to receptorAngle_p
Vector< StringantennaMounts_p
Cube< RigidVector< Double, 2 > > beamOffsets_p
 antenna (e.g.
Bool allBeamOffsetsZero_p
 each element of the cube in radians) in the antenna coordinate system.
PolFrame polFrame_p
 are zero (to speed things up in a single beam case)
Bool freqCacheOK_p
Vector< Doublefrequency_p
MFrequency frequency0_p
MFrequency restFrequency_p
MPosition telescopePosition_p
MSIntervaltimeComp_p

Detailed Description

An iterator class for MeasurementSets.

Intended use:

Public interface

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 iterate 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.

Definition at line 162 of file MSIter.h.


Member Enumeration Documentation

Enumerator:
Circular 

Circular polarization.

Linear 

Linear polarization.

Definition at line 165 of file MSIter.h.


Constructor & Destructor Documentation

casacore::MSIter::MSIter (  ) 

Default constructor - useful only to assign another iterator later.

Use of other member functions on this object is likely to dump core.

casacore::MSIter::MSIter ( const MeasurementSet ms,
const Block< Int > &  sortColumns,
Double  timeInterval = 0,
Bool  addDefaultSortColumns = True,
Bool  storeSorted = 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.

The storeSorted parameter determines how the resulting SORT_TABLE is managed. If storeSorted is true then the table will be stored on disk; this potentially allows its reuse in the future but has also been shown to be a problem when the MS is being read in parallel. If storeSorted is false then the SORTED_TABLE is constructed and used in memory which keeps concurrent readers from interfering with each other.

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

Same as above with multiple MSs as input.

casacore::MSIter::MSIter ( const MSIter other  ) 

Copy construct.

This calls the assigment operator.

virtual casacore::MSIter::~MSIter (  )  [virtual]

Destructor.


Member Function Documentation

void casacore::MSIter::advance (  )  [protected]

advance the iteration

Bool casacore::MSIter::allBeamOffsetsZero (  )  const [inline]

True if all elements of the cube returned by getBeamOffsets are zero.

Definition at line 529 of file MSIter.h.

const Vector< String > & casacore::MSIter::antennaMounts (  )  const [inline]

Return a string mount identifier for each antenna.

Definition at line 524 of file MSIter.h.

Int casacore::MSIter::arrayId (  )  const [inline]

Return the current ArrayId.

Definition at line 501 of file MSIter.h.

const Vector< SquareMatrix< Complex, 2 > > & casacore::MSIter::CJones (  )  const [inline]

Return the feed configuration/leakage matrix for feed 0 on each antenna TODO: CJonesAll can be used instead of this method in all instances.

Definition at line 516 of file MSIter.h.

const Matrix< SquareMatrix< Complex, 2 > > & casacore::MSIter::CJonesAll (  )  const [inline]

Return the feed configuration/leakage matrix for all feeds and antennae First axis is antennaId, 2nd axis is feedId.

Result of CJones() is a reference to the first column of the matrix returned by this method

Definition at line 518 of file MSIter.h.

void casacore::MSIter::construct ( const Block< Int > &  sortColumns,
Bool  addDefaultSortColumns 
) [protected]

handle the construction details

Int casacore::MSIter::dataDescriptionId (  )  const [inline]

Return current DataDescriptionId.

Definition at line 508 of file MSIter.h.

Int casacore::MSIter::fieldId (  )  const [inline]

Return the current FieldId.

Definition at line 502 of file MSIter.h.

const String & casacore::MSIter::fieldName (  )  const [inline]

Return the current Field Name.

Definition at line 503 of file MSIter.h.

const Vector<Double>& casacore::MSIter::frequency (  )  const

Return the frequencies corresponding to the DATA matrix.

const MFrequency& casacore::MSIter::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 Cube< RigidVector< Double, 2 > > & casacore::MSIter::getBeamOffsets (  )  const [inline]

Return a cube containing pairs of coordinate offset for each receptor of each feed (values are in radians, coordinate system is fixed with antenna and is the same as used to define the BEAM_OFFSET parameter in the feed table).

The cube axes are receptor, antenna, feed.

Definition at line 526 of file MSIter.h.

void casacore::MSIter::getSpwInFreqRange ( Block< Vector< Int > > &  spw,
Block< Vector< Int > > &  start,
Block< Vector< Int > > &  nchan,
Double  freqStart,
Double  freqEnd,
Double  freqStep 
)

Get the spw, start and nchan for all the ms's is this msiter that match the frequecy "freqstart-freqStep" and "freqEnd+freqStep" range.

Bool casacore::MSIter::isSubSet ( const Vector< uInt > &  r1,
const Vector< uInt > &  r2 
) [protected]

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

Bool casacore::MSIter::more (  )  const [inline]

Return False if there is no more data.

Definition at line 490 of file MSIter.h.

const MS& casacore::MSIter::ms ( const uInt  n  )  const

Get a reference to the nth ms in the list of ms associated with this iterator.

If larger than the list of ms's current ms is returned So better check wth numMS() before making the call

const MS & casacore::MSIter::ms (  )  const [inline]

Return reference to the current MS.

Definition at line 492 of file MSIter.h.

const ROMSColumns & casacore::MSIter::msColumns (  )  const [inline]

Return reference to the current ROMSColumns.

Definition at line 493 of file MSIter.h.

Int casacore::MSIter::msId (  )  const [inline]

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

Definition at line 499 of file MSIter.h.

Bool casacore::MSIter::newArray (  )  const [inline]

Return True if ArrayId has changed since last iteration.

Definition at line 495 of file MSIter.h.

Bool casacore::MSIter::newDataDescriptionId (  )  const [inline]

Return True if DataDescriptionId has changed since last iteration.

Definition at line 510 of file MSIter.h.

Bool casacore::MSIter::newField (  )  const [inline]

Return True if FieldId/Source has changed since last iteration.

Definition at line 496 of file MSIter.h.

Bool casacore::MSIter::newMS (  )  const [inline]

Return true if msId has changed since last iteration.

Definition at line 494 of file MSIter.h.

Bool casacore::MSIter::newPolarizationId (  )  const [inline]

Return True if polarization has changed since last iteration.

Definition at line 509 of file MSIter.h.

Bool casacore::MSIter::newSpectralWindow (  )  const [inline]

Return True if SpectralWindow has changed since last iteration.

Definition at line 497 of file MSIter.h.

Int casacore::MSIter::numMS (  )  const [inline]

Get the number of actual ms's associated wth this iterator.

Definition at line 500 of file MSIter.h.

MSIter& casacore::MSIter::operator++ (  ) 
MSIter& casacore::MSIter::operator++ ( int   ) 

Advance iterator through data.

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

Assigment.

This will reset the iterator to the origin.

void casacore::MSIter::origin (  ) 

Reset iterator to start of data.

const MDirection & casacore::MSIter::phaseCenter (  )  const [inline]

Return the current phase center as MDirection.

Definition at line 512 of file MSIter.h.

Int casacore::MSIter::polarizationId (  )  const [inline]

Return current PolarizationId.

Definition at line 507 of file MSIter.h.

Int casacore::MSIter::polFrame (  )  const [inline]

Return frame for polarization (returns PolFrame enum).

Definition at line 511 of file MSIter.h.

const Matrix< Double > & casacore::MSIter::receptorAngle (  )  const [inline]

Return the receptor angle for feed 0 on each antenna.

First axis is receptor number, 2nd axis is antennaId. TODO: receptorAngles() can be used instead of this method

Definition at line 520 of file MSIter.h.

const Cube< Double > & casacore::MSIter::receptorAngles (  )  const [inline]

Return the receptor angles for all feeds and antennae First axis is a receptor number, 2nd axis is antennaId, 3rd axis is feedId.

Result of receptorAngle() is just a reference to the first plane of the cube returned by this method

Definition at line 522 of file MSIter.h.

const MFrequency& casacore::MSIter::restFrequency ( Int  line = 0  )  const

Return the rest frequency of the specified line as a Measure.

void casacore::MSIter::setArrayInfo (  )  [protected]
void casacore::MSIter::setDataDescInfo (  )  [protected]
void casacore::MSIter::setFeedInfo (  )  [protected]
void casacore::MSIter::setFieldInfo (  )  [protected]
void casacore::MSIter::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 casacore::MSIter::setMSInfo (  )  [protected]
void casacore::MSIter::setState (  )  [protected]

set the iteration state

const String & casacore::MSIter::sourceName (  )  const [inline]

Return the current Source Name.

Definition at line 504 of file MSIter.h.

Int casacore::MSIter::spectralWindowId (  )  const [inline]

Return current SpectralWindow.

Definition at line 505 of file MSIter.h.

Int casacore::MSIter::startChan (  )  const [inline]

Return the channel number of the first channel in the DATA.

(non-zero for reference MS created by VisSet with channel selection)

Definition at line 528 of file MSIter.h.

Table casacore::MSIter::table (  )  const [inline]

Return the current Table iteration.

Definition at line 491 of file MSIter.h.

const MPosition & casacore::MSIter::telescopePosition (  )  const [inline]

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

Definition at line 514 of file MSIter.h.


Member Data Documentation

each element of the cube in radians) in the antenna coordinate system.

Cube axes are: receptor, antenna, feed.

Definition at line 474 of file MSIter.h.

Definition at line 466 of file MSIter.h.

antenna (e.g.

EQUATORIAL, ALT-AZ,...)

Definition at line 469 of file MSIter.h.

Definition at line 421 of file MSIter.h.

Definition at line 433 of file MSIter.h.

similar to receptorAngle_p

Definition at line 465 of file MSIter.h.

Definition at line 462 of file MSIter.h.

columns

Definition at line 451 of file MSIter.h.

Definition at line 451 of file MSIter.h.

Definition at line 451 of file MSIter.h.

Definition at line 428 of file MSIter.h.

Definition at line 432 of file MSIter.h.

Definition at line 430 of file MSIter.h.

Definition at line 429 of file MSIter.h.

Definition at line 428 of file MSIter.h.

Definition at line 431 of file MSIter.h.

Definition at line 428 of file MSIter.h.

Definition at line 429 of file MSIter.h.

Definition at line 430 of file MSIter.h.

Definition at line 427 of file MSIter.h.

Definition at line 479 of file MSIter.h.

Definition at line 481 of file MSIter.h.

Definition at line 480 of file MSIter.h.

time selection

Definition at line 444 of file MSIter.h.

Definition at line 428 of file MSIter.h.

Definition at line 432 of file MSIter.h.

Definition at line 430 of file MSIter.h.

Definition at line 428 of file MSIter.h.

Definition at line 431 of file MSIter.h.

Definition at line 430 of file MSIter.h.

Definition at line 433 of file MSIter.h.

Definition at line 426 of file MSIter.h.

Definition at line 433 of file MSIter.h.

Definition at line 433 of file MSIter.h.

Definition at line 433 of file MSIter.h.

Definition at line 433 of file MSIter.h.

Definition at line 433 of file MSIter.h.

Definition at line 433 of file MSIter.h.

Definition at line 425 of file MSIter.h.

cache for access functions

Definition at line 455 of file MSIter.h.

are zero (to speed things up in a single beam case)

Definition at line 478 of file MSIter.h.

Definition at line 433 of file MSIter.h.

channel selection

Definition at line 447 of file MSIter.h.

Definition at line 447 of file MSIter.h.

temporary retained for compatibility contain actually a reference to the first plane of receptorAngles_p

Definition at line 461 of file MSIter.h.

Definition at line 456 of file MSIter.h.

Definition at line 482 of file MSIter.h.

Definition at line 433 of file MSIter.h.

Definition at line 436 of file MSIter.h.

Globally control disk storage of SORTED_TABLE.

Definition at line 440 of file MSIter.h.

Definition at line 422 of file MSIter.h.

Definition at line 423 of file MSIter.h.

Definition at line 483 of file MSIter.h.

Definition at line 420 of file MSIter.h.

Definition at line 485 of file MSIter.h.

Definition at line 433 of file MSIter.h.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 31 Aug 2016 for casa by  doxygen 1.6.1