{ "cells": [ { "cell_type": "markdown", "id": "73693729", "metadata": {}, "source": [ "# GEPS and REPS\n", "\n", "This notebook demonstrates how to access Canada's ensemble model data with Herbie:\n", "\n", "- `model=\"geps\"` (Global Ensemble Prediction System)\n", "- `model=\"reps\"` (Regional Ensemble Prediction System)\n", "\n", "These are lightweight access examples (URL discovery, source checks, and inventory)." ] }, { "cell_type": "code", "execution_count": 15, "id": "9e9c9953", "metadata": {}, "outputs": [], "source": [ "from herbie import Herbie\n", "import pandas as pd" ] }, { "cell_type": "markdown", "id": "796419a7", "metadata": {}, "source": [ "## Pick a recent cycle\n", "\n", "GEPS and REPS are both ECCC models. We pick a recent 00/12 UTC cycle for examples." ] }, { "cell_type": "code", "execution_count": 16, "id": "9d15cb2b", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Timestamp('2026-04-17 00:00:00')" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "recent = pd.Timestamp(\"now\", tz=\"UTC\").floor(\"12h\").tz_convert(None) - pd.Timedelta(\"12h\")\n", "recent" ] }, { "cell_type": "markdown", "id": "174c5760", "metadata": {}, "source": [ "## GEPS example\n", "\n", "GEPS supports two products:\n", "\n", "- `product=\"geps-prod\"`\n", "- `product=\"geps-raw\"`" ] }, { "cell_type": "code", "execution_count": 17, "id": "d4a2ec8c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "✅ Found ┊ model=geps ┊ \u001b[3mproduct=geps-raw\u001b[0m ┊ \u001b[38;2;41;130;13m2026-Apr-17 00:00 UTC\u001b[92m F24\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" ] }, { "data": { "text/plain": [ "\u001b[48;2;255;255;255m\u001b[38;2;136;33;27m▌\u001b[0m\u001b[38;2;12;53;118m\u001b[48;2;240;234;210m▌\u001b[38;2;0;0;0m\u001b[1mHerbie\u001b[0m GEPS model \u001b[3mgeps-raw\u001b[0m product initialized \u001b[38;2;41;130;13m2026-Apr-17 00:00 UTC\u001b[92m F24\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3msource=local\u001b[0m" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "H = Herbie(\n", " recent,\n", " model=\"geps\",\n", " product=\"geps-raw\",\n", " fxx=24,\n", " variable=\"TMP\",\n", " level=\"ISBL_0850\",\n", ")\n", "H" ] }, { "cell_type": "code", "execution_count": 18, "id": "d2c9ecb9", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'msc': 'https://dd.weather.gc.ca/20260417/WXO-DD/ensemble/geps/grib2/raw/00/024/CMC_geps-raw_TMP_ISBL_0850_latlon0p5x0p5_2026041700_P024_allmbrs.grib2'}" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Candidate remote sources\n", "H.SOURCES" ] }, { "cell_type": "code", "execution_count": 19, "id": "66b67157", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'geps-prod': 'processed ensemble products (probabilities, means, etc.); files served from grib2/products',\n", " 'geps-raw': 'raw ensemble member output; files served from grib2/raw'}" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "H.PRODUCTS" ] }, { "cell_type": "code", "execution_count": 20, "id": "e7909e98", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Note: Returning a list of [2] xarray.Datasets because cfgrib opened with multiple hypercubes.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/kps5442/mapwall_dev/herbie-dev/src/herbie/core.py:1301: 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/plain": [ "[ Size: 1MB\n", " Dimensions: (latitude: 361, longitude: 720)\n", " Coordinates:\n", " * latitude (latitude) float64 3kB -90.0 -89.5 -89.0 ... 89.5 90.0\n", " * longitude (longitude) float64 6kB 0.0 0.5 1.0 ... 359.0 359.5\n", " number int64 8B 0\n", " time datetime64[ns] 8B 2026-04-17\n", " step timedelta64[ns] 8B 1 days\n", " isobaricInhPa float64 8B 850.0\n", " valid_time datetime64[ns] 8B ...\n", " gribfile_projection object 8B None\n", " Data variables:\n", " t (latitude, longitude) float32 1MB ...\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: geps\n", " product: geps-raw\n", " description: Canada's Global Ensemble Prediction System (GEPS)\n", " remote_grib: /home/meteo/kps5442/data/geps/20260417/CMC_geps-...\n", " local_grib: /home/meteo/kps5442/data/geps/20260417/CMC_geps-...\n", " search: None,\n", " Size: 21MB\n", " Dimensions: (number: 20, latitude: 361, longitude: 720)\n", " Coordinates:\n", " * number (number) int64 160B 1 2 3 4 5 6 7 ... 15 16 17 18 19 20\n", " * latitude (latitude) float64 3kB -90.0 -89.5 -89.0 ... 89.5 90.0\n", " * longitude (longitude) float64 6kB 0.0 0.5 1.0 ... 359.0 359.5\n", " time datetime64[ns] 8B 2026-04-17\n", " step timedelta64[ns] 8B 1 days\n", " isobaricInhPa float64 8B 850.0\n", " valid_time datetime64[ns] 8B ...\n", " gribfile_projection object 8B None\n", " Data variables:\n", " t (number, latitude, longitude) float32 21MB ...\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: geps\n", " product: geps-raw\n", " description: Canada's Global Ensemble Prediction System (GEPS)\n", " remote_grib: /home/meteo/kps5442/data/geps/20260417/CMC_geps-...\n", " local_grib: /home/meteo/kps5442/data/geps/20260417/CMC_geps-...\n", " search: None]" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Inspect GRIB inventory (if available for the selected source)\n", "H.xarray()" ] }, { "cell_type": "code", "execution_count": 21, "id": "60950b31", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['DBLL_100',\n", " 'DBLY_10',\n", " 'EATM_0',\n", " 'ISBL_1',\n", " 'ISBL_10',\n", " 'ISBL_100',\n", " 'ISBL_1000',\n", " 'ISBL_1015',\n", " 'ISBL_150',\n", " 'ISBL_175',\n", " 'ISBL_20',\n", " 'ISBL_200',\n", " 'ISBL_225',\n", " 'ISBL_250',\n", " 'ISBL_275',\n", " 'ISBL_30',\n", " 'ISBL_300',\n", " 'ISBL_350',\n", " 'ISBL_400',\n", " 'ISBL_450',\n", " 'ISBL_5',\n", " 'ISBL_50',\n", " 'ISBL_500',\n", " 'ISBL_550',\n", " 'ISBL_600',\n", " 'ISBL_650',\n", " 'ISBL_700',\n", " 'ISBL_750',\n", " 'ISBL_800',\n", " 'ISBL_850',\n", " 'ISBL_875',\n", " 'ISBL_900',\n", " 'ISBL_925',\n", " 'ISBL_950',\n", " 'ISBL_970',\n", " 'ISBL_985',\n", " 'ISBY_1000-500',\n", " 'MSL_0',\n", " 'NTAT_0',\n", " 'PVU_1',\n", " 'PVU_1.5',\n", " 'PVU_2',\n", " 'SFC_0',\n", " 'TGL_10',\n", " 'TGL_120',\n", " 'TGL_2',\n", " 'TGL_40',\n", " 'TGL_80']" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# View level names\n", "H.AVAILABLE_LEVELS" ] }, { "cell_type": "code", "execution_count": 22, "id": "b40e7378", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "['ABSV',\n", " 'ACPCP',\n", " 'ALERT',\n", " 'APCP',\n", " 'CAPE',\n", " 'CIN',\n", " 'CWAT',\n", " 'DEPR',\n", " 'DLWRF',\n", " 'DPT',\n", " 'DSWRF',\n", " 'GUST',\n", " 'HEATX',\n", " 'HGT',\n", " 'HPBL',\n", " 'KX',\n", " 'LHTFL',\n", " 'MU-VT-LI',\n", " 'NLWRS',\n", " 'NSWRS',\n", " 'PRATE',\n", " 'PRES',\n", " 'PRMSL',\n", " 'PTYPE',\n", " 'RH',\n", " 'SHWINX',\n", " 'SKINT',\n", " 'SNOD',\n", " 'SPFH',\n", " 'TCDC',\n", " 'TMAX',\n", " 'TMIN',\n", " 'TMP',\n", " 'UGRD',\n", " 'ULWRF',\n", " 'VGRD',\n", " 'VVEL',\n", " 'WCHIL',\n", " 'WDIR',\n", " 'WEAFR',\n", " 'WEAPE',\n", " 'WEARN',\n", " 'WEASN',\n", " 'WIND']" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# View variable names\n", "H.AVAILABLE_VARIABLES" ] }, { "cell_type": "markdown", "id": "e6300140", "metadata": {}, "source": [ "## REPS example\n", "\n", "REPS files are organized under the 10-km product path:\n", "\n", "- `product=\"10km/grib2\"`" ] }, { "cell_type": "code", "execution_count": 23, "id": "6c527971", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "✅ Found ┊ model=reps ┊ \u001b[3mproduct=10km/grib2\u001b[0m ┊ \u001b[38;2;41;130;13m2026-Apr-17 00:00 UTC\u001b[92m F06\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" ] }, { "data": { "text/plain": [ "\u001b[48;2;255;255;255m\u001b[38;2;136;33;27m▌\u001b[0m\u001b[38;2;12;53;118m\u001b[48;2;240;234;210m▌\u001b[38;2;0;0;0m\u001b[1mHerbie\u001b[0m REPS model \u001b[3m10km/grib2\u001b[0m product initialized \u001b[38;2;41;130;13m2026-Apr-17 00:00 UTC\u001b[92m F06\u001b[0m ┊ \u001b[38;2;255;153;0m\u001b[3msource=local\u001b[0m" ] }, "execution_count": 23, "metadata": {}, "output_type": "execute_result" } ], "source": [ "H = Herbie(\n", " recent,\n", " model=\"reps\",\n", " product=\"10km/grib2\",\n", " fxx=6,\n", " variable=\"ASNOW\",\n", " level=\"SFC\",\n", ")\n", "H" ] }, { "cell_type": "code", "execution_count": 24, "id": "d87bf871", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'msc': 'https://dd.weather.gc.ca/20260417/WXO-DD/ensemble/reps/10km/grib2/00/006/20260417T00Z_MSC_REPS_ASNOW_SFC_RLatLon0.09x0.09_PT006H.grib2'}" ] }, "execution_count": 24, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Candidate remote sources\n", "H.SOURCES" ] }, { "cell_type": "code", "execution_count": 25, "id": "c90f8c11", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "{'10km/grib2': 'regional 10 km ensemble domain'}" ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# The resolved remote file name from the selected model/date/fxx/variable/level\n", "H.PRODUCTS" ] }, { "cell_type": "code", "execution_count": 26, "id": "bf46b84c", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Note: Returning a list of [2] xarray.Datasets because cfgrib opened with multiple hypercubes.\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/home/kps5442/mapwall_dev/herbie-dev/src/herbie/core.py:1301: 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/plain": [ "[ Size: 17MB\n", " Dimensions: (y: 960, x: 908)\n", " Coordinates:\n", " latitude (y, x) float64 7MB ...\n", " longitude (y, x) float64 7MB ...\n", " number int64 8B 0\n", " time datetime64[ns] 8B 2026-04-17\n", " step timedelta64[ns] 8B 06:00:00\n", " surface float64 8B 0.0\n", " valid_time datetime64[ns] 8B ...\n", " gribfile_projection object 8B None\n", " Dimensions without coordinates: y, x\n", " Data variables:\n", " tsnowp (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: reps\n", " product: 10km/grib2\n", " description: Canada's Regional Ensemble Prediction System (REPS)\n", " remote_grib: /home/meteo/kps5442/data/reps/20260417/20260417T...\n", " local_grib: /home/meteo/kps5442/data/reps/20260417/20260417T...\n", " search: None,\n", " Size: 84MB\n", " Dimensions: (number: 20, y: 960, x: 908)\n", " Coordinates:\n", " * number (number) int64 160B 1 2 3 4 5 6 7 ... 15 16 17 18 19 20\n", " latitude (y, x) float64 7MB ...\n", " longitude (y, x) float64 7MB ...\n", " time datetime64[ns] 8B 2026-04-17\n", " step timedelta64[ns] 8B 06:00:00\n", " surface float64 8B 0.0\n", " valid_time datetime64[ns] 8B ...\n", " gribfile_projection object 8B None\n", " Dimensions without coordinates: y, x\n", " Data variables:\n", " tsnowp (number, y, x) float32 70MB ...\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: reps\n", " product: 10km/grib2\n", " description: Canada's Regional Ensemble Prediction System (REPS)\n", " remote_grib: /home/meteo/kps5442/data/reps/20260417/20260417T...\n", " local_grib: /home/meteo/kps5442/data/reps/20260417/20260417T...\n", " search: None]" ] }, "execution_count": 26, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# Looks like you get both the ensemble members and the control run in the same file?\n", "H.xarray()" ] } ], "metadata": { "kernelspec": { "display_name": "herbie-dev-local", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.14.4" } }, "nbformat": 4, "nbformat_minor": 5 }