{ "cells": [ { "cell_type": "markdown", "id": "607da258", "metadata": {}, "source": [ "# Rainfall Anomaly Index\n", "\n", "Based on van Rooy, M.P. (1965). A Rainfall Anomaly Index Independent of Time and Space. Notos." ] }, { "cell_type": "markdown", "id": "fbc30e7f", "metadata": {}, "source": [ "## Packages" ] }, { "cell_type": "code", "execution_count": null, "id": "dcef936f", "metadata": {}, "outputs": [], "source": [ "import matplotlib as mpl\n", "import matplotlib.pyplot as plt\n", "import pandas as pd\n", "\n", "from spei.rai import mrai, rai" ] }, { "cell_type": "markdown", "id": "40d04848", "metadata": {}, "source": [ "## Data" ] }, { "cell_type": "code", "execution_count": null, "id": "0c274c53", "metadata": {}, "outputs": [], "source": [ "df = pd.read_csv(\"data/DEBILT.csv\", index_col=0, parse_dates=True)\n", "prec = df[\"Prec [m/d] 260_DEBILT\"].multiply(1e3).resample(\"MS\").sum()" ] }, { "cell_type": "markdown", "id": "edfc521d", "metadata": {}, "source": [ "## Calculate Index" ] }, { "cell_type": "code", "execution_count": null, "id": "11dcd5f4", "metadata": {}, "outputs": [], "source": [ "ra_index = rai(prec)\n", "mra_index = mrai(prec, sf=1.7)" ] }, { "cell_type": "markdown", "id": "a6dc3eeb", "metadata": {}, "source": [ "## Visualize" ] }, { "cell_type": "code", "execution_count": null, "id": "92253a3f", "metadata": {}, "outputs": [], "source": [ "f, ax = plt.subplots(2, 1, figsize=(12, 6), sharex=True, sharey=True)\n", "ax[0].plot(ra_index.index, ra_index.values, color=\"C0\")\n", "ax[1].plot(mra_index.index, mra_index.values, color=\"C1\")\n", "ax[0].set_ylabel(\"Rainfall Anomaly Index\")\n", "ax[1].set_ylabel(\"Modified Rainfall Anomaly Index\")\n", "ax[0].grid(True)\n", "ax[1].grid(True)\n", "ax[1].yaxis.set_major_locator(mpl.ticker.MultipleLocator(1))\n", "ax[1].xaxis.set_major_locator(mpl.dates.YearLocator(1))\n", "ax[1].set_xlim(pd.Timestamp(\"2010-01-01\"), pd.Timestamp(\"2020-12-31\"))" ] }, { "cell_type": "markdown", "id": "fc772d44", "metadata": {}, "source": [ "Interpretation based on Hansel (2015) - [The Modified Rainfall Anomaly Index (mRAI)](https://doi.org/10.1007/s00704-015-1389-y)\n", "\n", "| RAI | Description | mRAI | Description |\n", "| :---------------------------------- | :---------------------------- | :-------------------------------- | :---------------------------- |\n", "| $\\ge$ 3.00 | Extremely wet | $\\ge$ 2.00 | Extremely wet |\n", "| 2.00 to 2.99 | Very wet | 1.50 to 1.99 | Very wet |\n", "| 1.00 to 1.99 | Moderately wet | 1.00 to 1.49 | Moderately wet |\n", "| 0.50 to 0.99 | Slightly wet | 0.50 to 0.99 | Slightly wet |\n", "| -0.49 to 0.49 | Near normal | -0.49 to 0.49 | Near normal |\n", "| -0.99 to -0.50 | Slightly dry | -0.99 to -0.50 | Slightly dry |\n", "| -1.99 to -1.00 | Moderately dry | -1.49 to -1.00 | Moderately dry |\n", "| -2.99 to -2.00 | Very dry | -1.99 to -1.50 | Very dry |\n", "| ≤-3.00 | Extremely dry | ≤-2.00 | Extremely dry |" ] }, { "cell_type": "markdown", "id": "75058050", "metadata": {}, "source": [] } ], "metadata": { "kernelspec": { "display_name": "SPEI", "language": "python", "name": "python3" }, "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.13.1" } }, "nbformat": 4, "nbformat_minor": 5 }