Table Of Contents

Previous topic

terapy.icons package

Next topic

terapy.scan package

This Page

terapy.plot package

Submodules

terapy.plot.base module

Base classes for canvases and plots

class terapy.plot.base.Plot(canvas=None, array=None)

Generic plot class.

Delete()

Delete plot.

GetColor()

Get plot color.

Output:
color (wx.Color)
GetData(data)

Get plot data.

Output:
data array (DataArray)
Recompute()

Recompute plot data.

SetColor(col)

Set plot color.

Parameters:
col - color (wx.Color)
SetData(data)

Set plot data.

Parameters:
data - data array (DataArray)
SetPlotColors()

Wrapper to parent canvas SetPlotColors function.

Update()

Update plot display.

class terapy.plot.base.PlotCanvas(parent=None, id=-1, *args, **kwargs)

Bases: wx._windows.Panel

Generic canvas class.

Properties:
is_data - if True, canvas is meant to display raw measurement data (bool) is_filter - if True, canvas is meant to display post-processed data (bool) dim - dimension of plots displayed on this canvas (int) name - name of canvas type (str)
AddCanvas(cls, event)

Add canvas of given class type to parent. Helper function to respond to popup menu action.

Parameters:
cls - canvas class event - wx.Event
AddPlot(array=None)

Add plot to canvas.

Parameters:
array - data array to be displayed (DataArray)
ChangeDefaultUnits(inst=None)

Change canvas units and scale plots to default units.

Parameters:
inst - pubsub data (not used)
ClearCanvas(event=None)

Actions required to clear canvas.

Parameters:
event - wx.Event
EditAxes(event=None)

Open dialog to change axes labels and units.

Parameters:
event - wx.Event
FindPlot(plt)

Find plot index in canvas.

Parameters:
plt - plot to be found (Plot)
Output:
plot index (int)
OnDelete(event=None)

Clean up before destroying object.

Parameters:
event - wx.Event
PopupMenuItems(menu)

Add popup menu items for canvas to given menu.

Parameters:
menu - wx.Menu
RemovePlot(plt)

Remove given plot from plot list.

Parameters:
plt - plot (Plot)
SetImage(n=-1)

Set canvas tab icon.

Parameters:
n - icon index in parent image list (int)
SetName(name='Plot')

Set canvas name.

Parameters:
name - name (str)
SetPlotColors()

Set canvas plot colors.

SetVisible()

Show canvas.

Update(event=None)

Update canvas.

Parameters:
event - wx.Event
dim = -1
is_data = False
is_filter = False
name = 'Plot'

terapy.plot.canvas1d module

Canvas class for 1D plots

class terapy.plot.canvas1d.PlotCanvas1D(parent=None, id=-1, xlabel=<AxisInfos(Delay, ps) instance at 0x110e2b290>, ylabel=<AxisInfos(Signal, V) instance at 0x110e3f2d8>, xscale='linear', yscale='linear')

Bases: terapy.plot.base.PlotCanvas, terapy.core.plotpanel.PlotPanel

Canvas class for 1D plots

Properties:
is_data - if True, canvas is meant to display raw measurement data (bool) is_filter - if True, canvas is meant to display post-processed data (bool) dim - dimension of plots displayed on this canvas (int) name - name of canvas type (str)
AddFilterCanvas(fname='', event=None)

Add post-processing canvas linked to current canvas.

Parameters:
fname - file name of post-processing filter bank (str, if none or invalid, load default bank) event - wx.Event
AddPlot(array=None)

Add plot to canvas.

Parameters:
array - data array to be displayed (DataArray)
Delete(event=None)

Delete canvas.

Parameters:
event - wx.Event
OnLeftClick(event)

Actions triggered on left mouse button click.

Parameters:
event - wx.Event
OnRightClick(event)

Actions triggered on right mouse button click.

Parameters:
event - wx.Event
RemoveFilterCanvases(event=None)

Remove post-processing canvases associated with this canvas.

Parameters:
event - wx.Event
RemovePlot(pos)

Remove given plot from canvas.

Parameters:
pos - plot index (int)
SetImage(n=1)

Set canvas tab icon.

Parameters:
n - icon index in parent image list (int)
SetLabels()

Set axes labels.

SetPlotColors()

Set canvas plot colors.

Update(event=None)

Update canvas.

Parameters:
event - wx.Event
dim = 1
name = '1D Plot'

terapy.plot.canvas2d module

Canvas class for 2D plots

class terapy.plot.canvas2d.PlotCanvas2D(parent=None, id=-1, xlabel=<AxisInfos(Delay, ps) instance at 0x11293d950>, ylabel=<AxisInfos(Distance, um) instance at 0x1128c87a0>, xscale='linear', yscale='linear')

Bases: terapy.plot.base.PlotCanvas, terapy.core.plotpanel.PlotPanel

Canvas class for 2D plots

Properties:
is_data - if True, canvas is meant to display raw measurement data (bool) is_filter - if True, canvas is meant to display post-processed data (bool) dim - dimension of plots displayed on this canvas (int) name - name of canvas type (str)
AddPlot(array=None)

Add plot to canvas.

Parameters:
array - data array to be displayed (DataArray)
Delete(event=None)

Delete canvas.

Parameters:
event - wx.Event
Destroy()
OnLeftClick(event)

Actions triggered on left mouse button click.

Parameters:
event - wx.Event
PopupMenuItems(menu)

Add popup menu items for canvas to given menu.

Parameters:
menu - wx.Menu
SetImage(n=2)

Set canvas tab icon.

Parameters:
n - icon index in parent image list (int)
SetLabels()

Set axes labels.

SetName(name='Plot')

Set canvas tab name.

Parameters:
name - name (str)
Update(event=None)

Update canvas.

Parameters:
event - wx.Event
dim = 2
is_data = True
name = '2D Plot'

terapy.plot.canvasF module

Canvas class for 1D post-processed data plots

class terapy.plot.canvasF.PlotCanvasF(parent=None, id=-1, xlabel=<AxisInfos(Frequency, THz) instance at 0x1122ef638>, ylabel=<AxisInfos(Spectrum, V $cdot$ THz$^{-1}$) instance at 0x1122ef098>, xscale='linear', yscale='log')

Bases: terapy.plot.canvas1d.PlotCanvas1D

Canvas class for 1D post-processed data plots

Properties:
is_data - False, canvas is not meant to display raw measurement data is_filter - True, canvas is meant to display post-processed data dim=1 - dimension of plots displayed on this canvas (int) name - name of canvas type (str)
OnDelete(event=None)

Actions triggered when canvas is deleted.

Parameters:
event - wx.Event
OnRightClick(event)

Actions triggered on mouse right button click.

Parameters:
event - wx.Event
PopupMenuItems(menu)

Add popup menu items for canvas to given menu.

Parameters:
menu - wx.Menu
PostProcess(inst=None)

Post-process displayed data.

Parameters:
inst - pubsub event data (filter.FilterBank)
SetFilterBank(bank)

Set filter bank associated to canvas.

Parameters:
bank - filter bank (filter.FilterBank)
is_filter = True
name = 'Post-processed data'

terapy.plot.canvasT module

Canvas class for 1D raw data plots

class terapy.plot.canvasT.PlotCanvasT(parent=None, id=-1, xlabel=<AxisInfos(Delay, ps) instance at 0x1124ae9e0>, ylabel=<AxisInfos(Signal, V) instance at 0x1124aea28>, xscale='linear', yscale='linear')

Bases: terapy.plot.canvas1d.PlotCanvas1D

Canvas class for 1D raw data plots

Properties:
is_data - True, canvas is meant to display raw measurement data is_filter - False, canvas is not meant to display post-processed data dim=1 - dimension of plots displayed on this canvas (int) name - name of canvas type (str)
OnLeftDblClick(event)

Actions triggered after double-click on left mouse button on canvas.

Parameters:
event - wx.Event
PopupMenuItems(menu)

Add popup menu items for canvas to given menu.

Parameters:
menu - wx.Menu
is_data = True
name = 'Time domain data'

terapy.plot.notebook module

Notebook class with canvas handling functions

class terapy.plot.notebook.PlotNotebook(parent, id=-1, pos=wx.Point(-1, -1), size=wx.Size(-1, -1), style=0, name=u'notebook')

Bases: wx._controls.Notebook

Notebook class with canvas handling functions

AddCanvas(cnv=None, title='Plot')

Add canvas to notebook.

Parameters:
cnv - canvas (PlotCanvas) title - name (str)
AddPlot(target='current', array=None)

Add plot to first available canvas (if none available, add one).

Parameters:
target - if “current”, attempt to find existing canvas
otherwise, create new canvas

array - data array (DataArray)

Broadcast(inst=None)

Send notebook reference through pubsub.

Parameters:
inst - pubsub event data
FindCanvas(cnv)

Find given canvas index.

Parameters:
cnv - canvas (PlotCanvas)
Output:
canvas index (int)
FindPlot(plt)

Find given plot and return index of canvas and plot.

Parameters:
plt - plot (Plot)
Output:
tuple: (canvas index, plot index)
GetTabStripBoundaries()

Compute tab strip boundaries.

Output:
tuple of int: ((xmin, xmax), (ymin, ymax))
InsertCanvas(cnv=None, pos=0, title='Plot', display=True)

Insert given canvas at given tab position.

Parameters:
cnv - canvas class (PlotCanvas) pos - position (int) title - tab name (str) display - if True, show tab
MoveTab(event=None)

Move tab during drag.

Parameters:
event - wx.Event
Indirect parameters:
self.drag_tab - tab to be moved (int)
OnAddCanvas(cls=None, event=None)

Add canvas of given class through menu event (made for popup menu action).

Parameters:
cls - canvas class (PlotCanvas) event - wx.Event
OnChangePage(event=None)

Actions following page change.

Parameters:
event - wx.Event
OnDrag(event=None)

Actions triggered on drag event.

Parameters:
event - wx.Event
OnEndDrag(x, y, data)

Actions consecutive to drop on plot notebook.

Parameters:

x,y - coordinates of drop action (int) data - dropped data (str)

Passing drag and drop data in wxpython is incovenient. Alternative used here: data is stored as self.drag_object
OnLeftClick(event=None)

Actions triggered on left mouse button click on notebook.

Parameters:
event - wx.Event
OnLeftDblClick(event=None)

Actions triggered on right mouse button click on notebook.

Parameters:
event - wx.Event
OnLeftUp(event=None)

Actions triggered when left mouse button is released.

Parameters:
event - wx.Event
OnRightClick(event=None)

Actions triggered on right mouse button click on notebook.

Parameters:
event - wx.Event
RemoveCanvas(inst=None, idx=None)

Remove canvas given by index.

Parameters:
inst - pubsub data idx - canvas index (int)
RenameTab(idx=-1, event=None)

Actions following a rename request for given tab index.

Parameters:
idx - canvas index (int) event - wx.Event
SetDragObject(inst)

Set drag object from pubsub event (used in drag and drop actions).

Parameters:
inst - pubsub event data

terapy.plot.plot1d module

Class for 1D plots

class terapy.plot.plot1d.Plot1D(canvas=None, array=None)

Bases: terapy.plot.base.Plot

Class for 1D plots

Delete()

Delete plot.

GetData()

Get plot data.

Output:
data array (DataArray)
SetColor(col)

Set plot color.

Parameters:
col - color (wx.Color)
SetData(array)

Set plot data.

Parameters:
data - data array (DataArray)
SetName(name='Plot')

Set plot name.

Parameters:
name - name (str)

terapy.plot.plot2d module

Class for 2D plots

class terapy.plot.plot2d.Plot2D(canvas=None, array=None)

Bases: terapy.plot.base.Plot

Class for 2D plots

Delete()

Delete plot.

GetData()

Get plot data.

Output:
data array (DataArray)
SetData(array)

Set plot data.

Parameters:
data - data array (DataArray)
SetName(name='Plot')

Set plot name.

Parameters:
name - name (str)

Module contents

Functions and classes to handle plot canvases and plots.

Properties:
canvas_modules - list of available canvas classes plot_modules - list of available plot classes

Each canvas must be implemented as a PlotCanvas class (see base.py). Each plot must be implemented as a Plot class (see base.py). PlotCanvas/Plot classes contained in Python scripts within this folder will be automatically recognized and added to appropriate list.