Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@taruma
Created December 14, 2019 07:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taruma/1502a7aa67cf074969d806cd3ffdf35c to your computer and use it in GitHub Desktop.
Save taruma/1502a7aa67cf074969d806cd3ffdf35c to your computer and use it in GitHub Desktop.
taruma_hk89_NRECA.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "taruma_hk89_NRECA.ipynb",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/taruma/1502a7aa67cf074969d806cd3ffdf35c/taruma_hk89_nreca.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "xMiGwXUN1dpz",
"colab_type": "text"
},
"source": [
"Berdasarkan isu [#89](https://github.com/taruma/hidrokit/issues/89): **pemodelan NRECA**\n",
"\n",
"Referensi isu:\n",
"- Crawford, N. H., & Thurin, S. M. (1981). _Hydrologic estimates for small hydroelectric projects_. 1800 Massachusetts Avenue NW, Washington, DC 20036: National Rural Electric Cooperative Association (NRECA).\n",
"- Megariansyah, Taruma S. (2015): Kajian Penerapan Model NRECA di Bendung Pamarayan, Skripsi Program Sarjana, Universitas Katolik Parahyangan.\n",
"\n",
"Deskripsi Permasalahan:\n",
"- Memperoleh nilai debit dari model NRECA dengan parameter seperti _Moist Storage_ `MSTOR` ($mm$), _Groundwater Storage_ `GSTOR` ($mm$), `PSUB`, `GWF`, _Crop Factor_ `CF`, `C`, _Area_ `AREA` ($m^2$), \n",
"\n",
"Strategi Penyelesaian:\n",
"- Perhitungan dan penamaan peubah mengikuti makalah Crawford & Thurin (1981).\n",
"- Membuat fungsi untuk setiap perhitungan yang digunakan dalam model (dengan ditandai imbuhan `_` dalam penamaan fungsi).\n",
"- Membuat fungsi `model_NRECA()` dengan kejelasan parameter sehingga bisa dikembangkan lebih lanjut untuk kalibrasi model atau mencari parameter terbaik.\n",
"\n",
"Catatan:\n",
"- Dataset yang digunakan diambil dari Megariansyah (2015). \n",
"- Input data berupa observasi curah hujan `PREP` ($mm$) dan evapotranspirasi `PET` ($mm$) setiap bulannya.\n",
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Ojoc5toiBOAU",
"colab_type": "text"
},
"source": [
"# PERSIAPAN DAN DATASET"
]
},
{
"cell_type": "code",
"metadata": {
"id": "ynPUBiKRmDuQ",
"colab_type": "code",
"colab": {}
},
"source": [
"import numpy as np\n",
"import pandas as pd\n",
"import matplotlib.pyplot as plt"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "Fk4zItWAqaXG",
"colab_type": "code",
"colab": {}
},
"source": [
"from google.colab import files\n",
"try:\n",
" pd.read_excel('NRECA_sample.xlsx')\n",
"except:\n",
" dataset_path = list(files.upload().keys())[0]"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "amiy0rELq4Y5",
"colab_type": "code",
"outputId": "aadaaaab-1886-4b06-8a76-fabe69607654",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 323
}
},
"source": [
"dataset = pd.read_excel(dataset_path, header=0, index_col=0, parse_dates=True)\n",
"dataset.info()\n",
"dataset.head()"
],
"execution_count": 19,
"outputs": [
{
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"DatetimeIndex: 120 entries, 1999-01-01 to 2008-12-01\n",
"Data columns (total 2 columns):\n",
"PRECIP 120 non-null float64\n",
"PET 120 non-null float64\n",
"dtypes: float64(2)\n",
"memory usage: 2.8 KB\n"
],
"name": "stdout"
},
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PRECIP</th>\n",
" <th>PET</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1999-01-01</th>\n",
" <td>507.000000</td>\n",
" <td>142.63</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-02-01</th>\n",
" <td>374.228918</td>\n",
" <td>128.84</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-03-01</th>\n",
" <td>211.762683</td>\n",
" <td>138.19</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-04-01</th>\n",
" <td>219.793874</td>\n",
" <td>138.32</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-05-01</th>\n",
" <td>132.121255</td>\n",
" <td>125.36</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PRECIP PET\n",
"1999-01-01 507.000000 142.63\n",
"1999-02-01 374.228918 128.84\n",
"1999-03-01 211.762683 138.19\n",
"1999-04-01 219.793874 138.32\n",
"1999-05-01 132.121255 125.36"
]
},
"metadata": {
"tags": []
},
"execution_count": 19
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Hvn2mEDDHkWD",
"colab_type": "text"
},
"source": [
"# KODE"
]
},
{
"cell_type": "code",
"metadata": {
"id": "wTKl_pvoh8uK",
"colab_type": "code",
"colab": {}
},
"source": [
"# FUNGSI NRECA\n",
"def _STORAT(STORAGE, NOMINAL):\n",
" return STORAGE/NOMINAL\n",
"\n",
"def _STORAGE(STORAGE, DELSTOR):\n",
" return STORAGE + DELSTOR\n",
"\n",
"def _PRERAT(PRECIP, PET):\n",
" return PRECIP/PET\n",
"\n",
"def _ETRAT(STORAT, PRERAT):\n",
" VAL = (STORAT / 2) + ((1 - (STORAT / 2)) * PRERAT) \n",
" return VAL if VAL < 1 else 1\n",
"\n",
"def _AET(ETRAT, PET, CF=1):\n",
" return ETRAT * PET * CF\n",
"\n",
"def _WATBAL(PRECIP, AET):\n",
" return PRECIP - AET\n",
"\n",
"def _EXMRAT(WATBAL, STORAT):\n",
" if WATBAL < 0:\n",
" return 0\n",
" if STORAT > 1:\n",
" return 1 - (0.5 * (2 - STORAT)**2)\n",
" else:\n",
" return 0.5 * (STORAT**2)\n",
"\n",
"def _EXMST(EXMRAT, WATBAL):\n",
" return EXMRAT * WATBAL\n",
"\n",
"def _DELSTOR(WATBAL, EXMST):\n",
" return WATBAL - EXMST\n",
"\n",
"def _GWRECH(PSUB, EXMST):\n",
" return PSUB * EXMST\n",
"\n",
"def _GWSTOR2(GWSTOR_1, GWRECH):\n",
" return GWSTOR_1 + GWRECH\n",
"\n",
"def _GWSTOR1(GWSTOR_2, GWFLOW):\n",
" return GWSTOR_2 - GWFLOW\n",
"\n",
"def _GWFLOW(GWRAT, GWSTOR_2):\n",
" return GWRAT * GWSTOR_2\n",
"\n",
"def _DFLOW(EXMST, GWRECH):\n",
" return EXMST - GWRECH\n",
"\n",
"def _FLOW(GWFLOW, DFLOW):\n",
" return GWFLOW + DFLOW\n",
"\n",
"def _DISCHARGE(FLOW, AREA, DAYS):\n",
" return (FLOW/1000) * AREA / (DAYS * 24 * 60 * 60)\n",
"\n",
"def _NOMINAL(C, PRECIP_MEAN_ANNUAL):\n",
" return 100 + C*PRECIP_MEAN_ANNUAL"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "WIxjNZKHn3qu",
"colab_type": "code",
"colab": {}
},
"source": [
"def model_NRECA(df, precip_col, pet_col,\n",
" MSTOR, GSTOR, PSUB, GWF, CF, C, AREA,\n",
" as_df=True, report='discharge'):\n",
"\n",
" # sub_df\n",
" data = df.loc[:, [precip_col, pet_col]]\n",
"\n",
" # info df\n",
" nrows = data.shape[0]\n",
"\n",
" # initialization\n",
" storage, storat, prerat = (np.zeros(nrows) for _ in range(3))\n",
" etrat, aet, watbal = (np.zeros(nrows) for _ in range(3))\n",
" exmst, exmrat, delstor, gwrech = (np.zeros(nrows) for _ in range(4))\n",
" gwstor1, gwstor2, gwflow = (np.zeros(nrows) for _ in range(3))\n",
" dflow, flow, discharge = (np.zeros(nrows) for _ in range(3))\n",
"\n",
" # calculation\n",
" precip_mean_annual = (data[precip_col].groupby(by=data.index.year)\n",
" .sum()\n",
" .mean())\n",
" nominal = _NOMINAL(C, precip_mean_annual)\n",
"\n",
" days = data.index.days_in_month\n",
" precip = data.iloc[:, 0].values\n",
" pet = data.iloc[:, 1].values\n",
"\n",
" for i in range(nrows):\n",
"\n",
" if i != 0:\n",
" storage[i] = _STORAGE(storage[i - 1], delstor[i - 1])\n",
" else:\n",
" storage[i] = _STORAGE(MSTOR, 0)\n",
"\n",
" storat[i] = _STORAT(storage[i], nominal)\n",
" prerat[i] = _PRERAT(precip[i], pet[i])\n",
" etrat[i] = _ETRAT(storat[i], prerat[i])\n",
" aet[i] = _AET(etrat[i], pet[i], CF=CF)\n",
" watbal[i] = _WATBAL(precip[i], aet[i])\n",
" exmrat[i] = _EXMRAT(watbal[i], storat[i])\n",
" exmst[i] = _EXMST(exmrat[i], watbal[i])\n",
" delstor[i] = _DELSTOR(watbal[i], exmst[i])\n",
" gwrech[i] = _GWRECH(PSUB, exmst[i])\n",
"\n",
" if i != 0:\n",
" gwstor1[i] = _GWSTOR1(gwstor2[i - 1], gwflow[i - 1])\n",
" else:\n",
" gwstor1[i] = _GWSTOR1(GSTOR, 0)\n",
"\n",
" gwstor2[i] = _GWSTOR2(gwstor1[i], gwrech[i])\n",
" gwflow[i] = _GWFLOW(GWF, gwstor2[i])\n",
" dflow[i] = _DFLOW(exmst[i], gwrech[i])\n",
" flow[i] = _FLOW(gwflow[i], dflow[i])\n",
" discharge[i] = _DISCHARGE(flow[i], AREA, days[i])\n",
"\n",
" # results\n",
" if report.lower() == 'full':\n",
" results = np.stack((\n",
" days, precip, pet, storage, storat, prerat, etrat, aet, watbal,\n",
" exmrat, delstor, gwrech, gwstor1, gwstor2, gwflow, dflow, flow,\n",
" discharge\n",
" ), axis=1)\n",
" columns_name = [\n",
" 'DAYS', 'PRECIP', 'PET', 'STORAGE', 'STORAT', 'PRERAT', 'ETRAT',\n",
" 'AET', 'WATBAL', 'EXMRAT', 'DELSTOR', 'GWRECH', 'GWSTOR1',\n",
" 'GWSTOR2', 'GWFLOW', 'DFLOW', 'FLOW', 'DISCHARGE'\n",
" ]\n",
" elif report.lower() == 'partial':\n",
" results = np.stack((\n",
" precip, pet, storage, gwstor2, flow, discharge), axis=1)\n",
" columns_name = ['PRECIP', 'PET', 'STORAGE',\n",
" 'GWSTOR2', 'FLOW', 'DISCHARGE']\n",
" elif report.lower() == 'flow':\n",
" results = flow\n",
" columns_name = ['FLOW']\n",
" elif report.lower() == 'discharge':\n",
" results = discharge\n",
" columns_name = ['DISCHARGE']\n",
" else:\n",
" raise ValueError(\n",
" str(report) + ' not identified. ' +\n",
" 'Use full / partial / flow / discharge.'\n",
" )\n",
"\n",
" if as_df:\n",
" return pd.DataFrame(\n",
" data=results, index=data.index, columns=columns_name\n",
" )\n",
" else:\n",
" return results"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "markdown",
"metadata": {
"id": "vf1hd_mnHgrv",
"colab_type": "text"
},
"source": [
"# FUNGSI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "758VwCt2Ht-4",
"colab_type": "text"
},
"source": [
"## Fungsi `model_NRECA()`\n",
"\n",
"Fungsi `model_NRECA()` membangkitkan nilai debit menggunakan model yang dikembangkan oleh Crawford & Thurin (1981). Untuk mengetahui masing-masing batasan parameter yang digunakan dalam model ini, harap melihat pada makalah terkait. Dalam _notebook_ ini akan lebih fokus dalam penggunaan fungsi.\n",
"\n",
"Fungsi memiliki 10 argumen yang harus diisi, dan 2 argumen opsional. Dibagi menjadi 3 bagian argumen yaitu:\n",
"- Argumen untuk dataset:\n",
" - `df`: dataset dalam bentuk `pandas.DataFrame`.\n",
" - `precip_col`: nama kolom untuk curah hujan (presipitasi).\n",
" - `pet_col`: nama kolom untuk evapotranspirasi potensial.\n",
"- Argumen untuk parameter model:\n",
" - `MSTOR`: _Moist Storage_ ($mm$).\n",
" - `GSTOR`: _Groundwater Storage_ ($mm$).\n",
" - `PSUB`: _Percent Discharge to Subbase_. ($0.3-0.8$)\n",
" - `GWF`: _Groundwater Fraction_. ($0.2-0.9$)\n",
" - `CF`: _Crop Factor_. \n",
" - `C`: Koefisien karakteristik DAS. ($\\{0.2,0.25\\}$)\n",
" - `AREA`: Luas DAS. ($m^2$)\n",
"- Argumen opsional untuk fungsi:\n",
" - `as_df`: `True` (default), keluaran berupa `pandas.DataFrame`. Keluaran berupa `numpy.ndarray` jika `False`.\n",
" - `report`: `discharge` (default). Terdapat beberapa nilai untuk `report`:\n",
" - `full`: keluaran akan menyertakan seluruh peubah yang dihitung dalam model seperti `WATBAL`, `ETRAT`, dll.\n",
" - `partial`: keluaran hanya menyertakan kolom `PRECIP`, `PET`, `STORAGE`, `GWSTOR2`, `FLOW`, dan `DISCHARGE`.\n",
" - `flow`: keluaran hanya menyertakan kolom `FLOW`.\n",
" - `discharge`: keluaran hanya menyertakan kolom `DISCHARGE`.\n",
"\n",
"\n",
"Berikut informasi satuan keluaran model:\n",
"- `PRECIP`, `PET`, `STORAGE`, `AET`, `WATBAL`, `EXMST`, `DELSTOR`, `GWRECH`, `GWSTOR1`, `GWSTOR2`, `GWFLOW`, `DFLOW`, `FLOW` bersatuan $mm/bulan$.\n",
"- `STORAGE`, `STORAT`, `PRERAT`, `ETRAT`, `EXMRAT` merupakan rasio."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "4XSEV-1oOhIm",
"colab_type": "text"
},
"source": [
"### `as_df=True`, `report='discharge'` (_default_)\n",
"\n",
"Keluaran berupa `pandas.DataFrame`."
]
},
{
"cell_type": "code",
"metadata": {
"id": "rb5cPtZ7Ol4G",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "efca4a89-584a-4ee7-8e28-d4c95f57324c"
},
"source": [
"model_NRECA(df=dataset, precip_col='PRECIP', pet_col='PET',\n",
" MSTOR=1000, GSTOR=100, PSUB=0.4, GWF=0.2, CF=0.6, C=0.25,\n",
" AREA=1450.6e6).head()"
],
"execution_count": 22,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>DISCHARGE</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1999-01-01</th>\n",
" <td>130.474329</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-02-01</th>\n",
" <td>124.872153</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-03-01</th>\n",
" <td>66.438083</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-04-01</th>\n",
" <td>70.787505</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-05-01</th>\n",
" <td>41.998656</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" DISCHARGE\n",
"1999-01-01 130.474329\n",
"1999-02-01 124.872153\n",
"1999-03-01 66.438083\n",
"1999-04-01 70.787505\n",
"1999-05-01 41.998656"
]
},
"metadata": {
"tags": []
},
"execution_count": 22
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "FpNrnfgLO_zj",
"colab_type": "text"
},
"source": [
"Sebagian argumen bisa disimpan dalam bentuk _dictionary_."
]
},
{
"cell_type": "code",
"metadata": {
"id": "7Zl3-6a-KrmA",
"colab_type": "code",
"outputId": "1a8f653d-0e71-427a-fb8f-e1fcf8f3de9b",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
}
},
"source": [
"parameter = {\n",
" 'MSTOR': 1000,\n",
" 'GSTOR': 100,\n",
" 'PSUB': 0.4,\n",
" 'GWF': 0.2,\n",
" 'CF': 0.6,\n",
" 'C': 0.25,\n",
" 'AREA': 1450.6e6\n",
"}\n",
"\n",
"model_NRECA(df=dataset, precip_col='PRECIP', pet_col='PET', **parameter).head()"
],
"execution_count": 23,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>DISCHARGE</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1999-01-01</th>\n",
" <td>130.474329</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-02-01</th>\n",
" <td>124.872153</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-03-01</th>\n",
" <td>66.438083</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-04-01</th>\n",
" <td>70.787505</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-05-01</th>\n",
" <td>41.998656</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" DISCHARGE\n",
"1999-01-01 130.474329\n",
"1999-02-01 124.872153\n",
"1999-03-01 66.438083\n",
"1999-04-01 70.787505\n",
"1999-05-01 41.998656"
]
},
"metadata": {
"tags": []
},
"execution_count": 23
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "aqGmrvDOPNdB",
"colab_type": "text"
},
"source": [
"### `as_df=False`\n",
"\n",
"Keluaran berupa `numpy.array`"
]
},
{
"cell_type": "code",
"metadata": {
"id": "X6-1O01ZPSgr",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 527
},
"outputId": "fa6b4ab5-a578-4a15-9b38-6da2bc74a1c9"
},
"source": [
"model_NRECA(df=dataset, precip_col='PRECIP', pet_col='PET', **parameter,\n",
" as_df=False)"
],
"execution_count": 24,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"array([130.47432853, 124.87215318, 66.43808331, 70.78750455,\n",
" 41.99865614, 28.45640939, 24.28274088, 19.7163445 ,\n",
" 12.90107429, 44.81356496, 53.93315909, 90.06341788,\n",
" 95.31267461, 145.23779804, 117.57476262, 78.75685187,\n",
" 91.24644372, 57.71641073, 37.27870151, 22.07183021,\n",
" 24.97489079, 22.58939002, 35.79315297, 26.23750108,\n",
" 138.0338475 , 235.17042934, 116.11823068, 87.70033456,\n",
" 104.97934937, 109.51542424, 116.47710193, 34.51540744,\n",
" 71.42737681, 33.81058852, 34.87405532, 36.58594762,\n",
" 110.40885462, 112.85425887, 66.53789581, 97.93354457,\n",
" 35.04151568, 22.39154574, 47.55438496, 16.65090467,\n",
" 13.76474786, 10.65657899, 119.65349912, 57.66475933,\n",
" 137.39388673, 199.12246399, 159.01388739, 172.29628498,\n",
" 133.74151565, 44.77420904, 34.66390377, 27.73112302,\n",
" 36.38175359, 120.31395471, 77.61700498, 126.38336198,\n",
" 114.21457768, 123.66605913, 174.79252429, 195.67904295,\n",
" 99.25002079, 61.22475824, 71.16772612, 31.42972227,\n",
" 57.45303916, 44.65959205, 50.75185708, 91.32761479,\n",
" 141.91241982, 103.15499701, 96.64076894, 63.34595895,\n",
" 91.80413108, 133.77947175, 81.64626021, 31.2233851 ,\n",
" 56.84185425, 53.0918533 , 111.44781119, 124.64417381,\n",
" 133.68443001, 82.44572213, 103.95773659, 78.36551337,\n",
" 70.09140577, 28.12253459, 21.77228484, 17.41782788,\n",
" 14.39873771, 11.14740984, 26.2002207 , 71.83216778,\n",
" 77.60770993, 94.77473292, 112.44031817, 75.38748734,\n",
" 52.32065854, 67.14854195, 35.46514257, 18.59214774,\n",
" 15.3695088 , 21.20863532, 10.74189578, 49.26924462,\n",
" 91.25050052, 170.94322505, 77.98879732, 81.89122336,\n",
" 59.30935231, 27.5965865 , 19.29362528, 28.03710337,\n",
" 13.98514355, 65.98636155, 69.40576331, 54.21634462])"
]
},
"metadata": {
"tags": []
},
"execution_count": 24
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "g02897ZTPgF7",
"colab_type": "text"
},
"source": [
"## `report`"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "pyxlwjxtPiff",
"colab_type": "text"
},
"source": [
"### `report='full'`"
]
},
{
"cell_type": "code",
"metadata": {
"id": "ne2C1nMkPlhH",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "305a0112-391d-48ca-bb18-55e41adb164f"
},
"source": [
"model_NRECA(df=dataset, precip_col='PRECIP', pet_col='PET', **parameter,\n",
" report='full').head()"
],
"execution_count": 25,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>DAYS</th>\n",
" <th>PRECIP</th>\n",
" <th>PET</th>\n",
" <th>STORAGE</th>\n",
" <th>STORAT</th>\n",
" <th>PRERAT</th>\n",
" <th>ETRAT</th>\n",
" <th>AET</th>\n",
" <th>WATBAL</th>\n",
" <th>EXMRAT</th>\n",
" <th>DELSTOR</th>\n",
" <th>GWRECH</th>\n",
" <th>GWSTOR1</th>\n",
" <th>GWSTOR2</th>\n",
" <th>GWFLOW</th>\n",
" <th>DFLOW</th>\n",
" <th>FLOW</th>\n",
" <th>DISCHARGE</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1999-01-01</th>\n",
" <td>31.0</td>\n",
" <td>507.000000</td>\n",
" <td>142.63</td>\n",
" <td>1000.000000</td>\n",
" <td>1.323067</td>\n",
" <td>3.554652</td>\n",
" <td>1.0</td>\n",
" <td>85.578</td>\n",
" <td>421.422000</td>\n",
" <td>0.770881</td>\n",
" <td>96.555980</td>\n",
" <td>129.946408</td>\n",
" <td>100.000000</td>\n",
" <td>229.946408</td>\n",
" <td>45.989282</td>\n",
" <td>194.919612</td>\n",
" <td>240.908894</td>\n",
" <td>130.474329</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-02-01</th>\n",
" <td>28.0</td>\n",
" <td>374.228918</td>\n",
" <td>128.84</td>\n",
" <td>1096.555980</td>\n",
" <td>1.450817</td>\n",
" <td>2.904602</td>\n",
" <td>1.0</td>\n",
" <td>77.304</td>\n",
" <td>296.924918</td>\n",
" <td>0.849199</td>\n",
" <td>44.776648</td>\n",
" <td>100.859308</td>\n",
" <td>183.957127</td>\n",
" <td>284.816435</td>\n",
" <td>56.963287</td>\n",
" <td>151.288962</td>\n",
" <td>208.252249</td>\n",
" <td>124.872153</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-03-01</th>\n",
" <td>31.0</td>\n",
" <td>211.762683</td>\n",
" <td>138.19</td>\n",
" <td>1141.332627</td>\n",
" <td>1.510059</td>\n",
" <td>1.532402</td>\n",
" <td>1.0</td>\n",
" <td>82.914</td>\n",
" <td>128.848683</td>\n",
" <td>0.879979</td>\n",
" <td>15.464559</td>\n",
" <td>45.353650</td>\n",
" <td>227.853148</td>\n",
" <td>273.206798</td>\n",
" <td>54.641360</td>\n",
" <td>68.030474</td>\n",
" <td>122.671834</td>\n",
" <td>66.438083</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-04-01</th>\n",
" <td>30.0</td>\n",
" <td>219.793874</td>\n",
" <td>138.32</td>\n",
" <td>1156.797186</td>\n",
" <td>1.530520</td>\n",
" <td>1.589025</td>\n",
" <td>1.0</td>\n",
" <td>82.992</td>\n",
" <td>136.801874</td>\n",
" <td>0.889794</td>\n",
" <td>15.076374</td>\n",
" <td>48.690200</td>\n",
" <td>218.565438</td>\n",
" <td>267.255638</td>\n",
" <td>53.451128</td>\n",
" <td>73.035300</td>\n",
" <td>126.486428</td>\n",
" <td>70.787505</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-05-01</th>\n",
" <td>31.0</td>\n",
" <td>132.121255</td>\n",
" <td>125.36</td>\n",
" <td>1171.873560</td>\n",
" <td>1.550467</td>\n",
" <td>1.053935</td>\n",
" <td>1.0</td>\n",
" <td>75.216</td>\n",
" <td>56.905255</td>\n",
" <td>0.898960</td>\n",
" <td>5.749712</td>\n",
" <td>20.462217</td>\n",
" <td>213.804510</td>\n",
" <td>234.266727</td>\n",
" <td>46.853345</td>\n",
" <td>30.693325</td>\n",
" <td>77.546671</td>\n",
" <td>41.998656</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" DAYS PRECIP PET ... DFLOW FLOW DISCHARGE\n",
"1999-01-01 31.0 507.000000 142.63 ... 194.919612 240.908894 130.474329\n",
"1999-02-01 28.0 374.228918 128.84 ... 151.288962 208.252249 124.872153\n",
"1999-03-01 31.0 211.762683 138.19 ... 68.030474 122.671834 66.438083\n",
"1999-04-01 30.0 219.793874 138.32 ... 73.035300 126.486428 70.787505\n",
"1999-05-01 31.0 132.121255 125.36 ... 30.693325 77.546671 41.998656\n",
"\n",
"[5 rows x 18 columns]"
]
},
"metadata": {
"tags": []
},
"execution_count": 25
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "oBjugGpePtoI",
"colab_type": "text"
},
"source": [
"### `report='partial'`"
]
},
{
"cell_type": "code",
"metadata": {
"id": "Ji_uVjh8PwOE",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "79e5e911-6bc9-4117-9a2e-ed772648c089"
},
"source": [
"model_NRECA(df=dataset, precip_col='PRECIP', pet_col='PET', **parameter,\n",
" report='partial').head()"
],
"execution_count": 26,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>PRECIP</th>\n",
" <th>PET</th>\n",
" <th>STORAGE</th>\n",
" <th>GWSTOR2</th>\n",
" <th>FLOW</th>\n",
" <th>DISCHARGE</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1999-01-01</th>\n",
" <td>507.000000</td>\n",
" <td>142.63</td>\n",
" <td>1000.000000</td>\n",
" <td>229.946408</td>\n",
" <td>240.908894</td>\n",
" <td>130.474329</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-02-01</th>\n",
" <td>374.228918</td>\n",
" <td>128.84</td>\n",
" <td>1096.555980</td>\n",
" <td>284.816435</td>\n",
" <td>208.252249</td>\n",
" <td>124.872153</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-03-01</th>\n",
" <td>211.762683</td>\n",
" <td>138.19</td>\n",
" <td>1141.332627</td>\n",
" <td>273.206798</td>\n",
" <td>122.671834</td>\n",
" <td>66.438083</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-04-01</th>\n",
" <td>219.793874</td>\n",
" <td>138.32</td>\n",
" <td>1156.797186</td>\n",
" <td>267.255638</td>\n",
" <td>126.486428</td>\n",
" <td>70.787505</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-05-01</th>\n",
" <td>132.121255</td>\n",
" <td>125.36</td>\n",
" <td>1171.873560</td>\n",
" <td>234.266727</td>\n",
" <td>77.546671</td>\n",
" <td>41.998656</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" PRECIP PET STORAGE GWSTOR2 FLOW DISCHARGE\n",
"1999-01-01 507.000000 142.63 1000.000000 229.946408 240.908894 130.474329\n",
"1999-02-01 374.228918 128.84 1096.555980 284.816435 208.252249 124.872153\n",
"1999-03-01 211.762683 138.19 1141.332627 273.206798 122.671834 66.438083\n",
"1999-04-01 219.793874 138.32 1156.797186 267.255638 126.486428 70.787505\n",
"1999-05-01 132.121255 125.36 1171.873560 234.266727 77.546671 41.998656"
]
},
"metadata": {
"tags": []
},
"execution_count": 26
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "ywp0-8M0Pv_R",
"colab_type": "text"
},
"source": [
"### `report='flow'`"
]
},
{
"cell_type": "code",
"metadata": {
"id": "Y2LKjs_VP8u5",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "ebe2cadb-c87b-4fc2-d243-524621dcadfb"
},
"source": [
"model_NRECA(df=dataset, precip_col='PRECIP', pet_col='PET', **parameter,\n",
" report='flow').head()"
],
"execution_count": 27,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>FLOW</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1999-01-01</th>\n",
" <td>240.908894</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-02-01</th>\n",
" <td>208.252249</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-03-01</th>\n",
" <td>122.671834</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-04-01</th>\n",
" <td>126.486428</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-05-01</th>\n",
" <td>77.546671</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" FLOW\n",
"1999-01-01 240.908894\n",
"1999-02-01 208.252249\n",
"1999-03-01 122.671834\n",
"1999-04-01 126.486428\n",
"1999-05-01 77.546671"
]
},
"metadata": {
"tags": []
},
"execution_count": 27
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "kZKr8DeQP-rK",
"colab_type": "text"
},
"source": [
"### `report='discharge'` (default)"
]
},
{
"cell_type": "code",
"metadata": {
"id": "E8Ln1zNxP-T-",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 204
},
"outputId": "dc9776ba-a2c6-4c75-ceb2-99aa3ae545bd"
},
"source": [
"model_NRECA(df=dataset, precip_col='PRECIP', pet_col='PET', **parameter,\n",
" report='discharge').head()"
],
"execution_count": 28,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>DISCHARGE</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>1999-01-01</th>\n",
" <td>130.474329</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-02-01</th>\n",
" <td>124.872153</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-03-01</th>\n",
" <td>66.438083</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-04-01</th>\n",
" <td>70.787505</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1999-05-01</th>\n",
" <td>41.998656</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" DISCHARGE\n",
"1999-01-01 130.474329\n",
"1999-02-01 124.872153\n",
"1999-03-01 66.438083\n",
"1999-04-01 70.787505\n",
"1999-05-01 41.998656"
]
},
"metadata": {
"tags": []
},
"execution_count": 28
}
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "89wbLYdo2ayf",
"colab_type": "text"
},
"source": [
"# Changelog\n",
"\n",
"```\n",
"- 20191214 - 1.0.0 - Initial\n",
"```\n",
"\n",
"#### Copyright &copy; 2019 [Taruma Sakti Megariansyah](https://taruma.github.io)\n",
"\n",
"Source code in this notebook is licensed under a [MIT License](https://choosealicense.com/licenses/mit/). Data in this notebook is licensed under a [Creative Common Attribution 4.0 International](https://creativecommons.org/licenses/by/4.0/). \n"
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment