Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Earthkit-hydro: Computing Catchment Statistics

earthkit-hydro-logo

Earthkit-hydro: Computing Catchment StatisticsΒΆ

Tnis notebook will show a simple example of computing catchment statistics.

import earthkit.plots as ekp
import earthkit.hydro as ekh
import earthkit.data as ekd
network = ekh.river_network.load("efas", "5")

da = ekd.from_source(
    "sample",
    "R06a.nc",
).to_xarray()["R06a"].isel(time=0).load() # making sure it's not chunked in space
River network not found in cache (/etc/ecmwf/ssd/ssd1/jupyterhub/macw-jupyterhub/tmpdirs/macw.39412013/tmp3tw77g5a_earthkit_hydro/1.2_0dc8123bbf944ff1cb86f41bc7506e891baaa990666d836fc0cf2edd503916db.joblib).
River network loaded, saving to cache (/etc/ecmwf/ssd/ssd1/jupyterhub/macw-jupyterhub/tmpdirs/macw.39412013/tmp3tw77g5a_earthkit_hydro/1.2_0dc8123bbf944ff1cb86f41bc7506e891baaa990666d836fc0cf2edd503916db.joblib).
                                                              

In practice, computing full-field accumulations is often not required and users may wish to calculate only for certain areas of interest. In hydrology, the canonical unit over which to calculate is typically a catchment.

In earthkit-hydro, catchments are specified by specifying the location of the most downstream cell.

As an example, we specify two disjoint catchments in this notebook.

locations={
    "Reading": (50.736364, 7.10807),
    "Bonn": (51.461325, -0.967884)
}

To begin, we visualise the catchments to confirm we have correctly specified the right location on the river network.

find_catchments = ekh.catchments.find(network, locations)

chart = ekp.Map(domain=[-6, 16, 45, 56])
chart.quickplot(find_catchments)
chart.legend(label="{variable_name}")
chart.title("Visualisation of Catchments")
chart.coastlines()
chart.gridlines()
chart.show()
<Figure size 700x800 with 2 Axes>

We can then easily compute catchment statistics over these areas. Many metrics are available. As an example, we compute catchment averages for both gauge locations.

ekh.catchments.mean(network, da, locations)
Loading...