{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Tutorial 3: Heavy Rainfall Analysis\n", "This tutorial shows how to identify and count heavy rainfall intervals exceeding a specified threshold and export the results to ArcGIS." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 1: Identification of Heavy Rainfall Intervals" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1. Import radproc" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import radproc as rp" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2. Identify Heavy Rainfall Intervals\n", "\n", "To identify and select all intervals exceeding a rainfall threshold x at least y times in season z, you can use the function\n", "\n", " find_heavy_rainfalls(HDFFile, year_start, year_end, thresholdValue, minArea, season)\n", " \n", "The following code will extract all intervals, in which an hourly precipitation of 30 mm is exceeded in at least five cells (these don't need to be adjacent cells!) in May 2016 in Hesse. " ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \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-ID427005427006427903427904427905427906428803428804428805428806...661855661856661857662752662753662754662755662756663652663655
Date (UTC)
2016-05-27 16:50:00+00:000.00.00.00.00.00.00.00.00.00.0...0.00.00.00.00.00.00.00.00.00.0
2016-05-27 17:50:00+00:000.00.00.00.00.00.00.00.00.00.0...0.00.00.00.00.00.00.00.00.00.0
2016-05-28 14:50:00+00:000.00.00.10.10.00.00.00.10.10.0...0.10.91.70.40.50.50.61.10.70.6
2016-05-28 15:50:00+00:001.21.11.31.21.11.11.41.11.31.2...4.74.04.39.27.86.33.83.410.63.9
2016-05-28 17:50:00+00:000.00.00.00.00.00.00.00.00.00.0...4.24.44.34.55.14.54.74.35.35.2
2016-05-29 16:50:00+00:000.00.00.00.00.00.00.00.00.00.0...0.00.00.00.00.00.00.00.00.00.0
2016-05-29 23:50:00+00:000.00.20.30.20.20.10.20.10.00.2...4.93.94.04.34.44.24.23.44.33.8
2016-05-30 00:50:00+00:000.00.00.00.00.00.00.00.00.00.0...4.53.83.53.73.54.24.13.64.03.6
\n", "

8 rows × 23320 columns

\n", "
" ], "text/plain": [ "Cell-ID 427005 427006 427903 427904 427905 427906 \\\n", "Date (UTC) \n", "2016-05-27 16:50:00+00:00 0.0 0.0 0.0 0.0 0.0 0.0 \n", "2016-05-27 17:50:00+00:00 0.0 0.0 0.0 0.0 0.0 0.0 \n", "2016-05-28 14:50:00+00:00 0.0 0.0 0.1 0.1 0.0 0.0 \n", "2016-05-28 15:50:00+00:00 1.2 1.1 1.3 1.2 1.1 1.1 \n", "2016-05-28 17:50:00+00:00 0.0 0.0 0.0 0.0 0.0 0.0 \n", "2016-05-29 16:50:00+00:00 0.0 0.0 0.0 0.0 0.0 0.0 \n", "2016-05-29 23:50:00+00:00 0.0 0.2 0.3 0.2 0.2 0.1 \n", "2016-05-30 00:50:00+00:00 0.0 0.0 0.0 0.0 0.0 0.0 \n", "\n", "Cell-ID 428803 428804 428805 428806 ... 661855 \\\n", "Date (UTC) ... \n", "2016-05-27 16:50:00+00:00 0.0 0.0 0.0 0.0 ... 0.0 \n", "2016-05-27 17:50:00+00:00 0.0 0.0 0.0 0.0 ... 0.0 \n", "2016-05-28 14:50:00+00:00 0.0 0.1 0.1 0.0 ... 0.1 \n", "2016-05-28 15:50:00+00:00 1.4 1.1 1.3 1.2 ... 4.7 \n", "2016-05-28 17:50:00+00:00 0.0 0.0 0.0 0.0 ... 4.2 \n", "2016-05-29 16:50:00+00:00 0.0 0.0 0.0 0.0 ... 0.0 \n", "2016-05-29 23:50:00+00:00 0.2 0.1 0.0 0.2 ... 4.9 \n", "2016-05-30 00:50:00+00:00 0.0 0.0 0.0 0.0 ... 4.5 \n", "\n", "Cell-ID 661856 661857 662752 662753 662754 662755 \\\n", "Date (UTC) \n", "2016-05-27 16:50:00+00:00 0.0 0.0 0.0 0.0 0.0 0.0 \n", "2016-05-27 17:50:00+00:00 0.0 0.0 0.0 0.0 0.0 0.0 \n", "2016-05-28 14:50:00+00:00 0.9 1.7 0.4 0.5 0.5 0.6 \n", "2016-05-28 15:50:00+00:00 4.0 4.3 9.2 7.8 6.3 3.8 \n", "2016-05-28 17:50:00+00:00 4.4 4.3 4.5 5.1 4.5 4.7 \n", "2016-05-29 16:50:00+00:00 0.0 0.0 0.0 0.0 0.0 0.0 \n", "2016-05-29 23:50:00+00:00 3.9 4.0 4.3 4.4 4.2 4.2 \n", "2016-05-30 00:50:00+00:00 3.8 3.5 3.7 3.5 4.2 4.1 \n", "\n", "Cell-ID 662756 663652 663655 \n", "Date (UTC) \n", "2016-05-27 16:50:00+00:00 0.0 0.0 0.0 \n", "2016-05-27 17:50:00+00:00 0.0 0.0 0.0 \n", "2016-05-28 14:50:00+00:00 1.1 0.7 0.6 \n", "2016-05-28 15:50:00+00:00 3.4 10.6 3.9 \n", "2016-05-28 17:50:00+00:00 4.3 5.3 5.2 \n", "2016-05-29 16:50:00+00:00 0.0 0.0 0.0 \n", "2016-05-29 23:50:00+00:00 3.4 4.3 3.8 \n", "2016-05-30 00:50:00+00:00 3.6 4.0 3.6 \n", "\n", "[8 rows x 23320 columns]" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "HDF = r\"O:\\Data\\RW.h5\"\n", "\n", "hr = rp.find_heavy_rainfalls(HDFFile=HDF, year_start=2016, year_end=2016, thresholdValue=30, minArea=5, season='May')\n", "hr" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 3. Export Results into ArcGIS Geodatabase\n", "The following function exports all rows from the resampled daily DataFrame calculated above into raster datasets in an ArcGIS File Geodatabase. Optionally, different statistics rasters can be created, in this case the sum and the maximum value of each cell." ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "idRaster = r\"O:\\Data\\idras\"\n", "outGDBPath = r\"O:\\Data\"\n", "GDBName = \"May16_30mm5c.gdb\"\n", "statistics = [\"sum\", \"max\"]\n", "\n", "rp.export_dfrows_to_gdb(dataDF=hr, idRaster=idRaster, outGDBPath=outGDBPath, GDBName=GDBName, statistics=statistics)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The new Geodatabase looks like this in ArcGIS:\n", "\n", "![HR_GDB](img/HR_GDB.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**Side Note**\n", "In this example, eight intervals meeting the given criteria have been identified at four days. The following code can be used as a simple approach to obtain daily sums for these events.\n", "(Of course this does not take into account that the interval at May 30th is most likely part of the same precipitation event as the ones from May 29th...this is a more complicated topic to be adressed in future versions of radproc)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \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-ID427005427006427903427904427905427906428803428804428805428806...661855661856661857662752662753662754662755662756663652663655
Date (UTC)
2016-05-27 00:00:00+00:000.00.00.00.00.00.00.00.00.00.0...0.00.00.00.0000000.00.00.0000000.00.00.0
2016-05-28 00:00:00+00:001.21.11.41.31.11.11.41.21.41.2...9.09.310.314.09999913.411.39.0999998.816.69.7
2016-05-29 00:00:00+00:000.00.20.30.20.20.10.20.10.00.2...4.93.94.04.3000004.44.24.2000003.44.33.8
2016-05-30 00:00:00+00:000.00.00.00.00.00.00.00.00.00.0...4.53.83.53.7000003.54.24.1000003.64.03.6
\n", "

4 rows × 23320 columns

\n", "
" ], "text/plain": [ "Cell-ID 427005 427006 427903 427904 427905 427906 \\\n", "Date (UTC) \n", "2016-05-27 00:00:00+00:00 0.0 0.0 0.0 0.0 0.0 0.0 \n", "2016-05-28 00:00:00+00:00 1.2 1.1 1.4 1.3 1.1 1.1 \n", "2016-05-29 00:00:00+00:00 0.0 0.2 0.3 0.2 0.2 0.1 \n", "2016-05-30 00:00:00+00:00 0.0 0.0 0.0 0.0 0.0 0.0 \n", "\n", "Cell-ID 428803 428804 428805 428806 ... 661855 \\\n", "Date (UTC) ... \n", "2016-05-27 00:00:00+00:00 0.0 0.0 0.0 0.0 ... 0.0 \n", "2016-05-28 00:00:00+00:00 1.4 1.2 1.4 1.2 ... 9.0 \n", "2016-05-29 00:00:00+00:00 0.2 0.1 0.0 0.2 ... 4.9 \n", "2016-05-30 00:00:00+00:00 0.0 0.0 0.0 0.0 ... 4.5 \n", "\n", "Cell-ID 661856 661857 662752 662753 662754 \\\n", "Date (UTC) \n", "2016-05-27 00:00:00+00:00 0.0 0.0 0.000000 0.0 0.0 \n", "2016-05-28 00:00:00+00:00 9.3 10.3 14.099999 13.4 11.3 \n", "2016-05-29 00:00:00+00:00 3.9 4.0 4.300000 4.4 4.2 \n", "2016-05-30 00:00:00+00:00 3.8 3.5 3.700000 3.5 4.2 \n", "\n", "Cell-ID 662755 662756 663652 663655 \n", "Date (UTC) \n", "2016-05-27 00:00:00+00:00 0.000000 0.0 0.0 0.0 \n", "2016-05-28 00:00:00+00:00 9.099999 8.8 16.6 9.7 \n", "2016-05-29 00:00:00+00:00 4.200000 3.4 4.3 3.8 \n", "2016-05-30 00:00:00+00:00 4.100000 3.6 4.0 3.6 \n", "\n", "[4 rows x 23320 columns]" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "hr_daily = hr.resample('D').sum()\n", "hr_daily" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "For example, the resulting raster dataset for the sum of the two intervals on May 27th looks like this:\n", "\n", "![HR_20160527](img/HR_Event_Wiesbaden.png)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Example 2: Counting Heavy Rainfall Intervals" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 1. Identify and Count Heavy Rainfall Intervals\n", "To count the number of times in which a rainfall threshold x is exceeded at every cell in season z, you can use the function\n", "\n", " count_heavy_rainfall_intervals(HDFFile, year_start, year_end, thresholdValue, minArea, season)\n", " \n", "*If you specify a minimum area a > 1, only intervals in which the threshold x is exceeded in at least y cells are taken into account.*\n", "\n", "The following code will count how many times an hourly precipitation of 10 mm is exceeded at every cell in May 2016 in Hesse. " ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \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-ID427005427006427903427904427905427906428803428804428805428806...661855661856661857662752662753662754662755662756663652663655
Date (UTC)
2016-05-31 00:00:00+00:000000000000...1101111121
\n", "

1 rows × 23320 columns

\n", "
" ], "text/plain": [ "Cell-ID 427005 427006 427903 427904 427905 427906 \\\n", "Date (UTC) \n", "2016-05-31 00:00:00+00:00 0 0 0 0 0 0 \n", "\n", "Cell-ID 428803 428804 428805 428806 ... 661855 \\\n", "Date (UTC) ... \n", "2016-05-31 00:00:00+00:00 0 0 0 0 ... 1 \n", "\n", "Cell-ID 661856 661857 662752 662753 662754 662755 \\\n", "Date (UTC) \n", "2016-05-31 00:00:00+00:00 1 0 1 1 1 1 \n", "\n", "Cell-ID 662756 663652 663655 \n", "Date (UTC) \n", "2016-05-31 00:00:00+00:00 1 2 1 \n", "\n", "[1 rows x 23320 columns]" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "HDF = r\"O:\\Data\\RW.h5\"\n", "\n", "hr_count = rp.count_heavy_rainfall_intervals(HDFFile=HDF, year_start=2016, year_end=2016, thresholdValue=10, minArea=1, season='May')\n", "hr_count" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Date (UTC)\n", "2016-05-31 00:00:00+00:00 4\n", "Freq: M, dtype: int32" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# print the maximum value\n", "hr_count.max(axis=1)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### 2. Export to Raster\n", "As the output DataFrame only has one row (because we only analyzed one month), it can be exported directly with\n", " \n", " export_to_raster(series, idRaster, outRaster)" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'O:\\\\Data\\\\hrcount10mm'" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "rp.export_to_raster(series=hr_count, idRaster=r\"O:\\Data\\idras\", outRaster=r\"O:\\Data\\hrcount10mm\")" ] } ], "metadata": { "kernelspec": { "display_name": "Python 2", "language": "python", "name": "python2" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.14" } }, "nbformat": 4, "nbformat_minor": 2 }