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-meteo: wind computations

In this notebook you will see how to:

  • compute the wind speed from NetCDF/Xarray data

import earthkit.data as ekd
from earthkit.meteo import wind
import earthkit.plots as ekp

Xarray

First, we get some NetCDF data.
ds = ekd.from_source("sample", "era5_tquv_pl_subarea.nc").to_xarray()
ds

Next, we compute the wind speed with earthkit.meteo.wind.speed. We pass DataArrays to this method.

sp = wind.speed(ds.u,ds.v)
sp

Earthkit-meteo is still work in progress and the metadata is not yet set in the resulting DataArray. We will set it manually.

sp.attrs["standard_name"] = "wind_speed"
sp.attrs["long_name"] = "wind_speed"
sp = sp.rename("ws")

Finally, we plot some of the data for visual checking.

# select one level and step and plot wind field overlaid with the computed speed
u = ds.u.sel(pressure_level=700, valid_time="2016-09-26T12")
v = ds.v.sel(pressure_level=700, valid_time="2016-09-26T12")
sp1 = sp.sel(pressure_level=700, valid_time="2016-09-26T12")

chart = ekp.Map()
chart.contourf(sp1, units="m s-1", colors="Greens", 
               levels=list(range(5,45,5)), alpha=1)

chart.quiver(u=u, v=v, headwidth=2.5, width=0.002)

# Add map features
chart.coastlines()
chart.land()
chart.gridlines()
chart.legend()

# Show the plot
chart.show()