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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.12 Windows x86-64

threedigrid_builder-1.23.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.23.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.23.1-cp311-cp311-win_amd64.whl (629.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

threedigrid_builder-1.23.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.23.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.23.1-cp310-cp310-win_amd64.whl (630.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

threedigrid_builder-1.23.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.23.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.23.1-cp39-cp39-win_amd64.whl (630.7 kB view details)

Uploaded CPython 3.9 Windows x86-64

threedigrid_builder-1.23.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.23.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.23.1.tar.gz.

File metadata

  • Download URL: threedigrid_builder-1.23.1.tar.gz
  • Upload date:
  • Size: 159.1 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.23.1.tar.gz
Algorithm Hash digest
SHA256 5944cb5a26a8688aced9b57ec36b3ea4e3bc7c6065458a206949761e7e0a002d
MD5 d94234205eda2809658dba1853d9b391
BLAKE2b-256 9dc52cce032f915facc67121235307c8810b4fbb4b04806ac319a0bd9ea17f22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 f880df6e36a9fed60177c845585ed50e6848895dbb8cc7e58b4c3ee050b9a307
MD5 f06e9fd131a0e600d265ac8a37e9fdf9
BLAKE2b-256 05a3c31d8d341925d216ee1fc4093c59d77fcc749cac3a63a80f9cb721c5a9e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 83e5211a1810a8899237ebd2786583e6456dfbd7365d38876da91b6b4468e227
MD5 0050b2730b3e41aebde8f4ed632ab879
BLAKE2b-256 6806457c482e8181afd773b3b8743017c52febe8c11c1ce20abba0df169cde4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e4f38037d9b57a56ded4fddb2f081448e0a71bf6ad0b1b3937161283b7bfb0e4
MD5 5fba9ef79ded2afd7a2b17ed8514cf48
BLAKE2b-256 da6e50a7798c80339b3b7a85886cdf2b2d2d78f89efe04ed695e52358a0eca9f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c89dfd0b0a0c370594833bea2d75d8bfa9dc39a0e09cd4d092199d3bbf294a51
MD5 3ec3eb049cda963c4e294e615241e1a8
BLAKE2b-256 9255ae3f9d649f8f76f2463cbb3ed6b1d627f33460a2d4d41ee51aacd0eaf488

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 77b26c8a819e21cdb254541ca923b3c1550add69a6ef2163e387814a097241c1
MD5 3583b16ddbe503ab880de515b8e226ae
BLAKE2b-256 14ba1e297c5af71382ad614a9390a9b2f26d05e1129ff8328e0c081657050980

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9c09cbccddbc2f395d0a916a8b8d4812d99682d7244a1869adc1e21018756547
MD5 d5f757d2e0ebc45897833211139b15c3
BLAKE2b-256 1c1d472c4dd52b8a4bb2922d6d38567648dc0c4e8b8c0e3d061b9910ef1e27ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 c51add31e64bfce383864bf3a7661d749a4eb9ba22a80b63ae48ad2f29aff9b4
MD5 bb8eb447e13e36457cc0d0568316703a
BLAKE2b-256 fcd4cfac27189aed78a01c1248345b750b17aad21e9e79244b40b1170776bf83

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 18cc9db81cf0ffeefaa38bb14a27fbd1485d7bda51a9df321f99b1bf59929130
MD5 47229a2b93de09842b476a97be8b14a9
BLAKE2b-256 f062813a21eec739e488153fa3ac1213c206b7cda821d7dd3895489068517a2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 8bc5ae528cb2ec5f60cccbd3b378b9696b27b113b5c9b6de848e5a6ddb799735
MD5 6ceae8a5e29231f65403309817d14937
BLAKE2b-256 76a9b90024b76fb36a973d5fde80d53cb507f4e3d73c6f98c20caa5e750585d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 332f601758345f7982725b8609bddf2b9406d2911882c1572db535226c555965
MD5 a31d5ed71998969125546f15e02fe515
BLAKE2b-256 e8612e33c40311c1c08d44b2f1c87bc514bc8e214ce8ac06d49a858767aed93f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fdd19743933351cabe76ce2b9dba9ff35ed2a08a66bfc2ad5e379b89e00344fb
MD5 baca7c26a330d146df9ed48c10423ba7
BLAKE2b-256 b1a608f3edf3bdb9fb149e354dfe9b2dfb448dd1a16dde715eea2b357350b80c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.23.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 76b45638f7c7803feb21b8bdda616819cd131554c58906b841308f372c8bd61c
MD5 3e5fb79730592fc9d647798b318b0b2f
BLAKE2b-256 4d93579c7560412da383d9e88c8f4dd024480712fe65f17e97cca6166f63fbec

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