ewatercycle.models.abstract module

class ewatercycle.models.abstract.AbstractModel(version: str, parameter_set: Optional[ParameterSet] = None, forcing: Optional[ForcingT] = None)

Bases: Generic[ForcingT]

Abstract class of a eWaterCycle model.

available_versions: ClassVar[Tuple[str, ...]] = ()

Versions of model that are available in this class

bmi: basic_modeling_interface.Bmi

Basic Modeling Interface object

abstract setup(*args, **kwargs) Tuple[str, str]

Performs model setup.

  1. Creates config file and config directory

  2. Start bmi container and store as self.bmi

Parameters
  • *args – Positional arguments. Sub class should specify each arg.

  • **kwargs – Named arguments. Sub class should specify each arg.

Returns

Path to config file and path to config directory

initialize(config_file: str) None

Initialize the model.

Parameters

config_file – Name of initialization file.

finalize() None

Perform tear-down tasks for the model.

update() None

Advance model state by one time step.

get_value(name: str) numpy.ndarray

Get a copy of values of the given variable.

Parameters

name – Name of variable

get_value_at_coords(name, lat: Iterable[float], lon: Iterable[float]) numpy.ndarray

Get a copy of values of the given variable at lat/lon coordinates.

Parameters
  • name – Name of variable

  • lat – Latitudinal value

  • lon – Longitudinal value

set_value(name: str, value: numpy.ndarray) None

Specify a new value for a model variable.

Parameters
  • name – Name of variable

  • value – The new value for the specified variable.

set_value_at_coords(name: str, lat: Iterable[float], lon: Iterable[float], values: numpy.ndarray) None

Specify a new value for a model variable at at lat/lon coordinates.

Parameters
  • name – Name of variable

  • lat – Latitudinal value

  • lon – Longitudinal value

  • values – The new value for the specified variable.

abstract get_value_as_xarray(name: str) xarray.DataArray

Get a copy values of the given variable as xarray DataArray.

The xarray object also contains coordinate information and additional attributes such as the units.

Args: name: Name of the variable

abstract property parameters: Iterable[Tuple[str, Any]]

Default values for the setup() inputs

property start_time: float

Start time of the model.

property end_time: float

End time of the model.

property time: float

Current time of the model.

property time_units: str

Time units of the model. Formatted using UDUNITS standard from Unidata.

property time_step: float

Current time step of the model.

property output_var_names: Iterable[str]

List of a model’s output variables.

property start_time_as_isostr: str

Start time of the model.

In UTC and ISO format string e.g. ‘YYYY-MM-DDTHH:MM:SSZ’.

property end_time_as_isostr: str

End time of the model.

In UTC and ISO format string e.g. ‘YYYY-MM-DDTHH:MM:SSZ’.

property time_as_isostr: str

Current time of the model.

In UTC and ISO format string e.g. ‘YYYY-MM-DDTHH:MM:SSZ’.

property start_time_as_datetime: datetime

Start time of the model as a datetime object.

property end_time_as_datetime: datetime

End time of the model as a datetime object’.

property time_as_datetime: datetime

Current time of the model as a datetime object’.