Giter Club home page Giter Club logo

bmi-python's Introduction

Python wrapper for BMI models

This is ctypes wrapper for BMI models.

The BMI describes a low level interface for numerical models.

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
# 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 :meth:`start` and :meth:`stop` yourself and using the :attr:`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>

Links

bmi-python's People

Contributors

gena avatar siggyf avatar

Watchers

Mischa Jansen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.