This tutorial illustrates how to modify the boundary conditions of an interior rectangle in the grid if you know the x and y coordinates of the rectangle.
from landlab import RasterModelGrid
import numpy as np
from landlab.plot.imshow import imshow_grid_at_node
from matplotlib.pyplot import show
%matplotlib inline
mg = RasterModelGrid((10, 10))
Known coordinates of rectangle:
min_x = 2.5
max_x = 5.
min_y = 3.5
max_y = 7.5
Define the area inside x and y coordinates:
x_condition = np.logical_and(mg.x_of_node < max_x, mg.x_of_node > min_x)
y_condition = np.logical_and(mg.y_of_node < max_y, mg.y_of_node > min_y)
my_nodes = np.logical_and(x_condition, y_condition)
Define boundaries as CLOSED:
mg.status_at_node[my_nodes] = mg.BC_NODE_IS_CLOSED
Make a new elevation field for display:
z = mg.add_zeros('topographic__elevation', at='node')
imshow_grid_at_node(mg, z)