landlab

landlab.framework package

Submodules

landlab.framework.collections module

Collections of components

class Arena[source]

Bases: landlab.framework.collections.Collection

A collection of component instances.

connect(user_name, provider_name, var_name)[source]

Connect two components through a variable. user_name is the name of the component that uses var_name and provider_name is the name of the component that provides var_name.

If the arena doesn’t contain either user_name or provider_name, UnknownComponentError() is raised.

instantiate(cls, name)[source]

Instantiate a component and call it name. The component, cls, is either an instance of a BMI-like object or a class that implements the BMI. If cls is a class, it is instantiated by calling it’s __init__ method without any arguments.

walk(root, tree=None)[source]

Walk a connected set of components.

Walk a connected set of components with the component named root. If the tree keyword is given, treat it as a list of components already in the tree and add to that list. If a component is already in the tree, do not iterate through that component. This function returns a list of component names in the order they are visited by the walk.

exception BadVarNameError(var_name)[source]

Bases: landlab.framework.collections.Error

Raise this exception if a variable name is not found for a component.

class Collection(**kwds)[source]

Bases: dict

A collection of components that implement a BmiBase

find_connections()[source]

Find connections between components that use and provide variables. The returned dictionary will have keys that are names of components that provide varaibles. Its keys will be a dictionary of variable names and list of components that use the variable.

find_provider(var_name)[source]

Find a component in the collection that provides the CSDMS standard name, var_name. The returned list contains the names of the components providing var_name.

find_user(var_name)[source]

Find components in the collection that use the specified CSDMS standard variable name, var_name. The returned list contains the names of the components using var_name.

list()[source]

Get a list of component names in the collection.

provides()[source]

Get a list of variable names that components in the collection provides.

uses()[source]

Get a list of variable names that components in the collection uses.

exception Error[source]

Bases: exceptions.Exception

Base exception for this module

exception MultipleProvidersError(var_name)[source]

Bases: landlab.framework.collections.Error

Raise this exception if multiple components provide the same variable

exception NoProvidersError(var_name)[source]

Bases: landlab.framework.collections.Error

Raise this exception if no components provide the a variable

class Palette(*args, **kwds)[source]

Bases: landlab.framework.collections.Collection

A collection of component classes that have yet to be instantiated.

exception UnknownComponentError(name)[source]

Bases: landlab.framework.collections.Error

Raise this exception when requesting a component unknown to the framework

get_var_names(component, intent='input')[source]

Get a list of input or output variable names from component (a BMI-like object). Use the intent keyword to specify whether to return input or output variable names. intent must be one of input or output.

landlab.framework.component module

Utility functions for loading components for The Landlab.

iscomponent(value, cls)[source]

Check if value is a component for The Landlab. value is a component if it implements the cls or it is an instance of cls.

Returns True if value is a component, otherwise False.

load_components(cls, paths=None)[source]

Load components from a series of directories.

Components found earlier in the search path order override those discovered later. Use the paths keyword to specify a list of paths to search for components.

load_components_from_dir(path, cls)[source]

Look for components for Landlab in path. Identify components as being an instance of cls. Returns a dictionary of discovered component names as keys and component classes as values.

load_landlab_components(paths=None)[source]

Load components for The Landlab. These are classes that implement BmiBase. See load_components_from_dir() for the meaning of paths keyword.

landlab.framework.decorators module

Decorators for TheLandlab package.

exception Error[source]

Bases: exceptions.Exception

Exceptions for this module.

class Implements(*interfaces)[source]

Bases: object

Decorator to indicate if a class implements interfaces. Similar to the ImplementsOrRaise decorator except that this decorator silently ignores implemention errors. If the class does implement the interface, decorate it with a __implements__ data mamber that is a tuple of the interfaces it implements. Otherwise, don’t do anything.

class ImplementsOrRaise(*interfaces)[source]

Bases: object

Decorator to indicate if a class implements interfaces. If the class does not implement the interface, raise an InterfaceImplementationError. If the class does implement the interface, decorate it with a __implements__ data mamber that is a tuple of the interfaces it implements.

exception InterfaceImplementationError(cls, interface)[source]

Bases: landlab.framework.decorators.Error

Raise this error if the class does not implement an interface.

camel_case(text, sep=None)[source]

Convert text to camel case. Use the sep keyword to specify the word separator. The default is to split on whitespace.

>>> from landlab.framework.decorators import camel_case
>>> camel_case('camel case')
'CamelCase'
>>> camel_case('camel_case', sep='_')
'CamelCase'
is_implementation(cls, interface)[source]

Check if cls implements interface. A class implements the interface class if it has the same members, the members have the same type, and methods have the same signature.

Returns True if cls implements interface, otherwise False.

landlab.framework.framework module

exception Error[source]

Bases: exceptions.Exception

Base exception for this module

class Framework[source]

Bases: object

A framework for connecting and running component from The Landlab.

arena_provides()[source]

Get a list of variable names that components in the arena provide.

arena_uses()[source]

Get a list of variable names that components in the arena use.

instantiate(name)[source]

Instantiate a component called name from the palette and move it to the arena.

list_arena()[source]

Get a list of names of the components in the arena.

list_palette()[source]

Get a list of names of the components in the palette.

palette_provides()[source]

Get a list of variable names that components in the palette provide.

palette_uses()[source]

Get a list of variable names that components in the palette use.

remove(name)[source]

Remove a component called name from the arena.

landlab.framework.interfaces module

The Basic Modeling Interface.

exception BadVarNameError(name)[source]

Bases: landlab.framework.interfaces.Error

Exception to indicate a bad input/output variable name

class BmiBase[source]

Bases: object

Definition of the Basic Modeling Interface

finalize()[source]

Clean-up model

get_current_time()[source]

Current time of model.

get_end_time()[source]

Model stop time.

get_input_var_names()[source]

Get names of input variables to the model as standard names.

Returns:A list of input standard names as strings
get_output_var_names()[source]

Get names of output variables to the model as standard names.

Returns:A list of output standard names as strings
get_start_time()[source]

Model start time.

get_time_step()[source]

Model time step.

get_var_rank(var_name)[source]

Rank of exchange item.

get_var_type(var_name)[source]

Get type of an exchange item.

get_var_units(var_name)[source]

Get units of an exchange item.

initialize(file_name)[source]

Initialize model.

File_name:String of configuration file
update(**kwds)[source]

Update model by one time step.

class BmiExtendedBase[source]

Bases: object

An extension interface for a BMI.

run_model()[source]

Initialize, run, and finalize a model.

update_until(time)[source]

Update model until some time.

Time:Update duration
class BmiGridType[source]

Bases: int

Base type to indicate the type of a BMI model’s grid.

Code:Grid type code as an int
Name:Name of the grid type as a string
class BmiNoGrid[source]

Bases: object

BMI for a model that does not have a grid.

class BmiRectilinear[source]

Bases: object

BMI for a model that uses a rectilinear grid.

get_columns(name)[source]

Get coordinates of grid columns.

get_grid_shape(name)[source]

Get shape of grid for variable, name.

Name:Standard name
get_rows(name)[source]

Get coordinates of grid rows.

class BmiStructured[source]

Bases: object

BMI for a model that uses a structured grid.

get_grid_shape(name)[source]

Get shape of grid for variable, name.

Name:Standard name
get_x(name)[source]

Get x-coordinates of grid nodes.

get_y(name)[source]

Get y-coordinates of grid nodes.

class BmiUniformRectilinear[source]

Bases: object

BMI for a model that exposes a uniform rectilinear grid.

get_grid_origin(name)[source]

Get origin of grid for variable, name.

Name:Standard name
get_grid_shape(name)[source]

Get shape of grid for variable, name.

Name:Standard name
get_grid_spacing(name)[source]

Get spacing of grid for variable, name.

Name:Standard name
class BmiUnstructured[source]

Bases: object

BMI for a model that uses an unstructured grid.

get_connectivity(name)[source]

Get cell connectivity.

get_offset(name)[source]

Get cell offset.

get_x(name)[source]

Get x-coordinates of grid nodes.

get_y(name)[source]

Get y-coordinates of grid nodes.

exception Error[source]

Bases: exceptions.Exception

Base class for BMI exceptions

exception FatalError[source]

Bases: exceptions.Exception

Raise this exception if an unrecoverable error was found

exception MissingModelAttributeError(attrib)[source]

Bases: landlab.framework.interfaces.Error

Raise this exception if a component is missing a required attribute.

exception TimeBoundsError[source]

Bases: landlab.framework.interfaces.Error

Raise this exception if a component updates beyond its time horizon

Module contents

The Landlab modeling framework.