Currently, CellArray objects are only available in PyGist.

- from cellarray import *
- ca = CellArray (
*<keylist>*)

A CellArray is a regular two dimensional rectangular mesh whose cells are color filled as specified by the keyword argument z. The keywords accepted by CellArray are:

**z, x0, y0, x1, y1, hide, label**In addition, CellArray objects have the methods new and set, like all other 2d geometric objects.

The following keyword arguments can be specified for CellArrays:

z = <2d sequence of numeric or unsigned character values>

specifies the coloring to be given to the CellArray. If numeric, the values are interpolated onto a palette. If unsigned character, the values are used to index into the palette.The argument z is required.If the dimensions of z are n_{1}and n_{2}, then the cell array will be n_{1}by n_{2}cells in size.

x0, y0 -- floating point scalars; if present, the coordinates of the lower left corner of the cell array. The default is (0., 0.).

These coordinates are optional, but if they are present then x1, y1 must be also (see below).

x1, y1 -- floating point scalars; if present, the coordinates of the upper right corner of the cell array. If these optional keywords are missing, then x0, y0 must be also missing, and their default values (1.0, 1.0) will be used.

hide = 0/1 (1 to hide this part of the graph)

label = <string> label for this part of the graph.

Methods new and set are as in the other 2d classes.

The following simple example creates a 10 by 19 CellArray object and plots it.

- from cellarray import *
- nx= 10
- ny= 19
- # 'b' (byte) is the typecode used by Python for
- # unsigned character:
- ndx = reshape (arange (nx * ny, typecode = 'b'), (nx, ny))
- # Instantiate a CellArray object:
- cla = CellArray ( z = ndx )
- # Create a Graph2d object containing it:
- gca = Graph2d ( cla , titles = "Cell Array",
- axis_scales = "linlin" ) # (axis scales is redundant)
- # Plot it:
- gca.plot ( )
Another (and more interesting) example of a CellArray is given below. First we show the functions mag and a3, which are used to calculate the data plotted.

- def mag ( *args ) :
- r = 0
- for i in range (len (args)) :
- r = r + args[i] * args[i]
- return sqrt (r)
- def a3 (lb, ub, n) :
- return reshape (array(n*span(lb,ub,n), Float), (n,n))
- # The following computation produces the plot
- x=a3(-6,6,200)
- y=transpose (x)
- r=mag(y,x)
- theta=arctan2(y,x)
- funky=cos(r)**2*cos(3*theta)
- from cellarray import *
- c1 = CellArray(z=funky)
- g1 = Graph2d (c1, color_card = "earth.gp",
- titles ="Cell array, three cycles in theta,r",
- axis_limits = "defaults")
- g1.plot()
- nz = 20
- x = arange (-nz, nz+1, typecode = Float )
- y = x
- z = zeros ((2*nz + 2, 2*nz + 2), Float)
- for i in range ( len (x) ) :
- for j in range ( len (y)) :
- r = sqrt ( x [i] * x[i] + y [j] * y [j] ) + 1.e-12
- z [i, j] = sin (r) / r
- # cell array plot
- cla = CellArray ( z = z)
- gca = Graph2d ( cla , titles = "Sombrero Function",
- color_card = "rainbow.gp", axis_limits="defaults")
- gca.plot ( )

[Top] [Prev] [Next] [Bottom]

support@icf.llnl.gov