import sys
sys.path.append('../..') # add the pde package to the python path
import pde
# define a simple grid
grid = pde.UnitGrid([32, 32])
grid.plot()
# define scalar field, initially filled with zeros
field = pde.ScalarField(grid)
field.average
# do computations on the field
field += 1
field.average
# define a scalar field initialized with random colored noise and plot it
scalar = pde.ScalarField.random_colored(grid, exponent=-2)
scalar.plot(colorbar=True);
# apply operators to the field
smoothed = scalar.smooth(1)
laplace = smoothed.laplace(bc='natural')
laplace.plot(colorbar=True);
# initialize a vector field and plot it
vector = pde.VectorField.random_colored(grid, exponent=-4)
vector.plot(method='streamplot');
# plot the first component of the vector field
vector[0].plot()