{"id":20065415,"url":"https://github.com/nens/threedigrid","last_synced_at":"2026-01-07T16:09:23.096Z","repository":{"id":30071372,"uuid":"110174743","full_name":"nens/threedigrid","owner":"nens","description":"grid administration for 3Di models ","archived":false,"fork":false,"pushed_at":"2025-02-05T10:32:19.000Z","size":1146,"stargazers_count":9,"open_issues_count":14,"forks_count":0,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-01T14:49:46.358Z","etag":null,"topics":["hdf5","hydrological-modelling","library","spatial-data","threedi"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nens.png","metadata":{"files":{"readme":"README.rst","changelog":"HISTORY.rst","contributing":"CONTRIBUTING.rst","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.rst","dei":null}},"created_at":"2017-11-09T22:46:03.000Z","updated_at":"2025-02-05T10:32:20.000Z","dependencies_parsed_at":"2024-02-04T17:44:38.509Z","dependency_job_id":"ee41f2a1-ad5a-4a6a-bf74-b63a60220f00","html_url":"https://github.com/nens/threedigrid","commit_stats":{"total_commits":441,"total_committers":16,"mean_commits":27.5625,"dds":0.7482993197278911,"last_synced_commit":"7c1ec92c16431b284ec7a72becaa2009606c9c9a"},"previous_names":[],"tags_count":108,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nens%2Fthreedigrid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nens%2Fthreedigrid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nens%2Fthreedigrid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nens%2Fthreedigrid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nens","download_url":"https://codeload.github.com/nens/threedigrid/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252553032,"owners_count":21766816,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hdf5","hydrological-modelling","library","spatial-data","threedi"],"created_at":"2024-11-13T13:50:02.585Z","updated_at":"2026-01-07T16:09:23.046Z","avatar_url":"https://github.com/nens.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Threedigrid: The 3Di grid admin framework\n=========================================\n\nThe Python package for the threedigrid administration.\n\n\n.. image:: https://github.com/nens/threedigrid/workflows/Linux/badge.svg\n\t:alt: Github Actions status\n\t:target: https://github.com/nens/threedigrid/actions/workflows/test.yml?query=branch%3Amaster\n\n\n.. image:: https://readthedocs.org/projects/threedigrid/badge/?version=latest\n        :target: https://threedigrid.readthedocs.io/en/latest/?badge=latest\n        :alt: Documentation Status\n\n.. PyPI\n\n.. image:: https://img.shields.io/pypi/v/threedigrid.svg\n\t:alt: PyPI\n\t:target: https://pypi.org/project/threedigrid/\n\n.. Anaconda\n\n.. image:: https://img.shields.io/conda/vn/conda-forge/threedigrid\n  :alt: Anaconda\n  :target: https://anaconda.org/conda-forge/threedigrid\n\n\n* Free software: BSD license\n* Documentation: https://threedigrid.readthedocs.io.\n\nOverview\n========\n\nFeatures\n--------\n- access to the threedicore administration by a single instance of the ``GridH5Admin`` object\n- query the model data by pre-defined subsets and django style filters\n- export model data to gis formats like shapefile, geopackage\n- serialize model data as geojson\n\n\nQuick start\n-----------\n\nThe standard threedigrid distribution is pretty lightweight, installing as little dependencies\nas possible. If you want to make use of all capabilities threedigrid has to ofter (e.g. spatial\noperations and command line tools) install like this::\n\n    $ pip install threedigrid[geo,results]\n\n\nConsole scripts\n+++++++++++++++\n\nUsing the 3digrid_explore shortcut, simply run::\n\n    $ 3digrid_explore --grid-file=\u003cpath to grid file\u003e --ipy\n\nThis will invoke an ipython session with a ``GridH5Admin`` instance already loaded.\n\nTo get a quick overview of the threedimodels meta data omit the ``--ipy`` option or\nexplicitly run::\n\n    $ 3digrid_explore --grid-file=\u003cthe to grid file\u003e --no-ipy\n\nThis will give you output like this::\n\n    Overview of model specifics:\n\n    model slug:              v2_bergermeer-v2_bergermeer_bres_maalstop-58-b1f8179f1f3c2333adb08c9e6933fa7b9a8cd163\n    threedicore version:     0-20180315-3578e9b-1\n    threedi version:         1.63.dev0\n    has 1d:                  True\n    has 2d:                  True\n    has groundwater:         True\n    has levees:              True\n    has breaches:            True\n    has pumpstations:        True\n\n\n(I)Python shell\n+++++++++++++++\nGet a grid admin instance::\n\n    from threedigrid.admin.gridadmin import GridH5Admin\n\n    f = 'gridadmin.h5'\n    ga = GridH5Admin(f)\n\n\nThe grid admin directly holds some model specific attributes like whether the model has a 1D or 2D\nor groundwater section::\n\n    In [4]: ga.has_groundwater\n    Out[4]: False\n\n    In [5]: ga.has_1d\n    Out[5]: True\n\n\n\nThere are different types of filters but a filter, generally speaking, acts on field. That means you can\nfilter by value. If you have a line model instance you can filter the data by the kcu field::\n\n    ga.lines.filter(kcu__in=[100,102])\n\nor by the lik value::\n\n    ga.lines.filter(lik__eq=4)\n\nThe filtering is lazy, that is, to retrieve data you have to call data explicitly::\n\n    ga.lines.filter(lik__eq=4).data  # will return an ordered dict\n\n\nThe structure control actions netcdf can also be analyzed and exported using threedigrid::\n\n    from threedigrid.admin.gridresultadmin import GridH5StructureControl\n    from threedigrid.admin.structure_controls.exporters import structure_control_actions_to_csv\n\n    gst = GridH5StructureControl(\"gridadmin.h5\", \"structure_control_actions_3di.nc\")\n    gst.table_control\n    structure_control_actions_to_csv(gst, \"test.csv\")\n\nRemote procedure calls\n----------------------\n\nCurrently only the client-side is included. The server-side might be added in a later stage.\nNote: this is an advanced feature used inside the 3Di stack, probably you don't need this.\nNote2: you need Python 3.7 or higher for this to work.\n\n\nInstallation::\n\n    $ pip install threedigrid[rpc]\n\n\nBasic usage::\n\n    ga = GridH5ResultAdmin('rpc://REDIS_HOST/SIMULATION_ID', 'rpc://REDIS_HOST/SIMULATION_ID')\n    # Replace REDIS_HOST and SIMULATION_ID with actual values.\n    future_result = ga.nodes.filter(lik__eq=4).data\n    data = await future_result.resolve()\n\nSubscription usage::\n\n    subscription = await future_result.subscribe()\n\n    async for item in subscription.enumerate():\n          # do something with item\n\nLocal development\n-----------------\n\nIn order to set up a virtual environment, perform the following steps:\n\nClone the repo and fetch the LFS objects::\n\n    git lfs fetch origin refs/remotes/origin/master\n    git lfs checkout\n\nInstall platform dependencies::\n\n    sudo apt-get update \u0026\u0026 sudo apt-get install --yes --no-install-recommends libgdal-dev\n\nCreate and activate a virtual environment::\n\n    python -m venv ./venv\n    source ./venv/bin/activate\n\nInstall the dependencies. For your distribution, check the dependency matrix in .github/workflows/test.yml. For example, for Python 3.10::\n\n    pip install --disable-pip-version-check --upgrade pip setuptools wheel\n    pip install -e .[geo,results] pygdal==$(gdal-config --version).* ipython pytest flake8 sphinx==1.8.5 docutils==0.17.* sphinx_rtd_theme\u003e=0.4.3 numpy==1.23.* h5py==3.7.* shapely==1.8.* pyproj==3.4.* geojson==2.5.* mercantile==1.2.1 cftime==1.6.2\n\n\nCredits\n-------\n\nThis package was created with Cookiecutter_ and the `audreyr/cookiecutter-pypackage`_ project template.\n\n.. _Cookiecutter: https://github.com/audreyr/cookiecutter\n.. _`audreyr/cookiecutter-pypackage`: https://github.com/audreyr/cookiecutter-pypackage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnens%2Fthreedigrid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnens%2Fthreedigrid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnens%2Fthreedigrid/lists"}