StructuredQuadCellGrid
(shape)[source]¶Bases: object
node_at_cell
¶number_of_cell_columns
¶number_of_cell_rows
¶number_of_cells
¶shape
¶cell_id_at_nodes
(shape, bad=-1)[source]¶Cell ID at each node.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.cells import cell_id_at_nodes
>>> cell_id_at_nodes((4, 5), bad=-1)
array([[-1, -1, -1, -1, -1],
[-1, 0, 1, 2, -1],
[-1, 3, 4, 5, -1],
[-1, -1, -1, -1, -1]])
cell_ids
(shape)[source]¶IDs of all cells.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.cells import cell_ids
>>> cell_ids((3, 4))
array([[0, 1]])
node_id_at_cells
(shape)[source]¶Node ID at each cell.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.cells import node_id_at_cells
>>> node_id_at_cells((3, 4))
array([[5, 6]])
face_at_link
(shape, bad_index_value=-1)[source]¶Get face for each link of a grid.
Parameters: | shape : tuple of int
|
---|
Examples
>>> from landlab.grid.structured_quad.faces import face_at_link
>>> face_at_link((4, 5), bad_index_value=-1)
...
array([-1, -1, -1, -1, -1, 0, 1, 2, -1,
3, 4, 5, 6, -1, 7, 8, 9, -1,
10, 11, 12, 13, -1, 14, 15, 16, -1,
-1, -1, -1, -1])
link_at_face
(shape)[source]¶Get the link at each face.
Parameters: | shape : tuple of int
|
---|
Notes
The algorithm is based on the following considerations:
Examples
>>> from landlab.grid.structured_quad.faces import link_at_face
>>> link_at_face((3, 5))
array([ 5, 6, 7,
9, 10, 11, 12,
14, 15, 16])
active_link_ids
(shape, node_status)[source]¶Get active links.
Parameters: | shape : tuple of int
node_status : array_link
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid import RasterModelGrid
>>> from landlab.grid.structured_quad.links import active_link_ids
>>> rmg = RasterModelGrid((3, 4))
>>> rmg.set_closed_boundaries_at_grid_edges(True, True, True, True)
>>> status = rmg.status_at_node
>>> status
array([4, 4, 4, 4,
4, 0, 0, 4,
4, 4, 4, 4], dtype=int8)
>>> active_link_ids((3, 4), status)
array([8])
bottom_edge_horizontal_ids
(shape)[source]¶Link IDs of bottom edge horizontal links.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*--27-->*--28-->*--29-->*--30-->*
*--18-->*--19-->*--20-->*--21-->*
*---9-->*--10-->*--11-->*--12-->*
*---0-->*---1-->*---2-->*---3-->*
Note
Only horizontal links are shown.
*
indicates nodes
Numeric values correspond to the horizontal IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import (
... bottom_edge_horizontal_ids)
>>> rmg = RasterModelGrid(4, 5)
>>> shape = rmg.shape
>>> bottom_edge_horizontal_ids(shape)
array([0, 1, 2, 3])
bottom_edge_vertical_ids
(shape)[source]¶Link IDs of bottom edge vertical links.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
* * * * *
^ ^ ^ ^ ^
22 23 24 25 26
| | | | |
* * * * *
^ ^ ^ ^ ^
13 14 15 16 17
| | | | |
* * * * *
^ ^ ^ ^ ^
4 5 6 7 8
| | | | |
* * * * *
Note
Only vertical links are shown.
*
indicates nodes
Numeric values correspond to the vertical IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import bottom_edge_vertical_ids
>>> rmg = RasterModelGrid(4, 5)
>>> shape = rmg.shape
>>> bottom_edge_vertical_ids(shape)
array([4, 5, 6, 7, 8])
d4_horizontal_active_link_neighbors
(shape, horizontal_ids, bad_index_value=-1)[source]¶returns IDs of all 4 horizontal link neighbors.
Parameters: | shape : tuple of int
horizontal_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray
|
Examples
Sample grid, giving neighbors for link ID 20:
*------>*------>*------>*------>*
*------>*--19-->*--20-->*------>*
*------>*--10-->*--11-->*------>*
*------>*------>*------>*------>*
Note
Only horizontal links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the horizontal ACTIVE_LINK
IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid((4, 5))
>>> rmg.set_closed_boundaries_at_grid_edges(True, True, True, True)
>>> active_ids = active_link_ids(rmg.shape, rmg.status_at_node)
>>> horizontal_ids = horizontal_active_link_ids(
... rmg.shape, active_ids)
>>> d4_horizontal_active_link_neighbors(rmg.shape, horizontal_ids)
array([[11, 19, -1, -1],
[-1, 20, 10, -1],
[20, -1, -1, 10],
[-1, -1, 19, 11]])
d4_horizontal_link_neighbors
(shape, horizontal_ids, bad_index_value=-1)[source]¶IDs of all 4 horizontal link neighbors.
Parameters: | shape : tuple of int
horizontal_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
Sample grid, giving neighbors for link ID 10:
*------>*------>*------>*------>*
*------>*--19-->*------>*------>*
*---9-->*--10-->*--11-->*------>*
*------>*---1-->*------>*------>*
Note
Only horizontal links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the horizontal IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid(4, 5)
>>> horizontal_links = horizontal_link_ids(rmg.shape).flatten()
>>> d4_horizontal_link_neighbors(rmg.shape, horizontal_links)
array([[ 1, 9, -1, -1],
[ 2, 10, 0, -1],
[ 3, 11, 1, -1],
[-1, 12, 2, -1],
[10, 18, -1, 0],
[11, 19, 9, 1],
[12, 20, 10, 2],
[-1, 21, 11, 3],
[19, 27, -1, 9],
[20, 28, 18, 10],
[21, 29, 19, 11],
[-1, 30, 20, 12],
[28, -1, -1, 18],
[29, -1, 27, 19],
[30, -1, 28, 20],
[-1, -1, 29, 21]])
d4_vertical_active_link_neighbors
(shape, vertical_ids, bad_index_value=-1)[source]¶IDs of all 4 vertical link neighbors.
Parameters: | shape : tuple of int
vertical_active_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
* * * * *
^ ^ ^ ^ ^
22 23 24 25 26
| | | | |
* * * * *
^ ^ ^ ^ ^
13 14 15 16 17
| | | | |
* * * * *
^ ^ ^ ^ ^
4 5 6 7 8
| | | | |
* * * * *
Note
Only vertical links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the vertical IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import (active_link_ids,
... vertical_active_link_ids, d4_vertical_active_link_neighbors)
>>> rmg = RasterModelGrid(4, 5)
>>> active_link_ids = active_link_ids(rmg.shape, rmg.status_at_node)
>>> vertical_active_ids = vertical_active_link_ids(
... rmg.shape, active_link_ids)
>>> d4_vertical_active_link_neighbors(rmg.shape, vertical_active_ids)
array([[ 6, 14, -1, -1],
[ 7, 15, 5, -1],
[-1, 16, 6, -1],
[15, 23, -1, 5],
[16, 24, 14, 6],
[-1, 25, 15, 7],
[24, -1, -1, 14],
[25, -1, 23, 15],
[-1, -1, 24, 16]])
d4_vertical_link_neighbors
(shape, vertical_ids, bad_index_value=-1)[source]¶IDs of all 4 vertical link neighbors.
Parameters: | shape : tuple of int
vertical_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
* * * * *
^ ^ ^ ^ ^
22 23 24 25 26
| | | | |
* * * * *
^ ^ ^ ^ ^
13 14 15 16 17
| | | | |
* * * * *
^ ^ ^ ^ ^
4 5 6 7 8
| | | | |
* * * * *
Note
Only vertical links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the vertical IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid(4, 5)
>>> vertical_ids = vertical_link_ids(rmg.shape)
>>> d4_vertical_link_neighbors(rmg.shape, vertical_ids)
array([[ 5, 13, -1, -1],
[ 6, 14, 4, -1],
[ 7, 15, 5, -1],
[ 8, 16, 6, -1],
[-1, 17, 7, -1],
[14, 22, -1, 4],
[15, 23, 13, 5],
[16, 24, 14, 6],
[17, 25, 15, 7],
[-1, 26, 16, 8],
[23, -1, -1, 13],
[24, -1, 22, 14],
[25, -1, 23, 15],
[26, -1, 24, 16],
[-1, -1, 25, 17]])
fixed_link_ids
(shape, node_status)[source]¶ID of fixed links.
Parameters: | shape : tuple of int
node_status : array_link
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import fixed_link_ids
>>> import numpy as np
>>> rmg = RasterModelGrid(4, 5)
>>> z = np.arange(0, rmg.number_of_nodes)
>>> s = np.arange(0, rmg.number_of_links)
>>> rmg.at_node['topographic__elevation'] = z
>>> rmg.at_link['topographic__slope'] = s
>>> rmg.set_fixed_link_boundaries_at_grid_edges(True, True, True, True)
>>> rmg.status_at_node
array([2, 2, 2, 2, 2,
2, 0, 0, 0, 2,
2, 0, 0, 0, 2,
2, 2, 2, 2, 2], dtype=int8)
>>> fixed_link_ids(rmg.shape, rmg.status_at_node)
array([ 5, 6, 7, 9, 12, 18, 21, 23, 24, 25])
horizontal_active_link_ids
(shape, active_ids, bad_index_value=-1)[source]¶ID of horizontal active links.
Parameters: | shape : tuple of int
active_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*---I-->*---I-->*---I-->*---I-->*
^ ^ ^ ^ ^
I I I I I
| | | | |
*---I-->o--24-->o--25-->o---I-->*
^ ^ ^ ^ ^
I V V V I
| | | | |
*---I-->o--20-->o--21-->o---I-->*
^ ^ ^ ^ ^
I I I I I
| | | | |
*---I-->*---I-->*---I-->*---I-->*
Note
*
indicates the nodes that are set to CLOSED_BOUNDARY
o
indicates the nodes that are set to CORE_NODE
I
indicates the links that are set to INACTIVE_LINK
V
indicates vertical active ids, which are ignored by this
function.
Numeric values correspond to the horizontal ACTIVE_LINK
ID.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import (active_link_ids,
... horizontal_active_link_ids)
>>> rmg = RasterModelGrid(4, 5)
>>> rmg.set_closed_boundaries_at_grid_edges(True, True, True, True)
>>> status = rmg.status_at_node
>>> status
array([4, 4, 4, 4, 4,
4, 0, 0, 0, 4,
4, 0, 0, 0, 4,
4, 4, 4, 4, 4], dtype=int8)
>>> active_ids = active_link_ids((4,5), status)
>>> horizontal_active_link_ids((4,5), active_ids)
...
array([-1, -1, -1, -1,
-1, 10, 11, -1,
-1, 19, 20, -1,
-1, -1, -1, -1])
horizontal_east_link_neighbor
(shape, horizontal_ids, bad_index_value=-1)[source]¶IDs of east, horizontal link neighbor.
Parameters: | shape : tuple of int
horizontal_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*--27-->*--28-->*--29-->*--30-->*
*--18-->*--19-->*--20-->*--21-->*
*---9-->*--10-->*--11-->*--12-->*
*---0-->*---1-->*---2-->*---3-->*
Note
Only horizontal links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the horizontal ACTIVE_LINK
IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid(4, 5)
>>> horizontal_links = horizontal_link_ids(rmg.shape).flatten()
>>> horizontal_east_link_neighbor(rmg.shape, horizontal_links)
array([ 1, 2, 3, -1, 10, 11, 12, -1, 19, 20, 21, -1, 28, 29, 30, -1])
horizontal_fixed_link_ids
(shape, fixed_ids, bad_index_value=-1)[source]¶ID of horizontal fixed links.
Parameters: | shape : tuple of int
fixed_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*---I-->*---I-->*---I-->*---I-->*
^ ^ ^ ^ ^
I V V V I
| | | | |
*--18-->o------>o------>o--21-->*
^ ^ ^ ^ ^
I V V V I
| | | | |
*---9-->o------>o------>o--12-->*
^ ^ ^ ^ ^
I V V V I
| | | | |
*---I-->*---I-->*---I-->*---I-->*
Note
*
indicates the nodes that are set to FIXED_VALUE_BOUNDARY
o
indicates the nodes that are set to CORE_NODE
I
indicates the links that are set to INACTIVE_LINK
V
indicates vertical ids, which are ignored by this function
H
indicates horizontal ACTIVE_LINK
ids, which are ignored by
this function
Numeric values correspond to the horizontal FIXED_LINK
ID.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import (fixed_link_ids,
... horizontal_fixed_link_ids)
>>> import numpy
>>> rmg = RasterModelGrid(4, 5)
>>> rmg.at_node['topographic__elevation'] = numpy.arange(
... 0, rmg.number_of_nodes)
>>> rmg.at_link['topographic__slope'] = numpy.arange(
... 0, rmg.number_of_links)
>>> rmg.set_fixed_link_boundaries_at_grid_edges(True, True, True, True)
>>> status = rmg.status_at_node
>>> status
array([2, 2, 2, 2, 2,
2, 0, 0, 0, 2,
2, 0, 0, 0, 2,
2, 2, 2, 2, 2], dtype=int8)
>>> fixed_ids = fixed_link_ids((4, 5), status)
>>> horizontal_fixed_link_ids((4, 5), fixed_ids)
...
array([-1, -1, -1, -1,
9, -1, -1, 12,
18, -1, -1, 21,
-1, -1, -1, -1])
horizontal_link_ids
(shape)[source]¶Horizontal links in a structured quad grid.
Parameters: | shape : tuple of int
|
---|---|
Returns: | (M, N) ndarray :
|
Examples
>>> from landlab.grid.structured_quad.links import horizontal_link_ids
>>> horizontal_link_ids((3, 4))
array([[ 0, 1, 2],
[ 7, 8, 9],
[14, 15, 16]])
horizontal_north_link_neighbor
(shape, horizontal_ids, bad_index_value=-1)[source]¶ID of north, horizontal link neighbor.
Parameters: | shape : tuple of int
horizontal_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*--27-->*--28-->*--29-->*--30-->*
*--18-->*--19-->*--20-->*--21-->*
*---9-->*--10-->*--11-->*--12-->*
*---0-->*---1-->*---2-->*---3-->*
Note
Only horizontal links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the horizontal ACTIVE_LINK
IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid(4, 5)
>>> horizontal_links = horizontal_link_ids(rmg.shape).flatten()
>>> horizontal_north_link_neighbor(rmg.shape, horizontal_links)
array([ 9, 10, 11, 12, 18, 19, 20, 21, 27, 28, 29, 30, -1, -1, -1, -1])
horizontal_south_link_neighbor
(shape, horizontal_ids, bad_index_value=-1)[source]¶ID of south horizontal link neighbor.
Parameters: | shape : tuple of int
horizontal_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*--27-->*--28-->*--29-->*--30-->*
*--18-->*--19-->*--20-->*--21-->*
*---9-->*--10-->*--11-->*--12-->*
*---0-->*---1-->*---2-->*---3-->*
Note
Only horizontal links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the horizontal IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid(4, 5)
>>> horizontal_links = horizontal_link_ids(rmg.shape).flatten()
>>> horizontal_south_link_neighbor(rmg.shape, horizontal_links)
array([-1, -1, -1, -1, 0, 1, 2, 3, 9, 10, 11, 12, 18, 19, 20, 21])
horizontal_west_link_neighbor
(shape, horizontal_ids, bad_index_value=-1)[source]¶ID of west, horizontal link neighbor.
Parameters: | shape : tuple of int
horizontal_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*--27-->*--28-->*--29-->*--30-->*
*--18-->*--19-->*--20-->*--21-->*
*---9-->*--10-->*--11-->*--12-->*
*---0-->*---1-->*---2-->*---3-->*
Note
Only horizontal links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the horizontal IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid(4, 5)
>>> horizontal_links = horizontal_link_ids(rmg.shape).flatten()
>>> horizontal_west_link_neighbor(rmg.shape, horizontal_links)
array([-1, 0, 1, 2, -1, 9, 10, 11, -1, 18, 19, 20, -1, 27, 28, 29])
is_active_link
(shape, node_status)[source]¶Link IDs of active links.
Parameters: | shape : tuple of int
node_status : array_link
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.nodes import (
... status_with_perimeter_as_boundary)
>>> from landlab.grid.structured_quad.links import is_active_link
>>> status = status_with_perimeter_as_boundary((3, 4))
>>> status
array([[4, 4, 4, 4],
[4, 0, 0, 4],
[4, 4, 4, 4]])
>>> is_active_link((3, 4), status)
array([False, False, False,
False, False, False, False,
False, True, False,
False, False, False, False,
False, False, False], dtype=bool)
is_diagonal_link
(shape, links)[source]¶Test if a link is diagonal.
Parameters: | shape : tuple of int
links : array of int
|
---|---|
Returns: | ndarray of bool
|
Examples
>>> from landlab.grid.structured_quad.links import (is_diagonal_link,
... number_of_links)
>>> import numpy as np
>>> shape = (3, 4)
>>> links = np.array([0, 3, 16, 17])
>>> is_diagonal_link(shape, links)
array([False, False, False, True], dtype=bool)
is_fixed_link
(shape, node_status)[source]¶ID of active links.
Parameters: | shape : tuple of int
node_status : array_link
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import is_fixed_link
>>> import numpy as np
>>> rmg = RasterModelGrid((4, 5))
>>> z = np.arange(0, rmg.number_of_nodes)
>>> s = np.arange(0, rmg.number_of_links)
>>> rmg.at_node['topographic__elevation'] = z
>>> rmg.at_link['topographic__slope'] = s
>>> rmg.set_fixed_link_boundaries_at_grid_edges(True, True, True, True)
>>> rmg.status_at_node
array([2, 2, 2, 2, 2,
2, 0, 0, 0, 2,
2, 0, 0, 0, 2,
2, 2, 2, 2, 2], dtype=int8)
>>> is_fixed_link(rmg.shape, rmg.status_at_node)
array([False, False, False, False, False, True, True, True, False,
True, False, False, True, False, False, False, False, False,
True, False, False, True, False, True, True, True, False,
False, False, False, False], dtype=bool)
is_horizontal_link
(shape, links)[source]¶Test if a link is horizontal.
Parameters: | shape : tuple of int
links : array of int
|
---|---|
Returns: | ndarray of bool
|
Examples
>>> from landlab.grid.structured_quad.links import (is_horizontal_link,
... number_of_links)
>>> import numpy as np
>>> shape = (3, 4)
>>> links = np.arange(number_of_links(shape))
>>> is_horizontal_link(shape, links)
array([ True, True, True, False, False, False, False,
True, True, True, False, False, False, False,
True, True, True], dtype=bool)
is_vertical_link
(shape, links)[source]¶Test if links are vertical.
Parameters: | shape : tuple of int
links : array of int
|
---|---|
Returns: | ndarray of bool
|
Examples
>>> from landlab.grid.structured_quad.links import (is_vertical_link,
... number_of_links)
>>> import numpy as np
>>> shape = (3, 4)
>>> links = np.arange(number_of_links(shape))
>>> is_vertical_link(shape, links)
array([False, False, False, True, True, True, True,
False, False, False, True, True, True, True,
False, False, False], dtype=bool)
left_edge_horizontal_ids
(shape)[source]¶Link IDs of left edge horizontal links.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*--27-->*--28-->*--29-->*--30-->*
*--18-->*--19-->*--20-->*--21-->*
*---9-->*--10-->*--11-->*--12-->*
*---0-->*---1-->*---2-->*---3-->*
Note
Only horizontal links are shown.
*
indicates nodes
Numeric values correspond to the horizontal IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import left_edge_horizontal_ids
>>> rmg = RasterModelGrid(4, 5)
>>> shape = rmg.shape
>>> left_edge_horizontal_ids(shape)
array([ 0, 9, 18, 27])
left_edge_vertical_ids
(shape)[source]¶Link IDs of left edge vertical links.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
* * * * *
^ ^ ^ ^ ^
22 23 24 25 26
| | | | |
* * * * *
^ ^ ^ ^ ^
13 14 15 16 17
| | | | |
* * * * *
^ ^ ^ ^ ^
4 5 6 7 8
| | | | |
* * * * *
Note
Only vertical links are shown.
*
indicates nodes
Numeric values correspond to the vertical IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import left_edge_vertical_ids
>>> rmg = RasterModelGrid(4, 5)
>>> shape = rmg.shape
>>> left_edge_vertical_ids(shape)
array([ 4, 13, 22])
link_dirs_at_node
(shape)[source]¶Construct a matrix of link directions at each node.
Parameters: | shape : tuple of int
|
---|---|
Returns: | (N, 4) ndarray of int
|
Examples
>>> from landlab.grid.structured_quad.links import link_dirs_at_node
>>> link_dirs_at_node((4, 3))
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]])
links_at_node
(shape)[source]¶Get link ids for each node.
Parameters: | shape : tuple of int
|
---|---|
Returns: | (N, 4) ndarray of int
|
Examples
>>> from landlab.grid.structured_quad.links import links_at_node
>>> links_at_node((4, 3))
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]])
neighbors_at_link
(shape, links)[source]¶Get neighbor links.
Examples
>>> import numpy as np
>>> from landlab.grid.structured_quad.links import neighbors_at_link
>>> neighbors_at_link((3, 2), np.arange(7))
array([[-1, 3, -1, -1],
[ 2, 4, -1, -1], [-1, 5, 1, -1],
[-1, 6, -1, 0],
[ 5, 7, -1, 1], [-1, -1, 4, 2],
[-1, -1, -1, 3]])
node_id_at_link_end
(shape)[source]¶Node ID at end of links.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.links import node_id_at_link_end
>>> node_id_at_link_end((3, 4))
array([ 1, 2, 3,
4, 5, 6, 7,
5, 6, 7,
8, 9, 10, 11,
9, 10, 11])
node_id_at_link_start
(shape)[source]¶Node ID at start of links.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.links import node_id_at_link_start
>>> node_id_at_link_start((3, 4))
array([ 0, 1, 2,
0, 1, 2, 3,
4, 5, 6,
4, 5, 6, 7,
8, 9, 10])
node_in_link_ids
(shape)[source]¶Links entering each node.
Parameters: | shape : tuple of int
|
---|---|
Returns: | tuple :
|
Examples
>>> from landlab.grid.structured_quad.links import node_in_link_ids
>>> (links, offset) = node_in_link_ids((3, 4))
>>> links
array([ 0, 1, 2, 3, 4, 7, 5, 8, 6, 9, 10, 11, 14, 12, 15, 13, 16])
>>> offset
array([ 0, 0, 1, 2, 3, 4, 6, 8, 10, 11, 13, 15, 17])
The links entering the 1st, 5th, and last node. The first node does not have any links entering it.
>>> offset[0] == offset[1]
True
>>> for link in [4, 11]: links[offset[link]:offset[link + 1]]
array([3])
array([13, 16])
node_link_ids
(shape)[source]¶Link IDs for links entering and leaving each node.
Parameters: | shape : tuple of int
|
---|---|
Returns: | tuple :
|
Examples
>>> from landlab.grid.structured_quad.links import node_link_ids
>>> (links, offset) = node_link_ids((3, 4))
>>> links
array([ 0, 3, 1, 4, 0, 2, 5, 1, 6, 2,
7, 10, 3, 8, 11, 7, 4, 9, 12, 8, 5, 13, 9, 6,
14, 10, 15, 14, 11, 16, 15, 12, 16, 13])
>>> offset
array([ 0, 2, 5, 8, 10, 13, 17, 21, 24, 26, 29, 32, 34])
The links attached to node 0
>>> links[offset[0]:offset[1]]
array([0, 3])
The links attached to node 5
>>> links[offset[5]:offset[6]]
array([ 8, 11, 7, 4])
node_out_link_ids
(shape)[source]¶Links leaving each node.
Parameters: | shape : tuple of int
|
---|---|
Returns: | tuple :
|
Examples
>>> from landlab.grid.structured_quad.links import node_out_link_ids
>>> (links, offset) = node_out_link_ids((3, 4))
>>> links
array([ 3, 0, 4, 1, 5, 2, 6, 10, 7, 11, 8, 12, 9, 13, 14, 15, 16])
>>> offset
array([ 0, 2, 4, 6, 7, 9, 11, 13, 14, 15, 16, 17, 17])
The links leaving the 1st, 8th, and last node. The last node does not have any links leaving it.
>>> offset[11] == offset[12]
True
>>> for link in [0, 7]: links[offset[link]:offset[link + 1]]
array([3, 0])
array([13])
nth_horizontal_link
(shape, links)[source]¶Convert link ID to horizontal link ID.
Parameters: | shape : tuple of int
links : array of int
|
---|---|
Returns: | ndarray of int
|
Examples
>>> from landlab.grid.structured_quad.links import nth_horizontal_link
>>> shape = (3, 4)
>>> nth_horizontal_link(shape, 16)
8
>>> nth_horizontal_link(shape, (1, 7, 8))
array([1, 3, 4])
nth_vertical_link
(shape, links)[source]¶Convert link ID to vertical link ID.
Parameters: | shape : tuple of int
links : array of int
|
---|---|
Returns: | ndarray of int
|
Examples
>>> from landlab.grid.structured_quad.links import nth_vertical_link
>>> shape = (3, 4)
>>> nth_vertical_link(shape, 4)
1
>>> nth_vertical_link(shape, (3, 4, 11))
array([0, 1, 5])
number_of_horizontal_links
(shape)[source]¶Number of horizontal links in a structured quad grid.
Parameters: | shape : tuple of int
|
---|---|
Returns: | int :
|
Examples
>>> from landlab.grid.structured_quad.links import (
... number_of_horizontal_links)
>>> number_of_horizontal_links((3, 4))
9
number_of_in_links_per_node
(shape)[source]¶Number of links entering each node.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.links import (
... number_of_in_links_per_node)
>>> number_of_in_links_per_node((3, 4))
array([[0, 1, 1, 1],
[1, 2, 2, 2],
[1, 2, 2, 2]])
number_of_links
(shape)[source]¶Number of links in a structured quad grid.
Parameters: | shape : tuple of int
|
---|---|
Returns: | int :
|
Examples
>>> from landlab.grid.structured_quad.links import number_of_links
>>> number_of_links((3, 4))
17
number_of_links_per_node
(shape)[source]¶Number of links touching each node.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.links import (
... number_of_links_per_node, number_of_in_links_per_node,
... number_of_out_links_per_node)
>>> number_of_links_per_node((3, 4))
array([[2, 3, 3, 2],
[3, 4, 4, 3],
[2, 3, 3, 2]])
>>> (number_of_in_links_per_node((3, 4)) +
... number_of_out_links_per_node((3, 4)))
array([[2, 3, 3, 2],
[3, 4, 4, 3],
[2, 3, 3, 2]])
number_of_out_links_per_node
(shape)[source]¶Number of links leaving each node.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.links import (
... number_of_out_links_per_node)
>>> number_of_out_links_per_node((3, 4))
array([[2, 2, 2, 1],
[2, 2, 2, 1],
[1, 1, 1, 0]])
number_of_vertical_links
(shape)[source]¶Number of vertical links in a structured quad grid.
Parameters: | shape : tuple of int
|
---|---|
Returns: | int :
|
Examples
>>> from landlab.grid.structured_quad.links import number_of_vertical_links
>>> number_of_vertical_links((3, 4))
8
right_edge_horizontal_ids
(shape)[source]¶IDs of right edge horizontal links.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*--27-->*--28-->*--29-->*--30-->*
*--18-->*--19-->*--20-->*--21-->*
*---9-->*--10-->*--11-->*--12-->*
*---0-->*---1-->*---2-->*---3-->*
Note
Only horizontal links are shown.
*
indicates nodes
Numeric values correspond to the horizontal IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import (
... right_edge_horizontal_ids)
>>> rmg = RasterModelGrid(4, 5)
>>> shape = rmg.shape
>>> right_edge_horizontal_ids(shape)
array([ 3, 12, 21, 30])
right_edge_vertical_ids
(shape)[source]¶Link IDs of right edge vertical links.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
* * * * *
^ ^ ^ ^ ^
22 23 24 25 26
| | | | |
* * * * *
^ ^ ^ ^ ^
13 14 15 16 17
| | | | |
* * * * *
^ ^ ^ ^ ^
4 5 6 7 8
| | | | |
* * * * *
Note
Only vertical links are shown.
*
indicates nodes
Numeric values correspond to the vertical IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import right_edge_vertical_ids
>>> rmg = RasterModelGrid(4, 5)
>>> shape = rmg.shape
>>> right_edge_vertical_ids(shape)
array([ 8, 17, 26])
shape_of_horizontal_links
(shape)[source]¶Shape of horizontal link grid.
Number of rows and columns of horizontal links that connect nodes in a structured grid of quadrilaterals.
Parameters: | shape : tuple of int
|
---|---|
Returns: | tuple of int :
|
Examples
>>> from landlab.grid.structured_quad.links import (
... shape_of_horizontal_links)
>>> shape_of_horizontal_links((3, 4))
(3, 3)
shape_of_vertical_links
(shape)[source]¶Shape of vertical link grid.
Number of rows and columns of vertical links that connect nodes in a structured grid of quadrilaterals.
Parameters: | shape : tuple of int
|
---|---|
Returns: | tuple of int :
|
Examples
>>> from landlab.grid.structured_quad.links import shape_of_vertical_links
>>> shape_of_vertical_links((3, 4))
(2, 4)
top_edge_horizontal_ids
(shape)[source]¶IDs of top edge horizontal links.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*--27-->*--28-->*--29-->*--30-->*
*--18-->*--19-->*--20-->*--21-->*
*---9-->*--10-->*--11-->*--12-->*
*---0-->*---1-->*---2-->*---3-->*
Note
Only horizontal links are shown.
*
indicates nodes
Numeric values correspond to the horizontal IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import top_edge_horizontal_ids
>>> rmg = RasterModelGrid(4, 5)
>>> shape = rmg.shape
>>> top_edge_horizontal_ids(shape)
array([27, 28, 29, 30])
top_edge_vertical_ids
(shape)[source]¶Link IDs of top edge vertical links.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
* * * * *
^ ^ ^ ^ ^
22 23 24 25 26
| | | | |
* * * * *
^ ^ ^ ^ ^
13 14 15 16 17
| | | | |
* * * * *
^ ^ ^ ^ ^
4 5 6 7 8
| | | | |
* * * * *
Note
Only vertical links are shown.
*
indicates nodes
Numeric values correspond to the vertical IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import top_edge_vertical_ids
>>> rmg = RasterModelGrid(4, 5)
>>> shape = rmg.shape
>>> top_edge_vertical_ids(shape)
array([22, 23, 24, 25, 26])
vertical_active_link_ids
(shape, active_ids, bad_index_value=-1)[source]¶ID of vertical active links.
Parameters: | shape : tuple of int
active_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*---I-->*---I-->*---I-->*---I-->*
^ ^ ^ ^ ^
I I I I I
| | | | |
*---I-->o---H-->o---H-->o---I-->*
^ ^ ^ ^ ^
I 6 7 8 I
| | | | |
*---I-->o---H-->o---H-->o---I-->*
^ ^ ^ ^ ^
I I I I I
| | | | |
*---I-->*---I-->*---I-->*---I-->*
Note
*
indicates the nodes that are set to CLOSED_BOUNDARY
o
indicates the nodes that are set to CORE_NODE
I
indicates the links that are set to INACTIVE_LINK
H
indicates horizontal active ids, which are ignored by this
function
Numeric values correspond to the vertical ACTIVE_LINK
IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import (active_link_ids,
... vertical_active_link_ids)
>>> rmg = RasterModelGrid((4, 5))
>>> active_ids = active_link_ids((4, 5), rmg.status_at_node)
>>> active_ids
array([ 5, 6, 7,
9, 10, 11, 12,
14, 15, 16,
18, 19, 20, 21,
23, 24, 25])
>>> vertical_active_link_ids((4, 5), active_ids)
...
array([-1, 5, 6, 7, -1,
-1, 14, 15, 16, -1,
-1, 23, 24, 25, -1])
>>> rmg.set_closed_boundaries_at_grid_edges(True, True, True, True)
>>> status = rmg.status_at_node
>>> active_ids = active_link_ids((4, 5), status)
>>> vertical_active_link_ids((4, 5), active_ids)
...
array([-1, -1, -1, -1, -1,
-1, 14, 15, 16, -1,
-1, -1, -1, -1, -1])
vertical_east_link_neighbor
(shape, vertical_ids, bad_index_value=-1)[source]¶Link IDs of east, vertical link neighbor.
Parameters: | shape : tuple of int
vertical_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
* * * * *
^ ^ ^ ^ ^
22 23 24 25 26
| | | | |
* * * * *
^ ^ ^ ^ ^
13 14 15 16 17
| | | | |
* * * * *
^ ^ ^ ^ ^
4 5 6 7 8
| | | | |
* * * * *
Note
Only vertical links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the vertical IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid(4, 5)
>>> vertical_links = vertical_link_ids(rmg.shape)
>>> vertical_east_link_neighbor(rmg.shape, vertical_links)
...
array([ 5, 6, 7, 8, -1,
14, 15, 16, 17, -1,
23, 24, 25, 26, -1])
vertical_fixed_link_ids
(shape, fixed_ids, bad_index_value=-1)[source]¶ID of vertical fixed links.
Parameters: | shape : tuple of int
fixed_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
*---I-->*---I-->*---I-->*---I-->*
^ ^ ^ ^ ^
I 23 24 25 I
| | | | |
*---H-->o---H-->o---H-->o---H-->*
^ ^ ^ ^ ^
I V V V I
| | | | |
*---H-->o---H-->o---H-->o---H-->*
^ ^ ^ ^ ^
I 5 6 7 I
| | | | |
*---I-->*---I-->*---I-->*---I-->*
Note
*
indicates the nodes that are set to
FIXED_GRADIENT_BOUNDARY
o
indicates the nodes that are set to CORE_NODE
I
indicates the links that are set to INACTIVE_LINK
H
indicates horizontal active and fixed links, which are ignored by
this function.
V
indicates vertical active ids, which are ignored by this
function.
Numeric values correspond to the vertical FIXED_LINK
IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import (fixed_link_ids,
... vertical_fixed_link_ids)
>>> import numpy
>>> rmg = RasterModelGrid((4, 5))
>>> rmg.at_node['topographic__elevation'] = numpy.arange(
... 0, rmg.number_of_nodes)
>>> rmg.at_link['topographic__slope'] = numpy.arange(
... 0, rmg.number_of_links)
>>> rmg.set_fixed_link_boundaries_at_grid_edges(True, True, True, True)
>>> status = rmg.status_at_node
>>> status
array([2, 2, 2, 2, 2,
2, 0, 0, 0, 2,
2, 0, 0, 0, 2,
2, 2, 2, 2, 2], dtype=int8)
>>> fixed_ids = fixed_link_ids((4, 5), status)
>>> vertical_fixed_link_ids((4,5), fixed_ids)
...
array([-1, 5, 6, 7, -1,
-1, -1, -1, -1, -1,
-1, 23, 24, 25, -1])
vertical_link_ids
(shape)[source]¶Vertical links in a structured quad grid.
Parameters: | shape : tuple of int
|
---|---|
Returns: | (M, N) ndarray :
|
Examples
>>> from landlab.grid.structured_quad.links import vertical_link_ids
>>> vertical_link_ids((3, 4))
array([[ 3, 4, 5, 6],
[10, 11, 12, 13]])
vertical_north_link_neighbor
(shape, vertical_ids, bad_index_value=-1)[source]¶Link IDs of north, vertical link neighbor.
Parameters: | shape : tuple of int
vertical_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
* * * * *
^ ^ ^ ^ ^
22 23 24 25 26
| | | | |
* * * * *
^ ^ ^ ^ ^
13 14 15 16 17
| | | | |
* * * * *
^ ^ ^ ^ ^
4 5 6 7 8
| | | | |
* * * * *
Note
Only vertical links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the vertical IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid(4, 5)
>>> vertical_ids = vertical_link_ids(rmg.shape)
>>> vertical_north_link_neighbor(rmg.shape, vertical_ids)
...
array([13, 14, 15, 16, 17,
22, 23, 24, 25, 26,
-1, -1, -1, -1, -1])
vertical_south_link_neighbor
(shape, vertical_ids, bad_index_value=-1)[source]¶Link IDs of south, vertical link neighbor.
Parameters: | shape : tuple of int
vertical_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
* * * * *
^ ^ ^ ^ ^
22 23 24 25 26
| | | | |
* * * * *
^ ^ ^ ^ ^
13 14 15 16 17
| | | | |
* * * * *
^ ^ ^ ^ ^
4 5 6 7 8
| | | | |
* * * * *
Note
Only vertical links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the vertical IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid((4, 5))
>>> vertical_links = vertical_link_ids(rmg.shape)
>>> vertical_south_link_neighbor(rmg.shape, vertical_links)
...
array([-1, -1, -1, -1, -1,
4, 5, 6, 7, 8,
13, 14, 15, 16, 17])
vertical_west_link_neighbor
(shape, vertical_ids, bad_index_value=-1)[source]¶Link IDs of west, vertical link neighbor.
Parameters: | shape : tuple of int
vertical_ids : array of int
bad_index_value: int, optional
|
---|---|
Returns: | ndarray :
|
Examples
The following example uses this grid:
* * * * *
^ ^ ^ ^ ^
22 23 24 25 26
| | | | |
* * * * *
^ ^ ^ ^ ^
13 14 15 16 17
| | | | |
* * * * *
^ ^ ^ ^ ^
4 5 6 7 8
| | | | |
* * * * *
Note
Only vertical links are shown. When no neighbor is found, bad_index_value is returned.
*
indicates nodes
Numeric values correspond to the vertical IDs.
>>> from landlab import RasterModelGrid
>>> from landlab.grid.structured_quad.links import *
>>> rmg = RasterModelGrid(4, 5)
>>> vertical_links = vertical_link_ids(rmg.shape)
>>> vertical_west_link_neighbor(rmg.shape, vertical_links)
...
array([-1, 4, 5, 6, 7,
-1, 13, 14, 15, 16,
-1, 22, 23, 24, 25])
bottom_iter
(shape)[source]¶Iterator for the bottom perimeter nodes.
Parameters: | shape : tuple of int
|
---|
bottom_top_iter
(shape)[source]¶Iterator for the bottom and top perimeter nodes.
Parameters: | shape : tuple of int
|
---|
Examples
>>> import numpy as np
>>> from landlab.grid.structured_quad.nodes import bottom_top_iter
>>> np.fromiter(bottom_top_iter((4, 3)), dtype=np.int)
array([ 0, 1, 2, 9, 10, 11])
corners
(shape)[source]¶IDs of corner nodes.
Parameters: | shape : tuple of int
|
---|---|
Returns: | (4, ) ndarray :
|
Examples
>>> from landlab.grid.structured_quad.nodes import corners
>>> corners((3, 4))
array([ 0, 3, 8, 11])
interior_nodes
(shape)[source]¶IDs of interior nodes.
Parameters: | shape : tuple of int
|
---|---|
Returns: | (M, N) ndarray :
|
Examples
>>> from landlab.grid.structured_quad.nodes import interior_nodes
>>> interior_nodes((3, 4))
array([[5, 6]])
>>> interior_nodes((4, 5))
array([[ 6, 7, 8],
[11, 12, 13]])
left_iter
(shape)[source]¶Iterator for the left perimeter nodes.
Parameters: | shape : tuple of int
|
---|
left_right_iter
(shape, stop) left_right_iter(shape, start, stop[, step])[source]¶Iterator for left and right perimeter nodes.
Parameters: | shape : tuple of int
start : int, optional
stop : int, optional
step : int, optional
|
---|
Examples
>>> import numpy as np
>>> from landlab.grid.structured_quad.nodes import left_right_iter
>>> np.fromiter(left_right_iter((4, 3)), dtype=np.int)
array([ 0, 2, 3, 5, 6, 8, 9, 11])
>>> np.fromiter(left_right_iter((4, 3), 2), dtype=np.int)
array([0, 2, 3, 5])
>>> np.fromiter(left_right_iter((4, 3), 2, 4), dtype=np.int)
array([ 6, 8, 9, 11])
>>> np.fromiter(left_right_iter((4, 3), 1, 4, 2), dtype=np.int)
array([ 3, 5, 9, 11])
node_ids
(shape)[source]¶IDs of nodes.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.nodes import node_ids
>>> node_ids((3, 4))
array([[ 0, 1, 2, 3],
[ 4, 5, 6, 7],
[ 8, 9, 10, 11]])
number_of_core_nodes
(shape)[source]¶Number of core nodes is a structured quad grid.
Parameters: | shape : tuple of int
|
---|---|
Returns: | int :
|
Examples
>>> from landlab.grid.structured_quad.nodes import number_of_core_nodes
>>> number_of_core_nodes((3, 4))
2
number_of_nodes
(shape)[source]¶Number of nodes is a structured quad grid.
Parameters: | shape : tuple of int
|
---|---|
Returns: | int :
|
Examples
>>> from landlab.grid.structured_quad.nodes import number_of_nodes
>>> number_of_nodes((3, 4))
12
perimeter
(shape)[source]¶Perimeter nodes.
Parameters: | shape : tuple of int
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.nodes import perimeter
>>> perimeter((3, 4))
array([ 0, 1, 2, 3, 4, 7, 8, 9, 10, 11])
perimeter_iter
(shape)[source]¶Iterator for all perimeter nodes.
Parameters: | shape : tuple of int
|
---|
Examples
>>> import numpy as np
>>> from landlab.grid.structured_quad.nodes import perimeter_iter
>>> np.fromiter(perimeter_iter((4, 3)), dtype=np.int)
array([ 0, 1, 2, 3, 5, 6, 8, 9, 10, 11])
right_iter
(shape)[source]¶Iterator for the right perimeter nodes.
Parameters: | shape : tuple of int
|
---|
status_with_perimeter_as_boundary
(shape, node_status=4)[source]¶Node status for a grid whose boundary is along its perimeter.
Parameters: | shape : tuple of int
node_status : int or array_lik of int, optional
|
---|---|
Returns: | ndarray :
|
Examples
>>> from landlab.grid.structured_quad.nodes import status_with_perimeter_as_boundary
>>> status_with_perimeter_as_boundary((3, 4))
array([[4, 4, 4, 4],
[4, 0, 0, 4],
[4, 4, 4, 4]])
>>> status_with_perimeter_as_boundary((3, 4), node_status=-1)
array([[-1, -1, -1, -1],
[-1, 0, 0, -1],
[-1, -1, -1, -1]])
RasterGrid
(shape, spacing=1.0, origin=0.0)[source]¶Bases: landlab.grid.structured_quad.rectilinear.UniformRectilinearGrid
Parameters: | shape : tuple
spacing : float, optional
origin : tuple, optional
|
---|
Examples
>>> from landlab.grid.structured_quad.rectilinear import RasterGrid
>>> grid = RasterGrid((4, 5), spacing=2, origin=(-1, 1))
>>> grid.number_of_nodes
20
#>>> grid.number_of_core_nodes 6 >>> grid.number_of_node_rows 4 >>> grid.number_of_node_columns 5 >>> grid.nodes_at_corners_of_grid array([ 0, 4, 15, 19]) >>> grid.number_of_cells 6 >>> grid.node_row_coord array([-1., 1., 3., 5.]) >>> grid.node_col_coord array([ 1., 3., 5., 7., 9.])
RectilinearGrid
(coord)[source]¶Bases: landlab.grid.structured_quad.structured.StructuredQuadGrid
Parameters: | coord : tuple
|
---|
Examples
>>> import numpy as np
>>> from landlab.grid.structured_quad.rectilinear import RectilinearGrid
>>> (y, x) = np.arange(4.), np.arange(5.)
>>> grid = RectilinearGrid((y, x))
>>> grid.number_of_nodes
20
>>> grid.number_of_node_rows
4
>>> grid.number_of_node_columns
5
>>> grid.nodes_at_corners_of_grid
array([ 0, 4, 15, 19])
>>> grid.number_of_cells
6
>>> grid.node_row_coord
array([ 0., 1., 2., 3.])
>>> grid.node_col_coord
array([ 0., 1., 2., 3., 4.])
coord
¶Node row and column coordinates.
node_col_coord
¶node_row_coord
¶UniformRectilinearGrid
(shape, spacing=(1.0, 1.0), origin=(0.0, 0.0))[source]¶Bases: landlab.grid.structured_quad.rectilinear.RectilinearGrid
Parameters: | shape : tuple
spacing : tuple, optional
origin : tuple, optional
|
---|
Examples
>>> from landlab.grid.structured_quad.rectilinear import UniformRectilinearGrid
>>> grid = UniformRectilinearGrid((4, 5), spacing=(2, 3), origin=(-1, 1))
>>> grid.number_of_nodes
20
#>>> grid.number_of_core_nodes 6 >>> grid.number_of_node_rows 4 >>> grid.number_of_node_columns 5 >>> grid.nodes_at_corners_of_grid array([ 0, 4, 15, 19]) >>> grid.number_of_cells 6 >>> grid.node_row_coord array([-1., 1., 3., 5.]) >>> grid.node_col_coord array([ 1., 4., 7., 10., 13.])
dx
¶Spacing between columns of grid nodes.
dy
¶Spacing between rows of grid nodes.
spacing
¶Spacing of rows and columns of grid nodes.
>>> import numpy as np
>>> from landlab.grid.structured_quad.structured import StructuredQuadGrid
>>> (y, x) = np.meshgrid(np.arange(4.), np.arange(5.), indexing='ij')
>>> grid = StructuredQuadGrid((y, x))
>>> grid.number_of_nodes
20
>>> grid.number_of_node_rows == 4
True
>>> grid.number_of_node_columns == 5
True
>>> grid.nodes_at_corners_of_grid
array([ 0, 4, 15, 19])
>>> grid.number_of_cells
6
StructuredQuadGrid
(node_coord, shape=None, axis_name=None, axis_units=None, links=True, cells=True, node_status=None)[source]¶Bases: landlab.grid.unstructured.base.BaseGrid
Parameters: | node_coord : tuple
shape : tuple, optional
|
---|
corner_nodes
¶nodes_at_corners_of_grid
¶Nodes in grid corners.
Return the IDs to the corner nodes of the grid, sorted by ID.
Returns: | (4, ) ndarray
|
---|
Examples
>>> import numpy as np
>>> from landlab.grid.structured_quad.structured import StructuredQuadGrid
>>> (x, y) = np.meshgrid(np.arange(4.), np.arange(5.), indexing='ij')
>>> grid = StructuredQuadGrid((x, y))
>>> grid.nodes_at_corners_of_grid
array([ 0, 4, 15, 19])
number_of_node_columns
¶Number of node columns.
Returns the number of columns, including boundaries.
number_of_node_rows
¶Number of node rows.
Returns the number of rows, including boundaries.
shape
¶Shape of the grid as rows, columns.