Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining landvalue when writing dfs2-file #283

Open
Achton-Boel opened this issue Feb 18, 2022 · 6 comments · May be fixed by #675
Open

Defining landvalue when writing dfs2-file #283

Achton-Boel opened this issue Feb 18, 2022 · 6 comments · May be fixed by #675

Comments

@Achton-Boel
Copy link

There does not seem to be an option to define a landvalue when wrtiting a dfs2-file from python with Dfs2().write. The landvalue is greyed out when opening the file in MIKE Zero.
We neeed the functionallity when importing a bathymetry into a simulation-setup such as .m21fm. When the dfs2 is used as a domain/mesh we are prompted with the error: "no landvalue set". How can we specify a custom landvalue?

@ecomodeller
Copy link
Member

That seems useful, I just have to figure out how the landvalue is actually stored in the dfs2 file.
I imagine it is stored here somehow
image
@JesperGr can you explain what is necessary to store a landvalue correctly in a dfs2 file?

@JesperGr
Copy link

JesperGr commented Feb 21, 2022

Land value is stored in the custom block named "M21_Misc", the 4th value, as is also seen from the attached image. To store that correctly in a dfs2 file, check out e.g. (C# code):
https://github.com/DHI/MIKECore-Examples/blob/47b5c74130d57091df2853254fb0718462c1c3b5/Examples/CSharp/ExamplesDfs2.cs#L220

builder.AddCustomBlock(factory.CreateCustomBlock("M21_Misc", new float[] { 327f, 0.2f, -900f, 10f, 0f, 0f, 0f }));

@JesperGr
Copy link

There is a similar example for Python in the mikecore-python repository:

https://github.com/DHI/mikecore-python/blob/04c36b1ee3dc6c81905d75ff8c39d7b8a8411bd7/tests/examples_dfs2.py#L165

builder.AddCustomBlock(factory.CreateCustomBlock("M21_Misc", np.array([ 327, 0.2, -900, 10, 0, 0, 0 ], np.float32)));

@JesperGr
Copy link

Well, there is actually a full example of making a bathymetry dfs2 file, look for CreateM21Bathymetry:

https://github.com/DHI/mikecore-python/blob/04c36b1ee3dc6c81905d75ff8c39d7b8a8411bd7/tests/examples_dfs2.py#L359

@ecomodeller
Copy link
Member

This issue has been raised earlier #202 so we will consider how to best support this in mikeio, and in the meantime, you should be able to get by just fine with the example that @JesperGr posted above, using mikecore directly.

@Achton-Boel
Copy link
Author

Hello Henrik and Jesper

Thanks for your quick respons. It helped a great deal.

We will look forward to see it implemented in MIKEIO 👍

@ecomodeller ecomodeller reopened this Dec 22, 2022
@ecomodeller ecomodeller linked a pull request Apr 16, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants