Skip to main content

threedigrid-builder

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 binary only, because its (Fortran) source code is proprietary. 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, there are two options: GDAL and rasterio. If you do not have GDAL (and its Python bindings) present, be sure to include the [rasters] extra dependency while installing threedigrid-builder. If you have GDAL present, this can be omitted.

Install the threedigrid-builder:

$ pip install threedigrid-builder[rasters]

For output into a file for the 3Di calculationcore, enable gridadmin output:

$ pip install threedigrid-builder[rasters,gridadmin]

For output into Geopackage for display in e.g. QGis, enable gpkg output:

$ pip install threedigrid-builder[rasters,gpkg]

Changelog of threedigrid-builder

0.8.0 (2021-11-30)

  • Added has_max_infiltration_capacity flag.

  • Added breaches and levees.

  • Implement GDAL as an alternative to RasterIO.

  • Check the raster EPSG code and use it if the model does not have one.

  • Removed ‘model_area_path’ feature from application.

  • Added an in-memory output interface. Supply out_path=None to instead of writing the grid to a file, receive the grid as dictionaries of 1D ndarrays.

  • Removed the “sqlalchemy<1.4” constraint, this library is compatible with SQLAlchemy 1.4

0.7.0 (2021-11-25)

  • Raise SchematisationError on invalid settings.

  • Removed SchematisationError on tabulated rectangle cross section definition with zero first “width” value.

  • Add calculation_type for nodes to be Dem averaged.

0.6.1 (2021-11-10)

  • Fixed l1dtot (exclude 1D boundaries).

0.6.0 (2021-11-09)

  • Raise SchematisationError on embedding linear objects that begin/end outside of 2D domain. Added tests for edge cases.

  • Fixed exchange_level (dpumax) for 1D2D lines attached to non-manhole connection nodes. The exchange_level is now derived from the bank_levels of attached channels.

  • Add discharge_coefficients for structures.

  • Swap the order in lines.line for 1D2D lines. The order is now (2D, 1D).

  • Fixed kcu for lines attached to 1D boundary conditions.

  • Copy crest_level from v2_levee if a v2_connected_point refers to one.

0.5.2 (2021-11-02)

  • Consistently write NaN (and not -9999.0) in gridadmin float datasets.

  • Fix tests with GEOS 3.10.0

  • Make ‘meta’ group complete.

0.5.1 (2021-11-01)

  • Add storage_area to calculation nodes.

  • Added ds1d_half to nodes.

  • Added has_embedded to attrs.

0.5.0 (2021-10-21)

  • Fixed nodes.is_manhole in the gridadmin output.

  • Handle user-supplied 1D-2D lines (connected point / calculation point).

  • Write initial_waterlevel for 1D nodes and add ‘has_initial_waterlevels’ to meta.

0.4.0 (2021-09-23)

  • Added 1D boundary conditions.

  • Added 2D boundary conditions.

  • Enable compression in HDF5 output.

  • Fixed 2D lines that connect a larger to a smaller cell in south east direction.

0.3.1 (2021-08-16)

  • Handle embedded connection nodes. These are removed from the grid and written to a new dataset “nodes_embedded”.

  • Fixed bug with cross sections tables being None in Grid instance

  • Handle embedded channels, pipes and culverts. Embedded objects result in embedded nodes and and lines with kcu LINE_1D_EMBEDDED between between 2D cells.

  • Fixed a bug with lines that connect nodes to themselves in quadtree generation.

  • Fixed a bug with wrong usage of lines.ds1d in bottom level and cross section weights computation. The added attribute lines.s1d is now used, and for clarity nodes.ds1d was renamed to nodes.s1d.

  • Added invert_level_start_point and invert_level_end_point attributes to lines.

  • Fixed coordinate order in lines.line_geometries field in gridadmin.h5.

0.3.0 (2021-07-28)

  • Read and convert cross section definitions.

  • Solve gridadmin off-by-one errors for pumps.

  • Add ‘dmax’ to nodes output.

  • Changed external API function name to “make_gridadmin”.

0.2.1 (2021-07-20)

  • Fixed issue when reprojecting 0 grid refinements with pyproj 2.*

  • Fixed issue when writing 0 pumps with h5py 2.*

  • Fixed missing transpose when writing pumps.coordinates to HDF5.

  • Added obstacles.

0.2.0 (2021-07-15)

  • Added threedigrid_builder.grid.geo_utils with segmentize and line_substring functions. These are used to compute the Lines.line_geometries for channel lines.

  • Fixed a bug in the refinement areas code (Fortran) on Ubuntu 20.04.

  • Added the Pipes model that is able to compute Nodes & Lines from Pipes. Pipes are also included in the calculation_type and bottom_level computations.

  • Added 1D-2D lines for connection nodes, manholes, and channels.

  • Added culverts, orifices, and weirs.

  • Added pumps (pumpstations).

  • Settings and metadata are read from the SQLite. Some metadata (like model_slug) can also be provided via the main (make_grid) function. The metadata is written to the root ‘attrs’ of the output gridadmin.h5. The settings are written into datasets inside newly addres groups “grid_settings” and “tables_settings”.

  • Fixes for models with no channels.

  • Add an optional progress callback.

0.1.2 (2021-04-28)

  • Added public API with 1 function: threedigrid_builder.make_grid.

0.1.1 (2021-04-20)

  • Fixed automatic PyPI upload.

0.1.0 (2021-04-20)

  • Partially ported functionality from inpy (generate 3di files, makegrid): 1D channel grid (including calculation_type and bottom_level), and 2D open water grid.

  • Added gridadmin and geopackage output.

  • Breaking change: the interpolation between cross section locations (channels) now also extrapolates for lines and nodes that are not in between two connection nodes. This happens only if the channel has at least 2 cross section locations. When extrapolatic, the line.cross_weight is less than 0 or greater than 1.

  • Breaking change: missing or empty values in float datasets in the output gridadmin are now denoted by NaN (not-a-number) instead of -9999.0.

  • Breaking change: integers in the output gridadmin are now always 32-bit (instead of sometimes 32-bit and sometimes 64-bit).

Release files for threedigrid-builder 0.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for threedigrid-builder 0.8.0
File
threedigrid_builder-0.8.0-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
threedigrid_builder-0.8.0-cp39-cp39-manylinux2010_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.12+ x86-64 Details
threedigrid_builder-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
threedigrid_builder-0.8.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
threedigrid_builder-0.8.0-cp38-cp38-manylinux2010_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.12+ x86-64 Details
threedigrid_builder-0.8.0-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
threedigrid_builder-0.8.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
threedigrid_builder-0.8.0-cp37-cp37m-manylinux2010_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64 Details
threedigrid_builder-0.8.0-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details
threedigrid_builder-0.8.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
threedigrid_builder-0.8.0-cp36-cp36m-manylinux2010_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64 Details
threedigrid_builder-0.8.0-cp36-cp36m-macosx_10_9_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 Details

Total release size: 18.1 MB

Release files / threedigrid_builder-0.8.0-cp39-cp39-win_amd64.whl

Download URL threedigrid_builder-0.8.0-cp39-cp39-win_amd64.whl
Size 875.5 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
19c825b568bf25bbda7e9fdde719c0286ad52f2a69ce2e0568e91f6f4d760d7a
BLAKE2b-256 checksum
How to use checksums
4a830f24e7f8629ab321814eae0b0c251d5a60c53859ba5d700cacbb1f5c9b78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp39-cp39-manylinux2010_x86_64.whl

Download URL threedigrid_builder-0.8.0-cp39-cp39-manylinux2010_x86_64.whl
Size 2.0 MB
Tags CPython 3.9 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
a87076ecbe0d7a537a2fe9dcc0f98dad3a0a3e7ae167105ef454d284d8ea52f3
BLAKE2b-256 checksum
How to use checksums
e23c8a4a0d2bf9d0843869bc25d7d5eb8a11b57c54ca92065402ca84c4199685
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl

Download URL threedigrid_builder-0.8.0-cp39-cp39-macosx_10_9_x86_64.whl
Size 1.6 MB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
8065bee543050e152bd59e83c96718c04f5b0047134f5db698b34e5eb52735df
BLAKE2b-256 checksum
How to use checksums
bc89839b0747721b78a76a99b05f27c256971cd357aa8cd81dbff206e41f1b97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp38-cp38-win_amd64.whl

Download URL threedigrid_builder-0.8.0-cp38-cp38-win_amd64.whl
Size 894.2 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
b775babb602893c707c91efb68430b1aea7bcbe4053905e7f9714911bed4ad64
BLAKE2b-256 checksum
How to use checksums
bf4687145f3bd72e9be4909f2ba4d6faaaa9e52f44ef3161a62ca5622e626aa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp38-cp38-manylinux2010_x86_64.whl

Download URL threedigrid_builder-0.8.0-cp38-cp38-manylinux2010_x86_64.whl
Size 2.0 MB
Tags CPython 3.8 Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
7e7734e712fa2b37cf7f5e673b8af3ae828c5265d681163982c5c2f635597c91
BLAKE2b-256 checksum
How to use checksums
60be2a94336cfbf8c203258ce4a9db11e5ce4dd182824f63ea5e3c90ffd31ed4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp38-cp38-macosx_10_9_x86_64.whl

Download URL threedigrid_builder-0.8.0-cp38-cp38-macosx_10_9_x86_64.whl
Size 1.7 MB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
2f4a0ebf93ff9584ce59842e51bda6a912d2433b6146da13fdaaefcdb20c7bf6
BLAKE2b-256 checksum
How to use checksums
03b737d3033cd34b0beafd77827fbe2835b9568fee82367ee8b0c9551faabb1c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp37-cp37m-win_amd64.whl

Download URL threedigrid_builder-0.8.0-cp37-cp37m-win_amd64.whl
Size 892.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
a8217298772b77db9a112d348ec37c85d19d869d230bfdd66759993f8bef8164
BLAKE2b-256 checksum
How to use checksums
411bd64b1018e87e6b97231d4bfc447262d418a326b1b55b21ed5dc85f81abab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp37-cp37m-manylinux2010_x86_64.whl

Download URL threedigrid_builder-0.8.0-cp37-cp37m-manylinux2010_x86_64.whl
Size 2.0 MB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
8f01eaa5e777d79512dcddcce3834cfa57033e018a1edf60be8cd0582490c6ea
BLAKE2b-256 checksum
How to use checksums
92470dfbd1afa40a96ba7cf065708993dfb4176870deffd51e455ae4cb97253b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL threedigrid_builder-0.8.0-cp37-cp37m-macosx_10_9_x86_64.whl
Size 1.7 MB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
4b451e82720ee9c7b7ae0fafa9e15326774c38326cd57f4ef010d553cfb3551d
BLAKE2b-256 checksum
How to use checksums
5f5791b809301859cc56a8268740276fbecac266640f3c2c6ab5971d053e2924
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp36-cp36m-win_amd64.whl

Download URL threedigrid_builder-0.8.0-cp36-cp36m-win_amd64.whl
Size 892.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
600c02697caa0eeae3790328ab5e112c7fd70be31d3509469484e87fa637277d
BLAKE2b-256 checksum
How to use checksums
cf59c4ddf639d459813885a8bdf3c2a6ebdf944bd26c8475b3d81d8c65d614d4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp36-cp36m-manylinux2010_x86_64.whl

Download URL threedigrid_builder-0.8.0-cp36-cp36m-manylinux2010_x86_64.whl
Size 2.0 MB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.12+ x86-64
SHA-256 checksum
How to use checksums
314255c85d7d7ab8a05945b99d936c2c550179b9342ff48627935fe8971c0191
BLAKE2b-256 checksum
How to use checksums
018284bafcc4b559e194dd380ffa2da427e88a31183d8e86a2bc2bb54d3e0cad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release files / threedigrid_builder-0.8.0-cp36-cp36m-macosx_10_9_x86_64.whl

Download URL threedigrid_builder-0.8.0-cp36-cp36m-macosx_10_9_x86_64.whl
Size 1.7 MB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
78514158a0b286a742a30203e93b0d040ae7ff10abd5d037f781a100c995b30e
BLAKE2b-256 checksum
How to use checksums
46a044a589b34592c52d147eed644a124c824c29c5b27c3008685ed0dec7b983
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

Release history Release notifications | RSS feed

1.8.0

13 release files

1.7.1

13 release files

1.7.0

13 release files

1.5.0

13 release files

1.4.0

13 release files

1.3.5

12 release files

1.3.4

12 release files

1.3.3

12 release files

1.2.1

12 release files

1.2.0

12 release files

1.1.0

12 release files

1.0.2

12 release files

1.0.1

12 release files

1.0.0

12 release files

0.9.2

12 release files

0.9.1

12 release files

0.9.0

12 release files

This release

0.8.0 This release

12 release files

0.7.0

12 release files

0.6.1

12 release files

0.5.0

12 release files

0.4.0

12 release files

0.3.1

8 release files

0.3.0

8 release files

0.2.1

8 release files

0.2.0

8 release files

0.1.2

8 release files

0.1.1

8 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page