mikeio icon indicating copy to clipboard operation
mikeio copied to clipboard

Time-invariant file ignores freq

Open ecomodeller opened this issue 3 years ago • 0 comments

Describe the bug Time-invariant file ignores freq. In a file with a single timestep, dt is perhaps not as important as in a multistep file, but is still available in the file, but is currently set to 1s, despite the freq in the pandas DatetimeIndex

To Reproduce

Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas as pd
>>> import numpy as np
>>> import mikeio
>>> da = mikeio.DataArray(data=np.zeros((1,10),dtype=float), geometry=mikeio.Grid1D(n=10,dx=0.1), time=pd.date_range(start="1970", freq='D', periods=1))
>>> da
<mikeio.DataArray>
name: NoName
dims: (time:1, x:10)
time: 1970-01-01 00:00:00 (time-invariant)
geometry: Grid1D (n=10, dx=0.1)
>>> da.to_dfs("single_timestep.dfs1")

Expected behavior Time Step (sec) == 86400 1 day

Screenshots image

System information:

  • Python 3.9.6
  • MIKEIO 0.10.a.2

ecomodeller avatar Apr 26 '22 17:04 ecomodeller