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

Uploaded Source

Built Distributions

threedigrid_builder-1.24.0-cp312-cp312-win_amd64.whl (628.9 kB view details)

Uploaded CPython 3.12 Windows x86-64

threedigrid_builder-1.24.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.24.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.24.0-cp311-cp311-win_amd64.whl (629.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

threedigrid_builder-1.24.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.24.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.24.0-cp310-cp310-win_amd64.whl (630.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

threedigrid_builder-1.24.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.24.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.24.0-cp39-cp39-win_amd64.whl (630.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

threedigrid_builder-1.24.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.24.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.24.0.tar.gz.

File metadata

  • Download URL: threedigrid_builder-1.24.0.tar.gz
  • Upload date:
  • Size: 159.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for threedigrid_builder-1.24.0.tar.gz
Algorithm Hash digest
SHA256 9e0e55f56956c02fa04f286ee94609a6383049ea08f0ded800212ffb72ec85fc
MD5 8e3f498157051a2ede2f891697ec9249
BLAKE2b-256 7d875fe09c80722485ab9c79eeff2f6ddc318d12b7c0f42b5c1e0262756b56d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 dbf0a4909d7d77d34e1db51c5e5c3baa2408b9e92ef8539a5f8f7f669ed08e10
MD5 fd3f8e06a2b99366ec64ec956fc2dfcf
BLAKE2b-256 9deb4f373b92089dbb7e8772b1a80f3e850b9e98dc15805c82449d46424d73de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e4fad6ddb127dc4b6557fd7fa88d15f1562b52a6de95ce047604191956b367a7
MD5 0f87453439e28a4df3643d2aea0ea853
BLAKE2b-256 f754d6beb88bf21298c36a1fc86f622026b568c9d39d6380cfdb0f419f745194

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 570168235f76f4c17dc749aa95a11f55e439ca62f5dca9f89adb4272f5d6e719
MD5 2ffefb067029b25e7bf4eed6222952e7
BLAKE2b-256 2c0e1e8db362c870ad2509bb630c90f9a644252a88bc7f63d0f12c4275f5bd2c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 3d343e59e9e125feb672679d4c3ca08acce86bf8009610d414904a41cbd0b114
MD5 1708cb445e77e393dc4caec251414190
BLAKE2b-256 0554e03e4302ec248af8f5b059f40392b4e3dd51d08d659a1301f38128cd438b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8ecbeddbd624fb9dffb97676e3b94db921d68d943477bf462d03b7cdd63ab803
MD5 5ec893bc0ccbd372d135e661a6c41c14
BLAKE2b-256 6dafd29eefc5fc466510aad2c3e5291fbcfbf23b7d4f6b034f562f78de4f6e19

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5e18c61da20cad2eb7fbb320cc83bc5da99833cc2c27434878aea267cca7fd2f
MD5 818d968cc893d61323e2aa0a97ef0640
BLAKE2b-256 ebf4109c7e10fae45807a327476c2e682fe649f7445310360c3abf1844974822

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 89d5f45315d94edaa26d6d5d0d7ee5e77d0aef01d6f2f0fad554ccfa5b7504c8
MD5 7ca1c60dca29026a7503ddd8483043d8
BLAKE2b-256 c970e516f6cabfb277d3ec46d386d341658d51660337640dd9295f57c7f2a388

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c9d2cf33e5791b910fb05a946fe4bf44ca5c731b5b504ef67e9a6e7c5988fb3d
MD5 0ba4debb2a35c4041f952fd87c87050d
BLAKE2b-256 10078cac304df78f158930282df9efacd17c13c53def91e674bac0346135419c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 28f74cb609cdb25f01984b350e24d0591c9d67cccaa40ab3c51f191d62969a2d
MD5 4e679f3da231e6bf3719e695921a1401
BLAKE2b-256 48771c2aa0b51e37ebe0f0f1149942d7be408b13af6cdfbaf7834da9ef8596b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5fa00e96623760fb3aebe25df51b3b878b317da750a40b97852f55ec546dff23
MD5 82d755e0b7c4868cee33d61d7e3b100f
BLAKE2b-256 31bf17962857bb5ccaab55837cba85dfa3d26bf94be1674582781dc4460fb0ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 cce345fa91c3d95e5c582e46f06f56755a6211c97d7348766eab95909d32b4f4
MD5 219e256093976f0733b2575c640bbd44
BLAKE2b-256 b778096789ce8b488efbedd889c0fb2c318f103cdfe0af38dad3aef67088ec5a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 993754eee658232a9d1b92cdd780cf8f71e7eda9aad494cd7c135b9a65da6c19
MD5 719f28376f9b713533684aeea8a222c3
BLAKE2b-256 720ff3e3d64edd647bac80e36f4026324cb6a1a10178080b8fe8b73fc9f2411f

See more details on using hashes here.

Supported by

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