landlab.grid.raster_divergence¶
Calculate flux divergence on a raster grid.
- calc_flux_div_at_node(unit_flux, out=None)[source]¶
Calculate divergence of link-based fluxes at nodes.
Given a flux per unit width across each face in the grid, calculate the net outflux (or influx, if negative) divided by cell area, at each node (zero or “out” value for nodes without cells).
- Parameters:
unit_flux (ndarray or field name) – Flux per unit width along links (x number of links).
- Returns:
Flux divergence at nodes.
- Return type:
ndarray (x number of nodes)
Examples
>>> from landlab import RasterModelGrid >>> from landlab.grid.raster_divergence import calc_flux_div_at_node
>>> grid = RasterModelGrid((3, 4), xy_spacing=10.0) >>> z = grid.add_zeros("topographic__elevation", at="node") >>> z[5] = 50.0 >>> z[6] = 36.0 >>> z.reshape(grid.shape) array([[ 0., 0., 0., 0.], [ 0., 50., 36., 0.], [ 0., 0., 0., 0.]]) >>> grads = grid.calc_grad_at_link(z) >>> grads[grid.horizontal_links].reshape((3, 3)) array([[ 0. , 0. , 0. ], [ 5. , -1.4, -3.6], [ 0. , 0. , 0. ]]) >>> grads[grid.vertical_links].reshape((2, 4)) array([[ 0. , 5. , 3.6, 0. ], [ 0. , -5. , -3.6, 0. ]]) >>> grid.calc_flux_div_at_node(-grads).reshape(grid.shape) array([[0. , 0. , 0. , 0. ], [0. , 1.64, 0.94, 0. ], [0. , 0. , 0. , 0. ]])
>>> grid.set_status_at_node_on_edges(right=grid.BC_NODE_IS_CLOSED) >>> grid.set_status_at_node_on_edges(top=grid.BC_NODE_IS_CLOSED) >>> unit_flux_at_links = grid.zeros(at="link") >>> unit_flux_at_links[grid.active_links] = -grads[grid.active_links] >>> grid.calc_flux_div_at_node(unit_flux_at_links).reshape(grid.shape) array([[0. , 0. , 0. , 0. ], [0. , 1.14, 0.22, 0. ], [0. , 0. , 0. , 0. ]]) >>> _ = grid.add_field("neg_grad_at_link", -grads, at="link") >>> grid.calc_flux_div_at_node("neg_grad_at_link").reshape(grid.shape) array([[0. , 0. , 0. , 0. ], [0. , 1.64, 0.94, 0. ], [0. , 0. , 0. , 0. ]])
Notes
Performs a numerical flux divergence operation on nodes.
- calc_net_face_flux_at_cell(grid, unit_flux_at_face, out=None)[source]¶
Calculate net face fluxes at cells.
Given a flux per unit width across each face in the grid, calculate the net outflux (or influx, if negative) at each cell.
- Parameters:
unit_flux_at_faces (ndarray or field name) – Flux per unit width associated with faces.
out (ndarray, optional) – Buffer to hold the result.
- Returns:
Net flux at cells.
- Return type:
ndarray (x number of cells)