MIKE IO 1D: input/output of MIKE 1D files in Python

Python version Full test PyPI version OS Downloads

Read, manipulate, and analyze res1d, res, resx, out, and xns11 files.

For other MIKE files (dfs0, dfs1, dfs2, dfsu, and mesh files), refer to MIKE IO

Most users of MIKE IO 1D will also find MIKE+Py of interest.

Getting started

Installation

pip install mikeio1d

Linux users will need to install .NET runtime. If you’re on the development branch, you need .NET SDK. Ubuntu users can install these dependencies as follows:

sudo apt install dotnet-runtime-8.0
sudo apt install dotnet-sdk-8.0

Read network results

Use mikeio1d.open to create a Res1D object, then read its content into a DataFrame.

import mikeio1d

res = mikeio1d.open("data/network.res1d")
df = res.read()
df.head()
WaterLevel:1 WaterLevel:2 WaterLevel:3 WaterLevel:4 WaterLevel:5 WaterLevel:6 WaterLevel:7 WaterLevel:8 WaterLevel:9 WaterLevel:10 ... Discharge:99l1:22.2508 WaterLevel:9l1:0 WaterLevel:9l1:10 Discharge:9l1:5 WaterLevel:Weir:119w1:0 WaterLevel:Weir:119w1:1 Discharge:Weir:119w1:0.5 WaterLevel:Pump:115p1:0 WaterLevel:Pump:115p1:82.4281 Discharge:Pump:115p1:41.214
1994-08-07 16:35:00.000 195.052994 195.821503 195.8815 193.604996 193.615005 193.625000 193.675003 193.764999 193.774994 193.804993 ... 0.000002 193.774994 193.764999 0.000031 193.550003 188.479996 0.0 193.304993 195.005005 0.0
1994-08-07 16:36:01.870 195.052994 195.821701 195.8815 193.604996 193.615005 193.625320 193.675110 193.765060 193.775116 193.804993 ... 0.000002 193.775070 193.765060 0.000031 193.550003 188.479996 0.0 193.306061 195.005005 0.0
1994-08-07 16:37:07.560 195.052994 195.821640 195.8815 193.604996 193.615005 193.625671 193.675369 193.765106 193.775513 193.804993 ... 0.000002 193.775391 193.765106 0.000033 193.550034 188.479996 0.0 193.307144 195.005005 0.0
1994-08-07 16:38:55.828 195.052994 195.821503 195.8815 193.604996 193.615005 193.626236 193.675751 193.765228 193.776077 193.804993 ... 0.000002 193.775894 193.765228 0.000037 193.550079 188.479996 0.0 193.308884 195.005005 0.0
1994-08-07 16:39:55.828 195.052994 195.821503 195.8815 193.604996 193.615005 193.626556 193.675949 193.765335 193.776352 193.804993 ... 0.000002 193.776154 193.765335 0.000039 193.550095 188.479996 0.0 193.309860 195.005005 0.0

5 rows × 495 columns

Request more specific data by using the Res1D object to select specific Locations.

df = res.reaches['100l1'].read()
df.head()
WaterLevel:100l1:0 WaterLevel:100l1:47.6827 Discharge:100l1:23.8414
1994-08-07 16:35:00.000 195.441498 194.661499 0.000006
1994-08-07 16:36:01.870 195.441498 194.661621 0.000006
1994-08-07 16:37:07.560 195.441498 194.661728 0.000006
1994-08-07 16:38:55.828 195.441498 194.661804 0.000006
1994-08-07 16:39:55.828 195.441498 194.661972 0.000006

Similarly, select a specific Quantity that you can both read and plot.

res.nodes['100'].WaterLevel.plot()

Read cross section data

Use mikeio1d.open to create an Xns11 object, then get a DataFrame overview of its content.

xns = mikeio1d.open("data/mikep_cs_demo.xns11")
xns.to_dataframe()
cross_section
location_id chainage topo_id
basin_left1 2.004 1 <CrossSection: basin_left1, 2.004, 1>
33.774 1 <CrossSection: basin_left1, 33.774, 1>
80.945 1 <CrossSection: basin_left1, 80.945, 1>
122.042 1 <CrossSection: basin_left1, 122.042, 1>
166.107 1 <CrossSection: basin_left1, 166.107, 1>
... ... ... ...
tributary 250.000 tributary <CrossSection: tributary, 250.000, tributary>
300.000 tributary <CrossSection: tributary, 300.000, tributary>
400.000 tributary <CrossSection: tributary, 400.000, tributary>
450.000 tributary <CrossSection: tributary, 450.000, tributary>
500.000 tributary <CrossSection: tributary, 500.000, tributary>

103 rows × 1 columns

Select a specific CrossSection using sel, then plot it with plot.

xs = xns.sel(location_id="basin_left1", chainage=122.042, topo_id='1')
xs.plot()

Learn more

Continue your learning journey with any of these resources:

  1. User Guide: covers fundamentals with short code examples.
  2. Examples: various notebook examples.

We recommend starting with the User Guide, however, feel free to also hop directly into the examples.

Where can I get help?