sequence.grid module#

Define the grid used for creating Sequence models.

class sequence.grid.SequenceModelGrid(shape: int | tuple[int, int], spacing: float | tuple[float, float] = 100.0)[source]#

Bases: RasterModelGrid

Create a Landlab ModelGrid for use with Sequence.

__init__(shape: int | tuple[int, int], spacing: float | tuple[float, float] = 100.0)[source]#

Create a Landlab ModelGrid for use with Sequence.

Parameters:
  • shape (int or tuple of int) – The number of columns in the cross-shore direction or, if a tuple, (n_rows, n_cols) where rows are in the along-shore direction and columns in the cross-shore direction.

  • spacing (float or tuple of float, optional) – The spacing between columns or, if len(shape) == 2, (row_spacing, col_spacing).

Examples

>>> from sequence.grid import SequenceModelGrid
>>> grid = SequenceModelGrid(5, spacing=10.0)
>>> grid.y_of_row
array([  0.,  1.,  2.])
>>> grid.x_of_column
array([ 0.,  10.,  20.,  30.,  40.])
>>> grid = SequenceModelGrid((3, 5), spacing=(10000.0, 10.0))
>>> grid.y_of_row
array([  0.,  10000.,  20000.,  30000., 40000.])
>>> grid.x_of_column
array([ 0.,  10.,  20.,  30.,  40.])
classmethod from_dict(params: dict) SequenceModelGrid[source]#

Create a SequenceModelGrid from a dict.

If possible, this alternate constructor simply passes along the dictionary’s items as keywords to __init__(). It also, however, supports a dictionary that contains the parameters used to create a general RasterModelGrid, quietly ignoring the extra parameters.

Parameters:

params (dict) – A dictionary that contains the parameters needed to create the grid.

Examples

>>> from sequence.grid import SequenceModelGrid
>>> params = {"shape": 5, "spacing": 10.0}
>>> grid = SequenceModelGrid.from_dict(params)
>>> grid.y_of_row
array([  0.,  1.,  2.])
>>> grid.x_of_column
array([ 0.,  10.,  20.,  30.,  40.])
>>> params = {"shape": (3, 5), "spacing": (10000.0, 10.0)}
>>> grid = SequenceModelGrid.from_dict(params)
>>> grid.y_of_row
array([  0.,  10000.,  20000.,  30000., 40000.])
>>> grid.x_of_column
array([ 0.,  10.,  20.,  30.,  40.])
classmethod from_toml(filepath: PathLike[str]) SequenceModelGrid[source]#

Load a SequenceModelGrid from a toml-formatted file.

Parameters:

filepath (os.PathLike[str]) – Path to the toml file that contains the grid parameters.

get_profile(name: str) ndarray[Any, dtype[_ScalarType_co]][source]#

Return the values of a field along the grid’s profile.

Parameters:

name (str) – The name of an at-node field.

Returns:

values – The values of the field located at the middle row of nodes.

Return type:

ndarray

property number_of_columns: int#

Number of columns of nodes.

property number_of_rows: int#

Number of rows of nodes.

property x_of_column: ndarray[Any, dtype[_ScalarType_co]]#

X-coordinate for each column of the grid.

property y_of_row: ndarray[Any, dtype[_ScalarType_co]]#

Y-coordinate for each row of the grid.