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.23.0.tar.gz (159.2 kB view details)

Uploaded Source

Built Distributions

threedigrid_builder-1.23.0-cp312-cp312-win_amd64.whl (628.9 kB view details)

Uploaded CPython 3.12 Windows x86-64

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

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

threedigrid_builder-1.23.0-cp312-cp312-macosx_10_9_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

threedigrid_builder-1.23.0-cp311-cp311-win_amd64.whl (628.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

threedigrid_builder-1.23.0-cp311-cp311-macosx_10_9_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

threedigrid_builder-1.23.0-cp310-cp310-win_amd64.whl (630.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

threedigrid_builder-1.23.0-cp310-cp310-macosx_10_9_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

threedigrid_builder-1.23.0-cp39-cp39-win_amd64.whl (630.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

threedigrid_builder-1.23.0-cp39-cp39-macosx_10_9_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: threedigrid_builder-1.23.0.tar.gz
  • Upload date:
  • Size: 159.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for threedigrid_builder-1.23.0.tar.gz
Algorithm Hash digest
SHA256 b5aa699347aeb28c918cfd09ef80d4c4b473d9f2183892811a377165312b2d46
MD5 51ffbe50aca3ae1af79eaa34d22ba17f
BLAKE2b-256 6ec78d24caf81377b4904647cde78f2b6b2d065099c7a144e946286c42f780b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1e678a7ced22b5f9e4ffe154863eb6b17587736f55f92b9addfea7d9cee60098
MD5 ab0d5ec1e981e9092d28799ba99a5b39
BLAKE2b-256 7dc9b652c8a06da90c83e8f44187fb40f39d802f021c1bab80a54dfb8d321202

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b1ab0eb9f6423940082c7ad8aef5b95ca6308a2de3a58a3b0f7686fc1b4b484a
MD5 1dee3d654b730d0dae9615cbad03f8fd
BLAKE2b-256 ffdfd79027fe158f2fdb62fbf480708ad67562ed126d1adb5ca687db66557cef

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.23.0-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 54d8100d434cf3268d5de964b8c7a9710ffd38e8c70263ae1f07b049e49515b4
MD5 c8e54bc12c8519be7414d7e61a6101e8
BLAKE2b-256 6ec183d427a3f7d4d98d425b8297f000bbeef63f6aabf292aa309350fc4620b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ef4f487a719476373f114430836782d869267b9523304013ff530ea80934f31a
MD5 d03e5ab624c71087bdf21e5585ac4914
BLAKE2b-256 2fae3c979e98c874bc3d079e39084a34f07151e6aab4e0e1651fffb64bee532e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0f8002d87098c616295e2149ee83060d3ff50205b922742be85c4b0713b4fd2a
MD5 db07d279092254e073c97add9d7b7fc3
BLAKE2b-256 a0fac44a71d2170d8d6b8cacf6466079271c4eb50bca7039152143a70fc088b8

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.23.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e1a0b5b72654e22fea046be8b984e0d945d494ed18ffab701c2fed3a1993cae5
MD5 e32bbbb1252e47ddccffbd9e0d07334f
BLAKE2b-256 583a3b498240a0e587d2926d0ca2efb770e6321bb5ed264384725a98eae9e883

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 9b366c62f12db383b428be2fe86a502f18697e2ed8b97f6dce2b76ed83fbe7ec
MD5 f7183a5500efaeb9e040712a538c82e3
BLAKE2b-256 d54125fb03b23ce99798984d5aae4f411ce66a559a5ff546bbb579c75bee127b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4febdfe951e43a9b41a5e9d83993b5bcea0d07ad9d3279662b5f0225fa3cc18e
MD5 914c1ff9dcff87862535e43c5ec51cdc
BLAKE2b-256 24ed480259f55edd8b8c32154c9d0f2be54de54292eb866eae945e73e30a8014

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.23.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 002b6e375d909dd92fd90481c87630b78b3e8830f7284ad1e24842f36cf76cfa
MD5 c8a3011eebe7a627c01916f892b8b9fc
BLAKE2b-256 fc8c998151c6071e5143589368c1ca38f4adf22725dc51be0e2421122d2adb04

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 760e283238a15e3abda2dc6e69826f0b066b6e6117f0a2e49b6fe0e715816519
MD5 63a18c91987ce538adce3653a130cdda
BLAKE2b-256 9472dcc484bc841f65668fb31f7aa10c875dea55331c0dfc639307c802c143d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c1ba2d406f47ce3822259a6717504fee2251a771e31f48f701ff8e7b5acb694e
MD5 a14d5e4aff3c28cbfb33cd0a1d26eb0b
BLAKE2b-256 b08facf23a84469ffcfd074e057b36309f5d23b3b2c363ad0220d8a01b7b7969

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.23.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.23.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3e1f5b59f937770d1a22586727468ced73168b12ab0e234ce707b2600d0fc802
MD5 f1609a2a0217a79dc76bdd70e76260bc
BLAKE2b-256 d272052e4ad9982179d386442eac8a0f0f0fbc86012753ed0993cb5bfdea7c29

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page