API Overview

This page points to the most important classes and functions of the xarray-simlab-ode API.

Top-level functions

xso.create(components[, time_unit])

Creates xsimlab Model instance, from dict of XSO components, automatically adding the necessary model backend, solver and time components.

xso.setup(solver, model, input_vars[, ...])

Create a specific setup for model runs.

Component

xso.component([cls])

A component decorator that adds everything needed to use the class as a XSO component.

Variable types

xso.variable([foreign, flux, negative, ...])

Create a state variable.

xso.parameter([foreign, dims, description, ...])

Create a parameter.

xso.forcing([foreign, setup_func, dims, ...])

Create a forcing variable.

xso.flux([flux_func, dims, group, ...])

Create a flux function.

xso.index([foreign, dims, description, attrs])

Create an index.

Backend components

xso.core.XSOCore(solver)

Backend core class that initializes solver and model, and translates between the two for model construction and solving.

xso.model.Model()

Base model class, containing dictionaries of all model variables and components, as well as the function that sorts through all of these, and computes each step at model runtime.

xso.solvers.SolverABC()

Abstract base class of backend solver class, use subclass to solve model within the XSO framework.

xso.solvers.IVPSolver()

Solver backend using scipy.integrate.solve_ivp to solve model.

xso.solvers.StepwiseSolver()

Solver that can handle stepwise calculation built into xsimlab framework.

xso.backendcomps.Backend(*, solver_type)

Xarray-simlab process initializing and storing model backend and solver.

xso.backendcomps.Context(*, core, m)

Inherited by all other model components to access backend.

xso.backendcomps.Time(*, core, m, time_input)

Process defining model time and registering it in model backend.

xso.backendcomps.RunSolver(*, core, m[, ...])

Inherits model backend from context and calls solver to run as final initialization stage of model runtime.

Xarray-simlab

Since XSO mostly wraps xarray-simlab, it can be helpful to also reference that API.

We can access the xarray-simlab API through the xsimlab accessor of the created input and output xarray Datasets:

>>> import xarray as xr         # first import xarray
>>> import xsimlab              # import xsimlab (the 'xsimlab' accessor is registered)
>>> ds = xr.Dataset()           # create or load an xarray Dataset
>>> ds.xsimlab.<meth_or_prop>   # access to the methods and properties listed below