An iterator class for MeasurementSets. More...
#include <MSIter.h>
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. | |
MSIter & | operator= (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. | |
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. | |
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 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 MS & | ms (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 | |
MSIter * | This |
Block< MeasurementSet > | bms_p |
PtrBlock< TableIterator * > | tabIter_p |
Block< Bool > | tabIterAtStart_p |
Int | nMS_p |
ROMSColumns * | msc_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< Int > | preselectedChanStart_p |
channel selection | |
Block< Int > | preselectednChan_p |
ScalarColumn< Int > | colArray_p |
columns | |
ScalarColumn< Int > | colDataDesc_p |
ScalarColumn< Int > | colField_p |
MDirection | phaseCenter_p |
cache for access functions | |
Matrix< Double > | receptorAnglesFeed0_p |
Cube< Double > | receptorAngles_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< String > | antennaMounts_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< Double > | frequency_p |
MFrequency | frequency0_p |
MFrequency | restFrequency_p |
MPosition | telescopePosition_p |
MSInterval * | timeComp_p |
An iterator class for MeasurementSets.
Public interface
MSIter stands for the MeasurementSet Iterator class.
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.
// 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.
// 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. }
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.
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.
void casacore::MSIter::advance | ( | ) | [protected] |
advance the iteration
Bool casacore::MSIter::allBeamOffsetsZero | ( | ) | const [inline] |
Int casacore::MSIter::arrayId | ( | ) | const [inline] |
const Vector< SquareMatrix< Complex, 2 > > & casacore::MSIter::CJones | ( | ) | const [inline] |
const Matrix< SquareMatrix< Complex, 2 > > & casacore::MSIter::CJonesAll | ( | ) | const [inline] |
void casacore::MSIter::construct | ( | const Block< Int > & | sortColumns, | |
Bool | addDefaultSortColumns | |||
) | [protected] |
handle the construction details
Int casacore::MSIter::dataDescriptionId | ( | ) | const [inline] |
Int casacore::MSIter::fieldId | ( | ) | const [inline] |
const String & casacore::MSIter::fieldName | ( | ) | const [inline] |
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.
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] |
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] |
const ROMSColumns & casacore::MSIter::msColumns | ( | ) | const [inline] |
Return reference to the current ROMSColumns.
Int casacore::MSIter::msId | ( | ) | const [inline] |
Bool casacore::MSIter::newArray | ( | ) | const [inline] |
Bool casacore::MSIter::newDataDescriptionId | ( | ) | const [inline] |
Bool casacore::MSIter::newField | ( | ) | const [inline] |
Bool casacore::MSIter::newMS | ( | ) | const [inline] |
Bool casacore::MSIter::newPolarizationId | ( | ) | const [inline] |
Bool casacore::MSIter::newSpectralWindow | ( | ) | const [inline] |
Int casacore::MSIter::numMS | ( | ) | const [inline] |
MSIter& casacore::MSIter::operator++ | ( | ) |
MSIter& casacore::MSIter::operator++ | ( | int | ) |
Advance iterator through data.
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.
Int casacore::MSIter::polarizationId | ( | ) | const [inline] |
Int casacore::MSIter::polFrame | ( | ) | 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
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
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 | ) |
void casacore::MSIter::setMSInfo | ( | ) | [protected] |
void casacore::MSIter::setState | ( | ) | [protected] |
set the iteration state
const String & casacore::MSIter::sourceName | ( | ) | const [inline] |
Int casacore::MSIter::spectralWindowId | ( | ) | const [inline] |
Int casacore::MSIter::startChan | ( | ) | const [inline] |
Table casacore::MSIter::table | ( | ) | const [inline] |
const MPosition & casacore::MSIter::telescopePosition | ( | ) | const [inline] |
Bool casacore::MSIter::allBeamOffsetsZero_p [protected] |
Vector<String> casacore::MSIter::antennaMounts_p [protected] |
Cube<RigidVector<Double, 2> > casacore::MSIter::beamOffsets_p [protected] |
Block<MeasurementSet> casacore::MSIter::bms_p [protected] |
Bool casacore::MSIter::checkFeed_p [protected] |
Matrix<SquareMatrix<Complex,2> > casacore::MSIter::CJones_p [protected] |
Vector<SquareMatrix<Complex,2> > casacore::MSIter::CJonesFeed0_p [protected] |
ScalarColumn<Int> casacore::MSIter::colArray_p [protected] |
ScalarColumn<Int> casacore::MSIter::colDataDesc_p [protected] |
ScalarColumn<Int> casacore::MSIter::colField_p [protected] |
Int casacore::MSIter::curArray_p [protected] |
Int casacore::MSIter::curDataDescId_p [protected] |
Int casacore::MSIter::curField_p [protected] |
String casacore::MSIter::curFieldName_p [protected] |
Int casacore::MSIter::curMS_p [protected] |
Int casacore::MSIter::curPolarizationId_p [protected] |
Int casacore::MSIter::curSource_p [protected] |
String casacore::MSIter::curSourceName_p [protected] |
Int casacore::MSIter::curSpectralWindow_p [protected] |
Table casacore::MSIter::curTable_p [protected] |
Bool casacore::MSIter::freqCacheOK_p [protected] |
MFrequency casacore::MSIter::frequency0_p [protected] |
Vector<Double> casacore::MSIter::frequency_p [protected] |
Double casacore::MSIter::interval_p [protected] |
Int casacore::MSIter::lastArray_p [protected] |
Int casacore::MSIter::lastDataDescId_p [protected] |
Int casacore::MSIter::lastField_p [protected] |
Int casacore::MSIter::lastMS_p [protected] |
Int casacore::MSIter::lastPolarizationId_p [protected] |
Int casacore::MSIter::lastSpectralWindow_p [protected] |
Bool casacore::MSIter::more_p [protected] |
ROMSColumns* casacore::MSIter::msc_p [protected] |
Bool casacore::MSIter::newArray_p [protected] |
Bool casacore::MSIter::newDataDescId_p [protected] |
Bool casacore::MSIter::newField_p [protected] |
Bool casacore::MSIter::newMS_p [protected] |
Bool casacore::MSIter::newPolarizationId_p [protected] |
Bool casacore::MSIter::newSpectralWindow_p [protected] |
Int casacore::MSIter::nMS_p [protected] |
MDirection casacore::MSIter::phaseCenter_p [protected] |
PolFrame casacore::MSIter::polFrame_p [protected] |
Bool casacore::MSIter::preselected_p [protected] |
Block<Int> casacore::MSIter::preselectedChanStart_p [protected] |
Block<Int> casacore::MSIter::preselectednChan_p [protected] |
Cube<Double> casacore::MSIter::receptorAngles_p [protected] |
Matrix<Double> casacore::MSIter::receptorAnglesFeed0_p [protected] |
MFrequency casacore::MSIter::restFrequency_p [protected] |
Bool casacore::MSIter::spwDepFeed_p [protected] |
Int casacore::MSIter::startChan_p [protected] |
Bool casacore::MSIter::storeSorted_p [protected] |
PtrBlock<TableIterator* > casacore::MSIter::tabIter_p [protected] |
Block<Bool> casacore::MSIter::tabIterAtStart_p [protected] |
MPosition casacore::MSIter::telescopePosition_p [protected] |
MSIter* casacore::MSIter::This [protected] |
MSInterval* casacore::MSIter::timeComp_p [protected] |
Bool casacore::MSIter::timeDepFeed_p [protected] |