{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# 3D *tobac* Tutorial: Gridded Radar Data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This tutorial will demonstrate how to use *tobac* to detect and track convection with gridded radar data. Because this tutorial uses 3D feature detection, you must use the v1.5 (3D and PBC changes) of *tobac*. \n", "\n", "\n", "This tutorial requires the use of pre-gridded radar data, which we generated during the Py-ART tutorial." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Imports" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "## You are using the Python ARM Radar Toolkit (Py-ART), an open source\n", "## library for working with weather radar data. Py-ART is partly\n", "## supported by the U.S. Department of Energy as part of the Atmospheric\n", "## Radiation Measurement (ARM) Climate Research Facility, an Office of\n", "## Science user facility.\n", "##\n", "## If you use this software to prepare a publication, please cite:\n", "##\n", "## JJ Helmus and SM Collis, JORS 2016, doi: 10.5334/jors.119\n", "\n" ] } ], "source": [ "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import cartopy.crs as ccrs\n", "import cartopy.feature as cfeature\n", "import xarray as xr\n", "import pyart\n", "import glob\n", "import datetime\n", "import matplotlib.gridspec as gridspec\n", "import pandas as pd\n", "import os\n", "import math\n", "from cartopy.mpl.ticker import LongitudeFormatter, LatitudeFormatter" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### DATA INPUT:\n", "https://tobac.readthedocs.io/en/latest/data_input.html\n", "\n", "We use the gridded data from the Py-ART tutorial." ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "tags": [] }, "outputs": [], "source": [ "gridded_files = sorted(glob.glob(\"../../data/uah-armor/gridded/*.nc\"))" ] }, { "cell_type": "code", "execution_count": 54, "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
<xarray.Dataset>\n", "Dimensions: (time: 25, z: 30, y: 600, x: 600)\n", "Coordinates:\n", " * time (time) datetime64[ns] 2008-04-11T18:12:23 ... 2008-04-11T20...\n", " * z (z) float64 0.0 517.2 1.034e+03 ... 1.448e+04 1.5e+04\n", " lat (y, x) float64 dask.array<chunksize=(600, 600), meta=np.ndarray>\n", " lon (y, x) float64 dask.array<chunksize=(600, 600), meta=np.ndarray>\n", " * y (y) float64 -1.5e+05 -1.495e+05 ... 1.495e+05 1.5e+05\n", " * x (x) float64 -1.5e+05 -1.495e+05 ... 1.495e+05 1.5e+05\n", "Data variables:\n", " reflectivity (time, z, y, x) float32 dask.array<chunksize=(1, 30, 600, 600), meta=np.ndarray>\n", " ROI (time, z, y, x) float32 dask.array<chunksize=(1, 30, 600, 600), meta=np.ndarray>
<xarray.Dataset>\n", "Dimensions: (index: 1014)\n", "Coordinates:\n", " * index (index) int64 0 1 2 3 4 ... 1010 1011 1012 1013\n", "Data variables: (12/13)\n", " frame (index) int64 0 0 0 0 0 0 0 ... 24 24 24 24 24 24\n", " idx (index) int64 1 2 3 4 6 7 8 ... 65 66 67 68 69 71\n", " hdim_1 (index) float64 190.9 305.6 232.7 ... 467.1 536.8\n", " hdim_2 (index) float64 217.4 132.7 187.5 ... 428.8 359.8\n", " num (index) int64 1079 9688 75 5 7 ... 223 12 15 37 7\n", " threshold_value (index) int64 30 30 30 30 30 30 ... 30 30 30 30 30\n", " ... ...\n", " time (index) object 2008-04-11 18:12:23 ... 2008-04-1...\n", " timestr (index) object '2008-04-11 18:12:23' ... '2008-0...\n", " projection_y_coordinate (index) float64 -5.438e+04 3.059e+03 ... 1.188e+05\n", " projection_x_coordinate (index) float64 -4.111e+04 -8.352e+04 ... 3.019e+04\n", " latitude (index) float64 34.16 34.67 34.34 ... 35.4 35.71\n", " longitude (index) float64 -87.22 -87.68 ... -86.06 -86.44
<xarray.Dataset>\n", "Dimensions: (index: 1014)\n", "Coordinates:\n", " * index (index) int64 0 1 2 3 4 ... 1010 1011 1012 1013\n", "Data variables: (12/13)\n", " frame (index) int64 0 0 0 0 0 0 0 ... 24 24 24 24 24 24\n", " idx (index) int64 1 2 3 4 6 7 8 ... 65 66 67 68 69 71\n", " hdim_1 (index) float64 190.9 305.6 232.7 ... 467.1 536.8\n", " hdim_2 (index) float64 217.4 132.7 187.5 ... 428.8 359.8\n", " num (index) int64 1079 9688 75 5 7 ... 223 12 15 37 7\n", " threshold_value (index) int64 30 30 30 30 30 30 ... 30 30 30 30 30\n", " ... ...\n", " time (index) object 2008-04-11 18:12:23 ... 2008-04-1...\n", " timestr (index) object '2008-04-11 18:12:23' ... '2008-0...\n", " projection_y_coordinate (index) float64 -5.438e+04 3.059e+03 ... 1.188e+05\n", " projection_x_coordinate (index) float64 -4.111e+04 -8.352e+04 ... 3.019e+04\n", " latitude (index) float64 34.16 34.67 34.34 ... 35.4 35.71\n", " longitude (index) float64 -87.22 -87.68 ... -86.06 -86.44
<xarray.Dataset>\n", "Dimensions: (track: 1, cell: 1, feature: 1014)\n", "Coordinates:\n", " * track (track) float64 0.0\n", " * cell (cell) int64 -1\n", " * feature (feature) int64 1 2 3 4 5 ... 1011 1012 1013 1014\n", "Data variables:\n", " cell_parent_track_id (cell) float64 0.0\n", " feature_parent_cell_id (feature) int64 -1 -1 -1 -1 -1 ... -1 -1 -1 -1 -1\n", " feature_parent_track_id (feature) float64 -1.0 -1.0 -1.0 ... -1.0 -1.0\n", " track_child_cell_count (track) float64 1.0\n", " cell_child_feature_count (cell) float64 1.014e+03
<xarray.Dataset>\n", "Dimensions: (index: 1014)\n", "Coordinates:\n", " * index (index) int64 0 1 2 3 4 ... 1010 1011 1012 1013\n", "Data variables: (12/13)\n", " frame (index) int64 ...\n", " idx (index) int64 ...\n", " hdim_1 (index) float64 ...\n", " hdim_2 (index) float64 ...\n", " num (index) int64 ...\n", " threshold_value (index) int64 ...\n", " ... ...\n", " time (index) datetime64[ns] ...\n", " timestr (index) object ...\n", " projection_y_coordinate (index) float64 ...\n", " projection_x_coordinate (index) float64 ...\n", " latitude (index) float64 ...\n", " longitude (index) float64 ...
<xarray.DataArray 'reflectivity' (time: 25, z: 30, y: 600, x: 600)>\n", "dask.array<concatenate, shape=(25, 30, 600, 600), dtype=float32, chunksize=(1, 30, 600, 600), chunktype=numpy.ndarray>\n", "Coordinates:\n", " * time (time) datetime64[ns] 2008-04-11T18:12:23 ... 2008-04-11T20:20:58\n", " * z (z) float64 0.0 517.2 1.034e+03 ... 1.397e+04 1.448e+04 1.5e+04\n", " lat (y, x) float64 dask.array<chunksize=(600, 600), meta=np.ndarray>\n", " lon (y, x) float64 dask.array<chunksize=(600, 600), meta=np.ndarray>\n", " * y (y) float64 -1.5e+05 -1.495e+05 -1.49e+05 ... 1.495e+05 1.5e+05\n", " * x (x) float64 -1.5e+05 -1.495e+05 -1.49e+05 ... 1.495e+05 1.5e+05\n", "Attributes:\n", " units: dBZ\n", " standard_name: equivalent_reflectivity_factor\n", " long_name: Reflectivity\n", " coordinates: elevation azimuth range
\n", " | frame | \n", "idx | \n", "hdim_1 | \n", "hdim_2 | \n", "num | \n", "threshold_value | \n", "feature | \n", "time | \n", "timestr | \n", "projection_y_coordinate | \n", "projection_x_coordinate | \n", "latitude | \n", "longitude | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0 | \n", "3 | \n", "232.654355 | \n", "187.475227 | \n", "75 | \n", "30 | \n", "1 | \n", "2008-04-11 18:12:23 | \n", "2008-04-11 18:12:23 | \n", "-33478.620116 | \n", "-56105.896173 | \n", "34.343593 | \n", "-87.382608 | \n", "
1 | \n", "0 | \n", "4 | \n", "256.679129 | \n", "59.120160 | \n", "5 | \n", "30 | \n", "2 | \n", "2008-04-11 18:12:23 | \n", "2008-04-11 18:12:23 | \n", "-21446.178957 | \n", "-120390.570710 | \n", "34.446289 | \n", "-88.084443 | \n", "
2 | \n", "0 | \n", "6 | \n", "271.000000 | \n", "227.817852 | \n", "7 | \n", "30 | \n", "3 | \n", "2008-04-11 18:12:23 | \n", "2008-04-11 18:12:23 | \n", "-14273.789649 | \n", "-35900.909033 | \n", "34.517206 | \n", "-87.163348 | \n", "
3 | \n", "0 | \n", "8 | \n", "291.189565 | \n", "62.745582 | \n", "5 | \n", "30 | \n", "4 | \n", "2008-04-11 18:12:23 | \n", "2008-04-11 18:12:23 | \n", "-4162.154494 | \n", "-118574.833957 | \n", "34.601917 | \n", "-88.067061 | \n", "
4 | \n", "0 | \n", "9 | \n", "324.167350 | \n", "103.064594 | \n", "111 | \n", "30 | \n", "5 | \n", "2008-04-11 18:12:23 | \n", "2008-04-11 18:12:23 | \n", "12354.265509 | \n", "-98381.672359 | \n", "34.752573 | \n", "-87.848376 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
1494 | \n", "24 | \n", "121 | \n", "181.281622 | \n", "275.366252 | \n", "88 | \n", "50 | \n", "1495 | \n", "2008-04-11 20:20:58 | \n", "2008-04-11 20:20:58 | \n", "-59207.868610 | \n", "-12087.018954 | \n", "34.113660 | \n", "-86.902791 | \n", "
1495 | \n", "24 | \n", "122 | \n", "197.820473 | \n", "325.438786 | \n", "10 | \n", "50 | \n", "1496 | \n", "2008-04-11 20:20:58 | \n", "2008-04-11 20:20:58 | \n", "-50924.637719 | \n", "12991.044798 | \n", "34.188142 | \n", "-86.630264 | \n", "
1496 | \n", "24 | \n", "124 | \n", "306.319990 | \n", "384.751210 | \n", "88 | \n", "50 | \n", "1497 | \n", "2008-04-11 20:20:58 | \n", "2008-04-11 20:20:58 | \n", "3415.687706 | \n", "42696.766189 | \n", "34.676028 | \n", "-86.304585 | \n", "
1497 | \n", "24 | \n", "125 | \n", "303.064874 | \n", "488.028903 | \n", "71 | \n", "50 | \n", "1498 | \n", "2008-04-11 20:20:58 | \n", "2008-04-11 20:20:58 | \n", "1785.412871 | \n", "94421.821376 | \n", "34.657907 | \n", "-85.739151 | \n", "
1498 | \n", "24 | \n", "126 | \n", "333.334980 | \n", "385.977828 | \n", "21 | \n", "50 | \n", "1499 | \n", "2008-04-11 20:20:58 | \n", "2008-04-11 20:20:58 | \n", "16945.733057 | \n", "43311.099281 | \n", "34.797679 | \n", "-86.297169 | \n", "
1499 rows × 13 columns
\n", "<xarray.Dataset>\n", "Dimensions: (index: 1499)\n", "Coordinates:\n", " * index (index) int64 0 1 2 3 4 ... 1495 1496 1497 1498\n", "Data variables: (12/13)\n", " frame (index) int64 0 0 0 0 0 0 0 ... 24 24 24 24 24 24\n", " idx (index) int64 3 4 6 8 9 12 ... 121 122 124 125 126\n", " hdim_1 (index) float64 232.7 256.7 271.0 ... 303.1 333.3\n", " hdim_2 (index) float64 187.5 59.12 227.8 ... 488.0 386.0\n", " num (index) int64 75 5 7 5 111 17 ... 30 88 10 88 71 21\n", " threshold_value (index) int64 30 30 30 30 30 30 ... 50 50 50 50 50\n", " ... ...\n", " time (index) object 2008-04-11 18:12:23 ... 2008-04-1...\n", " timestr (index) object '2008-04-11 18:12:23' ... '2008-0...\n", " projection_y_coordinate (index) float64 -3.348e+04 -2.145e+04 ... 1.695e+04\n", " projection_x_coordinate (index) float64 -5.611e+04 -1.204e+05 ... 4.331e+04\n", " latitude (index) float64 34.34 34.45 34.52 ... 34.66 34.8\n", " longitude (index) float64 -87.38 -88.08 ... -85.74 -86.3
\n", " | frame | \n", "idx | \n", "hdim_1 | \n", "hdim_2 | \n", "num | \n", "threshold_value | \n", "feature | \n", "time | \n", "timestr | \n", "projection_y_coordinate | \n", "projection_x_coordinate | \n", "latitude | \n", "longitude | \n", "cell | \n", "time_cell | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0 | \n", "0 | \n", "3 | \n", "232.654355 | \n", "187.475227 | \n", "75 | \n", "30 | \n", "1 | \n", "2008-04-11 18:12:23 | \n", "2008-04-11 18:12:23 | \n", "-33478.620116 | \n", "-56105.896173 | \n", "34.343593 | \n", "-87.382608 | \n", "1 | \n", "0 days 00:00:00 | \n", "
1 | \n", "0 | \n", "4 | \n", "256.679129 | \n", "59.120160 | \n", "5 | \n", "30 | \n", "2 | \n", "2008-04-11 18:12:23 | \n", "2008-04-11 18:12:23 | \n", "-21446.178957 | \n", "-120390.570710 | \n", "34.446289 | \n", "-88.084443 | \n", "-1 | \n", "NaT | \n", "
2 | \n", "0 | \n", "6 | \n", "271.000000 | \n", "227.817852 | \n", "7 | \n", "30 | \n", "3 | \n", "2008-04-11 18:12:23 | \n", "2008-04-11 18:12:23 | \n", "-14273.789649 | \n", "-35900.909033 | \n", "34.517206 | \n", "-87.163348 | \n", "-1 | \n", "NaT | \n", "
3 | \n", "0 | \n", "8 | \n", "291.189565 | \n", "62.745582 | \n", "5 | \n", "30 | \n", "4 | \n", "2008-04-11 18:12:23 | \n", "2008-04-11 18:12:23 | \n", "-4162.154494 | \n", "-118574.833957 | \n", "34.601917 | \n", "-88.067061 | \n", "-1 | \n", "NaT | \n", "
4 | \n", "0 | \n", "9 | \n", "324.167350 | \n", "103.064594 | \n", "111 | \n", "30 | \n", "5 | \n", "2008-04-11 18:12:23 | \n", "2008-04-11 18:12:23 | \n", "12354.265509 | \n", "-98381.672359 | \n", "34.752573 | \n", "-87.848376 | \n", "-1 | \n", "NaT | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
1494 | \n", "24 | \n", "121 | \n", "181.281622 | \n", "275.366252 | \n", "88 | \n", "50 | \n", "1495 | \n", "2008-04-11 20:20:58 | \n", "2008-04-11 20:20:58 | \n", "-59207.868610 | \n", "-12087.018954 | \n", "34.113660 | \n", "-86.902791 | \n", "-1 | \n", "NaT | \n", "
1495 | \n", "24 | \n", "122 | \n", "197.820473 | \n", "325.438786 | \n", "10 | \n", "50 | \n", "1496 | \n", "2008-04-11 20:20:58 | \n", "2008-04-11 20:20:58 | \n", "-50924.637719 | \n", "12991.044798 | \n", "34.188142 | \n", "-86.630264 | \n", "247 | \n", "0 days 00:33:48 | \n", "
1496 | \n", "24 | \n", "124 | \n", "306.319990 | \n", "384.751210 | \n", "88 | \n", "50 | \n", "1497 | \n", "2008-04-11 20:20:58 | \n", "2008-04-11 20:20:58 | \n", "3415.687706 | \n", "42696.766189 | \n", "34.676028 | \n", "-86.304585 | \n", "158 | \n", "0 days 01:15:23 | \n", "
1497 | \n", "24 | \n", "125 | \n", "303.064874 | \n", "488.028903 | \n", "71 | \n", "50 | \n", "1498 | \n", "2008-04-11 20:20:58 | \n", "2008-04-11 20:20:58 | \n", "1785.412871 | \n", "94421.821376 | \n", "34.657907 | \n", "-85.739151 | \n", "23 | \n", "0 days 02:08:35 | \n", "
1498 | \n", "24 | \n", "126 | \n", "333.334980 | \n", "385.977828 | \n", "21 | \n", "50 | \n", "1499 | \n", "2008-04-11 20:20:58 | \n", "2008-04-11 20:20:58 | \n", "16945.733057 | \n", "43311.099281 | \n", "34.797679 | \n", "-86.297169 | \n", "242 | \n", "0 days 00:38:59 | \n", "
1499 rows × 15 columns
\n", "