Bookmark and Share FiPy: A Finite Volume PDE Solver Using Python
Version 2.1.3

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 Documentation

This page contains the viewers Package documentation.

The viewers Package

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

Bases: fipy.viewers.viewer._Viewer

Create a _Viewer 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)
exception fipy.viewers.MeshDimensionError

Bases: exceptions.IndexError

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.

fipy.viewers.make(*args, **kwargs)

A deprecated synonym for Viewer

The multiViewer Module

class fipy.viewers.multiViewer.MultiViewer(viewers)

Bases: fipy.viewers.viewer._Viewer

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

The test Module

Test implementation of the viewers

The testinteractive Module

Interactively test the viewers

The tsvViewer Module

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

Bases: fipy.viewers.viewer._Viewer

“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.grid1D 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.getGrad())).plot() 
x       var     var_gauss_grad_x
0.2     0       2.5
0.6     2       6.25
1       5       3.75
>>> from fipy.meshes.grid2D 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.getGrad())).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.

The viewer Module

fipy.viewers.viewer.make(vars, title=None, limits=None)