{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "bd37e360-d885-4ea8-9623-c72813a68d27",
"metadata": {},
"source": [
"# RDPS 🅱\n",
"\n",
"\n",
"\n",
"BETA\n",
"Requires MetPy >=1.6\n",
"\n",
"This demonstrates using data from Canada's GEM Regional or Regional Deterministic Prediction System (RDPS).\n",
"\n",
"[RDPS Model Description](https://eccc-msc.github.io/open-data/msc-data/nwp_rdps/readme_rdps-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_gem_regional/) | Last 24 hours\n",
"\n",
"**Model Initialization**\n",
"\n",
"Model cyles every six hours.\n",
"\n",
"**Forecast Hour**\n",
"\n",
"For the most recent version of RDPS...\n",
"\n",
"|`fxx=`|Forecast lead time|\n",
"|--|--|\n",
"|`0` through `84`, step=1| hourly forecasts available\n",
"\n",
"\n",
"**Products**\n",
"\n",
"|`product=`| Product Description | \n",
"|--|--|\n",
"|`\"10km/grib2\"`| Regional 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=TGL_2` will give you the filename that contains\n",
">\n",
"> ```\n",
"> TMP_TGL_2\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 herbie.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(\"12h\") - pd.Timedelta(\"12h\")"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "2a6c7cc7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Found ┊ model=rdps ┊ \u001b[3mproduct=10km/grib2/\u001b[0m ┊ \u001b[38;2;41;130;13m2024-Apr-11 00: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_gem_regional/10km/grib2//00/032/CMC_reg_TMP_TGL_2_ps10km_2024041100_P032.grib2'"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# Some examples\n",
"\n",
"H = Herbie(\n",
" recent, # Datetime\n",
" model=\"rdps\",\n",
" fxx=32,\n",
" variable=\"TMP\",\n",
" level=\"TGL_2\",\n",
")\n",
"H.grib"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "e03b7b67",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Found ┊ model=rdps ┊ \u001b[3mproduct=10km/grib2/\u001b[0m ┊ \u001b[38;2;41;130;13m2024-Apr-11 00: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_gem_regional/10km/grib2//00/012/CMC_reg_HGT_ISBL_500_ps10km_2024041100_P012.grib2'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"H = Herbie(\n",
" recent, # Datetime\n",
" model=\"rdps\",\n",
" fxx=12,\n",
" variable=\"HGT\",\n",
" level=\"ISBL_500\",\n",
")\n",
"H.grib"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "4fab3cd3",
"metadata": {},
"source": [
"## Get the 2-metre temperature\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "ac4fc277-c878-42a0-843f-ffb60b21661f",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ Found ┊ model=rdps ┊ \u001b[3mproduct=10km/grib2/\u001b[0m ┊ \u001b[38;2;41;130;13m2024-Apr-11 00:00 UTC\u001b[92m F00\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",
"👨🏻🏭 Created directory: [/p/cwfs/blaylock/data/rdps/20240411]\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/p/home/blaylock/BB_python/Herbie/herbie/core.py:1105: UserWarning: Will not remove GRIB file because Herbie will only remove subsetted files (not full files).\n",
" warnings.warn(\n"
]
},
{
"data": {
"text/html": [
"
<xarray.Dataset> Size: 15MB\n",
"Dimensions: (y: 824, x: 935)\n",
"Coordinates:\n",
" time datetime64[ns] 8B 2024-04-11\n",
" step timedelta64[ns] 8B 00:00:00\n",
" heightAboveGround float64 8B 2.0\n",
" latitude (y, x) float64 6MB ...\n",
" longitude (y, x) float64 6MB ...\n",
" valid_time datetime64[ns] 8B ...\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" t2m (y, x) float32 3MB ...\n",
" gribfile_projection object 8B 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: rdps\n",
" product: 10km/grib2/\n",
" description: Canada's Regional Deterministic Prediction Syste...\n",
" remote_grib: /p/cwfs/blaylock/data/rdps/20240411/CMC_reg_TMP_...\n",
" local_grib: /p/cwfs/blaylock/data/rdps/20240411/CMC_reg_TMP_...\n",
" search: None<xarray.Dataset> Size: 18MB\n",
"Dimensions: (y: 824, x: 935)\n",
"Coordinates:\n",
" time datetime64[ns] 8B 2024-04-11\n",
" step timedelta64[ns] 8B 00:00:00\n",
" heightAboveGround float64 8B 10.0\n",
" latitude (y, x) float64 6MB 18.15 18.18 18.21 ... 45.49 45.41\n",
" longitude (y, x) float64 6MB 217.1 217.2 217.2 ... 349.8 349.8\n",
" valid_time datetime64[ns] 8B 2024-04-11\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" u10 (y, x) float32 3MB ...\n",
" gribfile_projection object 8B None\n",
" v10 (y, x) float32 3MB ...\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: rdps\n",
" product: 10km/grib2/\n",
" description: Canada's Regional Deterministic Prediction Syste...\n",
" remote_grib: /p/cwfs/blaylock/data/rdps/20240411/CMC_reg_UGRD...\n",
" local_grib: /p/cwfs/blaylock/data/rdps/20240411/CMC_reg_UGRD...\n",
" search: None<cartopy.crs.Stereographic object at 0x2b4759666490>" ], "text/plain": [ "
<xarray.Dataset> Size: 18MB\n",
"Dimensions: (y: 824, x: 935)\n",
"Coordinates:\n",
" time datetime64[ns] 8B 2024-04-11\n",
" step timedelta64[ns] 8B 00:00:00\n",
" isobaricInhPa float64 8B 500.0\n",
" latitude (y, x) float64 6MB 18.15 18.18 18.21 ... 45.49 45.41\n",
" longitude (y, x) float64 6MB 217.1 217.2 217.2 ... 349.8 349.8\n",
" valid_time datetime64[ns] 8B 2024-04-11\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" gh (y, x) float32 3MB ...\n",
" gribfile_projection object 8B None\n",
" r (y, x) float32 3MB ...\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: rdps\n",
" product: 10km/grib2/\n",
" description: Canada's Regional Deterministic Prediction Syste...\n",
" remote_grib: /p/cwfs/blaylock/data/rdps/20240411/CMC_reg_HGT_...\n",
" local_grib: /p/cwfs/blaylock/data/rdps/20240411/CMC_reg_HGT_...\n",
" search: None