Coder Social home page Coder Social logo

robjameswall / dhitools Goto Github PK

View Code? Open in Web Editor NEW
23.0 7.0 17.0 43.3 MB

Python tools for working with DHI MIKE21

Home Page: https://dhitools.readthedocs.io/en/latest/index.html

License: MIT License

Python 100.00%
coastal mikebydhi dhi mike21 hydrodynamic-modeling ocean-modelling coastal-modelling

dhitools's Introduction

DHI Tools

Documentation Status

Python tools for working with DHI MIKE21.

Features:

  • Interpolate multiple raster DEMs directly to .mesh file
  • Read and analyse .dfsu files
  • Create .dfsu roughness map (or any other map) directly from .shp and .mesh
  • Read and analyse .dfs0, .dfs1, .dfs2 files

Due to depending on the MIKE SDK DLL libraries only Windows is supported.

Mesh plot

Install

Requirements

Install

Recommended that Anaconda is used to install GDAL and geopandas. Alternatively, see here and here for installation instructions of these packages.

First, install MIKE software development kit:

Download installer from here

After installing the MIKE SDK:

conda install gdal
conda install geopandas
pip install pythonnet
pip install dhitools

Latest Build

Clone this repository

Examples

See the following Jupyter notebooks for examples:

Documentation

https://dhitools.readthedocs.io/en/latest/index.html

dhitools's People

Contributors

felix-james avatar robjameswall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dhitools's Issues

fixed start_datetime format in dfsu.py and may cause an error in different region settings

Rob, Thanks for your great tool and I think it is very helpful.
I found that the start_datetime format is fixed in the dfsu.py line 100 as following
self.start_datetime = dt.datetime.strptime(self.start_datetime_str, '%d/%m/%Y %H:%M:%S %p')
I searched that different regions use different date and time format as Date format by country and this may cause some errors.

I think the implantation of the start time in dfs.py line 47 is more flexible :
self.start_datetime = dt.datetime(year=dt_start_obj.Year, month=dt_start_obj.Month, day=dt_start_obj.Day, hour=dt_start_obj.Hour, minute=dt_start_obj.Minute, second=dt_start_obj.Second)

Do you have other considerations of time format in dfsu.py? I forked and test the latter and it works fine.

Thanks for your tools and great notebook examples!

Mesh mask error

Hi Rob, thank you for writing this great tool. I am having a problem with the dhitools.mesh.Mesh() object mask() method error. When I run it for my mesh I am getting this error:

Traceback (most recent call last):
  File "E:\anaconda3\envs\py36\lib\site-packages\numpy\core\fromnumeric.py", line 51, in _wrapfunc
    return getattr(obj, method)(*args, **kwds)
AttributeError: 'list' object has no attribute 'argmax'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "<input>", line 5, in <module>
  File "C:\Users\grbh\Desktop\Repositories\dhitools\dhitools\mesh.py", line 546, in mask
    poly_mask = _polygon_mask(all_poly_coords)
  File "C:\Users\grbh\Desktop\Repositories\dhitools\dhitools\mesh.py", line 902, in _polygon_mask
    max_area_idx = np.argmax(poly_areas)
  File "E:\anaconda3\envs\py36\lib\site-packages\numpy\core\fromnumeric.py", line 1037, in argmax
    return _wrapfunc(a, 'argmax', axis=axis, out=out)
  File "E:\anaconda3\envs\py36\lib\site-packages\numpy\core\fromnumeric.py", line 61, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
  File "E:\anaconda3\envs\py36\lib\site-packages\numpy\core\fromnumeric.py", line 41, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
ValueError: attempt to get argmax of an empty sequence

Funny enough, if I rerun the following 2 lines several times (5-6 times, random every time) eventually it works splendidly. I can send you my mesh if this would help with debugging.

m = dhitools.mesh.Mesh('path\to\mesh.mesh')
mask = m.mask()

Also had to change config.py since my MIKE is not on drive C. You can actually use the built-in os module to check all drives one by one until you find the MIKE SDK (or throw an exception if you do not) and set the variable dynamically during import.

help ///

An Error Has Occurred,when i ran this dode: dhitools/notebooks/dfs012_analysis.ipynb,
and my version of python is 3.7. (anconda) Can u help me solve this error?,thanks
error:
File "C:\ProgramData\Anaconda3\lib\site-packages\dhitools\dfs.py", line 45, in dfs_info
self.num_items = dfs_object.ItemInfo.Count
AttributeError: 'list' object has no attribute 'Count'

Indentation error

Hi. I have found an indentation error in dfs.py.
See attached picture. Line 223 should be inside the for loop.

Capture

Thanks for sharing your great code!

no issue, just thanks

Rob,

Just wanted to say thanks for putting this code on github. I have been developing my own DHI SDK python tools and have gotten a couple ideas from you and from the mikeio github page, and it has helped me with some roadblocks I had reached.

Great work on this.

Derek

Convert to raster

Dear Rob,
Can you show how to convert array of current speed interpolated a regular grid with a resolution of 500m to raster?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.