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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.12 Windows x86-64

threedigrid_builder-1.22.1-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.1-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.1-cp311-cp311-win_amd64.whl (629.5 kB view details)

Uploaded CPython 3.11 Windows x86-64

threedigrid_builder-1.22.1-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.1-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.1-cp310-cp310-win_amd64.whl (630.9 kB view details)

Uploaded CPython 3.10 Windows x86-64

threedigrid_builder-1.22.1-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.1-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.1-cp39-cp39-win_amd64.whl (631.3 kB view details)

Uploaded CPython 3.9 Windows x86-64

threedigrid_builder-1.22.1-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.1-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.1.tar.gz.

File metadata

  • Download URL: threedigrid_builder-1.22.1.tar.gz
  • Upload date:
  • Size: 159.7 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.1.tar.gz
Algorithm Hash digest
SHA256 22935a351df0175b962ff1e114c16979e9889df785d716c4235b281154368d34
MD5 10a3908497ec6d14205be6d2b7ea45d1
BLAKE2b-256 db32959939b84d2eb480c834a6ea669b2eb89c10e65c9b29d822f80bcc4b1724

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 b2fa4651475d1a939405e79d98348400a25625bf1f173035fbd1713380423514
MD5 85d1e88d568bb07429478698e4c5784f
BLAKE2b-256 778be109114f0ef9455391507bbf5143c019df4087ee5c13d86bf044f361f173

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 80b71689f432940648275690d604cb091b7c0769e00bb1b80226d2480c77bf6e
MD5 23d7ece9ca2c58a4571dca79e4d61387
BLAKE2b-256 904deb8619c8c206d55335de082771db4fd074454711942476096e34c83f322c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 53ce28661a4892aba2c6ba272372dbf8636ee18ef3fad47e7c63e7848ee4dce0
MD5 4feb0c350fdef00da8f5155868365fce
BLAKE2b-256 7eb0d6be639ebd41325f7e572e8731b69c5fa8a8e6b88040059b497add9f5e9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 5e8e5d3e7640b2375d9b99835b9cb601056401c7cde246bfeb30d3829370266f
MD5 a814da8e57bfcda43b8f13819bd78b40
BLAKE2b-256 2019cc18d129d1dfe8b298b7c31a6b0e70a34d0ead342dbd0807ef1a5c5de7d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 0defcadbb20c0df13e34fa439dfada6a49db30c3217c76bd323cb7199f8ff6bf
MD5 4953f3871e542d35cee36096a1591548
BLAKE2b-256 a169243f3bb2a42b5a2451b91915dfeb70395f0fe6372198e78b9732d0b93b41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f75fe3179fe0cc7800587f37a434c5a4e90dd4a2195fd725bd55b5fe4a68b245
MD5 9fe249931eeae25def8a3a542ccad7c8
BLAKE2b-256 2255ae389123835b3302322b585f83e81e8e8e985004bf0b01c72ae4988bc931

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f7ebca3b8232abf2ed4b6e0dd790b76de8d48891ad57d2a6065f684efe7f8477
MD5 c2e1da4d8759444142c0a976a26fb2d9
BLAKE2b-256 0a502e646debc3fa544ca70c2d9b134e772305c73e36e02ccfb6c24eb4f8e130

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a5fad972d3cea5bb6132e0e7a0dfa73142022ed87b4ea7970dc9567f1f29e1aa
MD5 f7992f012188f16044b96593d38bf4f8
BLAKE2b-256 7c6721df325b11626aa8be3cc0612b007c8dd90bfe1ae65375328bdff5a28cd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2fa63c9c1bbe7cd2e5a2bc72016c0c26502679f3e0d11f2c585c4c4c0792a400
MD5 9a318e3d2d6279aa36acbd8f264b03e3
BLAKE2b-256 c1384e2e59eefabed00dc2765868b4cc8eef96de536ed27761c4158c5b6c9290

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 e678031b200ac36afd1c93738dcc79740ecb96a702f55f343ddc5de3eea62026
MD5 c5efafde3cc1fc1b7458a238484306e9
BLAKE2b-256 692081c547c10cd5be0976244fd50251b59bce68e15c8f236049779330d4c67a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f5fc70711557e85b622ee4eb5138fdc63ed2162d935646a262356310e994da73
MD5 7a527759ada1144117c176ec247f4b18
BLAKE2b-256 07723757d9007539701027279ceb02175e549bbb82f21d275de7d5add65c34e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.22.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 af311d769587ba9086327207da749347cd061129de35ec98154f26aa59049ae6
MD5 f83c6db335c29712866df64970d20677
BLAKE2b-256 196a81e2975f1ba1029a36ddf5ab1471a57b1b50f0dcc630ab967bab55beb250

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