Quantities

Quantities are the actual model results, which can be read into a pandas DataFrame or plotted directly.

Data structures

Two main quantity structures exist: quantities and quantity collections.

Quantity

A quantity is a single quantity at a specific location. Quantities are accessed from a location object.

res.nodes['101'].WaterLevel # single quantity (i.e. water level) at a single location (i.e. node 101)
<Quantity: Water level (m)>

Quantity Collection

A quantity collection is a single quantity at multiple locations. Quantity collections are accessed from a location collection.

res.nodes.WaterLevel # single quantity (i.e. water level) at multiple locations (i.e. all nodes)
<QuantityCollection (119): Water level (m)>

Reading data

Quantities and quantity collections can be read into a pandas DataFrame with their read method.

df = res.nodes['101'].WaterLevel.read()
df.head()
WaterLevel:101
1994-08-07 16:35:00.000 195.931503
1994-08-07 16:36:01.870 195.931595
1994-08-07 16:37:07.560 195.931625
1994-08-07 16:38:55.828 195.931656
1994-08-07 16:39:55.828 195.931656
df = res.nodes.WaterLevel.read()
df.head()
WaterLevel:1 WaterLevel:2 WaterLevel:3 WaterLevel:4 WaterLevel:5 WaterLevel:6 WaterLevel:7 WaterLevel:8 WaterLevel:9 WaterLevel:10 ... WaterLevel:46 WaterLevel:55 WaterLevel:58 WaterLevel:116 WaterLevel:117 WaterLevel:118 WaterLevel:115 WaterLevel:119 WaterLevel:120 WaterLevel:Weir Outlet:119w1
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 ... 194.074997 195.005005 193.554993 193.550003 193.585007 193.585007 193.304993 193.550003 193.550003 193.779999
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 ... 194.074997 195.005005 193.555023 193.550064 193.585831 193.586807 193.306061 193.550003 193.550003 188.479996
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 ... 194.074997 195.005005 193.555084 193.550110 193.586426 193.588196 193.307144 193.550034 193.550003 188.479996
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 ... 194.074997 195.005005 193.555191 193.550156 193.586960 193.589706 193.308884 193.550079 193.550003 188.479996
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 ... 194.074997 195.005005 193.555267 193.550171 193.587112 193.590317 193.309860 193.550095 193.550003 188.479996

5 rows × 119 columns

Plotting data

Quantities and quantity collections can be plotted directly with their plot method.

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

res.nodes.WaterLevel.plot(legend=False)

Dynamic selections

Quantities or quantity collections can be conveniently combined into a single DataFrame with the ‘add’ method.

res.nodes['101'].WaterLevel.add()
res.nodes['100'].WaterLevel.add()
df = res.read()
df.head()
WaterLevel:101 WaterLevel:100
1994-08-07 16:35:00.000 195.931503 195.441498
1994-08-07 16:36:01.870 195.931595 195.441605
1994-08-07 16:37:07.560 195.931625 195.441620
1994-08-07 16:38:55.828 195.931656 195.441605
1994-08-07 16:39:55.828 195.931656 195.441605
res.nodes.WaterLevel.add()
res.reaches.WaterLevel.add()
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 ... WaterLevel:98l1:0 WaterLevel:98l1:16.0098 WaterLevel:99l1:0 WaterLevel:99l1:44.5016 WaterLevel:9l1:0 WaterLevel:9l1:10 WaterLevel:Weir:119w1:0 WaterLevel:Weir:119w1:1 WaterLevel:Pump:115p1:0 WaterLevel:Pump:115p1:82.4281
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 ... 194.581497 194.511505 194.661499 194.581497 193.774994 193.764999 193.550003 188.479996 193.304993 195.005005
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 ... 194.581497 194.511841 194.661575 194.581497 193.775070 193.765060 193.550003 188.479996 193.306061 195.005005
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 ... 194.581497 194.511795 194.661667 194.581497 193.775391 193.765106 193.550034 188.479996 193.307144 195.005005
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 ... 194.581497 194.511581 194.661865 194.581497 193.775894 193.765228 193.550079 188.479996 193.308884 195.005005
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 ... 194.581497 194.511505 194.661911 194.581497 193.776154 193.765335 193.550095 188.479996 193.309860 195.005005

5 rows × 366 columns

Note

The name ‘add’ indicates the quantity is added to a list of quantities to be read. The ‘read’ method reads all quantities in the list.

Examples

Tip

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