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

Uploaded Source

Built Distributions

threedigrid_builder-1.22.0-cp312-cp312-win_amd64.whl (629.5 kB view details)

Uploaded CPython 3.12 Windows x86-64

threedigrid_builder-1.22.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.22.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.22.0-cp311-cp311-win_amd64.whl (629.5 kB view details)

Uploaded CPython 3.11 Windows x86-64

threedigrid_builder-1.22.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.22.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.22.0-cp310-cp310-win_amd64.whl (630.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

threedigrid_builder-1.22.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.22.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.22.0-cp39-cp39-win_amd64.whl (631.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

threedigrid_builder-1.22.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.22.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.22.0.tar.gz.

File metadata

  • Download URL: threedigrid_builder-1.22.0.tar.gz
  • Upload date:
  • Size: 159.5 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.22.0.tar.gz
Algorithm Hash digest
SHA256 8042edd1dc217071a4fc54a206a1050a69d22c3830e81934dbcb1bcd7837f144
MD5 66905a2603b1d4a3fcfb0371f1dc71d3
BLAKE2b-256 83cd67b406a845a743da313cc00778f1850680b6e355f0913e701b6925fcda90

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 79808fe7625978bf23f27836c4309260e08bd56d6eabe38c64b8fd170e0b31cb
MD5 7e72abd8b7430c6d80974c7ca6c8f01f
BLAKE2b-256 8dbaef258186d1292810930ebb00af10088e72e8d538b2b33d66d78cec034a54

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cde0a6b24508898dd297f933c2d6ede4b4085a6c8c1470b2a90d1a9a0d8b7ba4
MD5 e4127f7829232ac79426e3e3c0411159
BLAKE2b-256 e22d49a4d3c316c330f59be818d9e4c60471ea25dccd077fb691163000c29ffe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1cea00a8b7b26e36f8d29b726c64407fe822b49c2d113474d2e84fb61eccae57
MD5 f34915e78f788a1853f573fd97c4f89d
BLAKE2b-256 5d018f2de44e5765c45e28a1c9397726a776b170c2cdcb4c149025ee053fec11

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0c25836d3a476c4680f87f725c20752bb7bb400f50fdf335cdaaf6118e900a60
MD5 eb969d5444b1c3b084072076b33b4690
BLAKE2b-256 e4f0fb956ba2240c8cd0dfd2ff19ff704e6e8f99941f947618dc8ececa5b73c7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 49818afffdece48e195270638158ba181d248f146dc8b8eb02a6e4bacd3684c2
MD5 c68524cabcdf616d5d8a5f9b7567395c
BLAKE2b-256 5cf908e4c13085d58afc87e8f640ea5c9224e099afcef158013678b97a91c1db

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d46d6d852e524bfa2528862e34dc6e433167148fc9460d2c560a04ed696da48f
MD5 f0e0fe064f6fa89f571ca40678962eea
BLAKE2b-256 431d24bd7aabdf821fdae15763c4e5ccfb10e65d4d878016ad066f1129bdcc5b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 200db53521df817a6e42949301d8fa16537f5a1a12665e2369b16493d4740f56
MD5 8b360587cb37fe0f33ea56e118396546
BLAKE2b-256 db97d4bfb3c85f2d4ad2e603b2c4101d1a3f334dbbccef7c66cc1b0373f53a16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cd2343014e2bad556ade87eb9d192744d5b2f8d59a6eeca5dc2b4eefda87412c
MD5 c546ca63f677f4803940c1b69fea990e
BLAKE2b-256 bf23a48fac67c5c9365f4f0506dd59b9a0b777be263fb4e30eabfd86d4894987

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 92fb952ff163b3c2f5ed0acc22e585869713d9ae34e0459e0fd4496ecf8f701b
MD5 1e2d98e5a06c29b1781f2473664c3c72
BLAKE2b-256 c32df56389e262e3690172c7ecf3d1514969e98aff32c8d89659a43a0b10f841

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ca03e08f859b4700611b16889a28c5121e93f4a8b96d19ae8ac41642ee7eb65a
MD5 afad4282e981185bf73781959cdf22c7
BLAKE2b-256 712e0975136d8ef2fb98fb7d943f4b9ae9e7f88b2065a24123ab4e1e2dde6673

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 58cac2136d7a21638ba6aef44d486cd189f6d2b4133ef3ed675f8a554c64cc0e
MD5 7254215a3310ddd5a502a93fe6358706
BLAKE2b-256 b012b7b5bc8db371a4827ee90bae3b82c243d284373b821ce8a8ce98bd7cc10c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b7bd26def6eb1d1d5e59cdb4a54df163f5359db8151047f7524f554c76c1829e
MD5 bc9a13ee2634db86e3192020f46e206a
BLAKE2b-256 1e7da316d356ecfc9fb7bfa2eb977c26e1915be41fad17a8470e6931e7150e72

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