Res1D

Res1D is the main interface for accessing data on a Network. Create a Res1D object by providing the path to a supported file type.

Supported file types

Support is provided for MIKE collection system, water distribution, and river modelling result files. Specific file extensions supported include:

  • MIKE 1D network and catchment .res1d files
  • MIKE 1D Long Term Statistics .res1d files
  • EPANET .res and .resx files generated by MIKE+
  • SWMM .out files
  • MOUSE legacy .PRF and .CRF files
Note

All file types use the Res1D object despite their different file extensions. Behind the scenes, they are converted into the common Res1D format.

Opening files

Network files can be opened by providing the path to a Res1D object.

from mikeio1d import Res1D
res = Res1D('../data/network.res1d')
res
<mikeio1d.Res1D>

Exploring contents

An overview of the file contents can be obtained by calling the info method.

res.info()
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 - Water level (m)
1 - Discharge (m^3/s)

The quantity IDs are accessible via the quantities attribute.

res.quantities
['WaterLevel', 'Discharge']

Res1D results share a common time index, which can be accessed via the time_index attribute.

res.time_index
DatetimeIndex([       '1994-08-07 16:35:00', '1994-08-07 16:36:01.870000',
               '1994-08-07 16:37:07.560000', '1994-08-07 16:38:55.828000',
               '1994-08-07 16:39:55.828000', '1994-08-07 16:40:55.828000',
               '1994-08-07 16:41:55.828000', '1994-08-07 16:42:55.828000',
               '1994-08-07 16:43:55.828000', '1994-08-07 16:44:55.828000',
               ...
               '1994-08-07 18:25:07.967000', '1994-08-07 18:26:07.967000',
               '1994-08-07 18:27:07.967000', '1994-08-07 18:28:07.967000',
               '1994-08-07 18:29:07.967000', '1994-08-07 18:30:07.967000',
               '1994-08-07 18:31:07.967000', '1994-08-07 18:32:07.967000',
               '1994-08-07 18:33:07.967000',        '1994-08-07 18:35:00'],
              dtype='datetime64[ns]', length=110, freq=None)

Reading all data

All data can be read into a pandas DataFrame by calling the read method.

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

Accessing locations

Locations are where model results exist in the network. The main location types are nodes, reaches, and catchments. Each of these location types are accessible via the Res1D object.

res.reaches
<ResultReaches> (118)
Quantities (2)
  • Water level (m)
  • Discharge (m^3/s)
Derived Quantities (6)
  • ReachAbsoluteDischarge
  • ReachFilling
  • ReachFlooding
  • ReachQQManning
  • ReachWaterDepth
  • ReachWaterLevelAboveCritical
res.nodes
<ResultNodes> (119)
Quantities (1)
  • Water level (m)
Derived Quantities (3)
  • NodeFlooding
  • NodeWaterDepth
  • NodeWaterLevelAboveCritical
res_cat = Res1D('../data/catchments.res1d')
res_cat.catchments
<ResultCatchments> (31)
Quantities (5)
  • Total Runoff (m^3/s)
  • Actual Rainfall (m/s)
  • Zink, Load, RR (kg/s)
  • Zink, Mass, Accumulated, RR (kg)
  • Zink, RR (mg/l)
Derived Quantities (0)

    Modifying data

    Limited functionality is provided for modifying result data. A common use case for this is hotstart files. Modifying static network data is not supported.

    # Add 1m to the water level of the node with ID '1'.
    df = res.read(column_mode='timeseries')
    df_modified = df.copy()
    index_to_mod = res.nodes['1'].WaterLevel.timeseries_id
    df_modified[index_to_mod] = df_modified[index_to_mod] + 1
    res.modify(df_modified, file_path='modified.res1d')

    Examples

    Tip

    There are also several notebook examples available on our GitHub repositoryhttps://github.com/DHI/mikeio1d/tree/main/notebooks.