{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Met Office UKV high-resolution atmosphere model data\n", "\n", "{bdg-primary}`Urban`\n", "{bdg-secondary}`Exploration`\n", "{bdg-warning}`Standard`\n", "{bdg-info}`Python`\n", "\n", "
\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
\n",
"
\n",
" \n",
" \n",
" \n",
" \n",
" \n",
" \n",
"
\n",
"
\n", " \n", " \n", " \n", " \n", " \n", " \n", "
" ] }, { "cell_type": "markdown", "metadata": { "tags": [ "target/urban", "theme/exploration", "track/regular", "kernel/python" ] }, "source": [ "## Context\n", "### Purpose\n", "To load, plot, regrid and extract an urban region from the UKV gridded model data using the [Iris package](https://scitools-iris.readthedocs.io/en/stable/).\n", "\n", "### Sensor description\n", "Met Office UKV model data is fairly high resolution (approximately 1 km horizontal) and available over the whole of the UK for a variety of atmospheric variables at surface and pressure levels. A selection of variables has been\n", "made openly available as part of the Met Office contribution to the COVID 19 modelling effort. A selection of variables at hourly and daily frequency in NetCDF format can be obtained from [this landing page](https://metdatasa.blob.core.windows.net/covid19-response-non-commercial/README.html). \n", "\n", "This notebook uses a single sample data file for 1.5 m temperature included with the notebook.\n", "\n", "### Highlights\n", "* Data for the whole UK is loaded and plotted using Iris\n", "* Data is regridded to a geographic projection \n", "* A region over London is extracted\n", "\n", "### Contributions\n", "\n", "#### Notebook\n", "* Samantha V. Adams (author), Met Office Informatics Lab, [@svadams](https://github.com/svadams)\n", "* Alejandro Coca-Castro (reviewer), The Alan Turing Institute, [@acocac](https://github.com/acocac)\n", "\n", "#### Dataset originator/creator\n", "* Met Office Informatics Lab (creator)\n", "* Microsoft (support)\n", "* European Regional Development Fund (support)\n", "\n", "#### Dataset authors\n", "* Met Office\n", "\n", "#### Dataset documentation\n", "```{bibliography}\n", " :style: plain\n", " :list: bullet\n", " :filter: topic % \"1b8921af-e77f-4ccf-ae38-4813cdceba0f\"\n", "```\n", "\n", ":::{note}\n", "Note this data should be used only for non-commercial purposes.\n", ":::" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Install and load libraries" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2024-03-11T19:32:10.808167Z", "iopub.status.busy": "2024-03-11T19:32:10.807753Z", "iopub.status.idle": "2024-03-11T19:32:11.879301Z", "shell.execute_reply": "2024-03-11T19:32:11.878675Z" }, "tags": [ "hide-input" ] }, "outputs": [], "source": [ "import os\n", "import iris\n", "import iris.analysis\n", "import iris.plot as iplt\n", "from iris.coords import DimCoord\n", "from iris.coord_systems import GeogCS\n", "from iris.cube import Cube\n", "\n", "from iris.fileformats.pp import EARTH_RADIUS\n", "\n", "import requests\n", "import urllib.request\n", "import pooch\n", "\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "\n", "import warnings\n", "warnings.filterwarnings(action='ignore')\n", "\n", "%matplotlib inline" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Set project structure" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2024-03-11T19:32:11.882504Z", "iopub.status.busy": "2024-03-11T19:32:11.881959Z", "iopub.status.idle": "2024-03-11T19:32:11.885203Z", "shell.execute_reply": "2024-03-11T19:32:11.884747Z" } }, "outputs": [], "source": [ "notebook_folder = './notebook'\n", "if not os.path.exists(notebook_folder):\n", " os.makedirs(notebook_folder)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Retrieve and load a sample data file" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2024-03-11T19:32:11.887205Z", "iopub.status.busy": "2024-03-11T19:32:11.887043Z", "iopub.status.idle": "2024-03-11T19:32:16.458166Z", "shell.execute_reply": "2024-03-11T19:32:16.457598Z" } }, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "Downloading data from 'doi:10.5281/zenodo.7087009/ukv_daily_t1o5m_mean_20150801.nc' to file '/home/jovyan/notebook/ukv_daily_t1o5m_mean_20150801.nc'.\n" ] } ], "source": [ "filepath = 'https://metdatasa.blob.core.windows.net/covid19-response-non-commercial/metoffice_ukv_daily/t1o5m_mean/'\n", "filename = 'ukv_daily_t1o5m_mean_20150801.nc'\n", "\n", "response = requests.get(filepath+filename)\n", "if response.status_code == 200:\n", " urllib.request.urlretrieve(filepath+filename, os.path.join(notebook_folder, filename))\n", "else:\n", " pooch.retrieve(\n", " url=\"doi:10.5281/zenodo.7087009/ukv_daily_t1o5m_mean_20150801.nc\",\n", " known_hash=\"md5:b71e092ead092f419f12073ddf2d3256\",\n", " path=notebook_folder,\n", " fname=\"ukv_daily_t1o5m_mean_20150801.nc\"\n", " )" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2024-03-11T19:32:16.460842Z", "iopub.status.busy": "2024-03-11T19:32:16.460489Z", "iopub.status.idle": "2024-03-11T19:32:16.502946Z", "shell.execute_reply": "2024-03-11T19:32:16.502338Z" } }, "outputs": [], "source": [ "air_temp = iris.load_cube(os.path.join(notebook_folder, filename))\n", "air_temp.coord('grid_latitude').guess_bounds()\n", "air_temp.coord('grid_longitude').guess_bounds()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Visualisation\n", "\n", "Here we use the Iris wrapper to matplotlib pyplot to plot the gridded data with added gridlines and coastline." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2024-03-11T19:32:16.505457Z", "iopub.status.busy": "2024-03-11T19:32:16.505279Z", "iopub.status.idle": "2024-03-11T19:32:18.076060Z", "shell.execute_reply": "2024-03-11T19:32:18.075433Z" }, "tags": [ "hide-input" ] }, "outputs": [ { "data": { "text/plain": [ "