SimDoppler.h

Classes

SimDoppler -- a container for spectral line information for simulated observations. (full description)
SimDopplerList -- a container for data destined for an MS DOPPLER table (full description)

class SimDoppler

Interface

Public Members
SimDoppler(uInt srcId, const MFrequency& rfreq, const String& transition, Int spwid=-1) : row_p(-1), src_p(srcId), rfreq_p(rfreq), trans_p(transition), spwids_p(1)
SimDoppler(uInt srcId, const MFrequency& rfreq, const String& transition, const Vector<Int>& spwids) : row_p(-1), src_p(srcId), rfreq_p(rfreq), trans_p(transition), spwids_p(spwids)
SimDoppler(const SimDoppler& s)
SimDoppler& operator=(const SimDoppler& s)
~SimDoppler()
Int getRow() const
void setRow(Int id)
uInt sourceId() const
const String& transition() const
const MFrequency& restFrequency() const
const Vector<Int>& spectralWindowIds()

Description

Prerequisite

Etymology

This is a container for describing doppler tracking in simulated observations.

Synopsis

This container holds data describing a spectral line to be observed, along with which spectral windows it can appear in. This information is ultimately destined to be recorded in a Measurement Set: the spectral line--that is, the species name, transition, and rest frequency--will go in the SOURCE table; however, the association with spectral windows is recorded in the DOPPLER table. This container is used to define simulated observations. Simulators would not normally create these objects directly but rather implicitly via the SimObservations class.

The spectral line information is set at construction time and cannot be updated later. The only writable data is a row marker (set with setRow()) which is used by SimDopplerList to flag whether the line has been recorded to an MS, yet. The marker value represents the first row in the DOPPLER table corresponding to the SimDoppler's spectral line. Since a line can be associated with multiple spectral windows, a single SimDoppler can result in several DOPPLER records (as well as SOURCE records).

Note that when a SimDoppler is created, no check is done to ensure that the source ID and spectral window IDs exist or are otherwise valid; in general, this should be done at a higher level. On the other hand, the SimDopperList does check validity when it writes the line data to an MS. It skips over any SimDopplers with invalid IDs, and it refuses associate a line with a window that has already been linked to a different line. Thus if a spectral line window is referenced multiple times, either within a single SimDoppler or across several, the first one encountered takes precendence.

Motivation

This container provides an simplified in-memory representation of feeds that will ultimately be written to a DOPPLER table. It is mainly needed as a way to associate spectral window with a particular a spectral line. The interface is oriented toward what is typical with current instruments and thus is simpler than the interface provided by the MS DOPPLER table.

To Do

Member Description

SimDoppler(uInt srcId, const MFrequency& rfreq, const String& transition, Int spwid=-1) : row_p(-1), src_p(srcId), rfreq_p(rfreq), trans_p(transition), spwids_p(1)

Create a record associating a spectral line with a single window. srcId is the ID of the Source associated with this line rfreq is the line's rest frequency. transition is a String representation of the species and transition (e.g. "CO J=1-0"). spwid is the ID of the spectral window to associate this line with. If this ID is < 0, then it will be associated with all the windows defined at the time the line data is written out.

SimDoppler(uInt srcId, const MFrequency& rfreq, const String& transition, const Vector<Int>& spwids) : row_p(-1), src_p(srcId), rfreq_p(rfreq), trans_p(transition), spwids_p(spwids)

Create a record associating a spectral line with a list of windows srcId is the ID of the Source associated with this line rfreq is the line's rest frequency. transition is a String representation of the species and transition (e.g. "CO J=1-0"). spwids is the list of spectral window IDs to associate this line with. If any of the IDs is < 0, then it will be associated with all the windows defined at the time the line data is written out.

SimDoppler(const SimDoppler& s)
SimDoppler& operator=(const SimDoppler& s)

create a copy

~SimDoppler()

Int getRow() const
void setRow(Int id)

get and set the row ID, the row in the DOPPLER table containing this record. An ID less than zero means that this record has not yet been recorded.

uInt sourceId() const

return the ID of the source observed in this field

const String& transition() const

return the name of the spectral line transition (e.g. "CO J=1-0");

const MFrequency& restFrequency() const

return the rest frequency of the spectral line transition

const Vector<Int>& spectralWindowIds()

return the list of window IDs this line is associated with. An id < 0 indicates that the line is associated with all windows


class SimDopplerList

Interface

SimDopplerList(uInt initsz=2, uInt stepsz=4) : n_p(0), chnk_p(stepsz), rec_p(initsz, 0)
SimDopplerList(const MSDoppler& dopt, const MSSource& srct, const MSSpectralWindow& spwt, uInt stepz=4)
SimDopplerList(const SimDopplerList& t)
SimDopplerList& operator=(const SimDopplerList& t)
~SimDopplerList()
void clearIds()
SimDoppler& operator[](Int i)
const SimDoppler& operator[](Int i) const
Int numDopplers() const
SimDoppler& addDoppler(uInt srcId, const MFrequency& rfreq, const String& transition, Int spwid=-1)
SimDoppler& addDoppler(uInt srcId, const MFrequency& rfreq, const String& transition, const Vector<Int>& spwids)
SimDoppler& addDoppler(uInt srcId, const MFrequency& rfreq, const String& transition, const Vector<uInt>& spwids)
void initFrom(const MSDoppler& dopt, const MSSource& srct, const MSSpectralWindow& spwt)
void flush(MSDoppler& dopt, MSSource& srct, MSSpectralWindow& spwt)
Private Members
void deleteRecs()
SimDoppler& get(Int i) const
void throwOutOfRange(uInt legallength, Int index) const
void add(SimDoppler *dop)

Description

Prerequisite

//

Etymology

This class holds a list of SimDoppler objects.

Synopsis

This class holds a list of SimDoppler instances which, as a group, describes a list of spectral lines to observe. When using this class, one does not create SimDoppler objects directly, but rather implicitly via the addDoppler() function. The ultimate purpose of this container is to support simulated observations. Simulators would not normally create these objects directly but rather implicitly via the SimObservations class.

An important function handled by this class is the recording of the spectral lines to a Measurement Set. This is done with the flush() function which writes to the SOURCE, SPECTRAL_WINDOW, and DOPPLER tables. When a SimDoppler is written out, it sets the row number of the first DOPPLER record corresponding to it via the setRow() function; this is used as a flag indicating that the SimDoppler has been flushed. This allows one to later add additional setups to the list; when flush() is called again, only the new SimDoppler data are written out. This, of course, assumes that the same set of output MS tables are passed to the flush() function each time. If you want to write all the data to a new DOPPLER table, you can call clearIds() to clear all the row markers.

A list of polarization setups can be read in from a DOPPLER table as well using the initFrom() method or the SimDopplerList(const MSDoppler&, const MSSource&, const MSpectralWindow&) constructor. These will implicitly set the row markers from the input table. This allows one to add new setups to the already recorded set.

Note that when a SimDoppler is added to the list, no check is done to ensure that the source ID and spectral window IDs exist or are otherwise valid (in general, this should be done at a higher level). Validity is checked, however, when the list is written out to an MS. It skips over any SimDopplers with invalid IDs, and it refuses associate a line with a window that has already been linked to a different line. Thus if a spectral line window is referenced multiple times within the list, the first one encountered takes precendence.

Motivation

This container provides an simplified in-memory representation of spectral lines that will ultimately be written to an MS's SOURCE, DOPPLER and SPECTRAL_WINDOW tables. The interface is oriented toward what is typical with current instruments and thus is simpler than the interface provided by the MS table interfaces.

To Do

Member Description

SimDopplerList(uInt initsz=2, uInt stepsz=4) : n_p(0), chnk_p(stepsz), rec_p(initsz, 0)

create an empty list

SimDopplerList(const MSDoppler& dopt, const MSSource& srct, const MSSpectralWindow& spwt, uInt stepz=4)

create a list and fill it with the contents of a DOPPLER table

SimDopplerList(const SimDopplerList& t)
SimDopplerList& operator=(const SimDopplerList& t)

create a copy

~SimDopplerList()

void clearIds()

reset all the row markers used to flag the SimDoppler members that have been recorded to a Measurement Set already. Thus, the next call to flush() will record all SimFields to the proper tables. This should be used when writing to a new MS, different from one previously read from or written to.

SimDoppler& operator[](Int i)
const SimDoppler& operator[](Int i) const

access the i-th spectral line description in the list.

Int numDopplers() const

return the number of descriptions in this list.

SimDoppler& addDoppler(uInt srcId, const MFrequency& rfreq, const String& transition, Int spwid=-1)
SimDoppler& addDoppler(uInt srcId, const MFrequency& rfreq, const String& transition, const Vector<Int>& spwids)
SimDoppler& addDoppler(uInt srcId, const MFrequency& rfreq, const String& transition, const Vector<uInt>& spwids)

Create a record associating a spectral line with a one or more windows. srcId is the ID of the Source associated with this line rfreq is the line's rest frequency. transition is a String representation of the species and transition (e.g. "CO J=1-0"). spwid is the ID of the spectral window to associate this line with. If this ID is < 0, then it will be associated with all the windows defined at the time the line data is written out. spwids is the list of spectral window IDs to associate this line with. If any of the IDs is < 0, then it will be associated with all the windows defined at the time the line data is written out.

void initFrom(const MSDoppler& dopt, const MSSource& srct, const MSSpectralWindow& spwt)

add spectral line descriptions from an MS DOPPLER table

void flush(MSDoppler& dopt, MSSource& srct, MSSpectralWindow& spwt)

write out all spectral lines that have yet to be written

void deleteRecs()

SimDoppler& get(Int i) const

void throwOutOfRange(uInt legallength, Int index) const

void add(SimDoppler *dop)