Create landlab model grids.
BadGridTypeError
(grid_type)[source]¶Bases: landlab.grid.create.Error
Raise this error for a bad grid type.
create_and_initialize_grid
(input_source)[source]¶Create and initialize a grid from a file.
Creates, initializes, and returns a new grid object using parameters specified in input_source. input_source is either a ModelParameterDictionary instance (or, really, just dict-like) or a named input file.
Parameters: | input_source : str or dict
|
---|---|
Raises: | KeyError
|
Examples
>>> from six import StringIO
>>> test_file = StringIO('''
... GRID_TYPE:
... raster
... NUM_ROWS:
... 4
... NUM_COLS:
... 5
... GRID_SPACING:
... 2.5
... ''')
>>> from landlab import create_and_initialize_grid
>>> grid = create_and_initialize_grid(test_file)
>>> grid.number_of_nodes
20