landlab

Grid creation from a formatted input file

Create landlab model grids.

exception BadGridTypeError(grid_type)[source]

Bases: landlab.grid.create.Error

Raise this error for a bad grid type.

exception Error[source]

Bases: exceptions.Exception

Base class for exceptions from this module.

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

Input file or dict of parameter values.

Raises:

KeyError

If missing a key from the input file.

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