xarray-simlab-ode
The xso framework for building and solving models based on ordinary differential equations (ODEs), an extension of xarray-simlab.
Xarray-simlab provides a generic framework for building computational models in a modular fashion and an xarray extension for setting and running simulations using xarray's Dataset structure.
Xarray-simlab-ode (XSO) extends the framework with a set of variables, processes and a solver backend, suited towards ODE-based models. It is designed for flexible, interactive and reproducible modeling workflows.
Installation
$ pip install xso
In a nutshell
A highly simplified model based on ordinary differential equations is shown below.
- Create new model components by writing compact Python classes:
import xso
@xso.component
class Variable:
var = xso.variable(description='basic state variable', attrs={'units':'µM'})
@xso.component
class LinearGrowth:
var_ext = xso.variable(foreign=True, flux='growth', description='external state variable')
rate = xso.parameter(description='linear growth rate', attrs={'units':'$d^{-1}$'})
@xso.flux
def growth(self, var_ext, rate):
return var_ext * rate
- Create a new model just by providing a dictionary of model components:
model = xso.create({'Var':Variable,'Growth':LinearGrowth}, time_unit='d')
- Create an input xarray.Dataset, run the model and get an output xarray.Dataset:
import numpy as np
input_ds = xso.setup(solver='solve_ivp',
model=model,
time=np.arange(1,10,.1),
input_vars={
'Var':{'value_label':'X', 'value_init':1},
'Growth':{'var_ext':'X', 'rate':1.},
})
with model:
output_ds = input_ds.xsimlab.run()
4.Perform model setup, pre-processing, run, post-processing and visualization in a functional style, using method chaining:
with model:
batchout_ds = (input_ds
.xsimlab.update_vars(
input_vars={'Growth': {'rate': ('batch', [0.9, 1.0, 1.1, 1.2])}}
)
.xsimlab.run(parallel=True, batch_dim='batch')
.swap_dims({'batch':'Growth__rate'})
.Var__var_value.plot.line(x='time')
)
Documentation
Documentation is hosted on ReadTheDocs: https://xarray-simlab-ode.readthedocs.io
Contributing
The package is in the early stages of development, and contributions are very welcome. See GitHub Issues for specific issues, or raise your own. Code contributions can be made via Pull Requests on GitHub. Check out the contributing guidelines for more specific information.
License
xarray-simlab-ode was created by Benjamin Post. It is licensed under the terms of the BSD 3-Clause license.
Credits
Xarray-simlab-ode is an extension of xarray-simlab, created by Benoît Bovy.
Metadata
Release files for xso 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| xso-0.1.0.tar.gz | 20.4 kB | Without provenance | Details for xso-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| xso-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for xso-0.1.0-py3-none-any.whl |
Total release size: 42.8 kB
Release files / xso-0.1.0.tar.gz
| Download URL | xso-0.1.0.tar.gz |
|---|---|
| Size | 20.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bedc16b228790ae1427968ad18bb49319a02aa46146bfb8e26dc238d15a5639a
|
|
BLAKE2b-256 checksum How to use checksums |
a3f3ef93c6afd503aeff4e6b520a7273af3f311c4da3049ecd6cfd2e5e9e26f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1041-azure
|
Release files / xso-0.1.0-py3-none-any.whl
| Download URL | xso-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d61e8fee1cae07e165bdf95664e640f3c6de18df748277d995a36bd3951a519d
|
|
BLAKE2b-256 checksum How to use checksums |
4ba6e697bf620d5f3c2f0ccc0edf347663be3e36d8f0c7d5400bc2af49bd184f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1041-azure
|
Security for xso 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.