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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.12 Windows x86-64

threedigrid_builder-1.24.2-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.24.2-cp312-cp312-macosx_14_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

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

Uploaded CPython 3.11 Windows x86-64

threedigrid_builder-1.24.2-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.24.2-cp311-cp311-macosx_14_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

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

Uploaded CPython 3.10 Windows x86-64

threedigrid_builder-1.24.2-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.24.2-cp310-cp310-macosx_14_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10 macOS 14.0+ ARM64

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

Uploaded CPython 3.9 Windows x86-64

threedigrid_builder-1.24.2-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.24.2-cp39-cp39-macosx_14_0_arm64.whl (999.6 kB view details)

Uploaded CPython 3.9 macOS 14.0+ ARM64

File details

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

File metadata

  • Download URL: threedigrid_builder-1.24.2.tar.gz
  • Upload date:
  • Size: 159.3 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.2.tar.gz
Algorithm Hash digest
SHA256 4cd8c5360a590eb91deeb208623cb50f0129290c066615f4e039b06aea7546da
MD5 4ddee1481c9b4f840dd3d8765473cbcc
BLAKE2b-256 70b8cc78f9dd5f8c982b064e6379ea9ff73d18095cb4f6721e2856bf06a0c347

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6472ac0da629f1a7c5978b778cd5bf9290adb120277064b30586b5a451715535
MD5 908ee5db492a0474db48440df42c4dce
BLAKE2b-256 0c61b039a9c4b1c4e42bdc87123cd294d2017c3dd403dad754e8a1f01a94f24e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2e46116a2e1c217f7c01c2688eab22f4a9487e7e80840aad6f0f63405e6cad76
MD5 c4d77a3d91c0b9de7beedcce988af802
BLAKE2b-256 6bda2cd841ffbc12ab6622d9a6da2aee62a79b1d8e1ed13558d0441a548fe486

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 13680fe573cbac7e7d1135812add28c2d7b8404fd55dfe99288df78b793cf710
MD5 635802c324129ed5639538d954760a89
BLAKE2b-256 b9173143a1ab2920702cfd8d4d95e716b36b52dd8a4b2a235b702b69850579ad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 efbce0f088e570015ad2013d94dff4f03995202b9579ecd7c167515af55315d2
MD5 c71733a06fc7044857c32cfa05796d19
BLAKE2b-256 bc03568bde1388f3b8379c00cea87b9a7b3ce2640fc4d581a02ecd30c8fc4133

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7e757a826525e24d6f3983a8a81ff6f596d3eec9e7b1e82a372fe6e14d161d79
MD5 1bba821fda090ee6047f6ed9c0ae8ce3
BLAKE2b-256 f09eae44ffa57b5b987641daa863ecbe1ba63142c5205cb466f459617454f07f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ea8506546bda5e00f063d34d97f5e9b2c0c8539590892289e2a59cf5c3e3debe
MD5 5cbe4178455aa0797543b5db6aaab473
BLAKE2b-256 b56b922eed9869ad72e41c614ce84d61edb1ab2485c5d7de9dde67b67859c61b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f5417b2fd0448c02394a32bf72692709fa2fa2e39861a8cf9966dad05e451ee3
MD5 a59d1199d5a09d862a53133a6328e50e
BLAKE2b-256 c88d2c2a7a2f092650ef899074d966453cee834c6b0c7757d20106420f11bd1f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c958eddd4138d08dd36062bc948c018137159648d9f096ad4be33fce8bd463b1
MD5 408053b6c36119c326faff9c2740af65
BLAKE2b-256 c108198c754d41ef2f45a10138504169a02dd2964bef65f87eb3f2a69def31a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3f40a0f923e5c02694d00a2e086875a747d6bce69b053c0f384543e048211c9b
MD5 c87a3be68325475aa8702bd71e789aec
BLAKE2b-256 d94acfffaacb97c19dd3eb9eab193316a6536aaa4b787d262e3457afc1c53172

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a64ea282ec5ec58aa4a099f215971bfebc3c00d6c9fbe984b84f481a16ddef10
MD5 7993c4f4d19767173d7f4734b0678e86
BLAKE2b-256 7fe3c4d7226a704bbd525d913340c64f9cd8709fab00000e82d9f85a1c57697f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c8bdf41865879cf7f5e9a150dd5f4d68387cc9a8bba19be8af4564dfcd7d6095
MD5 88db0630dfcf9b89d1f9fb4aa116ca6e
BLAKE2b-256 c2b30bf4853f2cb9aef792ba65285d076813108987436ed05f09376269eb12b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.2-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3c86b41d6be35e2cb0a71600e11e172b0d17dd4eff4a1eef223fb9cd48f9d3fa
MD5 51dd4d931c9fec39dede473bef892765
BLAKE2b-256 a93312a93d17b3744e29a8a817cba054af5d3bd1e028f9ecfe8ba174bab45e68

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