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 ekpXarray¶
First, we get some NetCDF data.ds = ekd.from_source("sample", "era5_tquv_pl_subarea.nc").to_xarray()
dsNext, we compute the wind speed with earthkit
sp = wind.speed(ds.u,ds.v)
spEarthkit-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()