MSAsRaster.h

Classes

MSAsRaster -- Class for displaying data within an MS as a raster (gridded) image. (full description)
MSAsRasterDM -- (Minimal) DisplayMethod for MSAsRaster. (full description)

class MSAsRaster: public ActiveCaching2dDD

Interface

Public Members
MSAsRaster(const String msname)
virtual ~MSAsRaster()
virtual Bool setOptions(Record &rec, Record &recOut)
virtual Record getOptions()
virtual void setDefaultOptions()
virtual AttributeBuffer optionsAsAttributes()
virtual Bool conformsToCS(const WorldCanvasHolder& wch)
virtual Bool setActiveZIndex(Int zindex)
virtual String showValue(const Vector<Double> &world)
virtual String showPosition(const Vector<Double> &world, const Bool &displayAxesOnly = False)
virtual const Unit dataUnit()
virtual Display::DisplayDataType classType()
virtual const uInt nelements() const
virtual const uInt nelements(const WorldCanvasHolder &) const
virtual Bool labelAxes(const WCRefreshEvent &ev)
virtual void notifyRegister(WorldCanvasHolder *wch)
virtual void notifyUnregister(WorldCanvasHolder& wch, Bool ignoreRefresh = False)
virtual void handleEvent(DisplayEvent& ev)
virtual Bool zIndexHint(Int& preferredZIndex) const
virtual void purgeCache()
virtual void purgeCache(const WorldCanvasHolder& wch)
Protected Members
void constructParameters_()
void deleteParameters_()
virtual CachingDisplayMethod *newDisplayMethod(WorldCanvas *worldCanvas, AttributeBuffer *wchAttributes, AttributeBuffer *ddAttributes, CachingDisplayData *dd)
static Float real (const Complex& val)
static Float imag (const Complex& val)
Private Members
MSAsRaster(): mspos_(this)
MSAsRaster(const MSAsRaster &other): mspos_(this)
MSAsRaster& operator=(const MSAsRaster &other)
void initMSAR_()
void setDefaultMSAROptions_()
void selectVS_()
void findRanges_()
void setCS_()
void extract_()
void createDisplaySlice_()
Bool draw_(Display::RefreshReason reason, WorldCanvasHolder &wch, WorldCanvasHolder &wc)
Int bsln_(Int a1, Int a2) const
void a1a2_(Double& a1, Double& a2, Double bsl, Int abase=0) const
Double a1a2_(Double bsl, Int abase=0)
Double a1mult_()
String visMbLabel_()
void resetFreq_()
Int spw_(Int spwid)
void computeVisShape_(Block<Int>& visShp)
Int nframes_(const Block<Int>& frames, Int strtfrm, Int nfrms, Int& margin)
Int maxframes_(const Block<Int>& frames, Int& strtfrm, Int nfrms)
void resetMinMax_()
Bool flag_(IPosition& slot)
void setFlag_(IPosition& slot, Bool flag)
void addEdit_(WorldCanvas* wc, Int xStart, Int xShape, Int yStart, Int yShape)
void postEditsToDisp_()
Bool undoEdits_(String extent="all", Bool feedback=False)
Bool saveEdits_()
void computeTimeBoxcars_()
Float v_(Int t)
Float vAlt_(Float v)
Float dev_(Int t)
void computeDevRange_()
void createDevSlice_()
static Int ind_(const String& name, const Vector<String>& names)
Axis axisNum_(const String& axisName) const
VisType visTypeNum_(const String& visTypeName) const
VisComp visCompNum_(const String& visCompName) const

Description

Prerequisite

Etymology

"MSAsRaster" is a implementation of a ActiveCaching2dDD which provides for the display of Measurement Set data (visibilities) as a raster image.

Synopsis

MSAsRaster displays Measurement Set data which can be presented as a regular grid, on a WorldCanvas (data which is sparse and irregular on its display axes would typically be plotted using MSAsXY instead). Display or iteration axes include time, baseline, channels and polarizations. Visibilities of the selected slice are drawn as a Raster image.

Unlike many DDs, MSAsRaster has _two_ levels of underlying data: the source MS, and a hypercube of visibility data, which is extracted from the MS and gridded onto 5 main axes: time, baseline, spectral window, frequency and polarization. Extracting the data is a more time-consuming operation than display of various portions of gridded data, and is triggered only through the extract_() method. Data selection options do not take effect until triggered in this way. In contrast, many options affecting display of the extracted data (such as zooms, and colormapping) affect the display immediately, as with most DDs. Setting new display axes will trigger extract_() if the current extracted hypercube does not fill them.

Example

    MSAsRaster *mar = new MSAsRaster("filename_of.ms");
    wcHolder->addDisplayData(mar);

Motivation

To move compute-intensive tasks of data handling for Measurement Set display out of glish into C++

To Do

Member Description

MSAsRaster(const String msname)

constructor from the filename of an MS

virtual ~MSAsRaster()

Destructor

virtual Bool setOptions(Record &rec, Record &recOut)

Apply option values stored in rec to the DisplayData. A return value of True means a refresh is needed. recOut contains any fields which were implicitly changed as a result of the call to this function. Parameters from the 'adjust' gui are sent through here, controlling and triggering many of MSAsRaster's actions. (Other input is via the mouse on the canvas, which affects the object through the event handlers).

virtual Record getOptions()

Retrieve the current options. In addition to the values themselves, the returned record contains meta-information (prompts, help text, choices, defaults, etc.) useful in constructing gui elements to control the DD settings.

virtual void setDefaultOptions()

set all options to default values (unused so far; incomplete support in base classes...incomplete here as well).

virtual AttributeBuffer optionsAsAttributes()

Return the current options of this DisplayData as a 'restrictions' AttributeBuffer (only options that affect the way the image would be drawn are returned). It is used to determine which (if any) of the cached drawings can be used to satisfy the current draw request.

virtual Bool conformsToCS(const WorldCanvasHolder& wch)

Determine whether DD is compatible with the WC[H]'s current world coordinates. MSAsRaster DDs must be in charge (the CS master), Otherwise they will not respond. Multiple MSARs on one canvas (blinking, etc.) is not supported, because of possible confusion about which one(s) should respond to flagging edits.

virtual Bool setActiveZIndex(Int zindex)

This routine is called to inform the DD of the current canvas's animator index. Used by confromsTo() and related methods. Return value indicates whether the index is within the data's range.

virtual String showValue(const Vector<Double> &world)

Format the data value at the given world position. Call setActiveImage(zindex) with the desired animator position before calling this routine.

virtual String showPosition(const Vector<Double> &world, const Bool &displayAxesOnly = False)

Format the position of the cursor. Also requires previous call to setActiveImage(zindex); also used for position tracking.

virtual const Unit dataUnit()

get the Unit for displayed data values (visibilities)

virtual Display::DisplayDataType classType()

Return the type of this DisplayData.

virtual const uInt nelements() const
virtual const uInt nelements(const WorldCanvasHolder &) const

return the size of the animation axis.

virtual Bool labelAxes(const WCRefreshEvent &ev)

Handle axis labelling.

virtual void notifyRegister(WorldCanvasHolder *wch)
virtual void notifyUnregister(WorldCanvasHolder& wch, Bool ignoreRefresh = False)

Needed to enable or destroy drawlists and colormaps on corresp. canvas. (Only to be called by the relevant WCH).

virtual void handleEvent(DisplayEvent& ev)

handle flagging region selection events, via new-style (1/02) interface.

virtual Bool zIndexHint(Int& preferredZIndex) const

Return the animator position setting preferred if this DD about to be registered on a new DisplayPanel.

virtual void purgeCache()

Empty cache completely.

virtual void purgeCache(const WorldCanvasHolder& wch)

Empty cache of all DMs for a given WCH.

void constructParameters_()
void deleteParameters_()

Construct and destroy the user option DisplayParameters. To be used by constructors/destructor only.

virtual CachingDisplayMethod *newDisplayMethod(WorldCanvas *worldCanvas, AttributeBuffer *wchAttributes, AttributeBuffer *ddAttributes, CachingDisplayData *dd)

return a new MSAsRasterDM for the given WorldCanvas.

static Float real (const Complex& val)
static Float imag (const Complex& val)

Helper functions.

MSAsRaster(): mspos_(this)
MSAsRaster(const MSAsRaster &other): mspos_(this)
MSAsRaster& operator=(const MSAsRaster &other)

Default and copy constructors, and the assignment operator, are non-functional and should not be used. Do not make copies of DisplayData objects, or pass them by value; use references or pointers instead.

void initMSAR_()

Initialization common to all useful constructors

void setDefaultMSAROptions_()

set/restore default option values on this level only. (Not implemented).

void selectVS_()

prepare the selection MS and its VisSet.

void findRanges_()

find the ranges of the MS selection (VisSet) for the 5 hypercube axes

void setCS_()

update/set the (2d--canvas) coordinate system from the current MS selection and display axes.

void extract_()

Extract the hypercube buffer of visibilities for the requested MS selection and axis settings (the most time-consuming operation).

void createDisplaySlice_()

retrieve (2D) slice data Matrix, and corresponding mask/flag matrices, to send to the display canvas.

Bool draw_(Display::RefreshReason reason, WorldCanvasHolder &wch, WorldCanvasHolder &wc)

Actually do the drawing. The return value indicates whether the DD was able to draw.

Int bsln_(Int a1, Int a2) const

return baseline index (in the usual baseline ordering) from antenna numbers. Input must have 0 <= a1 <= a2 < nAnt_. Mapping leaves room for autocorrelations plus a 1-pixel gap between successive antenna1 groups.

void a1a2_(Double& a1, Double& a2, Double bsl, Int abase=0) const
Double a1a2_(Double bsl, Int abase=0)

A corresponding inverse, this handles non-integer 'baseline indices'. Set abase to 1 to number ant1 and ant2 from 1. (The baseline index bsl is always numbered from 0, internally). The version with the Double return value returns a1*a1mult_() + a2.

Double a1mult_()

Subsidiary routine for above, determines (in effect) how many decimal places are needed for an antenna number. Returns 1000, unless 4 places are needed, in which case it returns 10000, etc.

String visMbLabel_()

A small routine to return the label for the "Visibility Memory" slider widget. The label includes feedback on the selected MS's total size, and is updated when that changes.

void resetFreq_()

Reset Block of relevant Spectral window IDs, and return correponding Vectors of channel frequencies. freq_ is used for display of frequencies in position tracking. spwId_ translates spw 'index' into the actual spectral window ID.

Int spw_(Int spwid)

Translate actual spectral window ID into the 'spw' index (zero-based pixel coordinate) along the spectral window axis. Because the user can select specific spectral windows, these two may not be the same. Returns -1 if the spectral window ID is not in the selected MS data.

void computeVisShape_(Block<Int>& visShp)

Compute vis_ array dimensions which fit into allowed memory.

Int nframes_(const Block<Int>& frames, Int strtfrm, Int nfrms, Int& margin)

Return how many of the given (sorted) animation frames can be displayed from a given window (strtfrm, nfrms) on that axis. In cases where nframes>0, margin will be the minimum padding on either side, from the edges of the interval to the frames of interest.

Int maxframes_(const Block<Int>& frames, Int& strtfrm, Int nfrms)

Return the maximum number of the given (sorted) animation frames that can be displayed from a window or interval of a given size (nfrms). also returns where that interval should start (strtfrm).

void resetMinMax_()

Reset data scaling DParameters to newly-computed data ranges.

Bool flag_(IPosition& slot)
void setFlag_(IPosition& slot, Bool flag)

Return or set a flag within the bitmapped flags_ vector, as if it were a 5-axis Array corresponding in dimensions to vis_. (Note: flags_ is an internal array corresponding to the current state of flags in the MS, but these routines in themselves do not read or write any flags to disk).

void addEdit_(WorldCanvas* wc, Int xStart, Int xShape, Int yStart, Int yShape)

Add the edit request that just came in (from the mouse, via handleEvent) to the flagEdits_ List, then cause the display to be updated.

void postEditsToDisp_()

Assure that the display matrices are up-to-date with the flagging edits list, to provide visual feedback of the edits.

Bool undoEdits_(String extent="all", Bool feedback=False)

Undo unsaved edits. Return value indicates whether there were any edits to undo. extent=="all" means undo all, else just the last one. If feedback==True, a warning message will be printed about discarded edits.

Bool saveEdits_()

Save all edits permanently to the MS. The return value indicates whether there were any edits to save.

void computeTimeBoxcars_()

compute the lsTime_ and leTime_ vectors, which define the 'local neighborhoods' around each given time slot, for computing running averages.

Float v_(Int t)

Return a single visibility point from vis_ or disp_, as a function of time slot only. The row of times and mode must be predetermined by setting useVis_, dPos_, axlTm_ and flgdDev_ (below). goodData_ is set True by this routine if the data exists, is loaded and is not flagged (False otherwise).

Float vAlt_(Float v)

Phase deviations are calculated both for the original phases (in [-180,180]), and for the phases 180 degrees opposite (also expressed within [-180,180]); the minimum result is displayed. This is so that phases clustered around +-180 do not show artificially high deviations. (remainder(x,360) (from math.h) is always in [-180,180] -- wierd, but usable for this purpose).

Float dev_(Int t)

Return the visibility deviation for the time slot t. visDev_ determines whether this is an RMS deviation or absolute difference from the running mean. Maintains state from the prior calculation to speed things up in some cases. Must be initialized as for v_() above, and sT_ set to -1, at the beginning of a new row of times.

void computeDevRange_()

Calculate deviations throughout range of vis_. Used to set data scaling sliders when visibility deviations are to be displayed.

void createDevSlice_()

Create dispDev_ Matrix for displaying deviations. Both this routine and the one above initialize and use dev_() to calculate individual deviations.

static Int ind_(const String& name, const Vector<String>& names)

Generic string-to-index converter...

Axis axisNum_(const String& axisName) const
VisType visTypeNum_(const String& visTypeName) const
VisComp visCompNum_(const String& visCompName) const

...applied to 3 of the 'enums' used internally.


class MSAsRasterDM : public CachingDisplayMethod

Interface

Public Members
MSAsRasterDM(WorldCanvas *wc, AttributeBuffer *wchAttrs, AttributeBuffer *ddAttrs, hAttrs *dd): CachingDisplayMethod(wc, wchAttrs, ddAttrs, dd)
virtual ~MSAsRasterDM()
Protected Members
virtual Bool drawIntoList(Display::RefreshReason reason, WorldCanvasHolder &wcHolder)
Private Members
MSAsRasterDM()
MSAsRasterDM(const MSAsRasterDM &other)
MSAsRasterDM& operator=(const MSAsRasterDM &other)

Description

Prerequisite

Etymology

"MSAsRasterDM" is a implementation of a CachingDisplayMethod for MSAsRaster .

Synopsis

MSAsRasterDM a minimal skeleton; it is implemented in its entirety here. Its only purpose is to hold the cached drawlist and use it when appropriate via the mechanism and data structure implemented on the CachingDisplayMethod level. MSAsRasterDM just turns the draw request back over to MSAsRaster, since that's where the necessary data is.

This 'minimal' CachingDisplayMethod could be adapted and reused by any other CachingDisplayData that wanted to do its own drawing.

Member Description

MSAsRasterDM(WorldCanvas *wc, AttributeBuffer *wchAttrs, AttributeBuffer *ddAttrs, hAttrs *dd): CachingDisplayMethod(wc, wchAttrs, ddAttrs, dd)

Constructor. The parameters contain state that determines what should be drawn.

virtual ~MSAsRasterDM()

Destructor.

virtual Bool drawIntoList(Display::RefreshReason reason, WorldCanvasHolder &wcHolder)

The base CachingDM takes care of using any cached drawlist. When this method is called, we know that no drawlist applies, and that we must actually send drawing commands to the WC (though technically, they might _not_ actually be going into a drawlist). This skeleton DM just hands the drawing task back to the DD, where all the data has been created and maintained anyway.

MSAsRasterDM()
MSAsRasterDM(const MSAsRasterDM &other)
MSAsRasterDM& operator=(const MSAsRasterDM &other)

Default and copy constructors, and the assignment operator, are mon-functional and should not be used. Do not make copies of DisplayMethod objects, or pass them by value; use references or pointers instead.