VisibilityIterator.h

Classes

ROVisibilityIterator -- ROVisibilityIterator iterates through one or more readonly MeasurementSets (full description)
VisibilityIterator -- VisibilityIterator iterates through one or more writable MeasurementSets (full description)

class ROVisibilityIterator

Types

enum PolFrame

Circular = 0
Circular polarization
Linear = 1
Linear polarization

enum DataColumn

Observed = 0
Observed data
Model
Model data
Corrected
Corrected data

Interface

Public Members
ROVisibilityIterator()
ROVisibilityIterator(const MeasurementSet& ms, const Block<Int>& sortColumns, Double timeInterval=0)
ROVisibilityIterator(const Block<MeasurementSet>& mss, const Block<Int>& sortColumns, Double timeInterval=0)
ROVisibilityIterator(const ROVisibilityIterator & other)
ROVisibilityIterator & operator=(const ROVisibilityIterator &other)
virtual ~ROVisibilityIterator()
void origin()
void originChunks()
void setInterval(Double timeInterval)
void setRowBlocking(Int nRows=0)
Bool more() const
ROVisibilityIterator & operator++(int)
ROVisibilityIterator & operator++()
Bool moreChunks() const
Bool newMS() const
Int msId() const
ROVisibilityIterator& nextChunk()
Vector<Int>& antenna1(Vector<Int>& ant1) const
Vector<Int>& antenna2(Vector<Int>& ant2) const
Vector<Int>& feed1(Vector<Int>& fd1) const
Vector<Int>& feed2(Vector<Int>& fd2) const
Vector<Int>& channel(Vector<Int>& chan) const
Vector<SquareMatrix<Complex,2> >& CJones(Vector<SquareMatrix<Complex,2> >& cjones) const
const Cube<Double>& receptorAngles() const
const Vector<String>& antennaMounts() const
const Cube<RigidVector<Double, 2> >& getBeamOffsets() const
Bool allBeamOffsetsZero() const
const Vector<Float>& feed_pa(Double time) const
const Vector<MDirection>& azel(Double time) const
Int fieldId() const
Int arrayId() const
String fieldName() const
String sourceName() const
Cube<Bool>& flag(Cube<Bool>& flags) const
Matrix<Bool>& flag(Matrix<Bool>& flags) const
Vector<Bool>& flagRow(Vector<Bool>& rowflags) const
Vector<Int>& scan(Vector<Int>& scans) const
Vector<Double>& frequency(Vector<Double>& freq) const
Vector<Double>& lsrFrequency(Vector<Double>& freq) const
const MDirection& phaseCenter() const
Int polFrame() const
Vector<Int>& corrType(Vector<Int>& corrTypes) const
Vector<Float>& sigma(Vector<Float>& sig) const
Int spectralWindow() const
Int polarizationId() const
Vector<Double>& time(Vector<Double>& t) const
Vector<Double>& timeInterval(Vector<Double>& t) const
Cube<Complex>& visibility(Cube<Complex>& vis, DataColumn whichOne) const
Matrix<CStokesVector>& visibility(Matrix<CStokesVector>& vis, DataColumn whichOne) const
IPosition visibilityShape() const
Vector<RigidVector<Double,3> >& uvw(Vector<RigidVector<Double,3> >& uvwvec) const
Vector<Float>& weight(Vector<Float>& wt) const
Matrix<Float>& imagingWeight(Matrix<Float>& wt) const
Bool newFieldId() const
Bool newArrayId() const
Bool newSpectralWindow() const
Int channelIndex() const
Int channelGroupSize() const
Int nRow() const
Int nRowChunk() const
Int nSubInterval() const
ROVisibilityIterator& selectVelocity(Int nChan, const MVRadialVelocity& vStart, const MVRadialVelocity& vInc, MRadialVelocity::Types rvType = MRadialVelocity::LSR, MDoppler::Types dType = MDoppler::RADIO, Bool precise=False)
ROVisibilityIterator& velInterpolation(const String& type)
ROVisibilityIterator& selectChannel(Int nGroup=1, Int start=0, Int width=0, Int increment=0, Int spectralWindow=-1)
ROVisibilityIterator& selectChannel(Block< Vector<Int> >& blockNGroup, Block< Vector<Int> >& blockStart, Block< Vector<Int> >& blockWidth, Block< Vector<Int> >& blockIncr, Block< Vector<Int> >& blockSpw)
void attachVisBuffer(VisBuffer& vb)
void detachVisBuffer(VisBuffer& vb)
const ROMSColumns& msColumns() const
void allSelectedSpectralWindows(Vector<Int>& spws, Vector<Int>& nvischan)
void lsrFrequency(const Int& spw, Vector<Double>& freq, Bool& convert)
Protected Members
void advance()
void setSelTable()
void setState()
void getTopoFreqs()
void updateSlicer()
virtual void attachColumns()
void getInterpolatedVisFlagWeight(DataColumn whichOne) const
void getDataColumn(DataColumn whichOne, const Slicer& slicer, Cube<Complex>& data) const
void getDataColumn(DataColumn whichOne, Cube<Complex>& data) const
void doChannelSelection()

Description

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Etymology

The ROVisibilityIterator is a readonly iterator returning visibilities

Synopsis

ROVisibilityIterator provides iteration with various sort orders for one or more MSs. It has member functions to retrieve the fields commonly needed in synthesis calibration and imaging.

One should use VisBuffer to access chunks of data.

Example

//

Motivation

For imaging and calibration you need to access an MS in some consistent order (by field, spectralwindow, time interval etc.). This class provides that access.

Thrown Exceptions

To Do

Member Description

enum PolFrame

enum DataColumn

ROVisibilityIterator()

Default constructor - useful only to assign another iterator later

ROVisibilityIterator(const MeasurementSet& ms, const Block<Int>& sortColumns, Double timeInterval=0)

Construct from MS and a Block of MS column enums specifying the iteration order, if none are specified, time iteration is implicit. 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. SPECTRAL_WINDOW_ID and FIELD_ID). Using selectChannel(), a number of groups of channels can be requested. At present the channel group iteration will always occur before the interval iteration.

ROVisibilityIterator(const Block<MeasurementSet>& mss, const Block<Int>& sortColumns, Double timeInterval=0)

Same as previous constructor, but with multiple MSs to iterate over.

ROVisibilityIterator(const ROVisibilityIterator & other)

Copy construct. This calls the assigment operator.

ROVisibilityIterator & operator=(const ROVisibilityIterator &other)

Assigment. Any attached VisBuffers are lost in the assign.

virtual ~ROVisibilityIterator()

Destructor

void origin()

Members

Reset iterator to origin/start of data (of current chunk)

void originChunks()

Reset iterator to true start of data (first chunk)

void setInterval(Double timeInterval)

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

void setRowBlocking(Int nRows=0)

Set the 'blocking' size for returning data. With the default (0) only a single integration is returned at a time, this is what is currently required for the calibration software. With blocking set, up to nRows can be returned in one go. The chunk size determines the actual maximum.

Bool more() const

Return False if no more data (in current chunk)

ROVisibilityIterator & operator++(int)

Advance iterator through data

ROVisibilityIterator & operator++()

Bool moreChunks() const

Return False if no more 'Chunks' of data left

Bool newMS() const

Check if ms has change since last iteration

Int msId() const

ROVisibilityIterator& nextChunk()

Advance to the next Chunk of data

Vector<Int>& antenna1(Vector<Int>& ant1) const

Return antenna1

Vector<Int>& antenna2(Vector<Int>& ant2) const

Return antenna2

Vector<Int>& feed1(Vector<Int>& fd1) const

Return feed1

Vector<Int>& feed2(Vector<Int>& fd2) const

Return feed2

Vector<Int>& channel(Vector<Int>& chan) const

Return channel numbers in selected VisSet spectrum (i.e. disregarding possible selection on the iterator, but including the selection set when creating the VisSet)

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

Return feed configuration matrix for specified antenna

const Cube<Double>& receptorAngles() const

Return receptor angles for all antennae and feeds First axis of the cube is a receptor number, 2nd is antennaId, 3rd is feedId Note: the method is intended to provide an access to MSIter::receptorAngles for VisBuffer in the multi-feed case. It may be worth to change the interface of feed_pa to return the information for all feeds.

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 offsets for each receptor of each feed (values are in radians, coordinate system is fixed with antenna and is the same one as used to define the BEAM_OFFSET parameter in the feed table). The cube axes are receptor, antenna, feed.

Bool allBeamOffsetsZero() const

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

const Vector<Float>& feed_pa(Double time) const

Return feed parallactic angles Vector(nant) (1 feed/ant)

const Vector<MDirection>& azel(Double time) const

Return the antenna AZ/EL Vector(nant)

Int fieldId() const

Return the current FieldId

Int arrayId() const

Return the current ArrayId

String fieldName() const

Return the current Field Name

String sourceName() const

Return the current Source Name

Cube<Bool>& flag(Cube<Bool>& flags) const

Return flag for each polarization, channel and row

Matrix<Bool>& flag(Matrix<Bool>& flags) const

Return flag for each channel & row

Vector<Bool>& flagRow(Vector<Bool>& rowflags) const

Return row flag

Vector<Int>& scan(Vector<Int>& scans) const

Return scan number

Vector<Double>& frequency(Vector<Double>& freq) const

Return current frequencies

Vector<Double>& lsrFrequency(Vector<Double>& freq) const

Return frequencies in selected velocity frame, returns the same as frequency() if there is no vel selection active.

const MDirection& phaseCenter() const

Return the current phase center as an MDirection

Int polFrame() const

Return frame for polarization (returns PolFrame enum)

Vector<Int>& corrType(Vector<Int>& corrTypes) const

Return the correlation type (returns Stokes enums)

Vector<Float>& sigma(Vector<Float>& sig) const

Return sigma

Int spectralWindow() const

Return current SpectralWindow

Int polarizationId() const

Return current Polarization Id

Vector<Double>& time(Vector<Double>& t) const

Return MJD

Vector<Double>& timeInterval(Vector<Double>& t) const

Return MJD time interval

Cube<Complex>& visibility(Cube<Complex>& vis, DataColumn whichOne) const

Return the visibilities as found in the MS, Cube(npol,nchan,nrow).

Matrix<CStokesVector>& visibility(Matrix<CStokesVector>& vis, DataColumn whichOne) const

Return the visibility 4-vector of polarizations for each channel. If the MS doesn't contain all polarizations, it is assumed it contains one or two parallel hand polarizations.

IPosition visibilityShape() const

Return the shape of the visibility Cube

Vector<RigidVector<Double,3> >& uvw(Vector<RigidVector<Double,3> >& uvwvec) const

Return u,v and w (in meters)

Vector<Float>& weight(Vector<Float>& wt) const

Return weight

Matrix<Float>& imagingWeight(Matrix<Float>& wt) const

Return imaging weight (a weight for each channel)

Bool newFieldId() const

Return True if FieldId/Source has changed since last iteration

Bool newArrayId() const

Return True if arrayID has changed since last iteration

Bool newSpectralWindow() const

Return True if SpectralWindow has changed since last iteration

Int channelIndex() const

Return the index of the first channel of the current channel group in the total (selected) spectrum.

Int channelGroupSize() const

Return the width of the current group of channels, i.e., the number of channels returned by visibility() and frequency().

Int nRow() const

Return the number of rows in the current iteration

Int nRowChunk() const

Return the numbers of rows in the current chunk

Int nSubInterval() const

Return the number of sub-intervals in the current chunk

ROVisibilityIterator& selectVelocity(Int nChan, const MVRadialVelocity& vStart, const MVRadialVelocity& vInc, MRadialVelocity::Types rvType = MRadialVelocity::LSR, MDoppler::Types dType = MDoppler::RADIO, Bool precise=False)

Velocity selection - specify the output channels in velocity: nChan - number of output channels, vStart - start velocity, vInc - velocity increment. So channel i will have velocity vStart + i*vInc (i=0,nChan-1). Specify velocities as in e.g., MVRadialVelocity(Quantity(2001.,"km/s")). The reference type and velocity definition are specified separately. Note that no averaging is performed, the visibilities will be interpolated and sampled at the specified velocities, it's up to you to choose a vInc appropriate to the channel width. The REST_FREQUENCY column in the SPECTRAL_WINDOW subtable is used to determine the velocity-frequency conversion. By default calculations are done for a single velocity with offsets applied for the others (ok for non-rel velocities with RADIO defn), set precise to True to do a full conversion for each output channel.(NYI)

ROVisibilityIterator& velInterpolation(const String& type)

Select the velocity interpolation scheme. At present the choice is limited to : nearest and linear, linear is the default. TODO: add cubic, spline and possibly FFT

ROVisibilityIterator& selectChannel(Int nGroup=1, Int start=0, Int width=0, Int increment=0, Int spectralWindow=-1)

Channel selection - only the selected channels will be returned by the access functions. The default spectralWindow is the current one (or 0) This allows selection of the input channels, producing nGroup groups of width output channels. Default is to return all channels in a single group.

ROVisibilityIterator& selectChannel(Block< Vector<Int> >& blockNGroup, Block< Vector<Int> >& blockStart, Block< Vector<Int> >& blockWidth, Block< Vector<Int> >& blockIncr, Block< Vector<Int> >& blockSpw)

Same as above except when multiple ms's are to be accessed

void attachVisBuffer(VisBuffer& vb)

Attach a VisBuffer object. Note that while more than one VisBuffer may be attached, only the last one is actively updated. A Stack is kept internally, so after a detach, the previous VisBuffer becomes active again.

void detachVisBuffer(VisBuffer& vb)

Detach a VisBuffer object. If the object detached is not the last one attached an exception is thrown.

const ROMSColumns& msColumns() const

Access the current ROMSColumns object in MSIter

void allSelectedSpectralWindows(Vector<Int>& spws, Vector<Int>& nvischan)

get back the selected spectral windows and spectral channels for current ms

void lsrFrequency(const Int& spw, Vector<Double>& freq, Bool& convert)

Convert the frequency from the observe frame to lsr frame. Returns True in convert if given spw was not observed in the LSRK frame

void advance()

advance the iteration

void setSelTable()

set the currently selected table

void setState()

set the iteration state

void getTopoFreqs()

get the TOPO frequencies from the selected velocities and the obs. vel.

void updateSlicer()

update the DATA slicer

virtual void attachColumns()

attach the column objects to the currently selected table

void getInterpolatedVisFlagWeight(DataColumn whichOne) const

get the (velocity selected) interpolated visibilities, flags and weights

void getDataColumn(DataColumn whichOne, const Slicer& slicer, Cube<Complex>& data) const

get the visibility data (observed, corrected or model); deals with Float and Complex observed data (DATA or FLOAT_DATA)

void getDataColumn(DataColumn whichOne, Cube<Complex>& data) const

void doChannelSelection()

Re-Do the channel selection in multi ms case


class VisibilityIterator : public ROVisibilityIterator

Interface

Public Members
VisibilityIterator()
VisibilityIterator(MeasurementSet & ms, const Block<Int>& sortColumns, Double timeInterval=0)
VisibilityIterator(Block<MeasurementSet>& mss, const Block<Int>& sortColumns, Double timeInterval=0)
VisibilityIterator(const VisibilityIterator & MSI)
VisibilityIterator & operator=(const VisibilityIterator &MSI)
virtual ~VisibilityIterator()
VisibilityIterator & operator++(int)
VisibilityIterator & operator++()
void setFlag(const Matrix<Bool>& flag)
void setFlag(const Cube<Bool>& flag)
void setFlagRow(const Vector<Bool>& rowflags)
void setVis(const Matrix<CStokesVector>& vis, DataColumn whichOne)
void setVis(const Cube<Complex>& vis, DataColumn whichOne)
void setVisAndFlag(const Cube<Complex>& vis, const Cube<Bool>& flag, DataColumn whichOne)
void setWeight(const Vector<Float>& wt)
void setSigma(const Vector<Float>& sig)
void setImagingWeight(const Matrix<Float>& wt)
Protected Members
virtual void attachColumns()
void setInterpolatedVisFlag(const Cube<Complex>& vis, const Cube<Bool>& flag)
void setInterpolatedWeight(const Matrix<Float>& wt)
void putDataColumn(DataColumn whichOne, const Slicer& slicer, const Cube<Complex>& data)
void putDataColumn(DataColumn whichOne, const Cube<Complex>& data)

Description

Review Status

Date Reviewed:
yyyy/mm/dd

Prerequisite

Etymology

The VisibilityIterator is a read/write iterator returning visibilities

Synopsis

VisibilityIterator provides iteration with various sort orders for one or more MSs. It has member functions to retrieve the fields commonly needed in synthesis calibration and imaging. It is derived from the read-only iterator ROVisibilityIterator.

One should use VisBuffer to access chunks of data.

Example

//

Motivation

For imaging and calibration you need to access an MS in some consistent order (by field, spectralwindow, time interval etc.). This class provides that access.

#

Thrown Exceptions

To Do

Member Description

VisibilityIterator()

Constructors. Note: The VisibilityIterator is not initialized correctly by default, you need to call origin() before using it to iterate.

VisibilityIterator(MeasurementSet & ms, const Block<Int>& sortColumns, Double timeInterval=0)

VisibilityIterator(Block<MeasurementSet>& mss, const Block<Int>& sortColumns, Double timeInterval=0)

Same as previous constructor, but with multiple MSs to iterate over.

VisibilityIterator(const VisibilityIterator & MSI)

VisibilityIterator & operator=(const VisibilityIterator &MSI)

virtual ~VisibilityIterator()

Destructor

VisibilityIterator & operator++(int)

Members

Advance iterator through data

VisibilityIterator & operator++()

void setFlag(const Matrix<Bool>& flag)

Set/modify the flags in the data. This will flag all channels in the original data that contributed to the output channel in the case of channel averaging. All polarizations have the same flag value.

void setFlag(const Cube<Bool>& flag)

Set/modify the flags in the data. This sets the flags as found in the MS, Cube(npol,nchan,nrow), where nrow is the number of rows in the current iteration (given by nRow()).

void setFlagRow(const Vector<Bool>& rowflags)

Set/modify the flag row column; dimension Vector(nrow)

void setVis(const Matrix<CStokesVector>& vis, DataColumn whichOne)

Set/modify the visibilities. This is possibly only for a 'reference' MS which has a new DATA column. The first axis of the matrix should equal the selected number of channels in the original MS. If the MS does not contain all polarizations, only the parallel hand polarizations are used.

void setVis(const Cube<Complex>& vis, DataColumn whichOne)

Set/modify the visibilities This sets the data as found in the MS, Cube(npol,nchan,nrow).

void setVisAndFlag(const Cube<Complex>& vis, const Cube<Bool>& flag, DataColumn whichOne)

Set the visibility and flags, and interpolate from velocities if needed

void setWeight(const Vector<Float>& wt)

Set/modify the weights

void setSigma(const Vector<Float>& sig)

Set/modify the Sigma

void setImagingWeight(const Matrix<Float>& wt)

Set/modify the imaging weights

virtual void attachColumns()

void setInterpolatedVisFlag(const Cube<Complex>& vis, const Cube<Bool>& flag)

void setInterpolatedWeight(const Matrix<Float>& wt)

void putDataColumn(DataColumn whichOne, const Slicer& slicer, const Cube<Complex>& data)

Write the data column (observed, model or corrected); deals with Float or Complex observed data (DATA and FLOAT_DATA).

void putDataColumn(DataColumn whichOne, const Cube<Complex>& data)