{ "cells": [ { "attachments": {}, "cell_type": "markdown", "metadata": {}, "source": [ "# 🧭 CRS with MetPy\n", "\n", "What if you need to manually attach coordinate reference system because metpy can't detect it?" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from herbie import Herbie\n", "import metpy" ] }, { "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;13m2021-Jan-25 06: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" ] } ], "source": [ "H = Herbie(\"2021-01-25 06:00\", model=\"hrrr\")" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "👨🏻🏭 Created directory: [C:\\Users\\blaylock\\data\\hrrr\\20210125]\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "C:\\Users\\blaylock\\_GITHUB\\Herbie\\herbie\\archive.py:1041: UserWarning: sorry, on windows I couldn't remove the file.\n", " warnings.warn(\"sorry, on windows I couldn't remove the file.\")\n" ] } ], "source": [ "ds = H.xarray(\"TMP:2 m\")" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n",
"Dimensions: (y: 1059, x: 1799)\n",
"Coordinates:\n",
" time datetime64[ns] 2021-01-25T06:00:00\n",
" step timedelta64[ns] 00:00:00\n",
" heightAboveGround float64 2.0\n",
" latitude (y, x) float64 21.14 21.15 21.15 ... 47.86 47.85 47.84\n",
" longitude (y, x) float64 237.3 237.3 237.3 ... 299.0 299.0 299.1\n",
" valid_time datetime64[ns] 2021-01-25T06:00:00\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" t2m (y, x) float32 292.3 292.3 292.3 ... 272.9 272.9 273.0\n",
" gribfile_projection object None\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: C:\\Users\\blaylock\\data\\hrrr\\20210125\\subset_f7ef...\n",
" searchString: TMP:2 m<xarray.Dataset>\n",
"Dimensions: (y: 1059, x: 1799)\n",
"Coordinates:\n",
" time datetime64[ns] 2021-01-25T06:00:00\n",
" step timedelta64[ns] 00:00:00\n",
" heightAboveGround float64 2.0\n",
" latitude (y, x) float64 21.14 21.15 21.15 ... 47.86 47.85 47.84\n",
" longitude (y, x) float64 237.3 237.3 237.3 ... 299.0 299.0 299.1\n",
" valid_time datetime64[ns] 2021-01-25T06:00:00\n",
" metpy_crs object Projection: lambert_conformal_conic\n",
"Dimensions without coordinates: y, x\n",
"Data variables:\n",
" t2m (y, x) float32 292.3 292.3 292.3 ... 272.9 272.9 273.0\n",
" gribfile_projection object None\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: C:\\Users\\blaylock\\data\\hrrr\\20210125\\subset_f7ef...\n",
" searchString: TMP:2 m<xarray.DataArray 'gribfile_projection' ()>\n",
"array(None, dtype=object)\n",
"Coordinates:\n",
" time datetime64[ns] 2021-01-25T06:00:00\n",
" step timedelta64[ns] 00:00:00\n",
" heightAboveGround float64 2.0\n",
" valid_time datetime64[ns] 2021-01-25T06:00:00\n",
"Attributes: (12/17)\n",
" crs_wkt: PROJCRS["unknown",BASEGEOGCRS["unknown",D...\n",
" semi_major_axis: 6371229.0\n",
" semi_minor_axis: 6371229.0\n",
" inverse_flattening: 0.0\n",
" reference_ellipsoid_name: unknown\n",
" longitude_of_prime_meridian: 0.0\n",
" ... ...\n",
" standard_parallel: (38.5, 38.5)\n",
" latitude_of_projection_origin: 38.5\n",
" longitude_of_central_meridian: 262.5\n",
" false_easting: 0.0\n",
" false_northing: 0.0\n",
" long_name: HRRR model grid projection