casacore
|
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. More... | |
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. More... | |
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. More... | |
MSIter (const MeasurementSet &ms, const std::vector< std::pair< String, CountedPtr< BaseCompare >>> &sortColumns) | |
This constructor is similar to the previous ones but the comparison functions used to group the iterations are given explicitly, making the constructor more generic. More... | |
MSIter (const Block< MeasurementSet > &mss, const std::vector< std::pair< String, CountedPtr< BaseCompare >>> &sortColumns) | |
Same as above with multiple MSs as input. More... | |
MSIter (const MSIter &other) | |
Copy construct. More... | |
MSIter * | clone () const |
virtual | ~MSIter () |
Destructor. More... | |
MSIter & | operator= (const MSIter &other) |
Assigment. More... | |
void | setInterval (Double timeInterval) |
Set or reset the time interval to use for iteration. More... | |
virtual void | origin () |
Reset iterator to start of data. More... | |
virtual Bool | more () const |
Return False if there is no more data. More... | |
virtual MSIter & | operator++ (int) |
Advance iterator through data. More... | |
virtual MSIter & | operator++ () |
const String & | keyChange () const |
Report Name of slowest column that changes at end of current iteration. More... | |
Table | table () const |
Return the current Table iteration. More... | |
const MS & | ms () const |
Return reference to the current MS. More... | |
const MSColumns & | msColumns () const |
Return reference to the current MSColumns. More... | |
size_t | msId () const |
Return the current MS Id (according to the order in which they appeared in the constructor) More... | |
Bool | newMS () const |
Return true if msId has changed since last iteration. More... | |
const ScalarColumn< Int > & | colArrayIds () const |
Return the current ArrayIds for all rows in this iteration. More... | |
const ScalarColumn< Int > & | colFieldIds () const |
Return the current FieldIds for all rows in this iteration. More... | |
const ScalarColumn< Int > & | colDataDescriptionIds () const |
Return the current DataDescriptionIds for all rows in this iteration. More... | |
Int | arrayId () const |
Return the ArrayId of the first element in this iteration. More... | |
Bool | newArray () const |
Return True if ArrayId has changed since last iteration Note that if MS_ARRAY is not part of the sorting columns this will always be true. More... | |
Int | fieldId () const |
Return the FieldId of the first element in this iteration. More... | |
Bool | newField () const |
Return True if FieldId/Source has changed since last iteration Note that if MS_FIELD_ID is not part of the sorting columns this will always be true. More... | |
Int | spectralWindowId () const |
Return SpectralWindow of the first element in this iteration. More... | |
Bool | newSpectralWindow () const |
Return True if SpectralWindow has changed since last iteration Note that if MS_DATA_DESC_ID is not part of the sorting columns this will always be true. More... | |
Int | dataDescriptionId () const |
Return DataDescriptionId of the first element in this iteration. More... | |
Bool | newDataDescriptionId () const |
Return True if DataDescriptionId has changed since last iteration Note that if MS_DATA_DESC_ID is not part of the sorting columns this will always be true. More... | |
Int | polarizationId () const |
Return PolarizationId of the first element in this iteration. More... | |
Bool | newPolarizationId () const |
Return True if polarization has changed since last iteration Note that if MS_DATA_DESC_ID is not part of the sorting columns this will always be true. More... | |
Int | polFrame () const |
Return frame for polarization of the first element in this iteration. More... | |
const Vector< Double > & | frequency () const |
Return the frequencies corresponding to the DATA matrix. More... | |
const MFrequency & | frequency0 () const |
Return frequency of first channel of the first element in iteration with reference frame as a Measure. More... | |
const MFrequency & | restFrequency (Int line=0) const |
Return the rest frequency of the specified line as a Measure. More... | |
const MPosition & | telescopePosition () const |
Return the telescope position (if a known telescope) or the position of the first antenna (if unknown) More... | |
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. More... | |
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. More... | |
const Matrix< Double > & | receptorAngle () const |
Return the receptor angle for feed 0 on each antenna. More... | |
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. More... | |
const Vector< String > & | antennaMounts () const |
Return a string mount identifier for each antenna. More... | |
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). More... | |
Bool | allBeamOffsetsZero () const |
True if all elements of the cube returned by getBeamOffsets are zero. More... | |
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. More... | |
size_t | numMS () const |
Get the number of actual ms's associated wth this iterator. More... | |
const MS & | ms (const size_t n) const |
Get a reference to the nth ms in the list of ms associated with this iterator. More... | |
const MDirection & | phaseCenter () const |
Returns the phasecenter for the first time stamp of the iteration The time is important for field tables that have polynomial or ephemerides phasecenters, i.e time varying for a given field_id. More... | |
const MDirection | phaseCenter (const Int fldID, const Double timeStamp) const |
If the iterator is set so as one iteration has more that 1 value of time stamp or fieldid then the caller should use the phasecenter with field id and time explicitly. More... | |
const String & | fieldName () const |
return FIELD table associated current fieldname and sourcename respectively More... | |
const String & | sourceName () const |
Protected Member Functions | |
void | construct (const Block< Int > &sortColumns, Bool addDefaultSortColumns) |
handle the construction details More... | |
void | construct (const std::vector< std::pair< String, CountedPtr< BaseCompare >>> &sortColumns) |
handle the construction details using explicit comparison functions More... | |
void | advance () |
advance the iteration More... | |
virtual void | setState () |
set the iteration state More... | |
void | setMSInfo () |
void | setArrayInfo () |
void | setFeedInfo () const |
void | cacheCurrentDDInfo () const |
Store the current DD, SPW, Pol ID. More... | |
void | cacheExtraDDInfo () const |
Store extra info related to the DD. More... | |
void | setFieldInfo () const |
Bool | isSubSet (const Vector< rownr_t > &r1, const Vector< rownr_t > &r2) |
Determine if the numbers in r1 are a sorted subset of those in r2. More... | |
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.
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.
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 MeasurementSet & | ms, |
const std::vector< std::pair< String, CountedPtr< BaseCompare >>> & | sortColumns | ||
) |
This constructor is similar to the previous ones but the comparison functions used to group the iterations are given explicitly, making the constructor more generic.
Also, the column is specified as a string, to support sorting by columns not part of the standard MS definition. Note that with this constructor TIME is not treated in any special way and there are no default sorting columns, i.e., the sorting needs have to be set explicitly. The last element in vector sortColumns will be the column that will change faster in the iteration loop, whereas the first element will be the slower. For instance, if sortColumns[0].first = "DATA_DESC_ID" nad sortColumns[1].first = "ANTENNA1" then the first iterations will go through all possible values of ANTENNA1 for the first DDId, then it will start the iterations for the second DDId and so on.
casacore::MSIter::MSIter | ( | const Block< MeasurementSet > & | mss, |
const std::vector< std::pair< String, CountedPtr< BaseCompare >>> & | sortColumns | ||
) |
Same as above with multiple MSs as input.
casacore::MSIter::MSIter | ( | const MSIter & | other | ) |
Copy construct.
This calls the assigment operator.
|
virtual |
Destructor.
|
protected |
advance the iteration
|
inline |
True if all elements of the cube returned by getBeamOffsets are zero.
Definition at line 557 of file MSIter.h.
References allBeamOffsetsZero_p, feedInfoCached_p, and setFeedInfo().
Return a string mount identifier for each antenna.
Definition at line 553 of file MSIter.h.
References antennaMounts_p.
|
inline |
Return the ArrayId of the first element in this iteration.
Definition at line 527 of file MSIter.h.
References curArrayIdFirst_p.
|
protected |
Store the current DD, SPW, Pol ID.
It can be called in logically const objects although it modifies caching (mutable) variables for performance reasons.
Referenced by colDataDescriptionIds(), dataDescriptionId(), polarizationId(), polFrame(), and spectralWindowId().
|
protected |
Store extra info related to the DD.
It can be called in logically const objects although it modifies caching (mutable) variables for performance reasons.
Referenced by colDataDescriptionIds(), dataDescriptionId(), polarizationId(), polFrame(), and spectralWindowId().
|
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 545 of file MSIter.h.
References CJonesFeed0_p, feedInfoCached_p, and setFeedInfo().
|
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 547 of file MSIter.h.
References CJones_p, feedInfoCached_p, and setFeedInfo().
MSIter* casacore::MSIter::clone | ( | ) | const |
|
inline |
Return the current ArrayIds for all rows in this iteration.
Definition at line 520 of file MSIter.h.
References colArray_p.
|
inline |
Return the current DataDescriptionIds for all rows in this iteration.
Definition at line 524 of file MSIter.h.
References cacheCurrentDDInfo(), cacheExtraDDInfo(), colDataDesc_p, and curDataDescIdFirst_p.
|
inline |
Return the current FieldIds for all rows in this iteration.
Definition at line 522 of file MSIter.h.
References colField_p.
|
protected |
handle the construction details
|
protected |
handle the construction details using explicit comparison functions
|
inline |
Return DataDescriptionId of the first element in this iteration.
Definition at line 535 of file MSIter.h.
References cacheCurrentDDInfo(), cacheExtraDDInfo(), and curDataDescIdFirst_p.
|
inline |
Return the FieldId of the first element in this iteration.
Definition at line 528 of file MSIter.h.
References curFieldIdFirst_p, and setFieldInfo().
const String& casacore::MSIter::fieldName | ( | ) | const |
return FIELD table associated current fieldname and sourcename respectively
Return the frequencies corresponding to the DATA matrix.
const MFrequency& casacore::MSIter::frequency0 | ( | ) | const |
Return frequency of first channel of the first element in iteration 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.
|
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 555 of file MSIter.h.
References beamOffsets_p, feedInfoCached_p, and setFeedInfo().
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.
|
protected |
Determine if the numbers in r1 are a sorted subset of those in r2.
const String& casacore::MSIter::keyChange | ( | ) | const |
Report Name of slowest column that changes at end of current iteration.
|
inlinevirtual |
|
inline |
const MS& casacore::MSIter::ms | ( | const size_t | 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
|
inline |
|
inline |
|
inline |
Return True if ArrayId has changed since last iteration Note that if MS_ARRAY is not part of the sorting columns this will always be true.
Definition at line 514 of file MSIter.h.
References newArrayId_p.
|
inline |
Return True if DataDescriptionId has changed since last iteration Note that if MS_DATA_DESC_ID is not part of the sorting columns this will always be true.
Definition at line 539 of file MSIter.h.
References newDataDescId_p.
|
inline |
Return True if FieldId/Source has changed since last iteration Note that if MS_FIELD_ID is not part of the sorting columns this will always be true.
Definition at line 515 of file MSIter.h.
References newFieldId_p.
|
inline |
|
inline |
Return True if polarization has changed since last iteration Note that if MS_DATA_DESC_ID is not part of the sorting columns this will always be true.
Definition at line 538 of file MSIter.h.
References newPolarizationId_p.
|
inline |
Return True if SpectralWindow has changed since last iteration Note that if MS_DATA_DESC_ID is not part of the sorting columns this will always be true.
Definition at line 516 of file MSIter.h.
References newSpectralWindowId_p.
|
inline |
|
virtual |
Advance iterator through data.
|
virtual |
Assigment.
This will reset the iterator to the origin.
|
virtual |
Reset iterator to start of data.
const MDirection& casacore::MSIter::phaseCenter | ( | ) | const |
Returns the phasecenter for the first time stamp of the iteration The time is important for field tables that have polynomial or ephemerides phasecenters, i.e time varying for a given field_id.
If the iterator is set so as one iteration has more that 1 time stamp then this version is correct only for fixed phasecenters
const MDirection casacore::MSIter::phaseCenter | ( | const Int | fldID, |
const Double | timeStamp | ||
) | const |
If the iterator is set so as one iteration has more that 1 value of time stamp or fieldid then the caller should use the phasecenter with field id and time explicitly.
|
inline |
Return PolarizationId of the first element in this iteration.
Definition at line 532 of file MSIter.h.
References cacheCurrentDDInfo(), cacheExtraDDInfo(), and curPolarizationIdFirst_p.
|
inline |
Return frame for polarization of the first element in this iteration.
Definition at line 540 of file MSIter.h.
References cacheCurrentDDInfo(), cacheExtraDDInfo(), curPolarizationIdFirst_p, and polFrame_p.
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 549 of file MSIter.h.
References feedInfoCached_p, receptorAnglesFeed0_p, and setFeedInfo().
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 551 of file MSIter.h.
References feedInfoCached_p, receptorAngles_p, and setFeedInfo().
const MFrequency& casacore::MSIter::restFrequency | ( | Int | line = 0 | ) | const |
Return the rest frequency of the specified line as a Measure.
|
protected |
|
protected |
Referenced by allBeamOffsetsZero(), CJones(), CJonesAll(), getBeamOffsets(), receptorAngle(), and receptorAngles().
|
protected |
Referenced by fieldId().
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.
|
protected |
|
protectedvirtual |
set the iteration state
const String& casacore::MSIter::sourceName | ( | ) | const |
|
inline |
Return SpectralWindow of the first element in this iteration.
Definition at line 529 of file MSIter.h.
References cacheCurrentDDInfo(), cacheExtraDDInfo(), and curSpectralWindowIdFirst_p.
|
inline |
|
inline |
Return the telescope position (if a known telescope) or the position of the first antenna (if unknown)
Definition at line 543 of file MSIter.h.
References telescopePosition_p.
|
mutableprotected |
each element of the cube in radians) in the antenna coordinate system.
Cube axes are: receptor, antenna, feed.
Definition at line 494 of file MSIter.h.
Referenced by allBeamOffsetsZero().
Definition at line 488 of file MSIter.h.
Referenced by antennaMounts().
|
mutableprotected |
antenna (e.g.
EQUATORIAL, ALT-AZ,...)
Definition at line 490 of file MSIter.h.
Referenced by getBeamOffsets().
|
protected |
|
mutableprotected |
|
mutableprotected |
|
protected |
Definition at line 475 of file MSIter.h.
Referenced by colArrayIds().
|
mutableprotected |
This column is mutable since it is only attached when it is neccesary to read the DD Ids.
That might happen when calling a const accesor like dataDescriptionId().
Definition at line 474 of file MSIter.h.
Referenced by colDataDescriptionIds().
|
mutableprotected |
Definition at line 474 of file MSIter.h.
Referenced by colFieldIds().
|
protected |
|
mutableprotected |
These variables point to the current (as in this iteration) DD, SPW and polarization IDs.
They are mutable since they are evaluated in a lazy way, i.e., only when needed. If the DDId is part of the sorting columns then it is always computed when calling next(), otherwise it is only computed when some accesor of metadata that depends on them is called by the application.
Definition at line 453 of file MSIter.h.
Referenced by colDataDescriptionIds(), and dataDescriptionId().
|
mutableprotected |
|
mutableprotected |
|
protected |
|
mutableprotected |
Definition at line 453 of file MSIter.h.
Referenced by polarizationId(), and polFrame().
|
mutableprotected |
Definition at line 453 of file MSIter.h.
Referenced by spectralWindowId().
|
protected |
|
mutableprotected |
Variable to know whether the feed info is already computed.
Definition at line 462 of file MSIter.h.
Referenced by allBeamOffsetsZero(), CJones(), CJonesAll(), getBeamOffsets(), receptorAngle(), and receptorAngles().
|
mutableprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Definition at line 440 of file MSIter.h.
Referenced by msColumns().
|
protected |
Definition at line 457 of file MSIter.h.
Referenced by newArray().
|
protected |
Definition at line 457 of file MSIter.h.
Referenced by newDataDescriptionId().
|
protected |
Definition at line 457 of file MSIter.h.
Referenced by newField().
|
protected |
|
protected |
Definition at line 457 of file MSIter.h.
Referenced by newPolarizationId().
|
protected |
Definition at line 457 of file MSIter.h.
Referenced by newSpectralWindow().
|
protected |
|
mutableprotected |
|
mutableprotected |
are zero (to speed things up in a single beam case)
Definition at line 497 of file MSIter.h.
Referenced by polFrame().
|
mutableprotected |
temporary retained for compatibility contain actually a reference to the first plane of receptorAngles_p
Definition at line 484 of file MSIter.h.
Referenced by receptorAngles().
|
protected |
|
protected |
|
protected |
|
protected |
Definition at line 503 of file MSIter.h.
Referenced by telescopePosition().
|
protected |
|
protected |