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

Uploaded Source

Built Distributions

threedigrid_builder-1.24.1-cp312-cp312-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.12 Windows x86-64

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

Uploaded CPython 3.12 macOS 14.0+ ARM64

threedigrid_builder-1.24.1-cp311-cp311-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 macOS 14.0+ ARM64

threedigrid_builder-1.24.1-cp310-cp310-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 macOS 14.0+ ARM64

threedigrid_builder-1.24.1-cp39-cp39-win_amd64.whl (1.6 MB view details)

Uploaded CPython 3.9 Windows x86-64

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

File metadata

  • Download URL: threedigrid_builder-1.24.1.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.1.tar.gz
Algorithm Hash digest
SHA256 cafed6eb969905aec65190720a4d7a722e7229b34be5c967b42ea85e1b98a4cc
MD5 2380c7d41d4ab3cd905bfd73f6965ed0
BLAKE2b-256 a6d6e9f5c6e5f153e01bebed11be446e7035656fd36334be2e5da82d31c3ead5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c6dcddd298e3b3b33d79f451b873c246418376900a40f0a1f265b4d9dda3342b
MD5 cb5de349b6f2df93963225221d01cf3c
BLAKE2b-256 543d8525ba25c27aa8c1c7f4c7f31bc5962dbe1ef3bb33c3f4d7b5038a8a2394

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 daaba6675e30e8e2069f9bf2313a585fec0587b18db088f6b1cd14ca3940c6b8
MD5 dea50887a34178992908012917688802
BLAKE2b-256 89475a986cc2121ef382c40f6a50eb90fc86743441a547ef80b00dd4b1b2ec36

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp312-cp312-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 0b306a84e2c6e2bdaf94a511586cdfd435d52fc6c8ad08d967ab168fd84c4f12
MD5 98ebe1bd39f019739dedbc63668cdf56
BLAKE2b-256 8a7aaa25dcb4c0b169af26741be6061a460a08b0325efde0d68bc0a1f6a2428b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 8ef1659152d33d5cd6268167e8d5c87cb3249d079fccb20ef8dc0013a9c18343
MD5 52003568da0a5ba219e5306a0ee3cac6
BLAKE2b-256 d4abcf35e8782e0f9ae38d9817dafc9994ccd10d630031065d5cb560915d81cf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c918f705f490523908652f5452d39e528b574a80dc4b0ac3909567b36be2ab6a
MD5 8ead4a3d264fc13b21b6d3ea4bf86566
BLAKE2b-256 810d5808f89287676322fa30c1f5db29850b5d10b14804858772b9c96b768622

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp311-cp311-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 e8b2f05ff7f816ccffd500be72accc752cb1ae4d098c2907b930bfcc0c572f1b
MD5 ce0115b121c0cae7a7acbd567d719c3a
BLAKE2b-256 39d385fa8e95519ca4b45b43f88e4f1037b4d6a4e1fb586594e140052cf37763

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 33f27f29f3177978a5f790213d56c6e539f9043d0d41627a6637292f25c7d824
MD5 a1077901a9769ffea1b2a07f34dd3e44
BLAKE2b-256 dc16d5acd018313259458a349dc67bd25116a334e650f16c4923f847af52657f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fec1fcad9f120510d1d9de9f223531216c05e64070212a401743d9c1aa8977be
MD5 5d715c2994c8c57c31c2cfa98bfab03d
BLAKE2b-256 73fd68fc3681d8b3bc9e50fa94624dee16c7100b45d029f5cbc81ec73135e437

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp310-cp310-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ba400ca7c6338ffbc7a7088d79c9751c8b670caf2246983f7eabac63118a59b3
MD5 7e85ce1a68fe25005d563a4a23d21b4e
BLAKE2b-256 bae4266c909e2afb248169b0b8e357d4183bee9695ad6000f1a5af2ea8e1f6e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 5d85ec3bd62b45c5d171a020a80902b319ce07cdebe2e2262a089e993d4d62de
MD5 8b77c5b2c9e1e8e7cd5417fe9588afb7
BLAKE2b-256 fae8cc205f1c336bca1933a67ea2f2f27750540301d7fdc42f25dbe08b140caf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1a5fc86154fa8e15a9c9be8c64c24af857478b9fe862ebbab81058d596906908
MD5 552814a047bb70c2cda1ca83c8111f62
BLAKE2b-256 664918022a145c84b6a2f943422d093c3daccc54d9c338852646d560932e9fc7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-1.24.1-cp39-cp39-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 3a734b66d4953a34c407ea945c5c9169b1d9d61faa0fe9f06df99ed3b507212e
MD5 a08ab6de09edfe9ce190ae226889dd61
BLAKE2b-256 17657945da326e77e84275a225f5739da5def76d8c4e3126da80d49a651af625

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