{
"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, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "1910c7f021984cf0905bcc781e655d5d",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/1 [00:00, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" centre | \n",
" shortName | \n",
" typeOfLevel | \n",
" level | \n",
" dataDate | \n",
" dataTime | \n",
" stepRange | \n",
" dataType | \n",
" number | \n",
" gridType | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" ecmf | \n",
" dis06 | \n",
" surface | \n",
" 0 | \n",
" 20221008 | \n",
" 1200 | \n",
" 0-6 | \n",
" sfo | \n",
" None | \n",
" lambert_azimuthal_equal_area | \n",
"
\n",
" \n",
"
\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",
"<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, ?B/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" centre | \n",
" shortName | \n",
" typeOfLevel | \n",
" level | \n",
" dataDate | \n",
" dataTime | \n",
" stepRange | \n",
" dataType | \n",
" number | \n",
" gridType | \n",
"
\n",
" \n",
" \n",
" \n",
" | 0 | \n",
" ecmf | \n",
" 2t | \n",
" surface | \n",
" 0 | \n",
" 20200513 | \n",
" 1200 | \n",
" 0 | \n",
" an | \n",
" 0 | \n",
" regular_ll | \n",
"
\n",
" \n",
" | 1 | \n",
" ecmf | \n",
" msl | \n",
" surface | \n",
" 0 | \n",
" 20200513 | \n",
" 1200 | \n",
" 0 | \n",
" an | \n",
" 0 | \n",
" regular_ll | \n",
"
\n",
" \n",
"
\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",
"<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
}