{ "cells": [ { "cell_type": "markdown", "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "source": [ "## Projections" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import earthkit.data as ekd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "fab4f3d8e9c34377a70ae7e82756534d", "version_major": 2, "version_minor": 0 }, "text/plain": [ "efas.grib: 0%| | 0.00/1.16M [00:00\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
centreshortNametypeOfLevelleveldataDatedataTimestepRangedataTypenumbergridType
0ecmfdis06surface02022100812000-6sfoNonelambert_azimuthal_equal_area
\n", "" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange dataType \\\n", "0 ecmf dis06 surface 0 20221008 1200 0-6 sfo \n", "\n", " number gridType \n", "0 None lambert_azimuthal_equal_area " ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "efas = ekd.from_source(\"sample\", \"efas.grib\")\n", "efas.ls()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+proj=laea +lon_0=10.000000 +lat_0=52.000000 +a=6378137.000000 +b=6356752.314000\n" ] } ], "source": [ "projection = efas[0].projection()\n", "print(projection)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'+proj=laea +lon_0=10.000000 +lat_0=52.000000 +a=6378137.000000 +b=6356752.314000'" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "projection.to_proj_string()" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 2025-08-11T13:26:49.088027\n", " image/svg+xml\n", " \n", " \n", " Matplotlib v3.10.1, https://matplotlib.org/\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "
<cartopy.crs.LambertAzimuthalEqualArea object at 0x28e72eb10>
" ], "text/plain": [ "\n", "Name: unknown\n", "Axis Info [cartesian]:\n", "- E[east]: Easting (metre)\n", "- N[north]: Northing (metre)\n", "Area of Use:\n", "- undefined\n", "Coordinate Operation:\n", "- name: unknown\n", "- method: Lambert Azimuthal Equal Area\n", "Datum: unknown\n", "- Ellipsoid: unknown\n", "- Prime Meridian: Greenwich" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "projection.to_cartopy_crs()" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'central_longitude': 10.0, 'central_latitude': 52.0}\n", "{'semimajor_axis': 6378137.0, 'semiminor_axis': 6356752.314}\n" ] } ], "source": [ "print(projection.parameters)\n", "print(projection.globe)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "1d4d509ea0004fda9fd001d25bc4cc3b", "version_major": 2, "version_minor": 0 }, "text/plain": [ "test.grib: 0%| | 0.00/1.03k [00:00\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
centreshortNametypeOfLevelleveldataDatedataTimestepRangedataTypenumbergridType
0ecmf2tsurface02020051312000an0regular_ll
1ecmfmslsurface02020051312000an0regular_ll
\n", "" ], "text/plain": [ " centre shortName typeOfLevel level dataDate dataTime stepRange dataType \\\n", "0 ecmf 2t surface 0 20200513 1200 0 an \n", "1 ecmf msl surface 0 20200513 1200 0 an \n", "\n", " number gridType \n", "0 0 regular_ll \n", "1 0 regular_ll " ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "era5 = ekd.from_source(\"sample\", \"test.grib\")\n", "era5.ls()" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "+proj=longlat +datum=WGS84 +no_defs +type=crs\n" ] } ], "source": [ "projection = era5[0].projection()\n", "print(projection)" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'+proj=longlat +datum=WGS84 +no_defs +type=crs'" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "projection.to_proj_string()" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/html": [ "\n", "\n", "\n", " \n", " \n", " \n", " \n", " 2025-08-11T13:26:49.834726\n", " image/svg+xml\n", " \n", " \n", " Matplotlib v3.10.1, https://matplotlib.org/\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "\n", "
<cartopy.crs.PlateCarree object at 0x291dae650>
" ], "text/plain": [ "\n", "Name: unknown\n", "Axis Info [cartesian]:\n", "- E[east]: Easting (unknown)\n", "- N[north]: Northing (unknown)\n", "- h[up]: Ellipsoidal height (metre)\n", "Area of Use:\n", "- undefined\n", "Coordinate Operation:\n", "- name: unknown\n", "- method: Equidistant Cylindrical\n", "Datum: World Geodetic System 1984\n", "- Ellipsoid: WGS 84\n", "- Prime Meridian: Greenwich" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "projection.to_cartopy_crs()" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{}\n" ] } ], "source": [ "print(projection.parameters)" ] } ], "metadata": { "kernelspec": { "display_name": "dev", "language": "python", "name": "dev" }, "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.11.12" }, "vscode": { "interpreter": { "hash": "8704dbb6ec5f73a08b81b22d7c510a8e1ea00dbcecd62044e815aee569cc8cef" } } }, "nbformat": 4, "nbformat_minor": 4 }