Bookmark and Share FiPy: A Finite Volume PDE Solver Using Python
Version 3.0.1-dev139-ge5d2233

Previous topic

variables Package

Next topic

gistViewer Package

This Page

Contact

FiPy developers
Jonathan Guyer
Daniel Wheeler
James Warren

Join our mailing list

100 Bureau Drive, M/S 6555
Gaithersburg, MD 20899

301-975-5329 Telephone
301-975-4553 Facsimile

viewers Package

viewers Package

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

Generic function for creating a GistViewer.

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

Parameters :
vars

a CellVariable or tuple of CellVariable objects to plot

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, datamin, datamax

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.

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

Generic function for creating a GnuplotViewer.

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

Parameters :
vars

a CellVariable or tuple of CellVariable objects to plot

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, datamin, datamax

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.

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.

Parameters :
vars

a CellVariable or tuple of CellVariable objects to plot

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, datamin, datamax

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

the colormap. Defaults to matplotlib.cm.jet

colorbar

plot a colorbar in specified orientation if not None

axes

if not None, vars will be plotted into this Matplotlib Axes object

It is possible to view different Variables against different Matplotlib Axes

>>> from matplotlib import pylab
>>> from fipy import *
>>> pylab.ion()
>>> fig = pylab.figure()
>>> ax1 = pylab.subplot((221))
>>> ax2 = pylab.subplot((223))
>>> ax3 = pylab.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 = pylab.cm.OrRd)
>>> viewer = MultiViewer(viewers=(viewer1, viewer2, viewer3))
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()
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

a CellVariable or tuple of CellVariable objects to plot

title

displayed at the top of the Viewer window

xlog

log scaling of x axis if True

ylog

log scaling of y axis if True

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, datamin, datamax

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

place a legend at the specified position, if not None

axes

if not None, vars will be plotted into this Matplotlib Axes object

log

logarithmic data scaling

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")
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()

Creates a Matplotlib2DGridViewer.

Parameters :
vars

A CellVariable object.

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

cmap

The colormap. Defaults to matplotlib.cm.jet

xmin, xmax, ymin, ymax, datamin, datamax

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

colorbar

plot a colorbar in specified orientation if not None

axes

if not None, vars will be plotted into this Matplotlib Axes object

figaspect

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.

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")
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()

Creates a Matplotlib2DViewer.

Parameters :
vars

a CellVariable object.

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, datamin, datamax

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

cmap

the colormap. Defaults to matplotlib.cm.jet

colorbar

plot a colorbar in specified orientation if not None

axes

if not None, vars will be plotted into this Matplotlib Axes object

figaspect

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.

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")
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()

Creates a Matplotlib2DViewer.

Parameters :
vars

a CellVariable object.

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

cmap

the colormap. Defaults to matplotlib.cm.jet

xmin, xmax, ymin, ymax, datamin, datamax

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

colorbar

plot a colorbar in specified orientation if not None

axes

if not None, vars will be plotted into this Matplotlib Axes object

figaspect

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.

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

a rank-1 CellVariable or FaceVariable object.

title

displayed at the top of the Viewer window

scale

if not None, scale all arrow lengths by this value

sparsity

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

log

if True, arrow length goes at the base-10 logarithm of the magnitude

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, datamin, datamax

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

axes

if not None, vars will be plotted into this Matplotlib Axes object

figaspect

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.

quiver(sparsity=None, scale=None)
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")
>>> 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")
>>> 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")
>>> for kval in range(10):
...     k.setValue(kval)
...     viewer.plot()
>>> viewer._promptForOpinion()

Create a MayaviClient.

Parameters :
vars

a CellVariable or tuple of CellVariable objects to plot

title

displayed at the top of the Viewer window

xmin, xmax, ymin, ymax, zmin, zmax, datamin, datamax

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

the path to the script to run the separate MayaVi viewer process. Defaults to “fipy/viewers/mayaviViewer/mayaviDaemon.py”

fps

frames per second to attempt to display

plot(filename=None)
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

the viewers to bind together

getViewers(*args, **kwds)

Deprecated since version 3.0: use the viewers property instead

plot()
setLimits(limits={}, **kwlimits)
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

a CellVariable, a FaceVariable, a tuple of CellVariable objects, or a tuple of FaceVariable objects to plot

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, zmin, zmax, datamin, datamax

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

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

If not None, the name of a file to save the image into.

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

a _MeshVariable or tuple of _MeshVariable objects to plot

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, zmin, zmax, datamin, datamax

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.VTKCellViewer(vars, title=None, limits={}, **kwlimits)

Bases: fipy.viewers.vtkViewer.vtkViewer.VTKViewer

Renders CellVariable data in VTK format

Creates a VTKViewer

Parameters :
vars

a _MeshVariable or a tuple of them

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, zmin, zmax, datamin, datamax

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

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

a _MeshVariable or a tuple of them

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, zmin, zmax, datamin, datamax

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

exception fipy.viewers.MeshDimensionError

Bases: exceptions.IndexError

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

Bases: fipy.viewers.viewer.AbstractViewer

Create a AbstractViewer object.

Parameters :
vars

a CellVariable or tuple of CellVariable objects to plot

title

displayed at the top of the Viewer window

xmin, xmax, ymin, ymax, zmin, zmax, datamin, datamax

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.

plot(filename=None)
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 ‘gist‘, ‘gnuplot‘, ‘matplotlib‘, ‘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

a CellVariable or tuple of CellVariable objects to plot

title

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, xmax, ymin, ymax, zmin, zmax, datamin, datamax

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.

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

the viewers to bind together

getViewers(*args, **kwds)

Deprecated since version 3.0: use the viewers property instead

plot()
setLimits(limits={}, **kwlimits)

test Module

Test implementation of the viewers

testinteractive Module

Interactively test the 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

a CellVariable, a FaceVariable, a tuple of CellVariable objects, or a tuple of FaceVariable objects to plot

title

displayed at the top of the Viewer window

limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, zmin, zmax, datamin, datamax

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

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

If not None, the name of a file to save the image into.

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

a CellVariable or tuple of CellVariable objects to plot

title

displayed at the top of the Viewer window

xmin, xmax, ymin, ymax, zmin, zmax, datamin, datamax

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.

getVars(*args, **kwds)

Get the Variables

Deprecated since version 3.0: use the vars property instead

Deprecated since version Use: fipy.viewers.viewer.AbstractViewer.vars instead

plot(filename=None)

Update the display of the viewed variables.

Parameters :
filename

If not None, the name of a file to save the image into.

plotMesh(filename=None)

Display a representation of the mesh

Parameters :
filename

If not None, the name of a file to save the image into.

setLimits(limits={}, **kwlimits)

Update the limits.

Parameters :
limits : dict

a (deprecated) alternative to limit keyword arguments

xmin, xmax, ymin, ymax, zmin, zmax, datamin, datamax

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.