{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 🌬️ Dataset with wind\n", "\n", "When working with wind data, I often find myself computing the wind speed and direction from the U and V components. I wrote the Herbie `with_wind()` xarray accessor to quickly compute these quantities and include them in your xarray Dataset.\n", "\n", "Consistent with the [eccodes GRIB parameter database](https://codes.ecmwf.int/grib/param-db/), variables names are assigned as follows:\n", "\n", "- `si10` : 10 metre wind speed (note this is _not_ `ws10` as you might expect)\n", "- `wdir10` : 10 metre wind direction\n", "- `ws` : wind speed\n", "- `wdir` : wind direction" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from herbie import Herbie" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Dataset with both wind speed and direction" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "✅ Found ┊ model=hrrr ┊ \u001b[3mproduct=sfc\u001b[0m ┊ \u001b[38;2;41;130;13m2024-Jan-01 00:00 UTC\u001b[92m F00\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mGRIB2 @ aws\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mIDX @ aws\u001b[0m\n" ] }, { "data": { "text/html": [ "
<xarray.Dataset> Size: 61MB\n",
"Dimensions: (y: 1059, x: 1799)\n",
"Coordinates:\n",
" time datetime64[ns] 8B 2024-01-01\n",
" step timedelta64[ns] 8B 00:00:00\n",
" heightAboveGround float64 8B 10.0\n",
" latitude (y, x) float64 15MB 21.14 21.15 21.15 ... 47.85 47.84\n",
" longitude (y, x) float64 15MB 237.3 237.3 237.3 ... 299.0 299.1\n",
" valid_time datetime64[ns] 8B 2024-01-01\n",
" gribfile_projection object 8B None\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" u10 (y, x) float32 8MB -3.636 -3.636 -3.573 ... 9.552 9.552\n",
" v10 (y, x) float32 8MB -2.131 -2.193 ... -2.381 -2.006\n",
" si10 (y, x) float32 8MB 4.214 4.246 4.193 ... 9.844 9.76\n",
" wdir10 (y, x) float32 8MB 59.63 58.9 58.46 ... 284.0 281.9\n",
"Attributes:\n",
" GRIB_edition: 2\n",
" GRIB_centre: kwbc\n",
" GRIB_centreDescription: US National Weather Service - NCEP\n",
" GRIB_subCentre: 0\n",
" Conventions: CF-1.7\n",
" institution: US National Weather Service - NCEP\n",
" model: hrrr\n",
" product: sfc\n",
" description: High-Resolution Rapid Refresh - CONUS\n",
" remote_grib: https://noaa-hrrr-bdp-pds.s3.amazonaws.com/hrrr....\n",
" local_grib: /home/blaylock/data/hrrr/20240101/subset_6bef391...\n",
" search: GRD:10 m above<xarray.Dataset> Size: 191MB\n",
"Dimensions: (isobaricInhPa: 7, y: 1059, x: 1799)\n",
"Coordinates:\n",
" time datetime64[ns] 8B 2024-01-01\n",
" step timedelta64[ns] 8B 00:00:00\n",
" * isobaricInhPa (isobaricInhPa) float64 56B 1e+03 925.0 ... 300.0 250.0\n",
" latitude (y, x) float64 15MB 21.14 21.15 21.15 ... 47.85 47.84\n",
" longitude (y, x) float64 15MB 237.3 237.3 237.3 ... 299.0 299.1\n",
" valid_time datetime64[ns] 8B 2024-01-01\n",
" gribfile_projection object 8B None\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" u (isobaricInhPa, y, x) float32 53MB -3.676 ... 25.36\n",
" v (isobaricInhPa, y, x) float32 53MB -2.176 ... 6.523\n",
" ws (isobaricInhPa, y, x) float32 53MB 4.272 ... 26.18\n",
"Attributes:\n",
" GRIB_edition: 2\n",
" GRIB_centre: kwbc\n",
" GRIB_centreDescription: US National Weather Service - NCEP\n",
" GRIB_subCentre: 0\n",
" Conventions: CF-1.7\n",
" institution: US National Weather Service - NCEP\n",
" model: hrrr\n",
" product: sfc\n",
" description: High-Resolution Rapid Refresh - CONUS\n",
" remote_grib: https://noaa-hrrr-bdp-pds.s3.amazonaws.com/hrrr....\n",
" local_grib: /home/blaylock/data/hrrr/20240101/subset_6befab7...\n",
" search: GRD:.* mb<xarray.Dataset> Size: 12MB\n",
"Dimensions: (latitude: 721, longitude: 1440)\n",
"Coordinates:\n",
" time datetime64[ns] 8B 2024-01-01\n",
" step timedelta64[ns] 8B 00:00:00\n",
" isobaricInhPa float64 8B 500.0\n",
" * latitude (latitude) float64 6kB 90.0 89.75 89.5 ... -89.75 -90.0\n",
" * longitude (longitude) float64 12kB 0.0 0.25 0.5 ... 359.5 359.8\n",
" valid_time datetime64[ns] 8B 2024-01-01\n",
" gribfile_projection object 8B None\n",
"Data variables:\n",
" u (latitude, longitude) float32 4MB 3.755 3.755 ... 5.005\n",
" v (latitude, longitude) float32 4MB -0.1128 ... 6.267\n",
" wdir (latitude, longitude) float32 4MB 271.7 271.9 ... 218.6\n",
"Attributes:\n",
" GRIB_edition: 2\n",
" GRIB_centre: kwbc\n",
" GRIB_centreDescription: US National Weather Service - NCEP\n",
" GRIB_subCentre: 0\n",
" Conventions: CF-1.7\n",
" institution: US National Weather Service - NCEP\n",
" model: gfs\n",
" product: pgrb2.0p25\n",
" description: Global Forecast System\n",
" remote_grib: https://noaa-gfs-bdp-pds.s3.amazonaws.com/gfs.20...\n",
" local_grib: /home/blaylock/data/gfs/20240101/subset_6bef0f2c...\n",
" search: GRD:500 mb