DHI/mikeio

Bug with generic.concat?

Closed this issue · 2 comments

Describe the bug
Hi.

I have 2 files (dfs2 files, a little bit too large to upload).

  • Dec.dfs2: Spans from 2022-12-28 to 2022-12-31 (both days included)
  • Jan.dfs2 : Spans from 2022-12-31 to 2023-01-02 (both days included)
    They overlap in 1 day.

If I run the following code the resulting file is ok, spaning from 28-Dec to 02-Jan
mikeio.generic.concat(['Dec.dfs2','Jan.dfs2'],'Out.dfs2')

This other code also works:
mikeio.generic.concat(['Dec.dfs2','Jan.dfs2'],'Out.dfs2',keep='first')

However if I invert the order, The resulting file goes from 31-Dec until 03-Jan (ie, it overwrites the time axis, creating an additional day at the end)
mikeio.generic.concat(['Jan.dfs2','Dec.dfs2'],'Out.dfs2')

Expected behavior
I would except they kword keep , which is either first or last, just to handle the overlapping, not the initial time as well

System information:

  • Python version : 3.10.8
  • MIKE IO version : 1.6.2

The files have to be in chronological order, noted in the docs.
https://github.com/DHI/mikeio/blob/6ab5abfe8c0cc586de7486f5bcdc11d4adad0770/mikeio/generic.py#L441C1-L441C1

This could be more explicit, by validating the input.

Ok I will close this then.
I usually have my files in order but this time I did not and found out about this the hard way.