Skip to main content

Python distribution of mHM with bindings.

Project description

mHM - Python bindings

[TOC]

Python bindings to control mHM.

The wrapper (mhm/wrapper.f90) is just a small layer on top of the interfaces provided by mHM to be compatible with f2py.

Installation

There is a PyPI package to install the latest release:

pip install mhm

Installing the mHM Python package will provide the mhm command to execute mHM the traditional way.

In order to compile the Python bindings from scratch you need:

  1. Python with version at least v3.8 and pip
  2. a Fortran, a C and a C++ compiler (set the environment variables FC (and F77), CC and CXX accordingly). In case of gcc, this could look like:
    export FC="gfortran"
    export F77="gfortran"
    export CC="gcc"
    export CXX="g++"
    
  3. NetCDF-Fortran installed in your system path

See the Compilation instructions for these dependencies.

You can also use a conda environment (set up with miniforge for example) to get everything:

conda install -y pip netcdf-fortran fortran-compiler c-compiler cxx-compiler

To compile everything after cloning/downloading, you can use pip:

pip install -v .

To install it directly from the git repository you can type:

pip install -v git+https://git.ufz.de/mhm/mhm.git

Environment variables

The following environment variables can be used to control the compilation and installation of the python bindings for mHM:

  • SKBUILD_CMAKE_BUILD_TYPE=[Release|Debug]: build type for the mhm library (default: Release)
  • MHM_BUILD_FORCES_PATH=<path>: custom path to forces source dir (default: None)
  • MHM_BUILD_PARALLEL=[0|1]: whether to use OpenMP with mHM (default: 0)

Test domain download tool

Together with the Python bindings comes a command line script to download the test domains:

mhm-download --verbose --branch develop --domain 1 --path mhm_domain/

You can then run mHM on this test domain with:

mhm mhm_domain/

You can get help on how to use this script with mhm-download -h:

$ mhm-download -h
usage: mhm-download [-h] [-V] [-v] [-b BRANCH] [-d {1,2}] [-p PATH]

Download tool to retrieve the test domains for mHM.

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         display version information
  -v, --verbose         be verbose (default: False)
  -b BRANCH, --branch BRANCH
                        branch, tag, or commit of the mHM repository to take the test domain from,
                        by default tag determined from the mHM version (default: None)
  -d {1,2}, --domain {1,2}
                        test domain '1' or '2' (default: 1)
  -p PATH, --path PATH  destination path for the downloaded folder,
                        by default the original folder name in the current directory (default: None)

Within python scripts, you can use this tool with mhm.download_test. See below for examples.

Documentation

See mhm.tools and wrapper.f90 for further information on the provided routines.

Examples

If you have cloned the repository, you can do the following to simply run mhm without optimization:

import mhm

# download test domain 1
mhm.download_test(path="example_domain")
# run the downloaded example
mhm.model.init(cwd="example_domain")
mhm.model.run()
mhm.model.finalize()

Or you can do the following to control each timestep:

import mhm

# assuming to run from the mhm repo root
mhm.model.init()
mhm.run.prepare()
ndomians = mhm.run.get_ndomains()
for i in range(1, ndomians + 1):
    mhm.run.prepare_domain(domain=i) # 0 by default
    while not mhm.run.finished():
        mhm.run.do_time_step()
        mhm.run.write_output()
    mhm.run.finalize_domain()
mhm.run.finalize()
mhm.model.finalize()

See also the examples folder.

License

LGPLv3 (c) 2005-2023 mHM-Developers

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mhm-5.13.1.tar.gz (699.7 kB view details)

Uploaded Source

Built Distributions

mhm-5.13.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

mhm-5.13.1-cp311-cp311-macosx_10_9_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

mhm-5.13.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

mhm-5.13.1-cp310-cp310-macosx_10_9_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

mhm-5.13.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

mhm-5.13.1-cp39-cp39-macosx_10_9_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

mhm-5.13.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

mhm-5.13.1-cp38-cp38-macosx_10_9_x86_64.whl (5.2 MB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

Details for the file mhm-5.13.1.tar.gz.

File metadata

  • Download URL: mhm-5.13.1.tar.gz
  • Upload date:
  • Size: 699.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mhm-5.13.1.tar.gz
Algorithm Hash digest
SHA256 acd61f906a6c66b0bee71a22d14b5574ad6aa952b626d7b77e65384928823a24
MD5 a0cdf6c334968c458eb10e96afa032d6
BLAKE2b-256 d235fdb0dd51e92dcc3c23926e0f5da52074df8f0a72ce560b34c442f1609ac6

See more details on using hashes here.

File details

Details for the file mhm-5.13.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mhm-5.13.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ed1748f468e517baa60283f2343ac44259ddcb5920b45f5e26d0bd63dca1b1aa
MD5 49b6c0ed7f1d92bd0c0355658f8f102e
BLAKE2b-256 a064191daff97f4c1e356636984dbca7d42141199e9beae22f85af5c56f4c513

See more details on using hashes here.

File details

Details for the file mhm-5.13.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for mhm-5.13.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1a6521268df250bc843d12e5895ef9828e58c8c8a93a292041ba1d3aa60a0ca8
MD5 8f1572859397b181d4e24916b0f26c93
BLAKE2b-256 ce580500d3c2f80b597ff56f1a69c5a9e0db8c860fdbdb44eb81daab8f2d9642

See more details on using hashes here.

File details

Details for the file mhm-5.13.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mhm-5.13.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f917039d19f76c2425b9dd821a97d42f927a139895fbb7da0a16dd328360cf9c
MD5 d855a04f592b0da7c3347bf642218edc
BLAKE2b-256 f1480e42889157704c1d4cfd60467bec094077d0c75a38eeaa1dc6223ef1feb3

See more details on using hashes here.

File details

Details for the file mhm-5.13.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for mhm-5.13.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 33435a33187ffecf4b96300b8acac398aa2b8dff55f639eb59f5e18e8b89793c
MD5 3fbb705a0c1085de14a679f083d32a02
BLAKE2b-256 ad4794519329dc7e231b1153a13a141057fc9d4506e6b5e56ae7593a8cc0735d

See more details on using hashes here.

File details

Details for the file mhm-5.13.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mhm-5.13.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 93d91be1545c40a50d28acf37af9800d96ea8023c281a642009ac4d24c782e26
MD5 5e757b8006e432202a723cfd862ea6c7
BLAKE2b-256 f8ad3c242212ddef8b7011c31e03e19edf0100b999105e4219b5341ac14b803e

See more details on using hashes here.

File details

Details for the file mhm-5.13.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for mhm-5.13.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d5214d845bfe7b7627280eb20bfd1425f38fb456c418eb471fbdf52516e78de8
MD5 0acd9943685a10b4b2289b21743ff738
BLAKE2b-256 bac142451782539fd987670ad4148a564b6c91de1cf73c7bd60419b6938d501b

See more details on using hashes here.

File details

Details for the file mhm-5.13.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for mhm-5.13.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 da7010489ebc5f9c9439ecb08b91c68988d1eb8d1504d08d484ff6d90087fbb2
MD5 61349ff543217581653194a8eb37fdec
BLAKE2b-256 5835a92312a1d23507efa960acd388289943764e67c6a31b0d354c28a1e1a040

See more details on using hashes here.

File details

Details for the file mhm-5.13.1-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for mhm-5.13.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 222a962c5369b4c8d97bc451f8c962b894e19f5503ff27839fb54863772f4fae
MD5 63fba96f10324b8c8decb3cde0f1c33f
BLAKE2b-256 03578b53356715d3d14b172cb1e1af3181b699be3494aa13d471fae3a63f372b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page