{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "bd37e360-d885-4ea8-9623-c72813a68d27",
"metadata": {},
"source": [
"# HRDPS Data 🅱\n",
"\n",
"\n",
"\n",
"BETA\n",
"Requires MetPy >=1.6\n",
"\n",
"This demonstrates using data from Canada's High Resolution Deterministic Prediction System (HRDPS).\n",
"\n",
"[HRDPS Model Description](https://eccc-msc.github.io/open-data/msc-data/nwp_hrdps/readme_hrdps-datamart_en/#data-location)\n",
"\n",
"\n",
"**Data Sources**\n",
"\n",
"|`prioriy=`|Data source| Archive Duration|\n",
"|--|--|--|\n",
"|`\"mcs\"` | [Meteorological Service of Canada](https://dd.weather.gc.ca/model_hrdps/) | Last 24 hours\n",
"\n",
"**Model Initialization**\n",
"\n",
"Model cyles every hour.\n",
"\n",
"**Forecast Hour**\n",
"\n",
"For the most recent version of HRRR...\n",
"\n",
"|`fxx=`|Forecast lead time|\n",
"|--|--|\n",
"|`0` through `48`, step=1| hourly forecasts available\n",
"\n",
"\n",
"**Products**\n",
"\n",
"|`product=`| Product Description | \n",
"|--|--|\n",
"|`\"continental/2.5km\"`| Continental domain\n",
"\n",
"**Variable and Level**\n",
"\n",
"You will need to specify the variable and level for each request. \n",
"\n",
"
\n",
"\n",
"\n",
"> **NOTE:** The organization of these files is different than other NWP products.\n",
">\n",
"> 1. There are no index files provided.\n",
"> 1. Each GRIB2 file only contains one message. The variable name and level is in the file's name.\n",
">\n",
"> Herbie requires you provide a keyword argument for both `variable` and `level`. Pay special attention to model description (linked above) to understand how the model data is organized. If you don't provide input for `variable` or `level`, Herbie will give you some ideas. For example, `variable=TMP` and `level=AGL-2m` will give you the filename that contains\n",
">\n",
"> ```\n",
"> TMP_AGL-2m\n",
"> ```\n",
"\n",
"> **Note:** This requires MetPy version 1.6 or greater which has the capability to parse the _rotated latitude longitude_ map projection type (see [MetPy/#3123](https://github.com/Unidata/MetPy/pull/3123)).\n"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "c04a6a84-7862-4d19-8460-ba50b5577ac8",
"metadata": {},
"outputs": [],
"source": [
"from herbie import Herbie\n",
"import xarray as xr\n",
"import numpy as np\n",
"\n",
"import matplotlib.pyplot as plt\n",
"from toolbox import EasyMap, pc\n",
"import cartopy.crs as ccrs\n",
"import cartopy.feature as feature\n",
"import pandas as pd\n",
"\n",
"recent = pd.Timestamp(\"now\").floor(\"6H\") - pd.Timedelta(\"6H\")"
]
},
{
"cell_type": "markdown",
"id": "b9efa12f",
"metadata": {},
"source": [
"# Some Examples\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2a6c7cc7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Found ┊ model=hrdps ┊ \u001b[3mproduct=continental/2.5km\u001b[0m ┊ \u001b[38;2;41;130;13m2023-Aug-12 06:00 UTC\u001b[92m F32\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mGRIB2 @ msc\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mIDX @ None\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'https://dd.weather.gc.ca/model_hrdps/continental/2.5km/06/032/20230812T06Z_MSC_HRDPS_TMP_AGL-2m_RLatLon0.0225_PT032H.grib2'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Some examples\n",
"\n",
"H = Herbie(\n",
" recent, # Datetime\n",
" model=\"hrdps\",\n",
" fxx=32,\n",
" product=\"continental/2.5km\",\n",
" variable=\"TMP\",\n",
" level=\"AGL-2m\",\n",
")\n",
"H.grib"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "e03b7b67",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Found ┊ model=hrdps ┊ \u001b[3mproduct=continental/2.5km\u001b[0m ┊ \u001b[38;2;41;130;13m2023-Aug-12 06:00 UTC\u001b[92m F12\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mGRIB2 @ msc\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mIDX @ None\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"'https://dd.weather.gc.ca/model_hrdps/continental/2.5km/06/012/20230812T06Z_MSC_HRDPS_HGT_ISBL_0500_RLatLon0.0225_PT012H.grib2'"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"H = Herbie(\n",
" recent, # Datetime\n",
" model=\"hrdps\",\n",
" fxx=12,\n",
" product=\"continental/2.5km\",\n",
" variable=\"HGT\",\n",
" level=\"ISBL_0500\",\n",
")\n",
"H.grib"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "4fab3cd3",
"metadata": {},
"source": [
"## Get the 2-metre temperature\n"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "ac4fc277-c878-42a0-843f-ffb60b21661f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Found ┊ model=hrdps ┊ \u001b[3mproduct=continental/2.5km\u001b[0m ┊ \u001b[38;2;41;130;13m2023-Aug-12 06:00 UTC\u001b[92m F00\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mGRIB2 @ local\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3mIDX @ None\u001b[0m\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/home/blaylock/GITHUB/Herbie/herbie/core.py:1058: UserWarning: Will not remove GRIB file because it previously existed.\n",
" warnings.warn(\"Will not remove GRIB file because it previously existed.\")\n"
]
},
{
"data": {
"text/html": [
"
<xarray.Dataset>\n",
"Dimensions: (y: 1290, x: 2540)\n",
"Coordinates:\n",
" time datetime64[ns] 2023-08-12T06:00:00\n",
" step timedelta64[ns] 00:00:00\n",
" heightAboveGround float64 2.0\n",
" latitude (y, x) float64 ...\n",
" longitude (y, x) float64 ...\n",
" valid_time datetime64[ns] ...\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" t2m (y, x) float32 ...\n",
" gribfile_projection object None\n",
"Attributes:\n",
" GRIB_edition: 2\n",
" GRIB_centre: cwao\n",
" GRIB_centreDescription: Canadian Meteorological Service - Montreal\n",
" GRIB_subCentre: 0\n",
" Conventions: CF-1.7\n",
" institution: Canadian Meteorological Service - Montreal\n",
" model: hrdps\n",
" product: continental/2.5km\n",
" description: Canada's High Resolution Deterministic Predictio...\n",
" remote_grib: /home/blaylock/data/hrdps/20230812/20230812T06Z_...\n",
" local_grib: /home/blaylock/data/hrdps/20230812/20230812T06Z_...\n",
" searchString: None<xarray.Dataset>\n",
"Dimensions: (y: 1290, x: 2540)\n",
"Coordinates:\n",
" time datetime64[ns] 2023-08-12T06:00:00\n",
" step timedelta64[ns] 00:00:00\n",
" heightAboveGround float64 10.0\n",
" latitude (y, x) float64 39.63 39.63 39.64 ... 47.91 47.89 47.88\n",
" longitude (y, x) float64 -133.6 -133.6 -133.6 ... -40.73 -40.71\n",
" valid_time datetime64[ns] 2023-08-12T06:00:00\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" u10 (y, x) float32 ...\n",
" gribfile_projection object None\n",
" v10 (y, x) float32 ...\n",
"Attributes:\n",
" GRIB_edition: 2\n",
" GRIB_centre: cwao\n",
" GRIB_centreDescription: Canadian Meteorological Service - Montreal\n",
" GRIB_subCentre: 0\n",
" Conventions: CF-1.7\n",
" institution: Canadian Meteorological Service - Montreal\n",
" model: hrdps\n",
" product: continental/2.5km\n",
" description: Canada's High Resolution Deterministic Predictio...\n",
" remote_grib: /home/blaylock/data/hrdps/20230812/20230812T06Z_...\n",
" local_grib: /home/blaylock/data/hrdps/20230812/20230812T06Z_...\n",
" searchString: None<cartopy.crs.RotatedPole object at 0x7fb110150690>" ], "text/plain": [ "
<xarray.Dataset>\n",
"Dimensions: (y: 1290, x: 2540)\n",
"Coordinates:\n",
" time datetime64[ns] 2023-08-12T06:00:00\n",
" step timedelta64[ns] 00:00:00\n",
" isobaricInhPa float64 500.0\n",
" latitude (y, x) float64 39.63 39.63 39.64 ... 47.91 47.89 47.88\n",
" longitude (y, x) float64 -133.6 -133.6 -133.6 ... -40.73 -40.71\n",
" valid_time datetime64[ns] 2023-08-12T06:00:00\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" gh (y, x) float32 ...\n",
" gribfile_projection object None\n",
" r (y, x) float32 ...\n",
"Attributes:\n",
" GRIB_edition: 2\n",
" GRIB_centre: cwao\n",
" GRIB_centreDescription: Canadian Meteorological Service - Montreal\n",
" GRIB_subCentre: 0\n",
" Conventions: CF-1.7\n",
" institution: Canadian Meteorological Service - Montreal\n",
" model: hrdps\n",
" product: continental/2.5km\n",
" description: Canada's High Resolution Deterministic Predictio...\n",
" remote_grib: /home/blaylock/data/hrdps/20230812/20230812T06Z_...\n",
" local_grib: /home/blaylock/data/hrdps/20230812/20230812T06Z_...\n",
" searchString: None<xarray.Dataset>\n",
"Dimensions: (y: 825, x: 1465)\n",
"Coordinates:\n",
" time datetime64[ns] 2023-08-12\n",
" step timedelta64[ns] 00:00:00\n",
" heightAboveGround float64 2.0\n",
" latitude (y, x) float64 ...\n",
" longitude (y, x) float64 ...\n",
" valid_time datetime64[ns] ...\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" t2m (y, x) float32 ...\n",
" gribfile_projection object None\n",
"Attributes:\n",
" GRIB_edition: 2\n",
" GRIB_centre: cwao\n",
" GRIB_centreDescription: Canadian Meteorological Service - Montreal\n",
" GRIB_subCentre: 0\n",
" Conventions: CF-1.7\n",
" institution: Canadian Meteorological Service - Montreal\n",
" model: hrdps_north\n",
" product: north/grib2\n",
" description: Canada's High Resolution Deterministic Predictio...\n",
" remote_grib: /home/blaylock/data/hrdps_north/20230812/CMC_hrd...\n",
" local_grib: /home/blaylock/data/hrdps_north/20230812/CMC_hrd...\n",
" searchString: None<cartopy.crs.Stereographic object at 0x7fb113fc4910>" ], "text/plain": [ "