Skip to content

Commit

Permalink
Hydamo (#5)
Browse files Browse the repository at this point in the history
* added styles

* tested installation
  • Loading branch information
D2Hydro authored Sep 22, 2023
1 parent d1674bb commit 8c0d160
Show file tree
Hide file tree
Showing 14 changed files with 14,564 additions and 0 deletions.
136 changes: 136 additions & 0 deletions src/hydamo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# PyCharm .idea-folder
.idea/*

# Windows command-files
*.cmd
*.bat
42 changes: 42 additions & 0 deletions src/hydamo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# HyDAMO
Module to work with the Dutch Hydrological Data Model (HyDAMO). The original class is taken from [D-Hydamo](https://github.com/Deltares/HYDROLIB/tree/main/hydrolib/dhydamo) developed by [HKV](https://www.hkv.nl/) and further developed in the [ValidatieModule](https://github.com/HetWaterschapshuis/HyDAMOValidatieModule) developed by [D2Hydro](https://d2hydro.nl/). Here we will further improve it during the construction of the Landelijk Hydrologisch Model in Ribasim.

## Install a copy
- Get a local clone of this repository.
- Build an environment as in [environment](./environment.yml).
- Mak sure your environment is activated
- Go to the root of your repository (where you find setup.py) and install the package in edit-mode by:

```
pip install -e .
```

## Get Started
To start working, import the hydamo datamodel:
```
from hydamo.datamodel import HyDAMO
hydamo = HyDAMO()
```

The hydamo-object will have have GeoPandas.GeoDataFrame for every layer defined by HyDAMO, e.g. HydroObject. You can access this layer by calling the layer as hydamo-property:

```
hydamo.hydroobject
```

You can set data from an existing feature-file, e.g. an ESRI shapefile by calling the method `set_data`:

```
hydroobject_gdf = gpd.read_file(`hydroobject.shp`)
# map all your columns (and dtypes!) in `hydroobject_gdf` to HyDAMO
hydamo.hydroobject.set_data(hydroobject_gdf)
```

Finally you can write the entire model into one GeoPackage by calling the `to_geopackage` method on the hydamo-class:

```
hydamo.to_geopackage("hydamo.gpkg")
```
9 changes: 9 additions & 0 deletions src/hydamo/environment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: hydamo

dependencies:
- python=3.9.17
- black
- fiona=1.9.1
- GDAL=3.6.2
- geopandas=0.12.2
- pytest
4 changes: 4 additions & 0 deletions src/hydamo/hydamo/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
__version__ = "0.1.0"

from hydamo.datamodel import HyDAMO
#from hydamo.styles import get_layer_styles
Loading

0 comments on commit 8c0d160

Please sign in to comment.