fipy.viewers package

Submodules

fipy.viewers.multiViewer module

class fipy.viewers.multiViewer.MultiViewer(viewers)

Bases: fipy.viewers.viewer.AbstractViewer

Treat a collection of different viewers (such for different 2D plots or 1D plots with different axes) as a single viewer that will plot() all subviewers simultaneously.

Parameters

viewers (list of ~fipy.viewers.viewer.Viewer) – the viewers to bind together

__annotations__ = {}
__init__(viewers)
Parameters

viewers (list of ~fipy.viewers.viewer.Viewer) – the viewers to bind together

__module__ = 'fipy.viewers.multiViewer'
plot()

Update the display of the viewed variables.

Parameters

filename (str) – If not None, the name of a file to save the image into.

setLimits(limits={}, **kwlimits)

Update the limits.

Parameters
  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

fipy.viewers.test module

Test implementation of the viewers

fipy.viewers.testinteractive module

Interactively test the viewers

fipy.viewers.tsvViewer module

class fipy.viewers.tsvViewer.TSVViewer(vars, title=None, limits={}, **kwlimits)

Bases: fipy.viewers.viewer.AbstractViewer

“Views” one or more variables in tab-separated-value format.

Output is a list of coordinates and variable values at each cell center.

File contents will be, e.g.:

title
x       y       ...     var0    var2    ...
0.0     0.0     ...     3.14    1.41    ...
1.0     0.0     ...     2.72    0.866   ...
:
:

Creates a TSVViewer.

Any cell centers that lie outside the limits provided will not be included. Any values that lie outside the datamin or datamax will be replaced with nan.

All variables must have the same mesh.

It tries to do something reasonable with rank-1 CellVariable and FaceVariable objects.

Parameters
  • vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

__annotations__ = {}
__init__(vars, title=None, limits={}, **kwlimits)

Creates a TSVViewer.

Any cell centers that lie outside the limits provided will not be included. Any values that lie outside the datamin or datamax will be replaced with nan.

All variables must have the same mesh.

It tries to do something reasonable with rank-1 CellVariable and FaceVariable objects.

Parameters
  • vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

__module__ = 'fipy.viewers.tsvViewer'
plot(filename=None)

“plot” the coordinates and values of the variables to filename. If filename is not provided, “plots” to stdout.

>>> from fipy.meshes import Grid1D
>>> m = Grid1D(nx = 3, dx = 0.4)
>>> from fipy.variables.cellVariable import CellVariable
>>> v = CellVariable(mesh = m, name = "var", value = (0, 2, 5))
>>> TSVViewer(vars = (v, v.grad)).plot() 
x       var     var_gauss_grad_x
0.2     0       2.5
0.6     2       6.25
1       5       3.75
>>> from fipy.meshes import Grid2D
>>> m = Grid2D(nx = 2, dx = .1, ny = 2, dy = 0.3)
>>> v = CellVariable(mesh = m, name = "var", value = (0, 2, -2, 5))
>>> TSVViewer(vars = (v, v.grad)).plot() 
x       y       var     var_gauss_grad_x        var_gauss_grad_y
0.05    0.15    0       10      -3.33333333333333
0.15    0.15    2       10      5
0.05    0.45    -2      35      -3.33333333333333
0.15    0.45    5       35      5
Parameters

filename (str) – If not None, the name of a file to save the image into.

fipy.viewers.viewer module

class fipy.viewers.viewer.AbstractViewer(vars, title=None, **kwlimits)

Bases: object

Attention

This class is abstract. Always create one of its subclasses.

Create a AbstractViewer object.

Parameters
  • vars (CellVariable or list) – the CellVariable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

__dict__ = mappingproxy({'__module__': 'fipy.viewers.viewer', '__doc__': '\n .. attention:: This class is abstract. Always create one of its subclasses.\n ', '__init__': <function AbstractViewer.__init__>, '_getSuitableVars': <function AbstractViewer._getSuitableVars>, 'setLimits': <function AbstractViewer.setLimits>, '_getLimit': <function AbstractViewer._getLimit>, 'plot': <function AbstractViewer.plot>, 'plotMesh': <function AbstractViewer.plotMesh>, '_autoscale': <function AbstractViewer._autoscale>, '_validFileExtensions': <function AbstractViewer._validFileExtensions>, '_saved_stdout': <_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, '_serial_doctest_raw_input': <staticmethod object>, '_doctest_raw_input': <staticmethod object>, '_promptForOpinion': <function AbstractViewer._promptForOpinion>, '_test1D': <staticmethod object>, '_test2Dbase': <staticmethod object>, '_test2D': <staticmethod object>, '_test2Dirregular': <staticmethod object>, '_test2DvectorBase': <staticmethod object>, '_test2Dvector': <staticmethod object>, '_test2DvectorIrregular': <staticmethod object>, '_test3D': <staticmethod object>, '__dict__': <attribute '__dict__' of 'AbstractViewer' objects>, '__weakref__': <attribute '__weakref__' of 'AbstractViewer' objects>, '__annotations__': {}})
__init__(vars, title=None, **kwlimits)

Create a AbstractViewer object.

Parameters
  • vars (CellVariable or list) – the CellVariable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

__module__ = 'fipy.viewers.viewer'
__weakref__

list of weak references to the object (if defined)

plot(filename=None)

Update the display of the viewed variables.

Parameters

filename (str) – If not None, the name of a file to save the image into.

plotMesh(filename=None)

Display a representation of the mesh

Parameters

filename (str) – If not None, the name of a file to save the image into.

setLimits(limits={}, **kwlimits)

Update the limits.

Parameters
  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

Module contents

class fipy.viewers.DummyViewer(vars, title=None, **kwlimits)

Bases: fipy.viewers.viewer.AbstractViewer

Create a AbstractViewer object.

Parameters
  • vars (CellVariable or list) – the CellVariable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

__annotations__ = {}
__module__ = 'fipy.viewers'
plot(filename=None)

Update the display of the viewed variables.

Parameters

filename (str) – If not None, the name of a file to save the image into.

class fipy.viewers.Matplotlib1DViewer(vars, title=None, xlog=False, ylog=False, limits={}, legend='upper left', axes=None, **kwlimits)

Bases: fipy.viewers.matplotlibViewer.matplotlibViewer.AbstractMatplotlibViewer

Displays a y vs. x plot of one or more 1D CellVariable objects using Matplotlib.

>>> from fipy import *
>>> mesh = Grid1D(nx=100)
>>> x, = mesh.cellCenters
>>> xVar = CellVariable(mesh=mesh, name="x", value=x)
>>> k = Variable(name="k", value=0.)
>>> viewer = Matplotlib1DViewer(vars=(numerix.sin(k * xVar), numerix.cos(k * xVar / numerix.pi)),
...                 limits={'xmin': 10, 'xmax': 90},
...                 datamin=-0.9, datamax=2.0,
...                 title="Matplotlib1DViewer test")
>>> for kval in numerix.arange(0, 0.3, 0.03):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
Parameters
  • vars (CellVariable or list) – CellVariable objects to plot

  • title (str, optional) – displayed at the top of the Viewer window

  • xlog (bool) – log scaling of x axis if True

  • ylog (bool) – log scaling of y axis if True

  • limits (dict) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).

  • legend (str) – place a legend at the specified position, if not None

  • axes (Axes) – if not None, vars will be plotted into this Matplotlib Axes object

__annotations__ = {}
__init__(vars, title=None, xlog=False, ylog=False, limits={}, legend='upper left', axes=None, **kwlimits)
Parameters
  • vars (CellVariable or list) – CellVariable objects to plot

  • title (str, optional) – displayed at the top of the Viewer window

  • xlog (bool) – log scaling of x axis if True

  • ylog (bool) – log scaling of y axis if True

  • limits (dict) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale. (ymin and ymax are synonyms for datamin and datamax).

  • legend (str) – place a legend at the specified position, if not None

  • axes (Axes) – if not None, vars will be plotted into this Matplotlib Axes object

__module__ = 'fipy.viewers.matplotlibViewer.matplotlib1DViewer'
property log

logarithmic data scaling

class fipy.viewers.Matplotlib2DGridContourViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits)

Bases: fipy.viewers.matplotlibViewer.matplotlib2DViewer.AbstractMatplotlib2DViewer

Displays a contour plot of a 2D CellVariable object.

The Matplotlib2DGridContourViewer plots a 2D CellVariable using Matplotlib.

>>> from fipy import *
>>> mesh = Grid2D(nx=50, ny=100, dx=0.1, dy=0.01)
>>> x, y = mesh.cellCenters
>>> xyVar = CellVariable(mesh=mesh, name="x y", value=x * y)
>>> k = Variable(name="k", value=0.)
>>> viewer = Matplotlib2DGridContourViewer(vars=numerix.sin(k * xyVar),
...                 limits={'ymin': 0.1, 'ymax': 0.9},
...                 datamin=-0.9, datamax=2.0,
...                 title="Matplotlib2DGridContourViewer test")
>>> from builtins import range
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()

Creates a Matplotlib2DViewer.

Parameters
  • vars (CellVariable) – the Variable to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • cmap (Colormap, optional) – the Colormap. Defaults to matplotlib.cm.jet

  • colorbar (bool, optional) – plot a color bar if not None

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

  • figaspect (float, optional) – desired aspect ratio of figure. If a number, use that aspect ratio. If auto, the aspect ratio will be determined from the vars’s mesh.

__annotations__ = {}
__init__(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits)

Creates a Matplotlib2DViewer.

Parameters
  • vars (CellVariable) – the Variable to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • cmap (Colormap, optional) – the Colormap. Defaults to matplotlib.cm.jet

  • colorbar (bool, optional) – plot a color bar if not None

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

  • figaspect (float, optional) – desired aspect ratio of figure. If a number, use that aspect ratio. If auto, the aspect ratio will be determined from the vars’s mesh.

__module__ = 'fipy.viewers.matplotlibViewer.matplotlib2DGridContourViewer'
class fipy.viewers.Matplotlib2DGridViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits)

Bases: fipy.viewers.matplotlibViewer.matplotlib2DViewer.AbstractMatplotlib2DViewer

Displays an image plot of a 2D CellVariable object using Matplotlib.

>>> from fipy import *
>>> mesh = Grid2D(nx=50, ny=100, dx=0.1, dy=0.01)
>>> x, y = mesh.cellCenters
>>> xyVar = CellVariable(mesh=mesh, name="x y", value=x * y)
>>> k = Variable(name="k", value=0.)
>>> viewer = Matplotlib2DGridViewer(vars=numerix.sin(k * xyVar),
...                 limits={'ymin': 0.1, 'ymax': 0.9},
...                 datamin=-0.9, datamax=2.0,
...                 title="Matplotlib2DGridViewer test")
>>> from builtins import range
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()

Creates a Matplotlib2DGridViewer.

Parameters
  • vars (CellVariable) – the Variable to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • cmap (Colormap, optional) – the Colormap. Defaults to matplotlib.cm.jet

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • colorbar (bool, optional) – plot a color bar in specified orientation if not None

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

  • figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.

__annotations__ = {}
__init__(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits)

Creates a Matplotlib2DGridViewer.

Parameters
  • vars (CellVariable) – the Variable to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • cmap (Colormap, optional) – the Colormap. Defaults to matplotlib.cm.jet

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • colorbar (bool, optional) – plot a color bar in specified orientation if not None

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

  • figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.

__module__ = 'fipy.viewers.matplotlibViewer.matplotlib2DGridViewer'
class fipy.viewers.Matplotlib2DViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits)

Bases: fipy.viewers.matplotlibViewer.matplotlib2DViewer.AbstractMatplotlib2DViewer

Displays a contour plot of a 2D CellVariable object.

The Matplotlib2DViewer plots a 2D CellVariable using Matplotlib.

>>> from fipy import *
>>> mesh = (Grid2D(nx=5, ny=10, dx=0.1, dy=0.1)
...         + (Tri2D(nx=5, ny=5, dx=0.1, dy=0.1)
...          + ((0.5,), (0.2,))))
>>> x, y = mesh.cellCenters
>>> xyVar = CellVariable(mesh=mesh, name="x y", value=x * y)
>>> k = Variable(name="k", value=0.)
>>> viewer = Matplotlib2DViewer(vars=numerix.sin(k * xyVar),
...                 limits={'ymin': 0.1, 'ymax': 0.9},
...                 datamin=-0.9, datamax=2.0,
...                 title="Matplotlib2DViewer test")
>>> from builtins import range
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()

Creates a Matplotlib2DViewer.

Parameters
  • vars (CellVariable) – the Variable to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • cmap (Colormap, optional) – the Colormap. Defaults to matplotlib.cm.jet

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • colorbar (bool, optional) – plot a color bar in specified orientation if not None

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

  • figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.

__annotations__ = {}
__init__(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, figaspect='auto', **kwlimits)

Creates a Matplotlib2DViewer.

Parameters
  • vars (CellVariable) – the Variable to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • cmap (Colormap, optional) – the Colormap. Defaults to matplotlib.cm.jet

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • colorbar (bool, optional) – plot a color bar in specified orientation if not None

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

  • figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.

__module__ = 'fipy.viewers.matplotlibViewer.matplotlib2DViewer'
class fipy.viewers.MatplotlibStreamViewer(vars, title=None, log=False, limits={}, axes=None, figaspect='auto', density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1, **kwlimits)

Bases: fipy.viewers.matplotlibViewer.matplotlib2DViewer.AbstractMatplotlib2DViewer

Displays a stream plot of a 2D rank-1 CellVariable or FaceVariable object using Matplotlib

One issue is that this Viewer relies on scipy.interpolate.griddata, which interpolates on the convex hull of the data. The results is that streams are plotted across any concavities in the mesh.

Another issue is that it does not seem possible to remove the streams without calling cla(), which means that different set of streams cannot be overlaid.

>>> from fipy import *
>>> mesh = Grid2D(nx=50, ny=100, dx=0.1, dy=0.01)
>>> x, y = mesh.cellCenters
>>> xyVar = CellVariable(mesh=mesh, name="x y", value=x * y)
>>> k = Variable(name="k", value=1.)
>>> viewer = MatplotlibStreamViewer(vars=numerix.sin(k * xyVar).grad,
...                 title="MatplotlibStreamViewer test")
>>> for kval in numerix.arange(1, 10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
>>> viewer = MatplotlibStreamViewer(vars=numerix.sin(k * xyVar).faceGrad,
...                 title="MatplotlibStreamViewer test")
>>> for kval in numerix.arange(1, 10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
>>> from fipy import *
>>> mesh = (Grid2D(nx=5, ny=10, dx=0.1, dy=0.1)
...         + (Tri2D(nx=5, ny=5, dx=0.1, dy=0.1)
...          + ((0.5,), (0.2,))))
>>> x, y = mesh.cellCenters
>>> xyVar = CellVariable(mesh=mesh, name="x y", value=x * y)
>>> k = Variable(name="k", value=1.)
>>> viewer = MatplotlibStreamViewer(vars=numerix.sin(k * xyVar).grad,
...                 title="MatplotlibStreamViewer test")
>>> for kval in numerix.arange(1, 10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
>>> viewer = MatplotlibStreamViewer(vars=numerix.sin(k * xyVar).faceGrad,
...                 title="MatplotlibStreamViewer test")
>>> for kval in numerix.arange(1, 10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()

Creates a MatplotlibStreamViewer.

Parameters
  • vars (CellVariable or FaceVariable) – rank-1 Variable to display

  • title (str, optional) – displayed at the top of the Viewer window

  • log (bool, optional) – if True, arrow length goes at the base-10 logarithm of the magnitude

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

  • figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.

  • density (float or (float, float), optional) – Controls the closeness of streamlines. When density = 1, the domain is divided into a 30x30 grid. density linearly scales this grid. Each cell in the grid can have, at most, one traversing streamline. For different densities in each direction, use a tuple (density_x, density_y).

  • linewidth (array_like or CellVariable or FaceVariable, optional) – The width of the stream lines. With a rank-0 CellVariable or FaceVariable the line width can be varied across the grid. The MeshVariable must have the same type and be defined on the same Mesh as vars.

  • color (str or CellVariable or FaceVariable, optional) – The streamline color as a matplotlib color code or a field of numbers. If given a rank-0 CellVariable or FaceVariable, its values are converted to colors using cmap and norm. The MeshVariable must have the same type and be defined on the same Mesh as vars.

  • cmap (Colormap, optional) – Colormap used to plot streamlines and arrows. This is only used if color is a MeshVariable.

  • norm (Normalize, optional) – Normalize object used to scale luminance data to 0, 1. If None, stretch (min, max) to (0, 1). Only necessary when color is a MeshVariable.

  • arrowsize (float, optional) – Scaling factor for the arrow size.

  • arrowstyle (str, optional) – Arrow style specification. See ~matplotlib.patches.FancyArrowPatch.

  • minlength (float, optional) – Minimum length of streamline in axes coordinates.

__annotations__ = {}
__init__(vars, title=None, log=False, limits={}, axes=None, figaspect='auto', density=1, linewidth=None, color=None, cmap=None, norm=None, arrowsize=1, arrowstyle='-|>', minlength=0.1, **kwlimits)

Creates a MatplotlibStreamViewer.

Parameters
  • vars (CellVariable or FaceVariable) – rank-1 Variable to display

  • title (str, optional) – displayed at the top of the Viewer window

  • log (bool, optional) – if True, arrow length goes at the base-10 logarithm of the magnitude

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

  • figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.

  • density (float or (float, float), optional) – Controls the closeness of streamlines. When density = 1, the domain is divided into a 30x30 grid. density linearly scales this grid. Each cell in the grid can have, at most, one traversing streamline. For different densities in each direction, use a tuple (density_x, density_y).

  • linewidth (array_like or CellVariable or FaceVariable, optional) – The width of the stream lines. With a rank-0 CellVariable or FaceVariable the line width can be varied across the grid. The MeshVariable must have the same type and be defined on the same Mesh as vars.

  • color (str or CellVariable or FaceVariable, optional) – The streamline color as a matplotlib color code or a field of numbers. If given a rank-0 CellVariable or FaceVariable, its values are converted to colors using cmap and norm. The MeshVariable must have the same type and be defined on the same Mesh as vars.

  • cmap (Colormap, optional) – Colormap used to plot streamlines and arrows. This is only used if color is a MeshVariable.

  • norm (Normalize, optional) – Normalize object used to scale luminance data to 0, 1. If None, stretch (min, max) to (0, 1). Only necessary when color is a MeshVariable.

  • arrowsize (float, optional) – Scaling factor for the arrow size.

  • arrowstyle (str, optional) – Arrow style specification. See ~matplotlib.patches.FancyArrowPatch.

  • minlength (float, optional) – Minimum length of streamline in axes coordinates.

__module__ = 'fipy.viewers.matplotlibViewer.matplotlibStreamViewer'
class fipy.viewers.MatplotlibVectorViewer(vars, title=None, scale=None, sparsity=None, log=False, limits={}, axes=None, figaspect='auto', **kwlimits)

Bases: fipy.viewers.matplotlibViewer.matplotlib2DViewer.AbstractMatplotlib2DViewer

Displays a vector plot of a 2D rank-1 CellVariable or FaceVariable object using Matplotlib

>>> from fipy import *
>>> mesh = Grid2D(nx=50, ny=100, dx=0.1, dy=0.01)
>>> x, y = mesh.cellCenters
>>> xyVar = CellVariable(mesh=mesh, name="x y", value=x * y)
>>> k = Variable(name="k", value=1.)
>>> viewer = MatplotlibVectorViewer(vars=numerix.sin(k * xyVar).grad,
...                 title="MatplotlibVectorViewer test")
>>> for kval in numerix.arange(1, 10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
>>> viewer = MatplotlibVectorViewer(vars=numerix.sin(k * xyVar).faceGrad,
...                 title="MatplotlibVectorViewer test")
>>> for kval in numerix.arange(1, 10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
>>> for sparsity in numerix.arange(5000, 0, -500):
...     viewer.quiver(sparsity=sparsity)
...     viewer.plot()
>>> viewer._promptForOpinion()
>>> from fipy import *
>>> mesh = (Grid2D(nx=5, ny=10, dx=0.1, dy=0.1)
...         + (Tri2D(nx=5, ny=5, dx=0.1, dy=0.1)
...          + ((0.5,), (0.2,))))
>>> x, y = mesh.cellCenters
>>> xyVar = CellVariable(mesh=mesh, name="x y", value=x * y)
>>> k = Variable(name="k", value=1.)
>>> viewer = MatplotlibVectorViewer(vars=numerix.sin(k * xyVar).grad,
...                 title="MatplotlibVectorViewer test")
>>> for kval in numerix.arange(1, 10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
>>> viewer = MatplotlibVectorViewer(vars=numerix.sin(k * xyVar).faceGrad,
...                 title="MatplotlibVectorViewer test")
>>> for kval in numerix.arange(1, 10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()

Creates a Matplotlib2DViewer.

Parameters
  • vars (CellVariable or FaceVariable) – rank-1 Variable to display

  • title (str, optional) – displayed at the top of the Viewer window

  • scale (float, optional) – if not None, scale all arrow lengths by this value

  • sparsity (int, optional) – if not None, then this number of arrows will be randomly chosen (weighted by the cell volume or face area)

  • log (bool, optional) – if True, arrow length goes at the base-10 logarithm of the magnitude

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

  • figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.

__annotations__ = {}
__init__(vars, title=None, scale=None, sparsity=None, log=False, limits={}, axes=None, figaspect='auto', **kwlimits)

Creates a Matplotlib2DViewer.

Parameters
  • vars (CellVariable or FaceVariable) – rank-1 Variable to display

  • title (str, optional) – displayed at the top of the Viewer window

  • scale (float, optional) – if not None, scale all arrow lengths by this value

  • sparsity (int, optional) – if not None, then this number of arrows will be randomly chosen (weighted by the cell volume or face area)

  • log (bool, optional) – if True, arrow length goes at the base-10 logarithm of the magnitude

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

  • figaspect (float, optional) – desired aspect ratio of figure. If arg is a number, use that aspect ratio. If arg is auto, the aspect ratio will be determined from the Variable’s mesh.

__module__ = 'fipy.viewers.matplotlibViewer.matplotlibVectorViewer'
quiver(sparsity=None, scale=None)
fipy.viewers.MatplotlibViewer(vars, title=None, limits={}, cmap=None, colorbar='vertical', axes=None, **kwlimits)

Generic function for creating a MatplotlibViewer.

The MatplotlibViewer factory will search the module tree and return an instance of the first MatplotlibViewer it finds of the correct dimension and rank.

It is possible to view different Variables against different Matplotlib Axes

>>> from matplotlib import pyplot as plt
>>> from fipy import *
>>> plt.ion()
>>> fig = plt.figure()
>>> ax1 = plt.subplot((221))
>>> ax2 = plt.subplot((223))
>>> ax3 = plt.subplot((224))
>>> k = Variable(name="k", value=0.)
>>> mesh1 = Grid1D(nx=100)
>>> x, = mesh1.cellCenters
>>> xVar = CellVariable(mesh=mesh1, name="x", value=x)
>>> viewer1 = MatplotlibViewer(vars=(numerix.sin(0.1 * k * xVar), numerix.cos(0.1 * k * xVar / numerix.pi)),
...                            limits={'xmin': 10, 'xmax': 90},
...                            datamin=-0.9, datamax=2.0,
...                            title="Grid1D test",
...                            axes=ax1,
...                            legend=None)
>>> mesh2 = Grid2D(nx=50, ny=100, dx=0.1, dy=0.01)
>>> x, y = mesh2.cellCenters
>>> xyVar = CellVariable(mesh=mesh2, name="x y", value=x * y)
>>> viewer2 = MatplotlibViewer(vars=numerix.sin(k * xyVar),
...                            limits={'ymin': 0.1, 'ymax': 0.9},
...                            datamin=-0.9, datamax=2.0,
...                            title="Grid2D test",
...                            axes=ax2,
...                            colorbar=None)
>>> mesh3 = (Grid2D(nx=5, ny=10, dx=0.1, dy=0.1)
...          + (Tri2D(nx=5, ny=5, dx=0.1, dy=0.1)
...             + ((0.5,), (0.2,))))
>>> x, y = mesh3.cellCenters
>>> xyVar = CellVariable(mesh=mesh3, name="x y", value=x * y)
>>> viewer3 = MatplotlibViewer(vars=numerix.sin(k * xyVar),
...                            limits={'ymin': 0.1, 'ymax': 0.9},
...                            datamin=-0.9, datamax=2.0,
...                            title="Irregular 2D test",
...                            axes=ax3,
...                            cmap = plt.cm.OrRd)
>>> viewer = MultiViewer(viewers=(viewer1, viewer2, viewer3))
>>> from builtins import range
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
Parameters
  • vars (CellVariable or list) – the Variable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • cmap (Colormap, optional) – the Colormap. Defaults to matplotlib.cm.jet

  • colorbar (bool, optional) – plot a color bar in specified orientation if not None

  • axes (Axes, optional) – if not None, vars will be plotted into this Matplotlib Axes object

class fipy.viewers.MayaviClient(vars, title=None, daemon_file=None, fps=1.0, **kwlimits)

Bases: fipy.viewers.viewer.AbstractViewer

The MayaviClient uses the Mayavi python plotting package.

>>> from fipy import *
>>> mesh = Grid1D(nx=100)
>>> x, = mesh.cellCenters
>>> xVar = CellVariable(mesh=mesh, name="x", value=x)
>>> k = Variable(name="k", value=0.)
>>> viewer = MayaviClient(vars=(numerix.sin(k * xVar), numerix.cos(k * xVar / numerix.pi)),
...                 limits={'xmin': 10, 'xmax': 90},
...                 datamin=-0.9, datamax=2.0,
...                 title="MayaviClient test")
>>> for kval in numerix.arange(0, 0.3, 0.03):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
>>> from fipy import *
>>> mesh = Grid2D(nx=50, ny=100, dx=0.1, dy=0.01)
>>> x, y = mesh.cellCenters
>>> xyVar = CellVariable(mesh=mesh, name="x y", value=x * y)
>>> k = Variable(name="k", value=0.)
>>> viewer = MayaviClient(vars=numerix.sin(k * xyVar),
...                 limits={'ymin': 0.1, 'ymax': 0.9},
...                 datamin=-0.9, datamax=2.0,
...                 title="MayaviClient test")
>>> from builtins import range
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
>>> from fipy import *
>>> mesh = (Grid2D(nx=5, ny=10, dx=0.1, dy=0.1)
...         + (Tri2D(nx=5, ny=5, dx=0.1, dy=0.1)
...          + ((0.5,), (0.2,))))
>>> x, y = mesh.cellCenters
>>> xyVar = CellVariable(mesh=mesh, name="x y", value=x * y)
>>> k = Variable(name="k", value=0.)
>>> viewer = MayaviClient(vars=numerix.sin(k * xyVar),
...                 limits={'ymin': 0.1, 'ymax': 0.9},
...                 datamin=-0.9, datamax=2.0,
...                 title="MayaviClient test")
>>> from builtins import range
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
>>> from fipy import *
>>> mesh = Grid3D(nx=50, ny=100, nz=10, dx=0.1, dy=0.01, dz=0.1)
>>> x, y, z = mesh.cellCenters
>>> xyzVar = CellVariable(mesh=mesh, name=r"x y z", value=x * y * z)
>>> k = Variable(name="k", value=0.)
>>> viewer = MayaviClient(vars=numerix.sin(k * xyzVar),
...                     limits={'ymin': 0.1, 'ymax': 0.9},
...                     datamin=-0.9, datamax=2.0,
...                     title="MayaviClient test")
>>> from builtins import range
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()

Create a MayaviClient.

Parameters
  • vars (CellVariable or list) – CellVariable objects to plot

  • title (str, optional) – displayed at the top of the Viewer window

  • xmin (float) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • daemon_file (str, optional) – the path to the script to run the separate Mayavi viewer process. Defaults to fipy/viewers/mayaviViewer/mayaviDaemon.py

  • fps (float, optional) – frames per second to attempt to display

__annotations__ = {}
__del__()
__init__(vars, title=None, daemon_file=None, fps=1.0, **kwlimits)

Create a MayaviClient.

Parameters
  • vars (CellVariable or list) – CellVariable objects to plot

  • title (str, optional) – displayed at the top of the Viewer window

  • xmin (float) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • daemon_file (str, optional) – the path to the script to run the separate Mayavi viewer process. Defaults to fipy/viewers/mayaviViewer/mayaviDaemon.py

  • fps (float, optional) – frames per second to attempt to display

__module__ = 'fipy.viewers.mayaviViewer.mayaviClient'
plot(filename=None)

Update the display of the viewed variables.

Parameters

filename (str) – If not None, the name of a file to save the image into.

exception fipy.viewers.MeshDimensionError

Bases: IndexError

__annotations__ = {}
__module__ = 'fipy.viewers'
__weakref__

list of weak references to the object (if defined)

class fipy.viewers.MultiViewer(viewers)

Bases: fipy.viewers.viewer.AbstractViewer

Treat a collection of different viewers (such for different 2D plots or 1D plots with different axes) as a single viewer that will plot() all subviewers simultaneously.

Parameters

viewers (list of ~fipy.viewers.viewer.Viewer) – the viewers to bind together

__annotations__ = {}
__init__(viewers)
Parameters

viewers (list of ~fipy.viewers.viewer.Viewer) – the viewers to bind together

__module__ = 'fipy.viewers.multiViewer'
plot()

Update the display of the viewed variables.

Parameters

filename (str) – If not None, the name of a file to save the image into.

setLimits(limits={}, **kwlimits)

Update the limits.

Parameters
  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

class fipy.viewers.TSVViewer(vars, title=None, limits={}, **kwlimits)

Bases: fipy.viewers.viewer.AbstractViewer

“Views” one or more variables in tab-separated-value format.

Output is a list of coordinates and variable values at each cell center.

File contents will be, e.g.:

title
x       y       ...     var0    var2    ...
0.0     0.0     ...     3.14    1.41    ...
1.0     0.0     ...     2.72    0.866   ...
:
:

Creates a TSVViewer.

Any cell centers that lie outside the limits provided will not be included. Any values that lie outside the datamin or datamax will be replaced with nan.

All variables must have the same mesh.

It tries to do something reasonable with rank-1 CellVariable and FaceVariable objects.

Parameters
  • vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

__annotations__ = {}
__init__(vars, title=None, limits={}, **kwlimits)

Creates a TSVViewer.

Any cell centers that lie outside the limits provided will not be included. Any values that lie outside the datamin or datamax will be replaced with nan.

All variables must have the same mesh.

It tries to do something reasonable with rank-1 CellVariable and FaceVariable objects.

Parameters
  • vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

__module__ = 'fipy.viewers.tsvViewer'
plot(filename=None)

“plot” the coordinates and values of the variables to filename. If filename is not provided, “plots” to stdout.

>>> from fipy.meshes import Grid1D
>>> m = Grid1D(nx = 3, dx = 0.4)
>>> from fipy.variables.cellVariable import CellVariable
>>> v = CellVariable(mesh = m, name = "var", value = (0, 2, 5))
>>> TSVViewer(vars = (v, v.grad)).plot() 
x       var     var_gauss_grad_x
0.2     0       2.5
0.6     2       6.25
1       5       3.75
>>> from fipy.meshes import Grid2D
>>> m = Grid2D(nx = 2, dx = .1, ny = 2, dy = 0.3)
>>> v = CellVariable(mesh = m, name = "var", value = (0, 2, -2, 5))
>>> TSVViewer(vars = (v, v.grad)).plot() 
x       y       var     var_gauss_grad_x        var_gauss_grad_y
0.05    0.15    0       10      -3.33333333333333
0.15    0.15    2       10      5
0.05    0.45    -2      35      -3.33333333333333
0.15    0.45    5       35      5
Parameters

filename (str) – If not None, the name of a file to save the image into.

class fipy.viewers.VTKCellViewer(vars, title=None, limits={}, **kwlimits)

Bases: fipy.viewers.vtkViewer.vtkViewer.VTKViewer

Renders CellVariable data in VTK format

Creates a VTKViewer

Parameters
  • vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

__annotations__ = {}
__module__ = 'fipy.viewers.vtkViewer.vtkCellViewer'
class fipy.viewers.VTKFaceViewer(vars, title=None, limits={}, **kwlimits)

Bases: fipy.viewers.vtkViewer.vtkViewer.VTKViewer

Renders _MeshVariable data in VTK format

Creates a VTKViewer

Parameters
  • vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

__annotations__ = {}
__module__ = 'fipy.viewers.vtkViewer.vtkFaceViewer'
fipy.viewers.VTKViewer(vars, title=None, limits={}, **kwlimits)

Generic function for creating a VTKViewer.

The VTKViewer factory will search the module tree and return an instance of the first VTKViewer it finds of the correct dimension and rank.

Parameters
  • vars (CellVariable or FaceVariable or list) – the MeshVariable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict, optional) – a (deprecated) alternative to limit keyword arguments

  • xmin (float) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. Any limit set to a (default) value of None will autoscale.

fipy.viewers.Viewer(vars, title=None, limits={}, FIPY_VIEWER=None, **kwlimits)

Generic function for creating a Viewer.

The Viewer factory will search the module tree and return an instance of the first Viewer it finds that supports the dimensions of vars. Setting the FIPY_VIEWER environment variable to either matplotlib, mayavi, tsv, or vtk will specify the viewer.

The kwlimits or limits parameters can be used to constrain the view. For example:

Viewer(vars=some1Dvar, xmin=0.5, xmax=None, datamax=3)

or:

Viewer(vars=some1Dvar,
       limits={'xmin': 0.5, 'xmax': None, 'datamax': 3})

will return a viewer that displays a line plot from an x value of 0.5 up to the largest x value in the dataset. The data values will be truncated at an upper value of 3, but will have no lower limit.

Parameters
  • vars (CellVariable or list) – the Variable objects to display.

  • title (str, optional) – displayed at the top of the Viewer window

  • limits (dict) – a (deprecated) alternative to limit keyword arguments

  • FIPY_VIEWER – a specific viewer to attempt (possibly multiple times for multiple variables)

  • xmin (float) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • xmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • ymax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • zmax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamin (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

  • datamax (float, optional) – displayed range of data. A 1D Viewer will only use xmin and xmax, a 2D viewer will also use ymin and ymax, and so on. All viewers will use datamin and datamax. Any limit set to a (default) value of None will autoscale.

Last updated on Jan 14, 2021. Created using Sphinx 3.4.3.