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.21.2.dev0.tar.gz (159.6 kB view details)

Uploaded Source

Built Distributions

threedigrid_builder-1.21.2.dev0-cp312-cp312-win_amd64.whl (629.8 kB view details)

Uploaded CPython 3.12 Windows x86-64

threedigrid_builder-1.21.2.dev0-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.21.2.dev0-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.21.2.dev0-cp311-cp311-win_amd64.whl (629.9 kB view details)

Uploaded CPython 3.11 Windows x86-64

threedigrid_builder-1.21.2.dev0-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.21.2.dev0-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.21.2.dev0-cp310-cp310-win_amd64.whl (631.3 kB view details)

Uploaded CPython 3.10 Windows x86-64

threedigrid_builder-1.21.2.dev0-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.21.2.dev0-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.21.2.dev0-cp39-cp39-win_amd64.whl (631.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

threedigrid_builder-1.21.2.dev0-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.21.2.dev0-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.21.2.dev0.tar.gz.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0.tar.gz
Algorithm Hash digest
SHA256 b245289153db8ebbad024eccf0063963383ad37912f5d22e0c42aebde3e2a901
MD5 a15a3968190692afc8cb121c9b2f144c
BLAKE2b-256 f4745b9bb44df005896f68894962f383e983648f4ea4a84bf68865ad217612c6

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 7d4277ec3302fc1ac24e3134df2e0a1c06db2807067138bb94d9656108453998
MD5 a527893e949a9ee3d57239db9e02217d
BLAKE2b-256 b25c8383b602addf301804d3de29d76bc1449b0b87879b4102bf7a3d4661d31c

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 eb18cefdaa2935b4df123de5a70cef6feb4131ef90ba5d3998f0f2eb5f818ba0
MD5 c57b931fae85002c6047a8b05fd2846e
BLAKE2b-256 f1eef6bf2bd5ba1abac415b262fec0dfb020e0ce300cceef8c04c91c80409920

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 756f3da1b267fa9cdd8c1512c317a3a4072ce22d49ab5c37ef5ffd2350462e7d
MD5 0e8462cd087f2ba2cbf0d3095e061474
BLAKE2b-256 e601b22ce51c2ef3df31c8fe906e084974d5bbc79069f7fce5a04353a4d26a35

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 e6ea8ddf842d891598ab01569cccbdfa00f2bf57ab483113202dd50ed303e718
MD5 a7d0b3866c9593b120716e8169815514
BLAKE2b-256 1f68d2569bd6c1b0b6941e38267837290de3665ed0e00ff6cd95517d5dd17dc0

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 196304cd302fc0a629f9bc991f284af78e390edf8bf3ce21a48bff5f664baa26
MD5 f6d329f9a9c7c09f11a6f473759e0dad
BLAKE2b-256 fba4b26b4913aa62a2c659e0f9dfa52019425beb822b15b2741fb7c28b696480

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d7b4541ca86085f985b2a8fea4d08502debd8d29151b86aff609781a69ec3c9f
MD5 56d564d0e4695faf83922ec3a1913b3c
BLAKE2b-256 4db1001330b6907b35259178f4dc2eb3c2d3232376f62cd73f2f63200b08cfab

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 b7ac4be65e6392ba211cbb9522ca31b3e648911f23bd3b514029b04a372986d4
MD5 f48889a5d57f371175ed6570b730149c
BLAKE2b-256 333cb98fdbcb071082effbf521296dd08a94586d3d1410ee6cacf105db919e5e

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a73fb13b481fd569884a78d9510ada78f2960fdd5cff5802e156d28a804f5212
MD5 7b28c8a54b6347240fc38fae9e4c82b7
BLAKE2b-256 4eca5963851e33491f8495b6e98a2525c8dc1e0f3d69ee9305507f987e199447

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 eeed41b39bab7676752b80a53051aabbfe2a5536a2d7fb4018445787bc4af0f6
MD5 9a45c6a6014817a46bd3efc9b55ee645
BLAKE2b-256 33d2005d1c9ca18349128ad068f91f331ea3988c9e9a58f9a83d88fd1e09795a

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 840a689a7674133e584f981a46d4ab77218851fa0565bb4b630b90c65d34455b
MD5 1f21687d3a29a2df33242286499d2c6a
BLAKE2b-256 c226180dfc5d979d17f0750109871ca8e3e40ff3b792219e2b8d938aeeb3e5ec

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 24a3e31940f060d40d1286a79aa0a0969d2293eb724148de91f2dc7b8104c449
MD5 9faf83563fd8b2d05186e449e4c941c3
BLAKE2b-256 769ef0038b8b0037cf909d742f10c247fe86fbab6666c0359d7fdc068ff1a1b4

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.21.2.dev0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2.dev0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 593e237cc7183f39dc171ef5ab866c32307c74a7bff838311479541c1441899c
MD5 d0d7acadf1d2b4e75c0b352f8cbd92db
BLAKE2b-256 7535968d6e44de9d149da05c25da84bc4c62b6643f4c66076b5c0ee4b301791c

See more details on using hashes here.

Supported by

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