How to use the landlab.utils.decorators.cache_result_in_object function in landlab

To help you get started, we’ve selected a few landlab examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github landlab / landlab / landlab / grid / diagonals.py View on Github external
    @cache_result_in_object()
    @make_return_array_immutable
    def active_d8_dirs_at_node(self):
        return np.choose(
            self.d8_status_at_node == LinkStatus.ACTIVE, (0, self.d8_dirs_at_node)
        )
github landlab / landlab / landlab / grid / base.py View on Github external
    @cache_result_in_object()
    def active_link_dirs_at_node(self):
        """Link flux directions at each node: 1=incoming flux, -1=outgoing
        flux, 0=no flux. Note that inactive links receive zero, but active and
        fixed links are both reported normally.

        Returns
        -------
        (NODES, LINKS) ndarray of int
            Link directions relative to the nodes of a grid. The shape of the
            matrix will be number of nodes rows by max number of links per
            node. A zero indicates no link at this position.

        Examples
        --------
        >>> from landlab import RasterModelGrid
        >>> grid = RasterModelGrid((4, 3))
github landlab / landlab / landlab / grid / diagonals.py View on Github external
    @cache_result_in_object()
    @return_readonly_id_array
    def active_diagonals(self):
        return np.where(self.status_at_diagonal == LinkStatus.ACTIVE)[0]
github landlab / landlab / landlab / grid / diagonals.py View on Github external
    @cache_result_in_object()
    def number_of_diagonals(self):
        """Number of diagonals in the grid.

        Examples
        --------
        >>> from landlab import RasterModelGrid
        >>> grid = RasterModelGrid((4, 3))
        >>> grid.number_of_diagonals
        12
        """
        return 2 * np.prod(np.asarray(self.shape) - 1)
github landlab / landlab / landlab / grid / base.py View on Github external
    @cache_result_in_object()
    def angle_of_link_about_head(self):
        """Find and return the angle of a link about the node at the link head.

        Because links have direction, their angle can be specified as an angle
        about either the node at the link head, or the node at the link tail.
        The default behaviour of `angle_of_link` is to return the angle about
        the link tail, but this method gives the angle about the link head.

        Examples
        --------
        >>> from landlab import HexModelGrid
        >>> import numpy as np

        >>> grid = HexModelGrid((3, 2), node_layout="hex")
        >>> np.round(grid.angle_of_link[:3] / np.pi * 3.0)
        array([ 0., 2.,  1.])
github landlab / landlab / landlab / grid / base.py View on Github external
    @cache_result_in_object()
    def fixed_links(self):
        """Get array of fixed links.

        Examples
        --------
        >>> from landlab import NodeStatus, RasterModelGrid
        >>> grid = RasterModelGrid((3, 4))
        >>> grid.status_at_node # doctest: +NORMALIZE_WHITESPACE
        array([1, 1, 1, 1,
               1, 0, 0, 1,
               1, 1, 1, 1], dtype=uint8)
        >>> grid.fixed_links.size
        0

        >>> grid.status_at_node[:4] = NodeStatus.FIXED_GRADIENT
        >>> grid.status_at_node # doctest: +NORMALIZE_WHITESPACE
github landlab / landlab / landlab / grid / base.py View on Github external
    @cache_result_in_object()
    def fixed_value_boundary_nodes(self):
        """Get array of fixed value boundary nodes.

        Examples
        --------
        >>> from landlab import RasterModelGrid
        >>> grid = RasterModelGrid((4, 5))

        Initially all the perimeter nodes are fixed value boundary.

        >>> grid.fixed_value_boundary_nodes
        array([ 0,  1,  2,  3,  4, 5,  9, 10, 14, 15, 16, 17, 18, 19])

        Set left, right, and bottom edges to closed.

        >>> for edge in (grid.nodes_at_left_edge, grid.nodes_at_right_edge,
github landlab / landlab / landlab / grid / network.py View on Github external
    @cache_result_in_object()
    @make_return_array_immutable
    def y_of_link(self):
        """Get array of the y-coordinates of link midpoints.

        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.y_of_link
        array([ 0.5,  1.5,  1.5])

        LLCATS: LINF MEAS
        """
github landlab / landlab / landlab / grid / network.py View on Github external
    @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
        """
        return set_status_at_link(self.status_at_node[self.nodes_at_link])
github landlab / landlab / landlab / grid / diagonals.py View on Github external
    @cache_result_in_object()
    @return_readonly_id_array
    def active_d8(self):
        return np.where(self.status_at_d8 == LinkStatus.ACTIVE)[0]