Posted Tue, 17 Sep 2013 11:59:52 GMT by Aurelian
Hello everyone,

I am interested in reading and writeing dfs0 files at programming level. This will help me to adjust the time series using Auto Calibration tool (AUTOCAL) and for another purposes.

After I made some reserch on the Mike documentation, i found out this pdf file: "...\DHI\2012\MIKE Zero\Manuals\MIKE_ZERO\FileFormats\DFS_UserGuide.pdf". I was very glad to see that there is a .NET API for reading, modifying and creating DFS files. Unfortunatly, in my Mike 2012 Bin folder the "DHI.Generic.MikeZero.DFS.dll" file is missing.

1. In case you have Mike 2012 installed, do you have this file ?
2. Do you know any application tool to convert a time series stored in an ASCII file into a dfs0 ?

Thanks,
Aurelian
Posted Tue, 17 Sep 2013 13:08:01 GMT by Aurelian
Hi again,

I've just find where are located the files I need for managing dfs files:
"C:\Windows\Microsoft.NET\assembly\GAC_MSIL\DHI.Generic.MikeZero.DFS\v4.0_13.0.0.0__c513450b5d0bf0bf\DHI.Generic.MikeZero.DFS.dll"
"C:\Windows\Microsoft.NET\assembly\GAC_MSIL\DHI.Generic.MikeZero.EUM\v4.0_13.0.0.0__c513450b5d0bf0bf\DHI.Generic.MikeZero.EUM.dll"

I'm very happy about my first dfs0 file created programmatically! It seems like Mike11, but not only this Mike product, can be integrated in other softwares as an engine. You can read and write all the Mike11 input files and you can read the results files (*.res11) using "res11read.exe" tool.

Bye,
Aurelian
Posted Sun, 06 Oct 2013 18:28:16 GMT by nqmuow
Hi Aurelian,
I want to manage a *.dfs0 file (read/write like Mike 11)  and I used "DHI.Generic.MikeZero.DFS.dll" and "DHI.Generic.MikeZero.EUM.dll" as you said. But when I using DFSFileWrite, I cannot find its method to create a *.dfs0 file. Is there smth not right here. Could you pls explain in more details?
Thanks so much!
Posted Sun, 06 Oct 2013 20:33:49 GMT by Aurelian
Hello,

There is no specific API for handling dfs0 files, as it is written in the documentation ("DFS_UserGuide.pdf"), but the good news is that you can manage dfs0 files by using [i]DfsFileFactory[/i] class. You also must use the [i]IDfsFile[/i] interface which provides functionality for reading and writing any dfs file.

Example (C#):
// Open the [i]filename.dfs0[/i] file in edit mode.
IDfsFile dfs0File = DfsFileFactory.DfsGenericOpenEdit("filename.dfs0");

// Header information is contained in the IDfsFileInfo.
IDfsFileInfo fileInfo = dfs0File.FileInfo;

// Get the number of items and the number of time steps.
int noItems = dfs0File.ItemInfo.Count;
int noTimeSteps = fileInfo.TimeAxis.NumberOfTimeSteps;

//Lets assume that the data are stored as floats.
IDfsItemData<float> data;
float[,] values = new float[noItems, noTimeSteps];

// Iterate throw all the time steps in all the items,
// multiply each value by 2 and store them in the [i]values[/i] matrix.
for (int i = 0; i < noTimeSteps; i++)
    for (int j = 1; j <= noItems; j++)
    {
        data = (IDfsItemData<float>)dfs0File.ReadItemTimeStep(j, i);
        values[j - 1, i] = Convert.ToSingle(data.Data[0] * 2);
    }

// Write the updated values.
for (int i = 0; i < noTimeSteps; i++)
    for (int j = 1; j <= noItems; j++)
    {
        dfs0File.WriteItemTimeStep(j, i, 0, new float[] { values[j - 1, i] });
    }

dfs0File.Close();
//The End

I suggest you to analyze the example located at "...\DHI\2012\MIKE Zero\Manuals\MIKE_ZERO\FileFormats\Examples\CSharp\ExamplesDfs0.cs" and also the documentation.

Regards,
Aurelian
Posted Mon, 07 Oct 2013 01:31:47 GMT by nqmuow
Thanks mate,
I'm very happy when receiving your feedback. I'll try it.

Kind Regards,
nqmuow
Posted Thu, 10 Oct 2013 09:07:32 GMT by nqmuow
Hi mate,
I tried to download the DHI Mike 11 2012 on the site mybydhi.com. However, it is the trial version and I could not find or buy the license for it. So when using some .dll, I could not using DHI.Generic.MikeZero.EUM in my code. Could you help me to solve this problem?

Thanks so much!

Regards,
nqmuow
Posted Thu, 10 Oct 2013 09:47:38 GMT by Aurelian
Hi again,

I've just tried to use a C# programme (which uses those two dll files mentioned above) to read and write a dfs0 file and it worked perfectly in demo mode. The dfs0 file contains 4 items and 1050 time steps.

So, i think the problem is not the Mike license. Can you describe in more details your problem ?

Regards,
Aurelian
Posted Tue, 04 Mar 2014 03:49:32 GMT by nqmuow
Hi mate,

I cann't download Mike 11 2012 form their website. So could you pls send me 3 files .dll including:
- DHI.Generic.MikeZero.DFS.dll
- DHI.Generic.MikeZero.EUM.dll
- DHI.Generic.MikeZero.dll

Thanks for helping!
Posted Tue, 04 Mar 2014 08:37:27 GMT by Aurelian
Hi,

In order to download Mike 2012 you should follow a few steps:
1. Login with your account or register a new one at [url=http://mikebydhi.com/login/Login.aspx]http://mikebydhi.com/login/Login.aspx[/url].
2. Access this link: [url=http://mikebydhi.com/Download/MIKEByDHI2012.aspx]http://mikebydhi.com/Download/MIKEByDHI2012.aspx[/url].
3. Download any Mike software you want.

"These downloads are the original installers for Release 2012, i.e. no service packs are included. If you experience any difficulties downloading or installing the software, please consult our FAQ or call your local DHI office or DHI Customer Care."

Have a nice day,
Aurelian

Posted Wed, 03 Dec 2014 04:44:07 GMT by nishan.biswas.buet
Hi,
I have gone through read/write dfs0 as well as NAM Model result files from C#. But during reading Mike 11 HD Result files through C#, I was unable to get all the items. Rather I found that each item contains a reach. But I need all node timeseries, how it can be found? Can anyone please help me in this regard?

Thanks in advance.
Nishan Biswas

Posted Sat, 03 Jan 2015 11:59:30 GMT by Aurelian
Hi,

I've just tested the API for reading two dfs0 files. The first one was extracted from file with the default hydrodynamic results ("results.res11") and the second one from the file with additional HD results ("resultsHDAdd.res11"). Both files are very large (218 Mb, respectively 600 MB).

Everything went fine with the reading of the file. I found all the time series for all the nodes which should be stored in each of the files.

I hope you already know that in the default results file generated by Mike 11 from hydrodynamic models you get discharge time series in discharges nodes and water level time series in corresponding nodes. If you want to get discharges time series in water levels nodes, you have to use additional hydrodynamic results, named "....HDAdd.res11". To obtain this file after simulation, you must check (before running the model) some options in HD Parameters file, under "Add. Output" tab.

Regards,
Aurelian

You must be signed in to post in this forum.