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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.12 Windows x86-64

threedigrid_builder-1.21.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.21.2-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-cp311-cp311-win_amd64.whl (629.6 kB view details)

Uploaded CPython 3.11 Windows x86-64

threedigrid_builder-1.21.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.21.2-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-cp310-cp310-win_amd64.whl (631.1 kB view details)

Uploaded CPython 3.10 Windows x86-64

threedigrid_builder-1.21.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.21.2-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-cp39-cp39-win_amd64.whl (631.4 kB view details)

Uploaded CPython 3.9 Windows x86-64

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

File metadata

  • Download URL: threedigrid_builder-1.21.2.tar.gz
  • Upload date:
  • Size: 159.6 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.21.2.tar.gz
Algorithm Hash digest
SHA256 e7671d06665f7c410fb5f25ee24fb971b9af6ad029df21e76832d6ebfdfdff2a
MD5 ae788561a9c97639df69d9b681697848
BLAKE2b-256 7f5d9656bb250fdc9f5b72532e12a4f5236e482977647f40b37f1880b81ef578

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 35d804935fc2745c0bde4efc7b3bf149ab3d487ab6509b07db917d75aa76114e
MD5 4cb64168bd0dd602cdf89264683935f4
BLAKE2b-256 8ff0b4801c9a45f0515848d31f2d798f47cc20f9cb7ee0b193a405f66bf68222

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8af22fff601abe502283d08e3315512e75ccf78d9be8b0924a6353bca6e272f3
MD5 a7b577d56a7f158833590ba3115e7db1
BLAKE2b-256 2018391b33efdb12dba8c65503a92ef247f78f6dd3f35c76c160184a3a23d15c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9801f481d5b5e8721bcece17a4a072a5a060d5b8cac4b1f047722b3a07abc056
MD5 ea6d71d63349565c9923443e91d25707
BLAKE2b-256 2df5a6c025836f17817566a3f839c6642fabc994da289aac728bc3adf37197c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 914bece0be8a73a01bd9e238009a538a0e7798d4cab6ab35e475bea52c27d4c6
MD5 b3ebb9d13f1ace978c415007485a8a01
BLAKE2b-256 48e6137641113ac379457a65cd92f5b81873842068b2729dc2380154a786df66

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f3b69182163442d8a63c296d0a3f0ba3120951b73d8c141d61680c780dfd3985
MD5 8af93b6c66980f456b651a84b9986f38
BLAKE2b-256 b1965d8abc210f6f022213fca33e89532234dc227a85ec9c34ef868fa9970286

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4baaec0eaa59e6d74ab52c4e124b1585855bbf2f35deed9ea2a89b435db0b3e7
MD5 235ca7275733e6d0b04d0f5df0a78baa
BLAKE2b-256 a7c8d832eb63589d0e1c8aa20648ba45efd4518226088593eb36eea2d319e355

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 33dfab708702435e5458b6fd8b134c8bfcf806311450fffb8cdd2cf415ec6733
MD5 e114cf68addfe15717825cf040886b2e
BLAKE2b-256 87c0c14b757fefc0b21eaa141a40c9f769d9c36065a5731d1a2ce878ce25883e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 652275e4836ff0b29f58430fac7d804590f91681f052eea9a69c78b5dc13d537
MD5 0f731fda65c4b4c551da0d9566aba941
BLAKE2b-256 5e592719bac148fad1da85907bf4f590d4ac180e737a5b511bc90a1b45fa2928

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bb04a64de724d14a1dbd3991f35db4f75cadccca450ebe584e135108019e670c
MD5 8b68d28a2b3e62a27a9257b185bf36e6
BLAKE2b-256 e4719746491f72053d7d9f224f5f427dbf78deb22c4c87c15729af9c2fca6483

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 f38a252feab026d7408f688839bd43bcd8909f6236f453cda4ea430bc7d93fce
MD5 77c00cc2320ce734f5d7b31c288af997
BLAKE2b-256 119b1de4621967f6baaf1411f090ba81d0f09743b8a8c04815f413128efcd13f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c7287beb724b2d7556386cfe02b54647a1347173d13ccdae067be451c26effd9
MD5 41c3072d1e2f2fc85206ea741468e3f2
BLAKE2b-256 44e0a6537d2c46c9e8e7711c891378d5ad05b019d1bcce970eb09007ceeec096

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9088c765bf98a85589902e7ad28af62f64cc136b4a440ad340a3abb79bd577b3
MD5 9b772afbf2b46e3056ff0a7e52e5af14
BLAKE2b-256 efadb66eff8018b134459294eb9add8b4ebb7e71a6f56b92055258fbdd63cb80

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