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

Uploaded Source

Built Distributions

threedigrid_builder-1.24.3-cp312-cp312-win_amd64.whl (629.2 kB view details)

Uploaded CPython 3.12 Windows x86-64

threedigrid_builder-1.24.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.24.3-cp312-cp312-macosx_14_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.12 macOS 14.0+ ARM64

threedigrid_builder-1.24.3-cp311-cp311-win_amd64.whl (629.3 kB view details)

Uploaded CPython 3.11 Windows x86-64

threedigrid_builder-1.24.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.24.3-cp311-cp311-macosx_14_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.11 macOS 14.0+ ARM64

threedigrid_builder-1.24.3-cp310-cp310-win_amd64.whl (630.7 kB view details)

Uploaded CPython 3.10 Windows x86-64

threedigrid_builder-1.24.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.24.3-cp310-cp310-macosx_14_0_arm64.whl (1.0 MB view details)

Uploaded CPython 3.10 macOS 14.0+ ARM64

threedigrid_builder-1.24.3-cp39-cp39-win_amd64.whl (631.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

threedigrid_builder-1.24.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.24.3-cp39-cp39-macosx_14_0_arm64.whl (999.6 kB view details)

Uploaded CPython 3.9 macOS 14.0+ ARM64

File details

Details for the file threedigrid_builder-1.24.3.tar.gz.

File metadata

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

File hashes

Hashes for threedigrid_builder-1.24.3.tar.gz
Algorithm Hash digest
SHA256 cc7afa7d2af1ae364287824538cb03c70c52569161ea9e83791afdb04aca29fc
MD5 7c623a2b5149d459d16ca19cb2999563
BLAKE2b-256 c151870e531f85d9c3719480dac6a6fa57de0ff83dca75c4a3090a093e213f8a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 a1156a02da00493147dd235e972e469037a0e1e4ba38cf71bf7ee967dc0b85b9
MD5 f61809668da33cba3f75b1aed6e1078f
BLAKE2b-256 a1584ae5726a506ceaed76d11fb5c3648bdbd48b863cf06c0f0aa037ee939b35

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 d8d72a28dc62303b3d941325736f88261ed1ec87e41b5bfb62824505bddd50ef
MD5 8d2d94bceb02853527c92f03a73e9a38
BLAKE2b-256 784e060315a0ff5572aefb143638cb77689bf287dd09c2e7399cc58b4a0259d1

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.3-cp312-cp312-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 4e2d49fb323aa948eb6c312c214087e5b8c2c831dbbb59b995362a7003b7f11c
MD5 fdb4f9e2399cabdb885f9d2c530e62a8
BLAKE2b-256 ebfc11a056a1b529941012a23a040b953fbc659f6a18711e4548ee2049992896

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 cdbb9f699930c8d1d1e0113d342728b0f97b453a0de7887ff7eba39b69d7646c
MD5 0c69305337ea0b49f5a7c47b9009b5f7
BLAKE2b-256 25f518a651210e9bfa06b86c34a7537a861b503bc278d9e4f9436d3299c132c1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 44e43205c2833755dc563ab7beeb0c185cfc1e33112b78c27083ca5500047ddd
MD5 23878716695ed8332a83403656d70892
BLAKE2b-256 5636e077c90092e33a44c3fda123762e1768375048d9cf1431b6f382b7da0a48

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.3-cp311-cp311-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 a300782a005dd88aece75b7cbc5a0c7e63a2de414ac91bef9b5715fc7a6d3fdf
MD5 516670021dc36989d3dfc15e73335292
BLAKE2b-256 55dccaa3f4101b526aebc0fbc9492fa45d809bfcf813497a522f4bdabd36ac06

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 2f2e3a4f31a2af204de377e532189ee08f0789a612f7fef44922401e8abae3c3
MD5 e1392dfe937217f695ac8496c8d956a9
BLAKE2b-256 2435ebc830cf6a5fd6a5b4b30d09f354c1015d876cec2269d421402503d0e9b1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7ed7dd44a9aa65aeb5e4b3e2e3ffb8863fbbc3d7ad3ad3b02e0324facc4782d7
MD5 cd0e8a9851dda8a13dac182d0fe4c307
BLAKE2b-256 cd1a66450c63bb2e5531cd7fe3640869f14dfd9f653d4082a2d38f7384583f6b

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.3-cp310-cp310-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 6fb39927603bb5a1eb4ca4bf4871551b9fe4609e22685d8fb8c51553222f8ad7
MD5 29ae61a1f1105577f7c5ad497b84a776
BLAKE2b-256 68a5ff4574492dd019597144050b6ff6a2e2577009d62232133a0b06b76da4a5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9eb8768a2be6be6b33b587fcccd1cc973e3d555a8865f3b068341de5bb4d1e90
MD5 a28f74ea6089ee102565a603f9e12000
BLAKE2b-256 0dc576b91923135a4fa7c34a4c601a05d2e5bac39f81b2e203b0a7a3a707fc0b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3bbde2964d2ca120db5466204bd750a93a0f3781fbc7312a8596535c376dc4d3
MD5 5470736615ecc01c5f463d152c06acc7
BLAKE2b-256 807640137895ad7d9b467dd38a2999a599e3e7bcc37c12d21ffd6560833fb693

See more details on using hashes here.

File details

Details for the file threedigrid_builder-1.24.3-cp39-cp39-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-1.24.3-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e276f310f0d0b876dbfcbda938cd42956b2eb9361bb0bd97cf476a8ea000dbe1
MD5 98edb5f72d9e38e6d5e22cc0ecc772a6
BLAKE2b-256 7bb10894cd806e971410ef657fd17b967395d2caf10e50e7e07107c74076ade2

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