Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@make_return_array_immutable
def diagonals_at_node(self):
"""Diagonals attached to nodes.
Returns
-------
ndarray of int, shape `(n_nodes, 4)`
Diagonals at each node.
Examples
--------
>>> from landlab import RasterModelGrid
>>> grid = RasterModelGrid((4, 3))
>>> grid.diagonals_at_node.shape == (grid.number_of_nodes, 4)
True
>>> grid.diagonals_at_node
array([[ 0, -1, -1, -1], [ 2, 1, -1, -1], [-1, 3, -1, -1],
@make_return_array_immutable
def number_of_patches_present_at_node(self):
"""Return the number of patches at a node without a closed node.
Examples
--------
>>> from landlab import RasterModelGrid
>>> mg = RasterModelGrid((3, 3))
>>> mg.status_at_node[mg.nodes_at_top_edge] = mg.BC_NODE_IS_CLOSED
>>> mg.patches_present_at_node
array([[ True, False, False, False],
[ True, True, False, False],
[False, True, False, False],
[False, False, False, True],
[False, False, True, True],
[False, False, True, False],
[False, False, False, False],
@make_return_array_immutable
@cache_result_in_object()
def link_status_at_node(self):
return self.status_at_link[self.links_at_node]
@make_return_array_immutable
def node_axis_coordinates(self, axis=0):
"""Get the coordinates of nodes along a particular axis.
Return node coordinates from a given *axis* (defaulting to 0). Axis
numbering is the same as that for numpy arrays. That is, the zeroth
axis is along the rows, and the first along the columns.
Parameters
----------
axis : int, optional
Coordinate axis.
Returns
-------
ndarray
Coordinates of nodes for a given axis.
@make_return_array_immutable
def d8s_at_node(self):
"""Links and diagonals attached to nodes.
Returns
-------
ndarray of int, shape `(n_nodes, 8)`
Links and diagonals at each node.
Examples
--------
>>> import numpy as np
>>> from landlab import RasterModelGrid
>>> grid = RasterModelGrid((3, 4))
>>> grid.d8s_at_node.shape == (grid.number_of_nodes, 8)
True
@make_return_array_immutable
def status_at_d8(self):
return np.hstack(
(super().status_at_link, self.status_at_diagonal)
)
@make_return_array_immutable
def patches_present_at_node(self):
"""A boolean array, False where a patch has a closed node or is
missing.
The array is the same shape as :func:`patches_at_node`, and is designed
to mask it.
Note that in cases where patches may have more than 3 nodes (e.g.,
rasters), a patch is considered still present as long as at least 3
open nodes are present.
Examples
--------
>>> from landlab import RasterModelGrid
>>> mg = RasterModelGrid((3, 3))
>>> mg.status_at_node[mg.nodes_at_top_edge] = mg.BC_NODE_IS_CLOSED
@make_return_array_immutable
def second_ring_looped_neighbors_at_cell(self):
"""Get list of second ring looped neighbor cell IDs (all 16 neighbors).
Returns lists of looped second ring neighbor cell IDs of
given *cell ids*. If *cell ids* are not given, it returns
a 2D array of size ( self.number_of_cells, 16 ).
The cells are the 16 which encircle the nine true neighbor cells.
Order of neighbors: Starts with E and goes counter clockwise
Examples
--------
>>> from landlab import RasterModelGrid
>>> mg = RasterModelGrid((10, 10))
>>> mg.second_ring_looped_neighbors_at_cell[36, :]
array([38, 46, 54, 53, 52, 51, 50, 42, 34, 26, 18, 19, 20, 21, 22, 30])
@make_return_array_immutable
def patches_present_at_link(self):
"""A boolean array, False where a patch has a closed node or is
missing.
The array is the same shape as :func:`patches_at_link`, and is designed
to mask it.
Examples
--------
>>> from landlab import RasterModelGrid
>>> mg = RasterModelGrid((3, 3))
>>> mg.status_at_node[mg.nodes_at_top_edge] = mg.BC_NODE_IS_CLOSED
>>> mg.patches_at_link
array([[-1, 0],
[-1, 1],
[ 0, -1],
@make_return_array_immutable
@cache_result_in_object()
def status_at_link(self):
"""Get array of the status of all links.
Examples
--------
>>> from landlab import NetworkModelGrid
>>> y_of_node = (0, 1, 2, 2)
>>> x_of_node = (0, 0, -1, 1)
>>> nodes_at_link = ((1, 0), (2, 1), (3, 1))
>>> grid = NetworkModelGrid((y_of_node, x_of_node), nodes_at_link)
>>> grid.status_at_link
array([0, 0, 0], dtype=uint8)
LLCATS: LINF BC
"""