{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "tobac example: Tracking of deep convection based on OLR from convection permitting model simulations\n", "==\n", "This example notebook demonstrates the use of tobac to track deep convection based on the outgoing longwave radiation (OLR) from convection permitting simulations.\n", "\n", "The simulation results used in this example were performed as part of the ACPC deep convection intercomparison case study (http://acpcinitiative.org/Docs/ACPC_DCC_Roadmap_171019.pdf) with WRF using the Morrison microphysics scheme. Simulations were performed with a horizontal grid spacing of 4.5 km.\n", "\n", "The data used in this example is downloaded from Zenodo automatically as part of the notebooks." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Import libraries:**" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "execution": { "iopub.execute_input": "2026-02-02T20:13:53.584147Z", "iopub.status.busy": "2026-02-02T20:13:53.583773Z", "iopub.status.idle": "2026-02-02T20:13:54.343757Z", "shell.execute_reply": "2026-02-02T20:13:54.343300Z" } }, "outputs": [], "source": [ "# Import a range of python libraries used in this notebook:\n", "import datetime\n", "import shutil\n", "from pathlib import Path\n", "from six.moves import urllib\n", "\n", "import numpy as np\n", "import pandas as pd\n", "import xarray as xr\n", "\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "execution": { "iopub.execute_input": "2026-02-02T20:13:54.345490Z", "iopub.status.busy": "2026-02-02T20:13:54.345305Z", "iopub.status.idle": "2026-02-02T20:13:55.597642Z", "shell.execute_reply": "2026-02-02T20:13:55.597122Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "using tobac version 1.6.2\n" ] } ], "source": [ "# Import tobac itself:\n", "import tobac\n", "print('using tobac version', str(tobac.__version__))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "execution": { "iopub.execute_input": "2026-02-02T20:13:55.616590Z", "iopub.status.busy": "2026-02-02T20:13:55.616337Z", "iopub.status.idle": "2026-02-02T20:13:55.618527Z", "shell.execute_reply": "2026-02-02T20:13:55.618134Z" } }, "outputs": [], "source": [ "# Disable a few warnings:\n", "import warnings\n", "warnings.filterwarnings('ignore', category=UserWarning, append=True)\n", "warnings.filterwarnings('ignore', category=RuntimeWarning, append=True)\n", "warnings.filterwarnings('ignore', category=FutureWarning, append=True)\n", "warnings.filterwarnings('ignore',category=pd.io.pytables.PerformanceWarning)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "execution": { "iopub.execute_input": "2026-02-02T20:13:55.619826Z", "iopub.status.busy": "2026-02-02T20:13:55.619733Z", "iopub.status.idle": "2026-02-02T20:13:55.621667Z", "shell.execute_reply": "2026-02-02T20:13:55.621287Z" } }, "outputs": [], "source": [ "#Set up directory to save output and plots:\n", "savedir=Path(\"Save\")\n", "if not savedir.is_dir():\n", " savedir.mkdir()\n", "plot_dir=Path(\"Plot\")\n", "if not plot_dir.is_dir():\n", " plot_dir.mkdir()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Download example data:** \n", "The actual download is only necessary once for all example notebooks.\n" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "execution": { "iopub.execute_input": "2026-02-02T20:13:55.622885Z", "iopub.status.busy": "2026-02-02T20:13:55.622794Z", "iopub.status.idle": "2026-02-02T20:13:55.624270Z", "shell.execute_reply": "2026-02-02T20:13:55.623887Z" } }, "outputs": [], "source": [ "data_out=Path('../')" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "execution": { "iopub.execute_input": "2026-02-02T20:13:55.625357Z", "iopub.status.busy": "2026-02-02T20:13:55.625281Z", "iopub.status.idle": "2026-02-02T20:13:55.628618Z", "shell.execute_reply": "2026-02-02T20:13:55.628206Z" } }, "outputs": [], "source": [ "# Download the data: This only has to be done once for all tobac examples and can take a while\n", "data_file = list(data_out.rglob('data/Example_input_OLR_model.nc'))\n", "if len(data_file) == 0:\n", " file_path='https://zenodo.org/records/3195910/files/climate-processes/tobac_example_data-v1.0.1.zip'\n", " #file_path='http://zenodo..'\n", " tempfile=Path('temp.zip')\n", " print('start downloading data')\n", " request=urllib.request.urlretrieve(file_path, tempfile)\n", " print('start extracting data')\n", " shutil.unpack_archive(tempfile, data_out)\n", " tempfile.unlink()\n", " print('data extracted')\n", " data_file = list(data_out.rglob('data/Example_input_OLR_model.nc'))" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "execution": { "iopub.execute_input": "2026-02-02T20:13:55.629900Z", "iopub.status.busy": "2026-02-02T20:13:55.629816Z", "iopub.status.idle": "2026-02-02T20:13:56.298599Z", "shell.execute_reply": "2026-02-02T20:13:56.298035Z" } }, "outputs": [], "source": [ "#Load Data from downloaded file:\n", "OLR = xr.open_dataset(data_file[0]).OLR" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "execution": { "iopub.execute_input": "2026-02-02T20:13:56.300154Z", "iopub.status.busy": "2026-02-02T20:13:56.300001Z", "iopub.status.idle": "2026-02-02T20:13:56.306841Z", "shell.execute_reply": "2026-02-02T20:13:56.306386Z" } }, "outputs": [ { "data": { "text/html": [ "
<xarray.DataArray 'OLR' (time: 96, south_north: 110, west_east: 132)> Size: 6MB\n",
"[1393920 values with dtype=float32]\n",
"Coordinates:\n",
" * time (time) datetime64[ns] 768B 2013-06-19T19:05:00 ... 2013-06-2...\n",
" * south_north (south_north) int64 880B 156 157 158 159 ... 262 263 264 265\n",
" * west_east (west_east) int64 1kB 201 202 203 204 205 ... 329 330 331 332\n",
" latitude (south_north, west_east) float32 58kB ...\n",
" longitude (south_north, west_east) float32 58kB ...\n",
" x (west_east) float64 1kB ...\n",
" y (south_north) float64 880B ...\n",
" x_0 (west_east) int64 1kB ...\n",
" y_0 (south_north) int64 880B ...\n",
"Attributes:\n",
" units: W m-2| \n", " | frame | \n", "idx | \n", "hdim_1 | \n", "hdim_2 | \n", "num | \n", "threshold_value | \n", "feature | \n", "time | \n", "timestr | \n", "south_north | \n", "west_east | \n", "latitude | \n", "longitude | \n", "x | \n", "y | \n", "x_0 | \n", "y_0 | \n", "
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | \n", "0 | \n", "5 | \n", "62.743547 | \n", "59.631834 | \n", "9 | \n", "250 | \n", "1 | \n", "2013-06-19 19:05:00 | \n", "2013-06-19 19:05:00 | \n", "218.743547 | \n", "260.631834 | \n", "30.232511 | \n", "-92.171414 | \n", "1.175093e+06 | \n", "9.865960e+05 | \n", "260.631834 | \n", "218.743547 | \n", "
| 1 | \n", "0 | \n", "8 | \n", "67.672946 | \n", "53.464557 | \n", "6 | \n", "250 | \n", "2 | \n", "2013-06-19 19:05:00 | \n", "2013-06-19 19:05:00 | \n", "223.672946 | \n", "254.464557 | \n", "30.441024 | \n", "-92.459497 | \n", "1.147341e+06 | \n", "1.008778e+06 | \n", "254.464557 | \n", "223.672946 | \n", "
| 2 | \n", "0 | \n", "11 | \n", "73.655933 | \n", "130.435766 | \n", "5 | \n", "250 | \n", "3 | \n", "2013-06-19 19:05:00 | \n", "2013-06-19 19:05:00 | \n", "229.655933 | \n", "331.435766 | \n", "30.565232 | \n", "-88.779386 | \n", "1.493711e+06 | \n", "1.035702e+06 | \n", "331.435766 | \n", "229.655933 | \n", "
| 3 | \n", "0 | \n", "12 | \n", "74.385746 | \n", "122.150648 | \n", "6 | \n", "250 | \n", "4 | \n", "2013-06-19 19:05:00 | \n", "2013-06-19 19:05:00 | \n", "230.385746 | \n", "323.150648 | \n", "30.613178 | \n", "-89.172567 | \n", "1.456428e+06 | \n", "1.038986e+06 | \n", "323.150648 | \n", "230.385746 | \n", "
| 4 | \n", "0 | \n", "17 | \n", "64.398814 | \n", "49.861904 | \n", "8 | \n", "225 | \n", "5 | \n", "2013-06-19 19:05:00 | \n", "2013-06-19 19:05:00 | \n", "220.398814 | \n", "250.861904 | \n", "30.309673 | \n", "-92.634448 | \n", "1.131129e+06 | \n", "9.940447e+05 | \n", "250.861904 | \n", "220.398814 | \n", "