Skip to main content

Generate a 3Di simulation grid from a model schematisation.

Project description

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.2 (2021-12-05)

  • Fixed the Linux wheel distribution. These are now built with manylinux2014 instead of manylinux2010.

0.8.1 (2021-12-05)

  • Dropped support for Python 3.6.

  • Fixed __version__ attribute and “threedigrid_builder_version” HDF5 attribute.

  • Set the dpumax of a 1D line (channel, pipe, culvert, weir, orifice) always to the largest of its two invert levels. Previously, it was set to the largest of the two bottom_levels of the two adjacent nodes, which gave wrong results for lines attached to manholes.

  • Disable extrapolation for channel node/line attributes that are derived from crosssection locations.

  • Disable the SchematisationError when a Manhole has a bottom_level above a level of a connected object. Instead, emit a warning through the logger.

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).

Project details


Release history Release notifications | RSS feed

This version

0.8.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

threedigrid_builder-0.8.2-cp310-cp310-win_amd64.whl (879.7 kB view details)

Uploaded CPython 3.10Windows x86-64

threedigrid_builder-0.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

threedigrid_builder-0.8.2-cp310-cp310-macosx_10_9_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

threedigrid_builder-0.8.2-cp39-cp39-win_amd64.whl (877.3 kB view details)

Uploaded CPython 3.9Windows x86-64

threedigrid_builder-0.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

threedigrid_builder-0.8.2-cp39-cp39-macosx_10_9_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

threedigrid_builder-0.8.2-cp38-cp38-win_amd64.whl (896.3 kB view details)

Uploaded CPython 3.8Windows x86-64

threedigrid_builder-0.8.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

threedigrid_builder-0.8.2-cp38-cp38-macosx_10_9_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.8macOS 10.9+ x86-64

threedigrid_builder-0.8.2-cp37-cp37m-win_amd64.whl (894.7 kB view details)

Uploaded CPython 3.7mWindows x86-64

threedigrid_builder-0.8.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.17+ x86-64

threedigrid_builder-0.8.2-cp37-cp37m-macosx_10_9_x86_64.whl (1.7 MB view details)

Uploaded CPython 3.7mmacOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: threedigrid_builder-0.8.2-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 879.7 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for threedigrid_builder-0.8.2-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 1f64a14f294e16973705dc1c5b31179da71e3e669765f4900b82b1f73f963e85
MD5 9d33d1a82ad60e61a2b3069f30feda70
BLAKE2b-256 96690ccf00c5d399e5d9282bcfb58dacdaf1a328288a18e815dc7a626f2f8ccb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-0.8.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 38932e613d6a106d46f082a3dd970a8be015a188be4143f36bfca4afbdc79197
MD5 30e95cc28b95df0b57934975b868d964
BLAKE2b-256 31cef88dc113d87f80f5ad71434e9328a218d6c94fc0f9f1f7a5549a18bd850b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: threedigrid_builder-0.8.2-cp310-cp310-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.10, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for threedigrid_builder-0.8.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 7ff124f556b1752bb0f520cc1f27f0bef06aec6b71c7d4f418169bbd666b6fb3
MD5 2118b72e083c5c65a9752d44919f7be1
BLAKE2b-256 18601e88cf8e76e87713bac42a93b5c3fcbfc6c229c56160561e8b8ea92a397e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: threedigrid_builder-0.8.2-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 877.3 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for threedigrid_builder-0.8.2-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6fd6910f1a1f7425cae3431b3ad1c0b479524cc91b5930e11bda034616acd3d3
MD5 f03cade0e807131bb51994e5d149f22b
BLAKE2b-256 f296d919f6592f187bf06492fe0784fe0290887785d0be7633056e2d8f30fd2d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for threedigrid_builder-0.8.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a8946c9d1fe99c9b940a0bbbcb1137bbad77d36717722d8533bbc126a1fa3aef
MD5 14c58334a18c50a11fcd3061b8025ea7
BLAKE2b-256 c718bedf4fe688611087c8eaf9f1477d653a8b754676e9df8a18aba8e1000b66

See more details on using hashes here.

File details

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

File metadata

  • Download URL: threedigrid_builder-0.8.2-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for threedigrid_builder-0.8.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f0116db47d73e6fdb5f4a6599abd6151b9dce1fee2a708cb82e5aa890b54742b
MD5 84747525824223a56b7a2c93f17ff748
BLAKE2b-256 e959ab004016ee8a829b31506f33ab787bd194a79558295ac8060e2136f2c83d

See more details on using hashes here.

File details

Details for the file threedigrid_builder-0.8.2-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: threedigrid_builder-0.8.2-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 896.3 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for threedigrid_builder-0.8.2-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 0fe0311981ae7d85e4b923b2a20a24612daa461831287e78d7afbd5a1252a8aa
MD5 10f4d6a768ecd694d68825c666dd3f76
BLAKE2b-256 17539cf8f8f8e16cd43dbe0683f0f0c640e2877ff12806407aa403c3346cbd3b

See more details on using hashes here.

File details

Details for the file threedigrid_builder-0.8.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-0.8.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7c47913ba67159ef2927e975c025374a8e0718ed1fbd6a7bfd82595c5613ab83
MD5 c1e2c2b3db6eb769d3f2f09f22f5f073
BLAKE2b-256 7c93e11a3ce6a6ec875f75cd7d3c3e258e69a77ca009998d122a3a1a628be0ea

See more details on using hashes here.

File details

Details for the file threedigrid_builder-0.8.2-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: threedigrid_builder-0.8.2-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for threedigrid_builder-0.8.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b623ed6e12c22dd712281b6461e9144fff6ee37dbf1e35e9c28c7d3dc00343d7
MD5 4fcdc281db48692e7f00f4bbcca490c5
BLAKE2b-256 05225d4da3dab84b9d8098cbe01e64f8717eedb3d9b79ec261ddc604e28c80b3

See more details on using hashes here.

File details

Details for the file threedigrid_builder-0.8.2-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: threedigrid_builder-0.8.2-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 894.7 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for threedigrid_builder-0.8.2-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 8c351e606fa2e25d9805cfea962798b17065a397acd8d5ca65128caee5aa9c13
MD5 06876173b32f08414b27b0ea7258c08d
BLAKE2b-256 7337b58c5f7f1f9e1d5e2fa10baaccab2d31d415c2f4755e0e6ed51c21cbad1c

See more details on using hashes here.

File details

Details for the file threedigrid_builder-0.8.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for threedigrid_builder-0.8.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fef2fb50bd8502b61d296ab21f95cc33c10d32224fcb4e13512d1778a63b04ee
MD5 9763d776ba5d738c77198d2397a2aa98
BLAKE2b-256 7c89e7f3739adc49d6013c69c503f71ce658d80f212db1009a449ced8e303dac

See more details on using hashes here.

File details

Details for the file threedigrid_builder-0.8.2-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: threedigrid_builder-0.8.2-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for threedigrid_builder-0.8.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f76e86a14cca1d4ff70f5db8202b6518799b1918d2e93a9ce34ca6971f10758e
MD5 2f42d97d0fcc4ecfeda93beedd0bd3ef
BLAKE2b-256 be328cf551faefdb25c3ea7dbd9e59e86c644ea9327e49019e7f972bccdcd3aa

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page