Skip to main content

Generate a 3Di simulation grid from a model schematisation.

Project description

Github Actions status PyPI

Generate a 3Di simulation grid from a model schematisation.

Usage

This library converts a model schematisation to a 3Di simulation grid. This can be done using a single function that reads data from an SQLite and TIFF and then outputs the generated grid into a Geopackage or HDF5 file:

>>> from threedigrid_builder import make_gridadmin
>>> sqlite_path = "/path/to/model.sqlite"
>>> dem_path = "/path/to/dem.tiff"
>>> out_path = "grid.gpkg"  # or "something.h5" for HDF5 output
>>> make_gridadmin(sqlite_path, dem_path, out_path)

Alternatively, the generated grid can be output in-memory:

>>> make_gridadmin(sqlite_path, dem_path)
{'nodes': {'id': array([   1,    2,    3, ..., 7903, 7904, 7905], dtype=int32), ...}

Installation

This package is distributed as source and binary wheels on PyPI. The currently supported platforms are Windows, Linux, and OSX, all 64 bit versions only.

First install sqlite and spatialite libraries, e.g. on Ubuntu:

$ sudo apt-get install sqlite3 libsqlite3-mod-spatialite

For raster input, GDAL is required to be present. We omitted these from the dependencies because installation of GDAL depends on your platform an on your personal perference. One option is to install gdal using apt-get, and then pygdal with a matching version:

$ sudo apt-get libgdal-dev $ pip install pygdal=={your gdal version}.*

The current platform version of GDAL can be retrieved by:

$ gdalinfo –version

Install the threedigrid-builder:

$ pip install threedigrid-builder

For output into a file for the 3Di calculationcore, enable gridadmin output:

$ pip install threedigrid-builder[gridadmin]

For output into Geopackage for display in e.g. QGis, enable gpkg output:

$ pip install threedigrid-builder[gpkg]

The command line interface requires Typer:

$ pip install threedigrid-builder[cli]

Development

Clone the repo and fetch the LFS objects:

$ git lfs fetch origin refs/remotes/origin/master

Install the build tools:

$ sudo apt install cmake gfortran

Install platform dependencies:

$ sudo apt-get update && sudo apt-get install --yes --no-install-recommends libgdal-dev sqlite3 libsqlite3-mod-spatialite

Create and activate a virtual environment:

$ python -m venv ./venv
$ source ./venv/bin/activate

Install the dependencies. For your distribution, check the dependency matrix in .github/workflows/test.yml. For example, for Python 3.10 with numpy 1:

$ pip install --upgrade pip wheel scikit-build
$ pip install setuptools==63.*
$ pip install numpy==1.23.*
$ pip install -e .[test,gridadmin] --no-build-isolation h5py==3.7.* sqlalchemy==1.4.40 shapely==2.0.* pyproj==3.4.* "pygdal==$(gdal-config --version).*"

In case the Fortan code needs to be recompiled:

$ python setup.py develop

Now you should be able to run the tests:

$ pytest
$ pytest integration_tests

For VSCode, optionally select the python interpreter corresponding to the virtual environment.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

threedigrid_builder-1.24.4.tar.gz (159.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

threedigrid_builder-1.24.4-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12Windows x86-64

threedigrid_builder-1.24.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

threedigrid_builder-1.24.4-cp312-cp312-macosx_14_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12macOS 14.0+ ARM64

threedigrid_builder-1.24.4-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11Windows x86-64

threedigrid_builder-1.24.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

threedigrid_builder-1.24.4-cp311-cp311-macosx_14_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.11macOS 14.0+ ARM64

threedigrid_builder-1.24.4-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10Windows x86-64

threedigrid_builder-1.24.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

threedigrid_builder-1.24.4-cp310-cp310-macosx_14_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10macOS 14.0+ ARM64

threedigrid_builder-1.24.4-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9Windows x86-64

threedigrid_builder-1.24.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

threedigrid_builder-1.24.4-cp39-cp39-macosx_14_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.9macOS 14.0+ ARM64

File details

Details for the file threedigrid_builder-1.24.4.tar.gz.

File metadata

  • Download URL: threedigrid_builder-1.24.4.tar.gz
  • Upload date:
  • Size: 159.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for threedigrid_builder-1.24.4.tar.gz
Algorithm Hash digest
SHA256 5bb75258f577789f161cf9a9870453b2d5d334d6407693d8ac4e9089414c6fe7
MD5 f90ac991a4ac0df176c90d4430dcfcc6
BLAKE2b-256 529bbfdbef0f7b1b5aeae5e49972ac898d9eab8203da212f1fa9d87722bc082a

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 817c48c6d73e03e1a26384368e03e1ca3df06d873382e46fba72061ef9fea15b
MD5 40f0d0d86f6d7965e830f1e935eb6633
BLAKE2b-256 d13e489588fbaeae78afc7f89d36c6aece886798af053c443f89c4ed2efd4747

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a91610f9468ff722c416c65e490f0f16d386c1d6a89bbd71dc13f62876b62d24
MD5 60612d26758b5ae1f3a99177e7a8e89b
BLAKE2b-256 dc5a0432ceb103311195ed06af88ad0c8bfd74d7e945dad1af6b552b19b7d968

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 39bcbbaae1077e4d1f0902a4360fe2221b23c6a4ae4b71e132def98081f05428
MD5 7bc97af472369e009a671364bd220e6f
BLAKE2b-256 7181305ebcfc1979e63f9376cd7e6a403de63ed75dae7612ed1750f06c765eeb

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 692ea630c21bcd40f7d16991916a452c6e64f117d4b837c4b7cbc2db111a328f
MD5 fe0afb573f770a27219fb5a8cca4d78d
BLAKE2b-256 ae102addaf916cf7e21c0fd6196bc7d18e46b0456def584e13eff6b09657890b

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c23ba0fcb79c464d907d5f811fb342b2a67b6438b1258a4462ade8a98a1ec95c
MD5 c9adca1d89afe3edc3f46d064cc33896
BLAKE2b-256 0a22ade193f8ac1998d99b9c58e81910228c972a60d4f2871349aeb8e3142f22

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ccc4d827c779814cc6f85c1b411a07b3bd67775873ec7fbd70c25324853c876d
MD5 fc3b5a9ae89fdec54b196876f83e4e98
BLAKE2b-256 affc556b2ab3bea2fa85dc055e1cbeecdf8b47ec966ef9e1b845582c33abe441

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 a39cf49a6724b0da8b760ef4bdc6c0bd76750c5b96820e785f003b6017513367
MD5 d7ceabb71dc900ec4dc20f2f5df8e033
BLAKE2b-256 da7023fcc10ec7b0eed1b4d06e70c91729b4d73fa6dbf63dd616f20f444595dc

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8791a7131ab111ebc6151dd38a58c26a5f8e1838c412207236aaa86320362824
MD5 108c65bf55f71771fcdb8eac706fd6ff
BLAKE2b-256 745295cd207b1240041973158341c12a684c148fab4456b7e6d41f2e45f655a0

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 eeee3096ed3c27db1fde5ed4709e549590d16775c048ceea644436adff3f8922
MD5 d053701da10085136d01d100fb092d45
BLAKE2b-256 494b4b28b9ef8bc436034e3bc79e8cba343d2dc361b6d0b1e05f6ff25f31eed7

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 048389dc3df9f51a425d95c1ae9bfb3bb0969604ea6932318719d56f29c4e8c0
MD5 c2c40175035ec29b0dcd304e32c058d6
BLAKE2b-256 ee8bd52dae27f0d63e894738adea297bb600668277941d460c5185a8ec978632

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1cea0d97e479de53b36905c58b9821afb86f102b57c83c93f5b5d430010d0f33
MD5 d0f692c41e2d9a6f5863ba4d93d99f53
BLAKE2b-256 cb95c7e8ca248d2b9c0a7730b3780d83bcef74cbb062f5b451ec6c76dec8babf

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.4-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.4-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 853b2db1017a57dc47e88186fc28194178168305c7665f17d8752149f102ca05
MD5 44fb4841e1fa104f83bd48ca65b4e759
BLAKE2b-256 2d676c8ffadc0dea8528cd8ff50af90d407bb0e0bbb36a077a45e4863589b4fa

See more details on using hashes here.

Supported by

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