landlab.core.model_component

Defines the base component class from which Landlab components inherit.

Base component class methods

name

from_path(grid, path)

Create a component from an input file.

unit_agnostic

units

definitions

input_var_names

output_var_names

optional_var_names

var_type(name)

Returns the dtype of a field (float, int, bool, str...).

var_units(name)

Get the units of a particular field.

var_definition(name)

Get a description of a particular field.

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([values_per_element])

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.

class Component[source]

Bases: object

Base component class from which Landlab components inherit.

__init__(grid)[source]
static __new__(cls, *args, **kwds)[source]
cite_as = ''
property coords

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

property current_time

Current time.

Some components may keep track of the current time. In this case, the current_time attribute is incremented. Otherwise it is set to None.

Return type:

current_time

definitions = ()
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:

A newly-created component.

Return type:

Component

property grid

Return 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(values_per_element=None)[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. New fields are created as arrays of floats, unless the component specifies the variable type.

Parameters:

values_per_element (int (optional)) – On occasion, it is necessary to create a field that is of size (n_grid_elements, values_per_element) instead of the default size (n_grid_elements,). Use this keyword argument to acomplish this task.

input_var_names = ()
name = None
optional_var_names = ()
output_var_names = ()
property shape

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

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

Get a description of a particular field.

Parameters:

name (str) – A field name.

Returns:

A description of each field.

Return type:

tuple of (name, *description*)

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:

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

Return type:

str

var_mapping = ()
classmethod var_type(name)[source]

Returns the dtype of a field (float, int, bool, str…).

Parameters:

name (str) – A field name.

Returns:

The dtype of the field.

Return type:

dtype

classmethod var_units(name)[source]

Get the units of a particular field.

Parameters:

name (str) – A field name.

Returns:

Units for the given field.

Return type:

str

class classproperty[source]

Bases: property

__init__(*args, **kwargs)
__new__(**kwargs)
deleter()

Descriptor to obtain a copy of the property with a different deleter.

fdel
fget
fset
getter()

Descriptor to obtain a copy of the property with a different getter.

setter()

Descriptor to obtain a copy of the property with a different setter.