DHI/mikeio1d

Read res1d by timeframe / catchments

ryan-kipawa opened this issue · 2 comments

Is it possible to read a res1d file only between a certain timestamp or for certain catchments? As far as I can tell, it's only possible to query reaches and manholes, but not catchments or time steps. This is useful when dealing with large files >1gb.

As you already saw presently for mikeio1d version on master branch (v0.1) it is not possible to query catchments in an easy way. As far as I can tell even the querying of data for nodes and reaches tries to load the full res1d file and only puts filtered data to pandas data frame. If you are up for using experimental code I used improved Mike1D API to load res1d data more efficiently. Try to take a look at the branch feature/file_load_filter

There is a possibility to load a file in a "lazy" way, which means only relevant data is loaded:

import mikeio1d
from mikeio1d.res1d import Res1D, QueryDataCatchment
res1d = Res1D(filepath, lazy_load=True)
query = QueryDataCatchment("TotalRunoff", "MyCatchmentId")
df = res1d.read(query)

or use filtering functionality, which leads to a faster loading of data compared to "lazy" loading:

import mikeio1d
from mikeio1d.res1d import Res1D, QueryDataCatchment
catchments = ["MyCatchmentId"]
res1d = Res1D(filepath, catchments=catchments)
query = QueryDataCatchment("TotalRunoff", "MyCatchmentId")
df = res1d.read(query)

Let me know if it helps :-).

That worked like a charm, thanks!