Skip to main content

Python wrapper for BMI models

This is ctypes wrapper for BMI models.

The BMI describes a low level interface for numerical models.

https://travis-ci.org/openearth/bmi-python.svg?branch=master

Origin

This module is based on code from:

Models

Several models implement the BMI interface.

Prerequisites

We need a compiled BMI library (dll, so, dylib). There are a couple of common locations where we look for it.:

.
~/local/lib
~/.local/lib
/opt/modelname/lib
/usr/local/lib
/usr/lib

A convention on linux is to install the library into /opt/modelname/. If you are using one of the models above, the modelname will be 3di, dflowfm, xbeach or swan

In case you have an alternative location, you can set the LD_LIBRARY_PATH, (DYLD_LIBRARY_PATH in OSX, PATH in windows) environment variable, for example for 3Di:

$ export LD_LIBRARY_PATH=/home/user/svn/3di/trunk/subgridf90/src/.libs

(On windows the command is set instead of export).

Setup

The virtualenv way (assumes virtualenvwrapper and virtualenv are installed):

mkvirtualenv main
workon main
# get the version from pypi
pip install bmi-python
# or if you want to add your source directory to the path
pip install -e .

Combination Windows and Anaconda:

- Download + Install Anaconda
- Download and install the :faulthandler: package, from http://www.lfd.uci.edu/~gohlke/pythonlibs/#faulthandler
- Download and install the :NetCDF4: package, from http://www.lfd.uci.edu/~gohlke/pythonlibs/#netcdf4
- Open an (Anaconda) Python-terminal (Press :[Ctrl]:+:[Alt]+:A:).
- pip.bat install -e ``<path to your bmi-python GIT working copy>``

Usage

There are two ways to use the wrapper. A handy way is as a context manager, so with a with statement:

with BMIWrapper(engine="model", configfile='/full/path/model.ini') as model:
    # model is the actual library.
    model.something()

The second way is by calling start and stop yourself and using the library attribute to access the Fortran library:

wrapper = BMIWrapper(engine="model", configfile='/full/path/model.mdu')
wrapper.start()
wrapper.library.something()
...
wrapper.stop()

Note: Without the mdu argument, no model is loaded and you’re free to use the library as you want.

Convenience scripts

The python bmi library contains a script that can be used as a command line runner for your model:

bmi-runner <engine> <configfile>

Credits

  • Fedor Baart

  • Gena Donchyts

  • Jack Ha

  • Stef Hummel

  • Scott Peckham

  • Reinout van Rees

  • Sander Smits

Changelog of bmi-python

2014-02-07

  • allow relative path for config_file

  • fix exception when unicode is used as variable names

0.1 (2014-04-01)

  • Split of code from python-subgrid and openearthtools in general BMI wrapper.

Metadata

Release files for bmi-python 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bmi-python 0.3.0
File Size Uploaded Provenance Actions
bmi-python-0.3.0.tar.gz 35.4 kB Without provenance Details for bmi-python-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bmi-python 0.3.0
File Interpreter ABI Platform Actions
bmi_python-0.3.0-py2.py3-none-any.whl Python 3, Python 2 none any Details for bmi_python-0.3.0-py2.py3-none-any.whl

Total release size: 51.3 kB

Release files / bmi-python-0.3.0.tar.gz

Download URL bmi-python-0.3.0.tar.gz
Size 35.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f29e808f5cee3b8279510e10b45400489f8b5b1df3923c317cfdd72d564e9076
BLAKE2b-256 checksum
How to use checksums
b7c24e236917199983e416e2e0ed8281d80e4fdd521f02b2b115d2d9f6a5a0d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Release files / bmi_python-0.3.0-py2.py3-none-any.whl

Download URL bmi_python-0.3.0-py2.py3-none-any.whl
Size 15.9 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
d7207f522f69d260780bcc0e124725e2043cc2e537576d846633c164d915acc9
BLAKE2b-256 checksum
How to use checksums
194080cd4f42c9d3458305586ad36e977fa26c42d4f9e752898e2fd39a1f1a1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/3.6

Security for bmi-python 0.3.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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page