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

Uploaded Source

Built Distributions

threedigrid_builder-1.21.3-cp312-cp312-win_amd64.whl (629.7 kB view details)

Uploaded CPython 3.12 Windows x86-64

threedigrid_builder-1.21.3-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.3-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.3-cp311-cp311-win_amd64.whl (629.7 kB view details)

Uploaded CPython 3.11 Windows x86-64

threedigrid_builder-1.21.3-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.3-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.3-cp310-cp310-win_amd64.whl (631.2 kB view details)

Uploaded CPython 3.10 Windows x86-64

threedigrid_builder-1.21.3-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.3-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.3-cp39-cp39-win_amd64.whl (631.5 kB view details)

Uploaded CPython 3.9 Windows x86-64

threedigrid_builder-1.21.3-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.3-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.3.tar.gz.

File metadata

  • Download URL: threedigrid_builder-1.21.3.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.21.3.tar.gz
Algorithm Hash digest
SHA256 dadf10df247dad32397f2393d427c543e7c71348d1f8506064ac91fdd9440a97
MD5 cecd059192dba76918276a9d00f55ddf
BLAKE2b-256 07765166128d33b812b9f957e5981de67e81616c4eb2743965ac07c382dd0e7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 376bfb23792a7afb7ee2fb6321408f41fabbeaad833bb5f0225c8d67a8c5b67d
MD5 6b50df687e3f5292de42fe68703260f9
BLAKE2b-256 9985b59ba7ef553d1ae536e2c9e62f3e236406c69887155c0fb921d2fb9a666d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c8ebb443652c28ca7a99b6906229c611a026a06350fd001283afc58121125be2
MD5 2416ed357a19d87e23841bab76c9d45b
BLAKE2b-256 4039cf0909de58def73a2e728416addbeb50ef1bc1fc949a49cc1bde31329636

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 aecb92df200be2dac638c862ba9c25aa7a76f96eb0a4c5f0834a0d8dc936a6bb
MD5 3dd4e8a60ff34ee2a6a5ca8e8b0e31e8
BLAKE2b-256 b8cace88359642171ea44c62253ace5751f0e693cd0382ee4c2dcdc0fdfa8d49

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 56b3a7cba45899fa4522277a8cfc61e75064623b6f42782f09f7b835bf85b532
MD5 f9663fa5e879b3939844e2e9953dea61
BLAKE2b-256 99e06b50f8d967423bf2cc0af91afa3686df5367514f3521f65f339cefc311e1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fc42d61ecd3c4b0f8525f53daae9ac0a76c042b0a58fc2ba05d6148fec10b295
MD5 2223a6486a7a9c6eb688642bd1c7eb1e
BLAKE2b-256 b33481ab30f70e48fd0c64967f072b4ab6c94ddc36eeb20d5899fc7c733bf1c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1d91f1ebbb238ea4de8f9208fcd6a245f7986f5eda5b43b49de51f5e829ab5c8
MD5 fd87c66fd399e1bec33a0ba203706d74
BLAKE2b-256 6fb66a1531717f0f36773456d9479e57f27e41e9049335675cfb5bd19802bcb2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 76c7bf24943a646fbf35daa45ec9f7805abfeec7afd6b45cfe53ae1906fa2b02
MD5 4cafd9f70d6742882c9129c73764c2f3
BLAKE2b-256 028d6c64bff52acecce3cbad565910b11cbd97faaba812eca2ca69ddaaed311c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 78b6d311a5dbc65e8443598e9a7cfa94afd3fafd6960de8118b693d936e7b97c
MD5 7b89c33ae54512f621639891605526f1
BLAKE2b-256 12bd1793cfe0b0fdb4bf8fb6a2f2dddce1db165f024644b6531fc0c4fc23d1d5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 99a068357e3f186daaa2eb3acae149c2f581bb223254bd6a4ee62717b79fb525
MD5 2ffc78359c1cbd15cca4e42112e774b4
BLAKE2b-256 17f83bd7e6f43c75dae88159865278698d4a2ee71880e47c6f4248d61293847e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 651e4de28b0b6042fbfb766c66fa7cc6f7b83e681f8880a8dbddf78b65a87466
MD5 184a6e57037476a526aacb691912262e
BLAKE2b-256 a382eeeb987aa413faf9833aed97e5b013bbba131b59f4fb993d84f9bdeaaf6f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 db753d81fe31663f9a72dc62127d17f8f95aa0e4e8a602bee2469773964af054
MD5 783ab33f60b33eb87019482ee423367a
BLAKE2b-256 cc9b9351b22af170ae23578aa9a0dc84a7d9136c9c8c2e9a304341eb63b99e34

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.21.3-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 64cee8269202c9a37573ab3075ff3ba9a68b104dc1fd1769610b8ecca8a35d33
MD5 cf1c3e43dbb0e1ed44de07e3ab3dc731
BLAKE2b-256 38aa70c82927260213dd0c761f7e565fbb3ababac5524d87866d960a5967e95d

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