csdms

bmi.getter_setter module

Interface for getting and setting a model’s internal variables.

class bmi.getter_setter.BmiGetter[source]

Bases: object

Get values from a component.

Methods that get variables from a model’s state. Often a model’s state variables are changing with each time step, so getters are called to get current values.

Methods

get_value(var_name) Get a copy of values of the given variable.
get_value_at_indices(var_name, indices) Get values at particular indices.
get_value_ref(var_name) Get a reference to values of the given variable.
get_value(var_name)[source]

Get a copy of values of the given variable.

This is a getter for the model, used to access the model’s current state. It returns a copy of a model variable, with the return type, size and rank dependent on the variable.

Parameters:

var_name : str

An input or output variable name, a CSDMS Standard Name.

Returns:

array_like

The value of a model variable.

Notes

/* C */
int get_value(void * self, const char * var_name, void * buffer);
get_value_at_indices(var_name, indices)[source]

Get values at particular indices.

Parameters:

var_name : str

An input or output variable name, a CSDMS Standard Name.

indices : array_like

The indices into the variable array.

Returns:

array_like

Value of the model variable at the given location.

Notes

/* C */
int get_value_at_indices(void * self, const char * var_name,
                         void * buffer, int * indices, int len);
get_value_ref(var_name)[source]

Get a reference to values of the given variable.

This is a getter for the model, used to access the model’s current state. It returns a reference to a model variable, with the return type, size and rank dependent on the variable.

Parameters:

var_name : str

An input or output variable name, a CSDMS Standard Name.

Returns:

array_like

A reference to a model variable.

Notes

/* C */
int get_value_ref(void * self, const char * var_name,
                  void ** buffer);
class bmi.getter_setter.BmiSetter[source]

Bases: object

Set values into a component.

Methods that set variables of a model’s state.

Methods

set_value(var_name, src) Specify a new value for a model variable.
set_value_at_indices(var_name, indices, src) Specify a new value for a model variable at particular indices.
set_value(var_name, src)[source]

Specify a new value for a model variable.

This is the setter for the model, used to change the model’s current state. It accepts, through src, a new value for a model variable, with the type, size and rank of src dependent on the variable.

Parameters:

var_name : str

An input or output variable name, a CSDMS Standard Name.

src : array_like

The new value for the specified variable.

Notes

/* C */
int set_value(void * self, const char * var_name, void * src);
set_value_at_indices(var_name, indices, src)[source]

Specify a new value for a model variable at particular indices.

Parameters:

var_name : str

An input or output variable name, a CSDMS Standard Name.

indices : array_like

The indices into the variable array.

src : array_like

The new value for the specified variable.

Notes

/* C */
int set_value_at_indices(void * self, const char * var_name,
                         int * indices, int len, void * src);