Posted Fri, 12 Jul 2013 15:05:50 GMT by kin.gyo
I am trying to automate my simulation, and I have come across a problem. I am trying to convert a grid file from ASCII to a .dfs2 file so that I can load it into my MIKE21 fm flowmodel. The file in question is a 2d grid of bed resistance (chezy values.) If I open the file with MIKE Grid Series tool and create a new grid from that ASCII file, everything works fine and I can save it as .dfs2. (The ASCII file is generated from a program I wrote in python, with values/formulas for bed resistance)

However, because I am trying to automate this process I have been trying to do this with the mike zero toolbox. I have created a toolbox to automatically create a dfs2 file from the ASCII when it is run using GIS > Grd2Mike. As far as I can tell, you can only do this with .asc files (arcview), so I made my program output in that format instead, and I can now run the tool to convert them to dfs2.

However, by outputting the grid as .asc, the item type = chezy value information is lost, and now I can't load the dfs2 into my flowmodel as a grid of bed resistance, because the item type defaults back to water level.

So basically, is there a way to create a dfs2 file of chezy numbers, by using a batch/toolbox script which converts ASCII data in some form.

Thanks very much!
Posted Tue, 17 Sep 2013 04:44:58 GMT by Thanh Dang
I think you can write a C# routine to read dfs2 file and modify the items type to Chezy
Posted Mon, 25 Nov 2013 10:34:30 GMT by Jesper Grooss
What you can do in your Python program is to directly create a dfs2 file. You can also write a C# program that does it. Both are assuming that at least MIKE version 2012 installed.

What you need is a python version that can use the .NET framework. For that you can either use the common CPython and install the Python .NET package. Or you can use IronPython, which has build-in support for the .NET framework.

For an example on how to write the dfs2 file:
[list]
[li]For MIKE 2012: If you in the start-menu open the "MIKE Zero Documentation Index" in the section "File Formats", there should be a link to a zip file with examples[/li]
[li]For MIKE later than 2012: Install the MIKE SDK, and that includes a zip file with examples[/li]
[/list]
In the example.zip file there is a folder of IronPython examples, one is how to create dfs2 files. There are also C# examples on how to do the same.

Jesper

You must be signed in to post in this forum.