landlab

Base class from which all components inherit

Defines the base component class from which Landlab components inherit.

Base component class methods

from_path(grid, path) Create a component from an input file.
landlab.core.model_component.Component.name
units
landlab.core.model_component.Component.definitions
input_var_names
output_var_names
optional_var_names
var_type(name) Returns the dtype of a field (float, int, bool, str...), if declared.
var_units(name) Get the units of a particular field.
var_definition(name) Get a description of a particular field.
landlab.core.model_component.Component.var_mapping
var_loc(name) Location where a particular variable is defined.
var_help(name) Print a help message for a particular field.
initialize_output_fields() Create fields for a component based on its input and output var names.
initialize_optional_output_fields() Create fields for a component based on its optional field outputs, if declared in _optional_var_names.
shape Return the grid shape attached to the component, if defined.
grid Return the grid attached to the component.
coords Return the coordinates of nodes on grid attached to the component.
imshow(name, **kwds) Plot data on the grid attached to the component.
class Component(grid, map_vars=None, **kwds)[source]

Bases: object

Defines the base component class from which Landlab components inherit.

from_path(grid, path) Create a component from an input file.
landlab.core.model_component.Component.name
units
landlab.core.model_component.Component.definitions
input_var_names
output_var_names
optional_var_names
var_type(name) Returns the dtype of a field (float, int, bool, str...), if declared.
var_units(name) Get the units of a particular field.
var_definition(name) Get a description of a particular field.
landlab.core.model_component.Component.var_mapping
var_loc(name) Location where a particular variable is defined.
var_help(name) Print a help message for a particular field.
initialize_output_fields() Create fields for a component based on its input and output var names.
initialize_optional_output_fields() Create fields for a component based on its optional field outputs, if declared in _optional_var_names.
shape Return the grid shape attached to the component, if defined.
grid Return the grid attached to the component.
coords Return the coordinates of nodes on grid attached to the component.
imshow(name, **kwds) Plot data on the grid attached to the component.
coords

Return the coordinates of nodes on grid attached to the component.

definitions

classmethod(function) -> method

Convert a function to be a class method.

A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:

class C:
def f(cls, arg1, arg2, ...): ... f = classmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.

Class methods are different than C++ or Java static methods. If you want those, see the staticmethod builtin.

classmethod from_path(grid, path)[source]

Create a component from an input file.

Parameters:

grid : ModelGrid

A landlab grid.

path : str or file_like

Path to a parameter file, contents of a parameter file, or a file-like object.

Returns:

Component

A newly-created component.

grid

Return the grid attached to the component.

imshow(name, **kwds)[source]

Plot data on the grid attached to the component.

initialize_optional_output_fields()[source]

Create fields for a component based on its optional field outputs, if declared in _optional_var_names.

This method will create new fields (without overwrite) for any fields output by the component as optional. New fields are initialized to zero. New fields are created as arrays of floats, unless the component also contains the specifying property _var_type.

initialize_output_fields()[source]

Create fields for a component based on its input and output var names.

This method will create new fields (without overwrite) for any fields output by, but not supplied to, the component. New fields are initialized to zero. Ignores optional fields, if specified by _optional_var_names. New fields are created as arrays of floats, unless the component also contains the specifying property _var_type.

input_var_names = ()
name

classmethod(function) -> method

Convert a function to be a class method.

A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:

class C:
def f(cls, arg1, arg2, ...): ... f = classmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.

Class methods are different than C++ or Java static methods. If you want those, see the staticmethod builtin.

optional_var_names = ()
output_var_names = ()
shape

Return the grid shape attached to the component, if defined.

units = ()
classmethod var_definition(name)[source]

Get a description of a particular field.

Parameters:

name : str

A field name.

Returns:

tuple of (name, description)

A description of each field.

classmethod var_help(name)[source]

Print a help message for a particular field.

Parameters:

name : str

A field name.

classmethod var_loc(name)[source]

Location where a particular variable is defined.

Parameters:

name : str

A field name.

Returns:

str

The location (‘node’, ‘link’, etc.) where a variable is defined.

var_mapping

classmethod(function) -> method

Convert a function to be a class method.

A class method receives the class as implicit first argument, just like an instance method receives the instance. To declare a class method, use this idiom:

class C:
def f(cls, arg1, arg2, ...): ... f = classmethod(f)

It can be called either on the class (e.g. C.f()) or on an instance (e.g. C().f()). The instance is ignored except for its class. If a class method is called for a derived class, the derived class object is passed as the implied first argument.

Class methods are different than C++ or Java static methods. If you want those, see the staticmethod builtin.

classmethod var_type(name)[source]

Returns the dtype of a field (float, int, bool, str...), if declared. Default is float.

Parameters:

name : str

A field name.

Returns:

dtype

The dtype of the field.

classmethod var_units(name)[source]

Get the units of a particular field.

Parameters:

name : str

A field name.

Returns:

str

Units for the given field.

class classproperty[source]

Bases: property