from landlab import RasterModelGrid # create a 3x3 RasterModelGrid with spacing of 1 grid = RasterModelGrid((3, 3), xy_spacing=1)
import numpy as np # add a field 'elevation' with random values between 0 and 1 elev = np.random.rand(grid.number_of_nodes) grid.add_field('elevation', elev)
from landlab.bc import FixedValueBC # set boundary condition on the top row of nodes to fixed value of 1 bc = FixedValueBC(grid, 'top', value=1)This code sets a boundary condition to the top row of nodes in the grid, fixing their value to 1. Overall, the RasterModelGrid class is a powerful tool in the Landlab package library for creating and manipulating 2D raster grids.