{ "cells": [ { "cell_type": "markdown", "id": "mighty-vintage", "metadata": {}, "source": [ "# Intra-annual variability of precipitation\n", "> A comparison between the seasonality of Tel Aviv and London\n", "\n", "- toc: true \n", "- badges: true\n", "- comments: false\n", "- categories: [jupyter]" ] }, { "cell_type": "markdown", "id": "stunning-extreme", "metadata": {}, "source": [ "![](hydrology_figures/monthly_tel_aviv_london_bars.png)\n", "\n", "Let's shift the months according the the hydrological year: \n", "![](hydrology_figures/monthly_tel_aviv_london_bars_hydrological_year.png)\n", "\n", "![](hydrology_figures/radar_chart_tel_aviv_london.png)" ] }, { "cell_type": "markdown", "id": "polar-raise", "metadata": {}, "source": [ "## Seasonality Index, Walsh and Lawler (1981)\n", "http://leddris.aegean.gr/ses-parameters/293-rainfall-seasonality.html#:~:text=Rainfall%20seasonality%20index%20is%20a,in%20relation%20to%20water%20availability\n", "\n", "$R=$ mean annual precipitation \n", "$m_i$ precipitation mean for month $i$ \n", "\n", "$$ SI = \\displaystyle \\frac{1}{R} \\sum_{n=1}^{n=12} \\left| m_i - \\frac{R}{12} \\right| $$\n", "\n", "| $SI$ | Precipitation Regime |\n", "| --- | --- |\n", "| <0.19 | Precipitation spread throughout the year |\n", "| 0.20-0.39\t | Precipitation spread throughout the year, but with a definite wetter season |\n", "| 0.40-0.59\t | Rather seasonal with a short dry season |\n", "| 0.60-0.79\t | Seasonal |\n", "| 0.80-0.99\t | Marked seasonal with a long dry season |\n", "| 1.00-1.19\t\t | Most precipitation in <3 months |\n" ] }, { "cell_type": "code", "execution_count": 1, "id": "basic-glucose", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Seasonality index (Walsh and Lawler, 1981)\n", "London: 0.13\n", "Tel Aviv: 1.00\n" ] } ], "source": [ "#collapse-hide\n", "\n", "# import packages\n", "import numpy as np\n", "import pandas as pd\n", "from calendar import month_abbr\n", "\n", "# load data\n", "month_numbers = np.arange(1,13)\n", "month_names = [month_abbr[i] for i in month_numbers]\n", "def monthly_mean(station_name, freq):\n", " # import daily data\n", " df = pd.read_csv(station_name + '_' + freq + '.csv', sep=\",\")\n", " # make 'DATE' the dataframe index\n", " df['DATE'] = pd.to_datetime(df['DATE'])\n", " df = df.set_index('DATE')\n", " # print(df.index[0], df.index[-1])\n", " if freq == 'daily':\n", " # resample data by month\n", " df_month = df['PRCP'].resample('M').sum() # sum is labeled at the last day of the month \n", " df_month = df_month/10 # PRCP is given in tens of mm (see readme)\n", " if freq == 'monthly':\n", " df_month = df['PRCP']\n", " # calculate monthly mean\n", " monthly_mean = np.array([]) # empty array\n", " for m in month_numbers: # cycle over months (1, 2, 3, etc)\n", " this_month_all_indices = (df_month.index.month == m) # indices in df_month belonging to month m\n", " this_month_mean = df_month[this_month_all_indices].mean() # this is the monthly mean\n", " monthly_mean = np.append(monthly_mean, this_month_mean) # append\n", " # make new df and return it\n", " df_return = pd.DataFrame({'monthly rainfall (mm)':monthly_mean,\n", " 'month names':month_names,\n", " 'month number':month_numbers\n", " })\n", " return df_return\n", "\n", "# load monthly mean\n", "df_london = monthly_mean(\"LONDON HEATHROW\", 'monthly')\n", "df_telaviv = monthly_mean(\"TEL AVIV READING\", 'monthly')\n", "\n", "#collapse-hide\n", "\n", "def walsh_index(df):\n", " m = df[\"monthly rainfall (mm)\"]\n", " R = df[\"monthly rainfall (mm)\"].sum()\n", " SI = np.sum(np.abs(m-R/12)) / R\n", " return SI\n", "\n", "london_index = walsh_index(df_london)\n", "telaviv_index = walsh_index(df_telaviv)\n", "print(\"Seasonality index (Walsh and Lawler, 1981)\")\n", "print(f\"London: {london_index:.2f}\")\n", "print(f\"Tel Aviv: {telaviv_index:.2f}\")" ] }, { "cell_type": "markdown", "id": "contained-lucas", "metadata": {}, "source": [ "![](hydrology_figures/si_walsh_telaviv.png)\n", "![](hydrology_figures/si_walsh_london.png)" ] }, { "cell_type": "code", "execution_count": null, "id": "designed-database", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.9.7" } }, "nbformat": 4, "nbformat_minor": 5 }