from mikeio1d import Res1D
= Res1D('../data/network.res1d')
res = Res1D('../data/catchments.res1d') res_catchments
Locations
Locations are where model results exist in the Network. The main location types are nodes, reaches, gridpoints, and catchments.
Data structures
There are two main data structures for locations: location collections and single locations.
Location collections
Access location collections from a Res1D object. Each collection shows available quantities and location IDs.
res.nodes
Quantities (1)
- Water level (m)
Derived Quantities (3)
- NodeFlooding
- NodeWaterDepth
- NodeWaterLevelAboveCritical
res.reaches
Quantities (2)
- Water level (m)
- Discharge (m^3/s)
Derived Quantities (6)
- ReachAbsoluteDischarge
- ReachFilling
- ReachFlooding
- ReachQQManning
- ReachWaterDepth
- ReachWaterLevelAboveCritical
res_catchments.catchments
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)
Gridpoints only exist as single locations on a reach, and have no collection.
Single locations
Access a single location by indexing its respective collection with its unique ID. Each location shows available quantities and static properties.
'1'] res.nodes[
Attributes (8)
- id: 1
- type: Manhole
- xcoord: -687934.6000976562
- ycoord: -1056500.69921875
- ground_level: 197.07000732421875
- bottom_level: 195.0500030517578
- critical_level: inf
- diameter: 1.0
Quantities (1)
- Water level (m)
Derived Quantities (3)
- NodeFlooding
- NodeWaterDepth
- NodeWaterLevelAboveCritical
'100l1'] res.reaches[
Attributes (9)
- name: 100l1
- length: 47.6827148432828
- start_chainage: 0.0
- end_chainage: 47.6827148432828
- n_gridpoints: 3
- start_node: 100
- end_node: 99
- height: 0.30000001192092896
- full_flow_discharge: 0.12058743359507902
Quantities (2)
- Water level (m)
- Discharge (m^3/s)
Derived Quantities (6)
- ReachAbsoluteDischarge
- ReachFilling
- ReachFlooding
- ReachQQManning
- ReachWaterDepth
- ReachWaterLevelAboveCritical
# gridpoint on reach 100l1 at chainage 23.841
'100l1']['23.841'] res.reaches[
Attributes (5)
- reach_name: 100l1
- chainage: 23.8413574216414
- xcoord: -687897.8000488281
- ycoord: -1056390.4503479004
- bottom_level: 195.0500030517578
Quantities (1)
- Discharge (m^3/s)
Derived Quantities (0)
Gridpoints can also be indexed by number instead of chainage. For example:
'100l1'][0] # first gridpoint
res.reaches['100l1'][-1] # last gridpoint res.reaches[
'100_16_16'] res_catchments.catchments[
Attributes (3)
- id: 100_16_16
- area: 22800.0
- type: Kinematic Wave
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)
Quantities
Quantities are the actual model results. Each single location or location collection has associated quantities.
res.nodes.WaterLevel
<QuantityCollection (119): Water level (m)>
'1'].WaterLevel res.nodes[
<Quantity: Water level (m)>
The Network structure is generic and applies across different domains (e.g. collection systems, water distribution, rivers). Sometimes this can be challenging to find a particular result. Here are some examples of result types mapped onto this structure.
Location | Example quantities |
---|---|
Nodes | Water level (e.g. manhole, basin, outlet, junction) |
Pump discharge in structure | |
Reaches | Discharge (e.g. pipes, pumps, weirs) |
Water level (e.g. at specific chainges) | |
Catchments | Catchment discharge |
Total runoff | |
Global | Water balance |
User defined variable types |
Refer to the Quantities page for more information on how to read and plot the returned quantities.
Static attributes
Each location has a set of static attributes.
'1']._static_attributes res.nodes[
['id',
'type',
'xcoord',
'ycoord',
'ground_level',
'bottom_level',
'critical_level',
'diameter']
'1'].ground_level res.nodes[
197.07000732421875
Reading data
All result data for a single location or location collection can be read into a pandas DataFrame.
= res.reaches['100l1'].read()
df 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 |
= res.reaches.read()
df df.head()
WaterLevel:100l1:0 | WaterLevel:100l1:47.6827 | WaterLevel:101l1:0 | WaterLevel:101l1:66.4361 | WaterLevel:102l1:0 | WaterLevel:102l1:10.9366 | WaterLevel:103l1:0 | WaterLevel:103l1:26.0653 | WaterLevel:104l1:0 | WaterLevel:104l1:34.4131 | ... | Discharge:93l1:24.5832 | Discharge:94l1:21.2852 | Discharge:95l1:21.9487 | Discharge:96l1:14.9257 | Discharge:97l1:5.71207 | Discharge:98l1:8.00489 | Discharge:99l1:22.2508 | Discharge:9l1:5 | Discharge:Weir:119w1:0.5 | Discharge:Pump:115p1:41.214 | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1994-08-07 16:35:00.000 | 195.441498 | 194.661499 | 195.931503 | 195.441498 | 193.550003 | 193.550003 | 195.801498 | 195.701508 | 197.072006 | 196.962006 | ... | 0.000004 | 0.000003 | 0.000001 | 0.000005 | 0.000013 | 0.000003 | 0.000002 | 0.000031 | 0.0 | 0.0 |
1994-08-07 16:36:01.870 | 195.441498 | 194.661621 | 195.931503 | 195.441605 | 193.550140 | 193.550064 | 195.801498 | 195.703171 | 197.072006 | 196.962051 | ... | 0.000004 | 0.000003 | 0.000001 | 0.000005 | 0.000010 | 0.000003 | 0.000002 | 0.000031 | 0.0 | 0.0 |
1994-08-07 16:37:07.560 | 195.441498 | 194.661728 | 195.931503 | 195.441620 | 193.550232 | 193.550156 | 195.801498 | 195.703400 | 197.072006 | 196.962082 | ... | 0.000004 | 0.000003 | 0.000001 | 0.000005 | 0.000010 | 0.000003 | 0.000002 | 0.000033 | 0.0 | 0.0 |
1994-08-07 16:38:55.828 | 195.441498 | 194.661804 | 195.931503 | 195.441605 | 193.550369 | 193.550308 | 195.801498 | 195.703690 | 197.072006 | 196.962112 | ... | 0.000004 | 0.000003 | 0.000001 | 0.000005 | 0.000009 | 0.000003 | 0.000002 | 0.000037 | 0.0 | 0.0 |
1994-08-07 16:39:55.828 | 195.441498 | 194.661972 | 195.931503 | 195.441605 | 193.550430 | 193.550369 | 195.801498 | 195.703827 | 197.072006 | 196.962128 | ... | 0.000004 | 0.000003 | 0.000001 | 0.000005 | 0.000009 | 0.000003 | 0.000002 | 0.000039 | 0.0 | 0.0 |
5 rows × 376 columns
GeoDataFrames
Locations collections can be extracted into a GeoDataFrame, both with and without quantities.
= res.reaches.to_geopandas()
gdf gdf.plot()
= res.reaches.to_geopandas(agg='max')
gdf ='max_Discharge', linewidth=3, cmap='RdYlGn_r', legend=True) gdf.plot(column
Examples
There are also several notebook examples available on our GitHub repositoryhttps://github.com/DHI/mikeio1d/tree/main/notebooks.