Release: | 0.1 |
---|---|
Date: | June 23, 2016 |
Interface to the basic control functions of a model.
bmi.base.
BmiBase
[source]¶Bases: object
Functions that control model execution.
These BMI functions are critical to plug-and-play modeling because they give a calling component fine-grained control over the model execution.
Methods
finalize () |
Perform tear-down tasks for the model. |
initialize (filename) |
Perform startup tasks for the model. |
update () |
Advance model state by one time step. |
update_frac (time_frac) |
Advance model state by a fraction of a time step. |
update_until (time) |
Advance model state until the given time. |
finalize
()[source]¶Perform tear-down tasks for the model.
Perform all tasks that take place after exiting the model’s time loop. This typically includes deallocating memory, closing files and printing reports.
Notes
/* C */
int finalize(void *self);
initialize
(filename)[source]¶Perform startup tasks for the model.
Perform all tasks that take place before entering the model’s time loop, including opening files and initializing the model state. Model inputs are read from a text-based configuration file, specified by filename.
Parameters: | filename : str, optional
|
---|
Notes
Models should be refactored, if necessary, to use a configuration file. CSDMS does not impose any constraint on how configuration files are formatted, although YAML is recommended. A template of a model’s configuration file with placeholder values is used by the BMI.
/* C */
int initialize(void *self, char * filename);
update
()[source]¶Advance model state by one time step.
Perform all tasks that take place within one pass through the model’s
time loop. This typically includes incrementing all of the model’s
state variables. If the model’s state variables don’t change in time,
then they can be computed by the initialize()
method and this
method can return with no action.
Notes
/* C */
int update(void *self);
Interface that describes a model and it’s input and output variables.
bmi.info.
BmiInfo
[source]¶Bases: object
Get metadata about a model.
Methods
get_component_name () |
Name of the component. |
get_input_var_names () |
List of a model’s input variables. |
get_output_var_names () |
List of a model’s output variables. |
get_component_name
()[source]¶Name of the component.
Returns: | str
|
---|
Notes
/* C */
int get_component_name(void * self, char * name);
get_input_var_names
()[source]¶List of a model’s input variables.
Input variable names must be CSDMS Standard Names, also known as long variable names.
Returns: | list of str
|
---|
Notes
/* C */
int get_input_var_name_count(void * self, int * count);
int get_input_var_names(void * self, char ** names);
get_output_var_names
()[source]¶List of a model’s output variables.
Output variable names must be CSDMS Standard Names, also known as long variable names.
Returns: | list of str
|
---|
See also
Notes
/* C */
int get_output_var_name_count(void * self, int * count);
int get_output_var_names(void * self, char ** names);
Interface that describes the time stepping of a model.
bmi.time.
BmiTime
[source]¶Bases: object
Methods that get time information from a model.
Methods
get_current_time () |
Current time of the model. |
get_end_time () |
End time of the model. |
get_start_time () |
Start time of the model. |
get_time_step () |
Current time step of the model. |
get_time_units () |
Time units of the model. |
get_current_time
()[source]¶Current time of the model.
Returns: | float
|
---|
See also
Notes
/* C */
int get_current_time(void * self, double * time);
get_end_time
()[source]¶End time of the model.
Returns: | float
|
---|
See also
Notes
/* C */
int get_end_time(void * self, double * time);
get_start_time
()[source]¶Start time of the model.
Model times should be of type float. The default model start time is 0.
Returns: | float
|
---|
Notes
/* C */
int get_start_time(void * self, double * time);
Interface that describes a model’s input and output variables.
bmi.vars.
BmiVars
[source]¶Bases: object
Methods that get information about input and output variables.
These BMI functions obtain information about a particular input or output
variable. They must accommodate any variable that is returned by the BMI
functions get_input_var_names()
or
get_output_var_names()
.
Methods
get_var_grid (var_name) |
Get grid identifier for the given variable. |
get_var_itemsize (var_name) |
Get memory use for each array element in bytes. |
get_var_nbytes (var_name) |
Get size, in bytes, of the given variable. |
get_var_type (var_name) |
Get data type of the given variable. |
get_var_units (var_name) |
Get units of the given variable. |
get_var_grid
(var_name)[source]¶Get grid identifier for the given variable.
Parameters: | var_name : str
|
---|---|
Returns: | int
|
See also
bmi.info.BmiInfo.get_input_var_names
get_output_var_names()
.Notes
/* C */
int get_var_grid(void * self, const char * var_name, int * id);
get_var_itemsize
(var_name)[source]¶Get memory use for each array element in bytes.
Parameters: | var_name : str
|
---|---|
Returns: | int
|
Notes
/* C */
int get_var_itemsize(void * self, const char * var_name,
int * itemsize);
get_var_nbytes
(var_name)[source]¶Get size, in bytes, of the given variable.
Parameters: | var_name : str
|
---|---|
Returns: | int
|
Notes
/* C */
int get_var_nbytes(void * self, const char * var_name,
int * nbytes);
get_var_type
(var_name)[source]¶Get data type of the given variable.
Parameters: | var_name : str
|
---|---|
Returns: | str
|
Notes
/* C */
int get_var_type(void * self, const char * var_name, char * type);
get_var_units
(var_name)[source]¶Get units of the given variable.
Standard unit names, in lower case, should be used, such as
meters
or seconds
. Standard abbreviations, like m
for
meters, are also supported. For variables with compound units,
each unit name is separated by a single space, with exponents
other than 1 placed immediately after the name, as in m s-1
for velocity, W m-2
for an energy flux, or km2
for an
area.
Parameters: | var_name : str
|
---|---|
Returns: | str
|
Notes
CSDMS uses the UDUNITS standard from Unidata.
/* C */
int get_var_units(void * self, const char * var_name,
char * units);
Interface for getting and setting a model’s internal variables.
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
|
---|---|
Returns: | array_like
|
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
indices : array_like
|
---|---|
Returns: | array_like
|
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
|
---|---|
Returns: | array_like
|
Notes
/* C */
int get_value_ref(void * self, const char * var_name,
void ** buffer);
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
src : array_like
|
---|
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
indices : array_like
src : array_like
|
---|
Notes
/* C */
int set_value_at_indices(void * self, const char * var_name,
int * indices, int len, void * src);
Interface that describes uniform rectilinear grids.
bmi.grid_uniform_rectilinear.
BmiGridUniformRectilinear
[source]¶Bases: bmi.grid.BmiGrid
Methods that describe a uniform rectilinear grid.
In a 2D uniform grid, every grid cell (or element) is a rectangle and all cells have the same dimensions. If the dimensions are equal, then the grid is a tiling of squares.
Each of these functions returns information about each dimension of a
grid. The dimensions are ordered with “ij” indexing (as opposed to “xy”).
For example, the get_grid_shape()
function for the example grid would
return the array [4, 5]
. If there were a third dimension, the length of
the z dimension would be listed first. This same convention is used in
NumPy. Note that the grid shape is the number of nodes in the coordinate
directions and not the number of cells or elements. It is possible for
grid values to be associated with the nodes or with the cells.
Methods
get_grid_origin (grid_id) |
Get coordinates for the origin of the computational grid. |
get_grid_rank (grid_id) |
Get number of dimensions of the computational grid. |
get_grid_shape (grid_id) |
Get dimensions of the computational grid. |
get_grid_size (grid_id) |
Get the total number of elements in the computational grid. |
get_grid_spacing (grid_id) |
Get distance between nodes of the computational grid. |
get_grid_type (grid_id) |
Get the grid type as a string. |
get_grid_origin
(grid_id)[source]¶Get coordinates for the origin of the computational grid.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_origin(void * self, int grid_id, double * origin);
get_grid_shape
(grid_id)[source]¶Get dimensions of the computational grid.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_shape(void * self, int grid_id, int * shape);
get_grid_spacing
(grid_id)[source]¶Get distance between nodes of the computational grid.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_spacing(void * self, int grid_id, double * spacing);
Interface that describes rectilinear grids.
bmi.grid_rectilinear.
BmiGridRectilinear
[source]¶Bases: bmi.grid.BmiGrid
Methods that describe a rectilinear grid.
In a 2D rectilinear grid, every grid cell (or element) is a rectangle but different cells can have different dimensions. All cells in the same row have the same grid spacing in the y direction and all cells in the same column have the same grid spacing in the x direction. Grid spacings can be computed as the difference of successive x or y values.
Methods
get_grid_rank (grid_id) |
Get number of dimensions of the computational grid. |
get_grid_shape (grid_id) |
Get dimensions of the computational grid. |
get_grid_size (grid_id) |
Get the total number of elements in the computational grid. |
get_grid_type (grid_id) |
Get the grid type as a string. |
get_grid_x (grid_id) |
Get coordinates of grid nodes in the streamwise direction. |
get_grid_y (grid_id) |
Get coordinates of grid nodes in the transverse direction. |
get_grid_z (grid_id) |
Get coordinates of grid nodes in the normal direction. |
get_grid_shape
(grid_id)[source]¶Get dimensions of the computational grid.
Parameters: | grid_id : int
|
---|---|
Returns: | tuple of int
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_shape(void * self, const char * var_name,
int * shape);
get_grid_x
(grid_id)[source]¶Get coordinates of grid nodes in the streamwise direction.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like of float
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_x(void * self, const char * var_name, double * x);
get_grid_y
(grid_id)[source]¶Get coordinates of grid nodes in the transverse direction.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like of float
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_y(void * self, const char * var_name, double * y);
get_grid_z
(grid_id)[source]¶Get coordinates of grid nodes in the normal direction.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like of float
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_z(void * self, const char * var_name, double * z);
Interface that describes structured quadrilateral grids.
bmi.grid_structured_quad.
BmiGridStructuredQuad
[source]¶Bases: bmi.grid.BmiGrid
Methods that describe a structured grid of quadrilaterals.
Methods
get_grid_rank (grid_id) |
Get number of dimensions of the computational grid. |
get_grid_shape (grid_id) |
Get dimensions of the computational grid. |
get_grid_size (grid_id) |
Get the total number of elements in the computational grid. |
get_grid_type (grid_id) |
Get the grid type as a string. |
get_grid_x (grid_id) |
Get coordinates of grid nodes in the streamwise direction. |
get_grid_y (grid_id) |
Get coordinates of grid nodes in the transverse direction. |
get_grid_z (grid_id) |
Get coordinates of grid nodes in the normal direction. |
get_grid_shape
(grid_id)[source]¶Get dimensions of the computational grid.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_shape(void * self, int grid_id, int * shape);
get_grid_x
(grid_id)[source]¶Get coordinates of grid nodes in the streamwise direction.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_x(void * self, int grid_id, double * x);
get_grid_y
(grid_id)[source]¶Get coordinates of grid nodes in the transverse direction.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_y(void * self, int grid_id, double * y);
get_grid_z
(grid_id)[source]¶Get coordinates of grid nodes in the normal direction.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_z(void * self, int grid_id, double * z);
Interface that describes unstructured grids.
bmi.grid_unstructured.
BmiGridUnstructured
[source]¶Bases: bmi.grid.BmiGrid
Methods that describe an unstructured grid.
Methods
get_grid_connectivity (grid_id) |
Get connectivity array of the grid. |
get_grid_offset (grid_id) |
Get offsets for the grid nodes. |
get_grid_rank (grid_id) |
Get number of dimensions of the computational grid. |
get_grid_size (grid_id) |
Get the total number of elements in the computational grid. |
get_grid_type (grid_id) |
Get the grid type as a string. |
get_grid_x (grid_id) |
Get coordinates of grid nodes in the streamwise direction. |
get_grid_y (grid_id) |
Get coordinates of grid nodes in the transverse direction. |
get_grid_z (grid_id) |
Get coordinates of grid nodes in the normal direction. |
get_grid_connectivity
(grid_id)[source]¶Get connectivity array of the grid.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like or int
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_connectivity(void * self, int grid_id,
int * connectivity);
get_grid_offset
(grid_id)[source]¶Get offsets for the grid nodes.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like of int
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_offset(void * self, int grid_id, int * offset);
get_grid_x
(grid_id)[source]¶Get coordinates of grid nodes in the streamwise direction.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_x(void * self, int grid_id, double * x);
get_grid_y
(grid_id)[source]¶Get coordinates of grid nodes in the transverse direction.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_y(void * self, int grid_id, double * y);
get_grid_z
(grid_id)[source]¶Get coordinates of grid nodes in the normal direction.
Parameters: | grid_id : int
|
---|---|
Returns: | array_like
|
See also
bmi.vars.BmiVars.get_var_grid
Notes
/* C */
int get_grid_z(void * self, int grid_id, double * z);