DHI / mikeio

Read, write and manipulate dfs0, dfs1, dfs2, dfs3, dfsu and mesh files.
https://dhi.github.io/mikeio
BSD 3-Clause "New" or "Revised" License
138 stars 55 forks source link

Support for adding custom blocks on write #675

Open ecomodeller opened 6 months ago

ecomodeller commented 6 months ago

Custom blocks are a form of metadata used in particular situations to add additional information to a dfs file.

Example of how custom blocks are added to an existing dfs2 file without custom blocks.

import mikeio
import numpy as np
ds = mikeio.read("tests/testdata/gebco_sound.dfs2")
ds.to_dfs("new_file.dfs2",
        custom_blocks={"M21_Misc": np.array([327, 0.2, -900, 10, 0, 0, 0], np.float32)},
   )

This PR adds support for adding custom blocks in the moment a dataset is written to a file.