landlab.graph.structured_quad package#

Subpackages#

Submodules#

landlab.graph.structured_quad.dual_structured_quad module#

class DualRectilinearGraph(node_y_and_x)[source]#

Bases: DualGraph, RectilinearGraph

Create a dual graph for a rectilinear grid.

Examples

>>> from landlab.graph import DualRectilinearGraph
>>> graph = DualRectilinearGraph(([0, 1, 3], [0, 5, 15, 30]))
>>> graph.x_of_corner.reshape((2, 3))
array([[  2.5,  10. ,  22.5],
       [  2.5,  10. ,  22.5]])
>>> graph.y_of_corner.reshape((2, 3))
array([[ 0.5,  0.5,  0.5],
       [ 2. ,  2. ,  2. ]])
>>> graph.number_of_cells == 2
True
>>> graph.faces_at_cell
array([[3, 5, 2, 0],
       [4, 6, 3, 1]])
property adjacent_corners_at_corner#

Get adjacent corners.

See also

adjacent_nodes_at_node

property adjacent_faces_at_face#
property angle_of_face#

Get the angle of each face.

See also

angle_of_link

property area_of_cell#

Get the area of each cell.

See also

area_of_patch

property cells_at_corner#
property cells_at_face#
property corner_at_face_head#

Get corners at face head.

See also

node_at_link_head

property corner_at_face_tail#

Get corners at face tail.

See also

node_at_link_tail

property corner_x#
property corner_y#
property corners#

A shaped array of corner ids.

See also

nodes

property corners_at_bottom_edge#
property corners_at_cell#

Get the corners that define a cell.

See also

nodes_at_patch

property corners_at_face#

Get corners at either end of faces.

See also

nodes_at_link

property corners_at_left_edge#
property corners_at_nodes_of_grid#

Nodes at nodes of grid.

See also

nodes_at_corners_of_grid

property corners_at_right_edge#
property corners_at_top_edge#
property face_dirs_at_corner#
property faces_at_cell#

Get the faces that define a cell.

See also

links_at_patch

property faces_at_corner#
static get_corners(node_y_and_x)[source]#
property horizontal_faces#
property length_of_face#

Get the length of faces.

See also

length_of_link

property midpoint_of_face#

Get the middle of faces.

See also

midpoint_of_link

property node_corners#
property number_of_cells#

Get the number of cells.

See also

number_of_patches

property number_of_corner_columns#
property number_of_corner_rows#
property number_of_corners#

Get total number of corners.

See also

number_of_nodes

property number_of_faces#

Get corners at face head.

See also

number_of_links

property orientation_of_face#

Return array of face orientation codes (one value per face).

See also

orientation_of_link

property parallel_faces_at_face#

Return similarly oriented faces connected to each face.

See also

parallel_links_at_link

property perimeter_corners#
property unit_vector_at_corner#

Get a unit vector for each corner.

See also

unit_vector_at_node

property unit_vector_at_face#

Make arrays to store the unit vectors associated with each face.

See also

unit_vector_at_link

property vertical_faces#
property x_of_corner#

Get x-coordinate of corner.

See also

x_of_node

property xy_of_cell#

Get the centroid of each cell.

See also

xy_of_patch

property xy_of_corner#

Get x and y-coordinates of corner.

See also

xy_of_node

property xy_of_face#
property y_of_corner#

Get y-coordinate of corner.

See also

y_of_node

class DualStructuredQuadGraph(node_y_and_x, shape=None, sort=True)[source]#

Bases: DualGraph, StructuredQuadGraph

Dual graph of a structured grid of quadrilaterals.

Examples

>>> from landlab.graph import DualStructuredQuadGraph
>>> node_y = [-1, -2, -3, 0, 0, 0, 1, 2, 3]
>>> node_x = [0, 1, 2, 0, 2, 3, 0, 1, 2]
>>> graph = DualStructuredQuadGraph((node_y, node_x), shape=(3, 3), sort=True)
>>> graph.number_of_corners == 4
True
>>> graph.y_of_corner
array([-1.25, -0.75,  0.75,  1.25])
>>> graph.x_of_corner
array([ 2.  ,  0.75,  0.75,  2.  ])
>>> graph.node_at_cell
array([4])
property adjacent_corners_at_corner#

Get adjacent corners.

See also

adjacent_nodes_at_node

property adjacent_faces_at_face#
property angle_of_face#

Get the angle of each face.

See also

angle_of_link

property area_of_cell#

Get the area of each cell.

See also

area_of_patch

property cells_at_corner#
property cells_at_face#
property corner_at_face_head#

Get corners at face head.

See also

node_at_link_head

property corner_at_face_tail#

Get corners at face tail.

See also

node_at_link_tail

property corner_x#
property corner_y#
property corners#

A shaped array of corner ids.

See also

nodes

property corners_at_bottom_edge#
property corners_at_cell#

Get the corners that define a cell.

See also

nodes_at_patch

property corners_at_face#

Get corners at either end of faces.

See also

nodes_at_link

property corners_at_left_edge#
property corners_at_nodes_of_grid#

Nodes at nodes of grid.

See also

nodes_at_corners_of_grid

property corners_at_right_edge#
property corners_at_top_edge#
property face_dirs_at_corner#
property faces_at_cell#

Get the faces that define a cell.

See also

links_at_patch

property faces_at_corner#
static get_corners(node_y_and_x, shape)[source]#
static get_node_at_cell(shape)[source]#

Set up an array that gives the node at each cell.

Examples

>>> from landlab.graph.structured_quad import DualStructuredQuadGraph
>>> DualStructuredQuadGraph.get_node_at_cell((5, 6))
array([ 7,  8,  9, 10,
       13, 14, 15, 16,
       19, 20, 21, 22])
static get_nodes_at_face(shape)[source]#

Set up an array that gives the nodes on either side of each face.

Examples

>>> from landlab.graph.structured_quad import DualStructuredQuadGraph
>>> DualStructuredQuadGraph.get_nodes_at_face((3, 4))
array([[ 1,  5], [ 2,  6],
       [ 4,  5], [ 5,  6], [ 6,  7],
       [ 5,  9], [ 6, 10]])
property horizontal_faces#
property length_of_face#

Get the length of faces.

See also

length_of_link

property midpoint_of_face#

Get the middle of faces.

See also

midpoint_of_link

property node_corners#
property number_of_cells#

Get the number of cells.

See also

number_of_patches

property number_of_corner_columns#
property number_of_corner_rows#
property number_of_corners#

Get total number of corners.

See also

number_of_nodes

property number_of_faces#

Get corners at face head.

See also

number_of_links

property orientation_of_face#

Return array of face orientation codes (one value per face).

See also

orientation_of_link

property parallel_faces_at_face#

Return similarly oriented faces connected to each face.

See also

parallel_links_at_link

property perimeter_corners#
property unit_vector_at_corner#

Get a unit vector for each corner.

See also

unit_vector_at_node

property unit_vector_at_face#

Make arrays to store the unit vectors associated with each face.

See also

unit_vector_at_link

property vertical_faces#
property x_of_corner#

Get x-coordinate of corner.

See also

x_of_node

property xy_of_cell#

Get the centroid of each cell.

See also

xy_of_patch

property xy_of_corner#

Get x and y-coordinates of corner.

See also

xy_of_node

property xy_of_face#
property y_of_corner#

Get y-coordinate of corner.

See also

y_of_node

class DualUniformRectilinearGraph(shape, spacing=1.0, origin=(0.0, 0.0))[source]#

Bases: DualGraph, UniformRectilinearGraph

Create a dual graph for a uniform rectilinear grid.

Examples

>>> from landlab.graph import DualUniformRectilinearGraph
>>> graph = DualUniformRectilinearGraph((4, 3))
>>> graph.x_of_corner.reshape((3, 2))
array([[ 0.5,  1.5],
       [ 0.5,  1.5],
       [ 0.5,  1.5]])
>>> graph.y_of_corner.reshape((3, 2))
array([[ 0.5,  0.5],
       [ 1.5,  1.5],
       [ 2.5,  2.5]])
>>> graph.number_of_cells == 2
True
>>> graph.faces_at_cell
array([[2, 3, 1, 0],
       [5, 6, 4, 3]])
property adjacent_corners_at_corner#

Get adjacent corners.

See also

adjacent_nodes_at_node

property adjacent_faces_at_face#
property angle_of_face#

Get the angle of each face.

See also

angle_of_link

property area_of_cell#

Get the area of each cell.

See also

area_of_patch

property cells_at_corner#
property cells_at_face#
property corner_at_face_head#

Get corners at face head.

See also

node_at_link_head

property corner_at_face_tail#

Get corners at face tail.

See also

node_at_link_tail

property corner_x#
property corner_y#
property corners#

A shaped array of corner ids.

See also

nodes

property corners_at_bottom_edge#
property corners_at_cell#

Get the corners that define a cell.

See also

nodes_at_patch

property corners_at_face#

Get corners at either end of faces.

See also

nodes_at_link

property corners_at_left_edge#
property corners_at_nodes_of_grid#

Nodes at nodes of grid.

See also

nodes_at_corners_of_grid

property corners_at_right_edge#
property corners_at_top_edge#
property face_dirs_at_corner#
property faces_at_cell#

Get the faces that define a cell.

See also

links_at_patch

property faces_at_corner#
property horizontal_faces#
property length_of_face#

Get the length of faces.

See also

length_of_link

property midpoint_of_face#

Get the middle of faces.

See also

midpoint_of_link

property node_corners#
property number_of_cells#

Get the number of cells.

See also

number_of_patches

property number_of_corner_columns#
property number_of_corner_rows#
property number_of_corners#

Get total number of corners.

See also

number_of_nodes

property number_of_faces#

Get corners at face head.

See also

number_of_links

property orientation_of_face#

Return array of face orientation codes (one value per face).

See also

orientation_of_link

property parallel_faces_at_face#

Return similarly oriented faces connected to each face.

See also

parallel_links_at_link

property perimeter_corners#
property unit_vector_at_corner#

Get a unit vector for each corner.

See also

unit_vector_at_node

property unit_vector_at_face#

Make arrays to store the unit vectors associated with each face.

See also

unit_vector_at_link

property vertical_faces#
property x_of_corner#

Get x-coordinate of corner.

See also

x_of_node

property xy_of_cell#

Get the centroid of each cell.

See also

xy_of_patch

property xy_of_corner#

Get x and y-coordinates of corner.

See also

xy_of_node

property xy_of_face#
property y_of_corner#

Get y-coordinate of corner.

See also

y_of_node

landlab.graph.structured_quad.structured_quad module#

class RectilinearGraph(nodes, sort=False)[source]#

Bases: StructuredQuadGraphExtras

Graph of a rectlinear grid of nodes.

Examples

>>> from landlab.graph import RectilinearGraph
>>> graph = RectilinearGraph(([0, 1, 2, 3], [1, 4, 8]))
>>> graph.number_of_nodes
12
>>> graph.y_of_node.reshape(graph.shape)
array([[ 0.,  0.,  0.],
       [ 1.,  1.,  1.],
       [ 2.,  2.,  2.],
       [ 3.,  3.,  3.]])
>>> graph.x_of_node.reshape(graph.shape)
array([[ 1.,  4.,  8.],
       [ 1.,  4.,  8.],
       [ 1.,  4.,  8.],
       [ 1.,  4.,  8.]])

Define a graph of connected nodes.

Parameters:

mesh (Dataset) – xarray Dataset that defines the topology in ugrid format.

static setup_node_y_and_x(coords)[source]#
class StructuredQuadGraph(coords, shape=None, sort=False)[source]#

Bases: StructuredQuadGraphExtras

Define a graph of connected nodes.

Parameters:

mesh (Dataset) – xarray Dataset that defines the topology in ugrid format.

static setup_node_y_and_x(yx_at_node, shape=None)[source]#
class StructuredQuadGraphExtras(node_y_and_x, sort=False)[source]#

Bases: StructuredQuadGraphTopology, Graph

Define a graph of connected nodes.

Parameters:

mesh (Dataset) – xarray Dataset that defines the topology in ugrid format.

Get nodes at either end of links.

Examples

>>> from landlab.graph import Graph
>>> node_x, node_y = [0, 1, 2, 0, 1, 2, 0, 1, 2], [0, 0, 0, 1, 1, 1, 2, 2, 2]
>>> links = (
...     (0, 1),
...     (1, 2),
...     (0, 3),
...     (1, 4),
...     (2, 5),
...     (3, 4),
...     (4, 5),
...     (3, 6),
...     (4, 7),
...     (5, 8),
...     (6, 7),
...     (7, 8),
... )
>>> graph = Graph((node_y, node_x), links=links)
>>> graph.nodes_at_link
array([[0, 1], [1, 2],
       [0, 3], [1, 4], [2, 5],
       [3, 4], [4, 5],
       [3, 6], [4, 7], [5, 8],
       [6, 7], [7, 8]])

Return array of link orientation codes (one value per link).

Orientation codes are defined by LinkOrientation; 1 = E, 2 = ENE, 4 = NNE, 8 = N, 16 = NNW, 32 = ESE (using powers of 2 allows for future applications that might want additive combinations).

Return similarly oriented links connected to each link.

Return IDs of links of the same orientation that are connected to each given link’s tail or head node.

The data structure is a numpy array of shape (n_links, 2) containing the IDs of the “tail-wise” (connected to tail node) and “head-wise” (connected to head node) links, or -1 if the link is inactive (e.g., on the perimeter) or it has no attached parallel neighbor in the given direction.

For instance, consider a 3x4 raster, in which link IDs are as shown:

.-14-.-15-.-16-.
|    |    |    |
10  11   12   13
|    |    |    |
.--7-.--8-.--9-.
|    |    |    |
3    4    5    6
|    |    |    |
.--0-.--1-.--2-.

Here’s a mapping of the tail-wise (shown at left or bottom of links) and head-wise (shown at right or top of links) links:

.----.----.----.
|    |    |    |
|    |    |    |
|    4    5    |
.---8.7--9.8---.
|   11   12    |
|    |    |    |
|    |    |    |
.----.----.----.

So the corresponding data structure would be mostly filled with -1, but for the 7 active links, it would look like:

4: [[-1, 11],
5:  [-1, 12],
7:  [-1,  8],
8:  [ 7,  9],
9:  [ 8, -1],
11: [ 4, -1],
12: [ 5, -1]]

Examples

>>> from landlab import RasterModelGrid
>>> grid = RasterModelGrid((3, 4))
>>> pll = grid.parallel_links_at_link
>>> pll[4:13, :]
array([[-1, 11],
       [-1, 12],
       [-1, 13],
       [-1,  8],
       [ 7,  9],
       [ 8, -1],
       [ 3, -1],
       [ 4, -1],
       [ 5, -1]])
class StructuredQuadGraphTopology(shape)[source]#

Bases: object

property corner_nodes#
property nodes#

A shaped array of node ids.

Returns:

Node IDs in an array shaped as number_of_node_rows by number_of_node_columns.

Return type:

ndarray

property nodes_at_bottom_edge#
property nodes_at_corners_of_grid#

Nodes at corners of grid.

The nodes at at the corners of the grid. The nodes are returned counterclockwise starting with the upper-right.

Returns:

Nodes at the four corners.

Return type:

tuple of int

Examples

>>> from landlab.graph import UniformRectilinearGraph
>>> graph = UniformRectilinearGraph((4, 5))
>>> graph.nodes_at_corners_of_grid
(19, 15, 0, 4)
nodes_at_edge(edge)[source]#
property nodes_at_left_edge#
property nodes_at_right_edge#
property nodes_at_top_edge#
property number_of_node_columns#
property number_of_node_rows#
property patches_at_node#
property perimeter_nodes#
property shape#
class StructuredQuadLayout[source]#

Bases: ABC

static corner_nodes(shape)[source]#
abstract static patches_at_node(shape)[source]#
abstract static perimeter_nodes(shape)[source]#
class StructuredQuadLayoutCython[source]#

Bases: StructuredQuadLayout

Get links that define patches for a raster grid.

Examples

>>> from landlab.graph.structured_quad.structured_quad import (
...     StructuredQuadLayoutCython,
... )
>>> StructuredQuadLayoutCython.links_at_patch((3, 4))
array([[ 4,  7,  3,  0], [ 5,  8,  4,  1], [ 6,  9,  5,  2],
       [11, 14, 10,  7], [12, 15, 11,  8], [13, 16, 12,  9]])

Examples

>>> from landlab.graph.structured_quad.structured_quad import (
...     StructuredQuadLayoutCython,
... )
>>> StructuredQuadLayoutCython.nodes_at_link((3, 4))
array([[ 0,  1], [ 1,  2], [ 2,  3],
       [ 0,  4], [ 1,  5], [ 2,  6], [ 3,  7],
       [ 4,  5], [ 5,  6], [ 6,  7],
       [ 4,  8], [ 5,  9], [ 6, 10], [ 7, 11],
       [ 8,  9], [ 9, 10], [10, 11]])
static patches_at_node(shape)[source]#
static perimeter_nodes(shape)[source]#
class StructuredQuadLayoutPython[source]#

Bases: StructuredQuadLayout

static patches_at_node(shape)[source]#
static perimeter_nodes(shape)[source]#
class UniformRectilinearGraph(shape, spacing=1.0, origin=0.0, sort=False)[source]#

Bases: StructuredQuadGraphExtras

Graph of a structured grid of quadrilaterals.

Examples

>>> from landlab.graph import UniformRectilinearGraph
>>> graph = UniformRectilinearGraph((4, 3), spacing=(1, 2), origin=(-1, 0))
>>> graph.number_of_nodes
12
>>> graph.y_of_node.reshape(graph.shape)
array([[-1., -1., -1.],
       [ 0.,  0.,  0.],
       [ 1.,  1.,  1.],
       [ 2.,  2.,  2.]])
>>> graph.x_of_node.reshape(graph.shape)
array([[ 0.,  2.,  4.],
       [ 0.,  2.,  4.],
       [ 0.,  2.,  4.],
       [ 0.,  2.,  4.]])
>>> graph.links_at_node
array([[ 0,  2, -1, -1], [ 1,  3,  0, -1], [-1,  4,  1, -1],
       [ 5,  7, -1,  2], [ 6,  8,  5,  3], [-1,  9,  6,  4],
       [10, 12, -1,  7], [11, 13, 10,  8], [-1, 14, 11,  9],
       [15, -1, -1, 12], [16, -1, 15, 13], [-1, -1, 16, 14]])
>>> graph.link_dirs_at_node
array([[-1, -1,  0,  0], [-1, -1,  1,  0], [ 0, -1,  1,  0],
       [-1, -1,  0,  1], [-1, -1,  1,  1], [ 0, -1,  1,  1],
       [-1, -1,  0,  1], [-1, -1,  1,  1], [ 0, -1,  1,  1],
       [-1,  0,  0,  1], [-1,  0,  1,  1], [ 0,  0,  1,  1]], dtype=int8)
>>> graph.nodes_at_link
array([[ 0,  1], [ 1,  2], [ 0,  3], [ 1,  4], [ 2,  5],
       [ 3,  4], [ 4,  5], [ 3,  6], [ 4,  7], [ 5,  8],
       [ 6,  7], [ 7,  8], [ 6,  9], [ 7, 10], [ 8, 11],
       [ 9, 10], [10, 11]])
>>> graph.links_at_patch
array([[ 3,  5,  2,  0], [ 4,  6,  3,  1],
       [ 8, 10,  7,  5], [ 9, 11,  8,  6],
       [13, 15, 12, 10], [14, 16, 13, 11]])
>>> graph.nodes_at_patch
array([[ 4,  3,  0,  1], [ 5,  4,  1,  2],
       [ 7,  6,  3,  4], [ 8,  7,  4,  5],
       [10,  9,  6,  7], [11, 10,  7,  8]])

Define a graph of connected nodes.

Parameters:

mesh (Dataset) – xarray Dataset that defines the topology in ugrid format.

property dx#
property dy#
property origin#
property spacing#

Module contents#

class DualRectilinearGraph(node_y_and_x)[source]#

Bases: DualGraph, RectilinearGraph

Create a dual graph for a rectilinear grid.

Examples

>>> from landlab.graph import DualRectilinearGraph
>>> graph = DualRectilinearGraph(([0, 1, 3], [0, 5, 15, 30]))
>>> graph.x_of_corner.reshape((2, 3))
array([[  2.5,  10. ,  22.5],
       [  2.5,  10. ,  22.5]])
>>> graph.y_of_corner.reshape((2, 3))
array([[ 0.5,  0.5,  0.5],
       [ 2. ,  2. ,  2. ]])
>>> graph.number_of_cells == 2
True
>>> graph.faces_at_cell
array([[3, 5, 2, 0],
       [4, 6, 3, 1]])
property adjacent_corners_at_corner#

Get adjacent corners.

See also

adjacent_nodes_at_node

property adjacent_faces_at_face#
property angle_of_face#

Get the angle of each face.

See also

angle_of_link

property area_of_cell#

Get the area of each cell.

See also

area_of_patch

property cells_at_corner#
property cells_at_face#
property corner_at_face_head#

Get corners at face head.

See also

node_at_link_head

property corner_at_face_tail#

Get corners at face tail.

See also

node_at_link_tail

property corner_x#
property corner_y#
property corners#

A shaped array of corner ids.

See also

nodes

property corners_at_bottom_edge#
property corners_at_cell#

Get the corners that define a cell.

See also

nodes_at_patch

property corners_at_face#

Get corners at either end of faces.

See also

nodes_at_link

property corners_at_left_edge#
property corners_at_nodes_of_grid#

Nodes at nodes of grid.

See also

nodes_at_corners_of_grid

property corners_at_right_edge#
property corners_at_top_edge#
property face_dirs_at_corner#
property faces_at_cell#

Get the faces that define a cell.

See also

links_at_patch

property faces_at_corner#
static get_corners(node_y_and_x)[source]#
property horizontal_faces#
property length_of_face#

Get the length of faces.

See also

length_of_link

property midpoint_of_face#

Get the middle of faces.

See also

midpoint_of_link

property node_corners#
property number_of_cells#

Get the number of cells.

See also

number_of_patches

property number_of_corner_columns#
property number_of_corner_rows#
property number_of_corners#

Get total number of corners.

See also

number_of_nodes

property number_of_faces#

Get corners at face head.

See also

number_of_links

property orientation_of_face#

Return array of face orientation codes (one value per face).

See also

orientation_of_link

property parallel_faces_at_face#

Return similarly oriented faces connected to each face.

See also

parallel_links_at_link

property perimeter_corners#
property unit_vector_at_corner#

Get a unit vector for each corner.

See also

unit_vector_at_node

property unit_vector_at_face#

Make arrays to store the unit vectors associated with each face.

See also

unit_vector_at_link

property vertical_faces#
property x_of_corner#

Get x-coordinate of corner.

See also

x_of_node

property xy_of_cell#

Get the centroid of each cell.

See also

xy_of_patch

property xy_of_corner#

Get x and y-coordinates of corner.

See also

xy_of_node

property xy_of_face#
property y_of_corner#

Get y-coordinate of corner.

See also

y_of_node

class DualStructuredQuadGraph(node_y_and_x, shape=None, sort=True)[source]#

Bases: DualGraph, StructuredQuadGraph

Dual graph of a structured grid of quadrilaterals.

Examples

>>> from landlab.graph import DualStructuredQuadGraph
>>> node_y = [-1, -2, -3, 0, 0, 0, 1, 2, 3]
>>> node_x = [0, 1, 2, 0, 2, 3, 0, 1, 2]
>>> graph = DualStructuredQuadGraph((node_y, node_x), shape=(3, 3), sort=True)
>>> graph.number_of_corners == 4
True
>>> graph.y_of_corner
array([-1.25, -0.75,  0.75,  1.25])
>>> graph.x_of_corner
array([ 2.  ,  0.75,  0.75,  2.  ])
>>> graph.node_at_cell
array([4])
property adjacent_corners_at_corner#

Get adjacent corners.

See also

adjacent_nodes_at_node

property adjacent_faces_at_face#
property angle_of_face#

Get the angle of each face.

See also

angle_of_link

property area_of_cell#

Get the area of each cell.

See also

area_of_patch

property cells_at_corner#
property cells_at_face#
property corner_at_face_head#

Get corners at face head.

See also

node_at_link_head

property corner_at_face_tail#

Get corners at face tail.

See also

node_at_link_tail

property corner_x#
property corner_y#
property corners#

A shaped array of corner ids.

See also

nodes

property corners_at_bottom_edge#
property corners_at_cell#

Get the corners that define a cell.

See also

nodes_at_patch

property corners_at_face#

Get corners at either end of faces.

See also

nodes_at_link

property corners_at_left_edge#
property corners_at_nodes_of_grid#

Nodes at nodes of grid.

See also

nodes_at_corners_of_grid

property corners_at_right_edge#
property corners_at_top_edge#
property face_dirs_at_corner#
property faces_at_cell#

Get the faces that define a cell.

See also

links_at_patch

property faces_at_corner#
static get_corners(node_y_and_x, shape)[source]#
static get_node_at_cell(shape)[source]#

Set up an array that gives the node at each cell.

Examples

>>> from landlab.graph.structured_quad import DualStructuredQuadGraph
>>> DualStructuredQuadGraph.get_node_at_cell((5, 6))
array([ 7,  8,  9, 10,
       13, 14, 15, 16,
       19, 20, 21, 22])
static get_nodes_at_face(shape)[source]#

Set up an array that gives the nodes on either side of each face.

Examples

>>> from landlab.graph.structured_quad import DualStructuredQuadGraph
>>> DualStructuredQuadGraph.get_nodes_at_face((3, 4))
array([[ 1,  5], [ 2,  6],
       [ 4,  5], [ 5,  6], [ 6,  7],
       [ 5,  9], [ 6, 10]])
property horizontal_faces#
property length_of_face#

Get the length of faces.

See also

length_of_link

property midpoint_of_face#

Get the middle of faces.

See also

midpoint_of_link

property node_corners#
property number_of_cells#

Get the number of cells.

See also

number_of_patches

property number_of_corner_columns#
property number_of_corner_rows#
property number_of_corners#

Get total number of corners.

See also

number_of_nodes

property number_of_faces#

Get corners at face head.

See also

number_of_links

property orientation_of_face#

Return array of face orientation codes (one value per face).

See also

orientation_of_link

property parallel_faces_at_face#

Return similarly oriented faces connected to each face.

See also

parallel_links_at_link

property perimeter_corners#
property unit_vector_at_corner#

Get a unit vector for each corner.

See also

unit_vector_at_node

property unit_vector_at_face#

Make arrays to store the unit vectors associated with each face.

See also

unit_vector_at_link

property vertical_faces#
property x_of_corner#

Get x-coordinate of corner.

See also

x_of_node

property xy_of_cell#

Get the centroid of each cell.

See also

xy_of_patch

property xy_of_corner#

Get x and y-coordinates of corner.

See also

xy_of_node

property xy_of_face#
property y_of_corner#

Get y-coordinate of corner.

See also

y_of_node

class DualUniformRectilinearGraph(shape, spacing=1.0, origin=(0.0, 0.0))[source]#

Bases: DualGraph, UniformRectilinearGraph

Create a dual graph for a uniform rectilinear grid.

Examples

>>> from landlab.graph import DualUniformRectilinearGraph
>>> graph = DualUniformRectilinearGraph((4, 3))
>>> graph.x_of_corner.reshape((3, 2))
array([[ 0.5,  1.5],
       [ 0.5,  1.5],
       [ 0.5,  1.5]])
>>> graph.y_of_corner.reshape((3, 2))
array([[ 0.5,  0.5],
       [ 1.5,  1.5],
       [ 2.5,  2.5]])
>>> graph.number_of_cells == 2
True
>>> graph.faces_at_cell
array([[2, 3, 1, 0],
       [5, 6, 4, 3]])
property adjacent_corners_at_corner#

Get adjacent corners.

See also

adjacent_nodes_at_node

property adjacent_faces_at_face#
property angle_of_face#

Get the angle of each face.

See also

angle_of_link

property area_of_cell#

Get the area of each cell.

See also

area_of_patch

property cells_at_corner#
property cells_at_face#
property corner_at_face_head#

Get corners at face head.

See also

node_at_link_head

property corner_at_face_tail#

Get corners at face tail.

See also

node_at_link_tail

property corner_x#
property corner_y#
property corners#

A shaped array of corner ids.

See also

nodes

property corners_at_bottom_edge#
property corners_at_cell#

Get the corners that define a cell.

See also

nodes_at_patch

property corners_at_face#

Get corners at either end of faces.

See also

nodes_at_link

property corners_at_left_edge#
property corners_at_nodes_of_grid#

Nodes at nodes of grid.

See also

nodes_at_corners_of_grid

property corners_at_right_edge#
property corners_at_top_edge#
property face_dirs_at_corner#
property faces_at_cell#

Get the faces that define a cell.

See also

links_at_patch

property faces_at_corner#
property horizontal_faces#
property length_of_face#

Get the length of faces.

See also

length_of_link

property midpoint_of_face#

Get the middle of faces.

See also

midpoint_of_link

property node_corners#
property number_of_cells#

Get the number of cells.

See also

number_of_patches

property number_of_corner_columns#
property number_of_corner_rows#
property number_of_corners#

Get total number of corners.

See also

number_of_nodes

property number_of_faces#

Get corners at face head.

See also

number_of_links

property orientation_of_face#

Return array of face orientation codes (one value per face).

See also

orientation_of_link

property parallel_faces_at_face#

Return similarly oriented faces connected to each face.

See also

parallel_links_at_link

property perimeter_corners#
property unit_vector_at_corner#

Get a unit vector for each corner.

See also

unit_vector_at_node

property unit_vector_at_face#

Make arrays to store the unit vectors associated with each face.

See also

unit_vector_at_link

property vertical_faces#
property x_of_corner#

Get x-coordinate of corner.

See also

x_of_node

property xy_of_cell#

Get the centroid of each cell.

See also

xy_of_patch

property xy_of_corner#

Get x and y-coordinates of corner.

See also

xy_of_node

property xy_of_face#
property y_of_corner#

Get y-coordinate of corner.

See also

y_of_node

class RectilinearGraph(nodes, sort=False)[source]#

Bases: StructuredQuadGraphExtras

Graph of a rectlinear grid of nodes.

Examples

>>> from landlab.graph import RectilinearGraph
>>> graph = RectilinearGraph(([0, 1, 2, 3], [1, 4, 8]))
>>> graph.number_of_nodes
12
>>> graph.y_of_node.reshape(graph.shape)
array([[ 0.,  0.,  0.],
       [ 1.,  1.,  1.],
       [ 2.,  2.,  2.],
       [ 3.,  3.,  3.]])
>>> graph.x_of_node.reshape(graph.shape)
array([[ 1.,  4.,  8.],
       [ 1.,  4.,  8.],
       [ 1.,  4.,  8.],
       [ 1.,  4.,  8.]])

Define a graph of connected nodes.

Parameters:

mesh (Dataset) – xarray Dataset that defines the topology in ugrid format.

static setup_node_y_and_x(coords)[source]#
class StructuredQuadGraph(coords, shape=None, sort=False)[source]#

Bases: StructuredQuadGraphExtras

Define a graph of connected nodes.

Parameters:

mesh (Dataset) – xarray Dataset that defines the topology in ugrid format.

static setup_node_y_and_x(yx_at_node, shape=None)[source]#
class UniformRectilinearGraph(shape, spacing=1.0, origin=0.0, sort=False)[source]#

Bases: StructuredQuadGraphExtras

Graph of a structured grid of quadrilaterals.

Examples

>>> from landlab.graph import UniformRectilinearGraph
>>> graph = UniformRectilinearGraph((4, 3), spacing=(1, 2), origin=(-1, 0))
>>> graph.number_of_nodes
12
>>> graph.y_of_node.reshape(graph.shape)
array([[-1., -1., -1.],
       [ 0.,  0.,  0.],
       [ 1.,  1.,  1.],
       [ 2.,  2.,  2.]])
>>> graph.x_of_node.reshape(graph.shape)
array([[ 0.,  2.,  4.],
       [ 0.,  2.,  4.],
       [ 0.,  2.,  4.],
       [ 0.,  2.,  4.]])
>>> graph.links_at_node
array([[ 0,  2, -1, -1], [ 1,  3,  0, -1], [-1,  4,  1, -1],
       [ 5,  7, -1,  2], [ 6,  8,  5,  3], [-1,  9,  6,  4],
       [10, 12, -1,  7], [11, 13, 10,  8], [-1, 14, 11,  9],
       [15, -1, -1, 12], [16, -1, 15, 13], [-1, -1, 16, 14]])
>>> graph.link_dirs_at_node
array([[-1, -1,  0,  0], [-1, -1,  1,  0], [ 0, -1,  1,  0],
       [-1, -1,  0,  1], [-1, -1,  1,  1], [ 0, -1,  1,  1],
       [-1, -1,  0,  1], [-1, -1,  1,  1], [ 0, -1,  1,  1],
       [-1,  0,  0,  1], [-1,  0,  1,  1], [ 0,  0,  1,  1]], dtype=int8)
>>> graph.nodes_at_link
array([[ 0,  1], [ 1,  2], [ 0,  3], [ 1,  4], [ 2,  5],
       [ 3,  4], [ 4,  5], [ 3,  6], [ 4,  7], [ 5,  8],
       [ 6,  7], [ 7,  8], [ 6,  9], [ 7, 10], [ 8, 11],
       [ 9, 10], [10, 11]])
>>> graph.links_at_patch
array([[ 3,  5,  2,  0], [ 4,  6,  3,  1],
       [ 8, 10,  7,  5], [ 9, 11,  8,  6],
       [13, 15, 12, 10], [14, 16, 13, 11]])
>>> graph.nodes_at_patch
array([[ 4,  3,  0,  1], [ 5,  4,  1,  2],
       [ 7,  6,  3,  4], [ 8,  7,  4,  5],
       [10,  9,  6,  7], [11, 10,  7,  8]])

Define a graph of connected nodes.

Parameters:

mesh (Dataset) – xarray Dataset that defines the topology in ugrid format.

property dx#
property dy#
property origin#
property spacing#