Getting started
MIKE IO 1D is a python library for reading and writing network result files (e.g. .res1d). Its purpose is to be a useful tool for scientists, engineers, and modellers working with MIKE 1D network results.
What types of files can I read?
Any result file related to MIKE collection system, water distribution, and river modelling. Specific file extensions supported include:
MIKE 1D network and catchment .res1d files
MIKE 1D Long Term Statistics .res1d files
MOUSE legacy .PRF and .CRF files
EPANET .res and .resx files generated by MIKE+
SWMM .out files
Note
EPANET, SWMM, and MOUSE result files are read the same way as res1d files. No special syntax or alternative API is required.
Additionally, support is available for cross section data stored in .xns11 files.
Basics of the network structure
Working with MIKE IO 1D requires a conceptual understanding of network structure. All result data lives somewhere on the network. There’s four main elements of every network:
Nodes
Reaches (also consisting of grid points)
Catchments
Global data
When you first open a result file, you’ll see how many of these elements types exist in the file.
>>> from mikeio1d import Res1D
>>> res = Res1D('network.res1d)
<mikeio1d.Res1D>
Start time: 1994-08-07 16:35:00
End time: 1994-08-07 18:35:00
# Timesteps: 110
# Catchments: 0
# Nodes: 119
# Reaches: 118
# Globals: 0
0 - WaterLevel <m>
1 - Discharge <m^3/s>
Learn more about the network structure here.
Tip
The network structure is generic and applies to different domains (e.g. collection systems, water distribution, rivers). Here’s a few examples of result types mapped onto this structure.
Network Element |
Result Type |
---|---|
Nodes |
|
Reaches |
|
Catchments |
|
Global data |
|
Reading and plotting data
There’s various ways to read data into dataframes and make plots.
Read everything
>>> res = Res1D('network.res1d')
>>> res.read()
Read a specific result
>>> res = Res1D('network.res1d')
>>> df = res.nodes['101'].WaterLevel.read()
Read a group of results
>>> res = Res1D('network.res1d')
>>> df_node_water_levels = res.nodes.WaterLevel.read()
>>> df_reach_discharges = res.reaches.Discharge.read()
Combine various results into one dataframe
>>> res = Res1D('network.res1d')
>>> res.nodes['101'].WaterLevel.add()
>>> res.reaches['100l1'].Discharge.add()
>>> df = res.read()
Use plot() instead of read()
>>> res = Res1D('network.res1d')
>>> res.nodes['101'].WaterLevel.add()
>>> res.reaches['100l1'].Discharge.add()
>>> res.plot()
Hint
Think of add() as in ‘add this to some collection of results I eventually want to read to a dataframe’.
Caution
The add() workflow may change to something more intuitive. Join the discussion on GitHub to share your opinion :)’.
Inspect network elements
You can easily see what static and dynamic data is associated with a network element within a jupyter notebook.
Descriptive html representations
>>> res = Res1D('network.res1d')
>>> node = res.nodes['101']
Attributes
- id: 101
- type: Manhole
- xcoord: -687859.5004882812
- ycoord: -1056308.700012207
- ground_level: 196.67999267578125
- bottom_level: 195.92999267578125
- critical_level: inf
- diameter: 1.0
Quantities
- WaterLevel
Descriptive string representations
>>> res = Res1D('network.res1d')
>>> node = res.nodes['101']
>>> print(node)
<Manhole: 101>
Accessing static data
>>> res = Res1D('network.res1d')
>>> node = res.nodes['101']
>>> print(node.id, node.type, node.ground_level)
101 Manhole 196.67999267578125