From d1b1e1a96569a40eec909cc142af61a449d4c7c8 Mon Sep 17 00:00:00 2001
From: Benjamin <3benknight@gmail.com>
Date: Tue, 23 Jul 2024 16:11:18 -0400
Subject: [PATCH] Resolved loading error due to deprecated python.
---
notebooks/quick_starter.ipynb | 394 ++++++++++++++++++++++-------
xanthos/data_reader/data_load.py | 1 -
xanthos/diagnostics/diagnostics.py | 6 +-
xanthos/hydropower/actual.py | 4 +-
4 files changed, 310 insertions(+), 95 deletions(-)
diff --git a/notebooks/quick_starter.ipynb b/notebooks/quick_starter.ipynb
index b7a38f18..50df4e76 100644
--- a/notebooks/quick_starter.ipynb
+++ b/notebooks/quick_starter.ipynb
@@ -82,18 +82,11 @@
"name": "#%%\n"
},
"ExecuteTime": {
- "end_time": "2024-07-15T19:35:00.572554400Z",
- "start_time": "2024-07-15T19:33:06.645516100Z"
+ "end_time": "2024-07-23T16:16:46.296535300Z",
+ "start_time": "2024-07-23T16:14:50.780006200Z"
}
},
"outputs": [
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Matplotlib is building the font cache; this may take a moment.\n"
- ]
- },
{
"name": "stdout",
"output_type": "stream",
@@ -231,11 +224,11 @@
},
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 1,
"metadata": {
"ExecuteTime": {
- "end_time": "2024-07-15T19:35:54.675676100Z",
- "start_time": "2024-07-15T19:35:54.632716900Z"
+ "end_time": "2024-07-23T19:27:53.917182100Z",
+ "start_time": "2024-07-23T19:27:53.824116300Z"
}
},
"outputs": [],
@@ -259,14 +252,14 @@
},
{
"cell_type": "code",
- "execution_count": 3,
+ "execution_count": 2,
"metadata": {
"pycharm": {
"name": "#%%\n"
},
"ExecuteTime": {
- "end_time": "2024-07-15T19:36:05.832989Z",
- "start_time": "2024-07-15T19:36:05.798006600Z"
+ "end_time": "2024-07-23T19:27:53.944920300Z",
+ "start_time": "2024-07-23T19:27:53.833986Z"
}
},
"outputs": [
@@ -280,7 +273,7 @@
"ProjectName = pm_abcd_mrtm_watch_1971_2001\n",
"\n",
"# full path to directory containing input and output directories\n",
- "RootDir = example\n",
+ "RootDir = C:\\xanthos-dev\\xanthos-dev\\data\\example\n",
"\n",
"# input directory name contained in root\n",
"InputFolder = input\n",
@@ -427,10 +420,10 @@
"jobs = -1\n",
"\n",
"# minimum temperature file that is stored in the model directory in deg C\n",
- "TempMinFile = example/input/climate/tasmin_watch_monthly_degc_1971_2001.npy\n",
+ "TempMinFile = C:\\xanthos-dev\\xanthos-dev\\data\\example\\input/climate/pr_gpcc_watch_monthly_mmpermth_1971_2001.npy\n",
"\n",
"# monthly average precipitation in mm/mth\n",
- "PrecipitationFile = example/input/climate/pr_gpcc_watch_monthly_mmpermth_1971_2001.npy\n",
+ "PrecipitationFile = C:\\xanthos-dev\\xanthos-dev\\data\\example\\input/climate/pr_gpcc_watch_monthly_mmpermth_1971_2001.npy\n",
"\n",
"\n",
"# Set routing module type and individual parameters\n",
@@ -566,11 +559,11 @@
},
{
"cell_type": "code",
- "execution_count": 4,
+ "execution_count": 3,
"metadata": {
"ExecuteTime": {
- "end_time": "2024-07-15T19:36:23.707144500Z",
- "start_time": "2024-07-15T19:36:23.690293700Z"
+ "end_time": "2024-07-23T19:27:53.946921300Z",
+ "start_time": "2024-07-23T19:27:53.849261100Z"
}
},
"outputs": [],
@@ -596,11 +589,11 @@
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 4,
"metadata": {
"ExecuteTime": {
- "end_time": "2024-07-15T19:36:24.450054200Z",
- "start_time": "2024-07-15T19:36:24.420450700Z"
+ "end_time": "2024-07-23T19:27:54.103697800Z",
+ "start_time": "2024-07-23T19:27:53.901784400Z"
}
},
"outputs": [],
@@ -632,14 +625,14 @@
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 5,
"metadata": {
"pycharm": {
"name": "#%%\n"
},
"ExecuteTime": {
- "end_time": "2024-07-15T19:36:26.543379300Z",
- "start_time": "2024-07-15T19:36:26.501226300Z"
+ "end_time": "2024-07-23T19:27:54.195446100Z",
+ "start_time": "2024-07-23T19:27:54.077159500Z"
}
},
"outputs": [
@@ -945,14 +938,22 @@
},
{
"cell_type": "code",
- "execution_count": 7,
+ "execution_count": 6,
"metadata": {
"ExecuteTime": {
- "end_time": "2024-07-15T19:57:24.829118300Z",
- "start_time": "2024-07-15T19:37:03.047483800Z"
+ "end_time": "2024-07-23T19:47:38.800430600Z",
+ "start_time": "2024-07-23T19:28:01.816451900Z"
}
},
"outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "C:\\Users\\knig694\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\drought\\drought_stats.py:86: SyntaxWarning: invalid escape sequence '\\s'\n",
+ " \"\"\"Compute Severity, Intensity, and Duration statistics for a matrix of hydrological output.\n"
+ ]
+ },
{
"name": "stdout",
"output_type": "stream",
@@ -970,7 +971,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
- "C:\\Users\\knig694\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\data_reader\\data_load.py:360: UserWarning: Reading `.npy` or `.npz` file required additional header parsing as it was created on Python 2. Save the file again to speed up loading and avoid this warning.\n",
+ "C:\\Users\\knig694\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\data_reader\\data_load.py:359: UserWarning: Reading `.npy` or `.npz` file required additional header parsing as it was created on Python 2. Save the file again to speed up loading and avoid this warning.\n",
" data = np.load(fn)\n"
]
},
@@ -1011,20 +1012,20 @@
"INFO: \t\tProcessing Years: 1999 to 2000\n",
"INFO: \t\tProcessing Years: 2000 to 2001\n",
"INFO: \t\tProcessing Years: 2001 to 2001\n",
- "INFO: \tPET processed in 447.5781569480896 seconds---\n",
+ "INFO: \tPET processed in 340.7386016845703 seconds---\n",
"INFO: \tProcessing Runoff...\n",
"INFO: \t\tProcessing spin-up and simulation for basins 1...235\n",
- "INFO: \tRunoff processed in 15.192879676818848 seconds---\n",
+ "INFO: \tRunoff processed in 8.466723918914795 seconds---\n",
"INFO: \tProcessing Routing...\n",
- "INFO: \tRouting processed in 684.0795149803162 seconds---\n",
- "INFO: ---Simulation has finished successfully: 1146.8841090202332 seconds ---\n",
+ "INFO: \tRouting processed in 734.0991442203522 seconds---\n",
+ "INFO: ---Simulation has finished successfully: 1083.3363785743713 seconds ---\n",
"INFO: ---Start Accessible Water:\n",
- "INFO: ---Accessible Water has finished successfully: 7.200496435165405 seconds ------\n",
+ "INFO: ---Accessible Water has finished successfully: 5.677178859710693 seconds ------\n",
"INFO: ---Start Drought Statistics:\n",
"INFO: \tCalculating drought thresholds\n",
- "INFO: ---Drought Statistics has finished successfully: 0.7958569526672363 seconds ------\n",
+ "INFO: ---Drought Statistics has finished successfully: 0.674048662185669 seconds ------\n",
"INFO: ---Start Hydropower Potential:\n",
- "INFO: ---Hydropower Potential has finished successfully: 8.655556678771973 seconds ------\n",
+ "INFO: ---Hydropower Potential has finished successfully: 7.067700624465942 seconds ------\n",
"INFO: ---Start Hydropower Actual:\n"
]
},
@@ -1033,39 +1034,30 @@
"output_type": "stream",
"text": [
"C:\\Users\\knig694\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\hydropower\\actual.py:46: UserWarning: Reading `.npy` or `.npz` file required additional header parsing as it was created on Python 2. Save the file again to speed up loading and avoid this warning.\n",
- " self.rule_curves = np.load(settings.rule_curves) # rule curves for all 1593 dams\n",
- "C:\\Users\\knig694\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\hydropower\\actual.py:104: FutureWarning: Calling int on a single element Series is deprecated and will raise a TypeError in the future. Use int(ser.iloc[0]) instead\n",
- " return int(self.loc_refs[(self.loc_refs[\"long\"] == lon) & (self.loc_refs[\"lati\"] == lat)][\"ID\"])\n"
+ " self.rule_curves = np.load(settings.rule_curves) # rule curves for all 1593 dams\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
- "INFO: ---Hydropower Actual has finished successfully: 47.09125351905823 seconds ------\n",
- "INFO: ---Start Diagnostics:\n"
- ]
- },
- {
- "ename": "TypeError",
- "evalue": "Slicing a positional slice with .loc is not allowed, Use .loc with labels or .iloc with positions instead.",
- "output_type": "error",
- "traceback": [
- "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
- "\u001B[1;31mTypeError\u001B[0m Traceback (most recent call last)",
- "Cell \u001B[1;32mIn[7], line 4\u001B[0m\n\u001B[0;32m 1\u001B[0m \u001B[38;5;28;01mimport\u001B[39;00m \u001B[38;5;21;01mxanthos\u001B[39;00m\n\u001B[0;32m 3\u001B[0m \u001B[38;5;66;03m# run Xanthos \u001B[39;00m\n\u001B[1;32m----> 4\u001B[0m xanthos\u001B[38;5;241m.\u001B[39mrun_model(config_file)\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\model.py:121\u001B[0m, in \u001B[0;36mrun_model\u001B[1;34m(config_file)\u001B[0m\n\u001B[0;32m 112\u001B[0m \u001B[38;5;250m\u001B[39m\u001B[38;5;124;03m\"\"\"Run the Xanthos model based on a user-defined configuration.\u001B[39;00m\n\u001B[0;32m 113\u001B[0m \n\u001B[0;32m 114\u001B[0m \u001B[38;5;124;03m:param config_file: Full path with file name and extension to the input configuration file.\u001B[39;00m\n\u001B[0;32m 115\u001B[0m \u001B[38;5;124;03m:type config_file: str\u001B[39;00m\n\u001B[0;32m 116\u001B[0m \n\u001B[0;32m 117\u001B[0m \u001B[38;5;124;03m\"\"\"\u001B[39;00m\n\u001B[0;32m 119\u001B[0m xth \u001B[38;5;241m=\u001B[39m Xanthos(config_file)\n\u001B[1;32m--> 121\u001B[0m xth\u001B[38;5;241m.\u001B[39mexecute()\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\model.py:94\u001B[0m, in \u001B[0;36mXanthos.execute\u001B[1;34m(self, args)\u001B[0m\n\u001B[0;32m 91\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mconfig\u001B[38;5;241m.\u001B[39mlog_info()\n\u001B[0;32m 93\u001B[0m config_runner \u001B[38;5;241m=\u001B[39m ConfigRunner(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mconfig)\n\u001B[1;32m---> 94\u001B[0m results \u001B[38;5;241m=\u001B[39m config_runner\u001B[38;5;241m.\u001B[39mrun()\n\u001B[0;32m 96\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mcleanup()\n\u001B[0;32m 98\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m results\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\configurations.py:133\u001B[0m, in \u001B[0;36mConfigRunner.run\u001B[1;34m(self)\u001B[0m\n\u001B[0;32m 130\u001B[0m c\u001B[38;5;241m.\u001B[39mhydropower_actual()\n\u001B[0;32m 132\u001B[0m \u001B[38;5;66;03m# diagnostics\u001B[39;00m\n\u001B[1;32m--> 133\u001B[0m c\u001B[38;5;241m.\u001B[39mdiagnostics()\n\u001B[0;32m 135\u001B[0m \u001B[38;5;66;03m# output simulation data\u001B[39;00m\n\u001B[0;32m 136\u001B[0m c\u001B[38;5;241m.\u001B[39moutput_simulation()\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\components.py:437\u001B[0m, in \u001B[0;36mComponents.diagnostics\u001B[1;34m(self)\u001B[0m\n\u001B[0;32m 434\u001B[0m logging\u001B[38;5;241m.\u001B[39minfo(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m---Start Diagnostics:\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[0;32m 435\u001B[0m t0 \u001B[38;5;241m=\u001B[39m time\u001B[38;5;241m.\u001B[39mtime()\n\u001B[1;32m--> 437\u001B[0m Diagnostics(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39ms, \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mQ, \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mdata)\n\u001B[0;32m 439\u001B[0m logging\u001B[38;5;241m.\u001B[39minfo(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124m---Diagnostics has finished successfully: \u001B[39m\u001B[38;5;132;01m%s\u001B[39;00m\u001B[38;5;124m seconds ------\u001B[39m\u001B[38;5;124m\"\u001B[39m \u001B[38;5;241m%\u001B[39m (time\u001B[38;5;241m.\u001B[39mtime() \u001B[38;5;241m-\u001B[39m t0))\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\diagnostics\\diagnostics.py:82\u001B[0m, in \u001B[0;36mDiagnostics.__init__\u001B[1;34m(self, settings, xanthos_q, ref)\u001B[0m\n\u001B[0;32m 77\u001B[0m \u001B[38;5;66;03m# Only basins/countries/regions for which all four models have\u001B[39;00m\n\u001B[0;32m 78\u001B[0m \u001B[38;5;66;03m# values are used to estimate the RMSE values\u001B[39;00m\n\u001B[0;32m 79\u001B[0m \n\u001B[0;32m 80\u001B[0m \u001B[38;5;66;03m# Basin Based\u001B[39;00m\n\u001B[0;32m 81\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m settings\u001B[38;5;241m.\u001B[39mDiagnosticScale \u001B[38;5;241m==\u001B[39m \u001B[38;5;241m0\u001B[39m \u001B[38;5;129;01mor\u001B[39;00m settings\u001B[38;5;241m.\u001B[39mDiagnosticScale \u001B[38;5;241m==\u001B[39m \u001B[38;5;241m1\u001B[39m:\n\u001B[1;32m---> 82\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mwrite_diagnostics(\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mBasin\u001B[39m\u001B[38;5;124m'\u001B[39m, ref\u001B[38;5;241m.\u001B[39mbasin_ids, ref\u001B[38;5;241m.\u001B[39mbasin_names, q, qq, wbm, wbmc, UNH, \u001B[38;5;241m1\u001B[39m)\n\u001B[0;32m 84\u001B[0m \u001B[38;5;66;03m# Country Based\u001B[39;00m\n\u001B[0;32m 85\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m settings\u001B[38;5;241m.\u001B[39mDiagnosticScale \u001B[38;5;241m==\u001B[39m \u001B[38;5;241m0\u001B[39m \u001B[38;5;129;01mor\u001B[39;00m settings\u001B[38;5;241m.\u001B[39mDiagnosticScale \u001B[38;5;241m==\u001B[39m \u001B[38;5;241m2\u001B[39m:\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\diagnostics\\diagnostics.py:130\u001B[0m, in \u001B[0;36mDiagnostics.write_diagnostics\u001B[1;34m(self, scale, id_map, name_map, q, qq, wbm, wbmc, UNH, name_map_offset)\u001B[0m\n\u001B[0;32m 128\u001B[0m \u001B[38;5;66;03m# Add global total as top row\u001B[39;00m\n\u001B[0;32m 129\u001B[0m agg_df\u001B[38;5;241m.\u001B[39mloc[\u001B[38;5;241m-\u001B[39m\u001B[38;5;241m1\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mname\u001B[39m\u001B[38;5;124m'\u001B[39m] \u001B[38;5;241m=\u001B[39m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mGlobal\u001B[39m\u001B[38;5;124m'\u001B[39m\n\u001B[1;32m--> 130\u001B[0m agg_df\u001B[38;5;241m.\u001B[39mloc[\u001B[38;5;241m-\u001B[39m\u001B[38;5;241m1\u001B[39m, \u001B[38;5;241m1\u001B[39m:] \u001B[38;5;241m=\u001B[39m agg_df\u001B[38;5;241m.\u001B[39msum(numeric_only\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m)\n\u001B[0;32m 131\u001B[0m agg_df\u001B[38;5;241m.\u001B[39mindex \u001B[38;5;241m=\u001B[39m agg_df\u001B[38;5;241m.\u001B[39mindex \u001B[38;5;241m+\u001B[39m \u001B[38;5;241m1\u001B[39m\n\u001B[0;32m 132\u001B[0m agg_df \u001B[38;5;241m=\u001B[39m agg_df\u001B[38;5;241m.\u001B[39msort_index()\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\pandas\\core\\indexing.py:845\u001B[0m, in \u001B[0;36m_LocationIndexer.__setitem__\u001B[1;34m(self, key, value)\u001B[0m\n\u001B[0;32m 843\u001B[0m \u001B[38;5;28;01melse\u001B[39;00m:\n\u001B[0;32m 844\u001B[0m key \u001B[38;5;241m=\u001B[39m com\u001B[38;5;241m.\u001B[39mapply_if_callable(key, \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mobj)\n\u001B[1;32m--> 845\u001B[0m indexer \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_get_setitem_indexer(key)\n\u001B[0;32m 846\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_has_valid_setitem_indexer(key)\n\u001B[0;32m 848\u001B[0m iloc \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mname \u001B[38;5;241m==\u001B[39m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124miloc\u001B[39m\u001B[38;5;124m\"\u001B[39m \u001B[38;5;28;01melse\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mobj\u001B[38;5;241m.\u001B[39miloc\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\pandas\\core\\indexing.py:710\u001B[0m, in \u001B[0;36m_LocationIndexer._get_setitem_indexer\u001B[1;34m(self, key)\u001B[0m\n\u001B[0;32m 707\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(key, \u001B[38;5;28mtuple\u001B[39m):\n\u001B[0;32m 708\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m suppress(IndexingError):\n\u001B[0;32m 709\u001B[0m \u001B[38;5;66;03m# suppress \"Too many indexers\"\u001B[39;00m\n\u001B[1;32m--> 710\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_convert_tuple(key)\n\u001B[0;32m 712\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(key, \u001B[38;5;28mrange\u001B[39m):\n\u001B[0;32m 713\u001B[0m \u001B[38;5;66;03m# GH#45479 test_loc_setitem_range_key\u001B[39;00m\n\u001B[0;32m 714\u001B[0m key \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mlist\u001B[39m(key)\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\pandas\\core\\indexing.py:927\u001B[0m, in \u001B[0;36m_LocationIndexer._convert_tuple\u001B[1;34m(self, key)\u001B[0m\n\u001B[0;32m 923\u001B[0m \u001B[38;5;129m@final\u001B[39m\n\u001B[0;32m 924\u001B[0m \u001B[38;5;28;01mdef\u001B[39;00m \u001B[38;5;21m_convert_tuple\u001B[39m(\u001B[38;5;28mself\u001B[39m, key: \u001B[38;5;28mtuple\u001B[39m) \u001B[38;5;241m-\u001B[39m\u001B[38;5;241m>\u001B[39m \u001B[38;5;28mtuple\u001B[39m:\n\u001B[0;32m 925\u001B[0m \u001B[38;5;66;03m# Note: we assume _tupleize_axis_indexer has been called, if necessary.\u001B[39;00m\n\u001B[0;32m 926\u001B[0m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_validate_key_length(key)\n\u001B[1;32m--> 927\u001B[0m keyidx \u001B[38;5;241m=\u001B[39m [\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39m_convert_to_indexer(k, axis\u001B[38;5;241m=\u001B[39mi) \u001B[38;5;28;01mfor\u001B[39;00m i, k \u001B[38;5;129;01min\u001B[39;00m \u001B[38;5;28menumerate\u001B[39m(key)]\n\u001B[0;32m 928\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mtuple\u001B[39m(keyidx)\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\pandas\\core\\indexing.py:1382\u001B[0m, in \u001B[0;36m_LocIndexer._convert_to_indexer\u001B[1;34m(self, key, axis)\u001B[0m\n\u001B[0;32m 1379\u001B[0m labels \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mobj\u001B[38;5;241m.\u001B[39m_get_axis(axis)\n\u001B[0;32m 1381\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(key, \u001B[38;5;28mslice\u001B[39m):\n\u001B[1;32m-> 1382\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m labels\u001B[38;5;241m.\u001B[39m_convert_slice_indexer(key, kind\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mloc\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n\u001B[0;32m 1384\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m (\n\u001B[0;32m 1385\u001B[0m \u001B[38;5;28misinstance\u001B[39m(key, \u001B[38;5;28mtuple\u001B[39m)\n\u001B[0;32m 1386\u001B[0m \u001B[38;5;129;01mand\u001B[39;00m \u001B[38;5;129;01mnot\u001B[39;00m \u001B[38;5;28misinstance\u001B[39m(labels, MultiIndex)\n\u001B[0;32m 1387\u001B[0m \u001B[38;5;129;01mand\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mndim \u001B[38;5;241m<\u001B[39m \u001B[38;5;241m2\u001B[39m\n\u001B[0;32m 1388\u001B[0m \u001B[38;5;129;01mand\u001B[39;00m \u001B[38;5;28mlen\u001B[39m(key) \u001B[38;5;241m>\u001B[39m \u001B[38;5;241m1\u001B[39m\n\u001B[0;32m 1389\u001B[0m ):\n\u001B[0;32m 1390\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m IndexingError(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mToo many indexers\u001B[39m\u001B[38;5;124m\"\u001B[39m)\n",
- "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\pandas\\core\\indexes\\base.py:4126\u001B[0m, in \u001B[0;36mIndex._convert_slice_indexer\u001B[1;34m(self, key, kind)\u001B[0m\n\u001B[0;32m 4123\u001B[0m \u001B[38;5;28;01melif\u001B[39;00m is_positional:\n\u001B[0;32m 4124\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m kind \u001B[38;5;241m==\u001B[39m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mloc\u001B[39m\u001B[38;5;124m\"\u001B[39m:\n\u001B[0;32m 4125\u001B[0m \u001B[38;5;66;03m# GH#16121, GH#24612, GH#31810\u001B[39;00m\n\u001B[1;32m-> 4126\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mTypeError\u001B[39;00m(\n\u001B[0;32m 4127\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mSlicing a positional slice with .loc is not allowed, \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 4128\u001B[0m \u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mUse .loc with labels or .iloc with positions instead.\u001B[39m\u001B[38;5;124m\"\u001B[39m,\n\u001B[0;32m 4129\u001B[0m )\n\u001B[0;32m 4130\u001B[0m indexer \u001B[38;5;241m=\u001B[39m key\n\u001B[0;32m 4131\u001B[0m \u001B[38;5;28;01melse\u001B[39;00m:\n",
- "\u001B[1;31mTypeError\u001B[0m: Slicing a positional slice with .loc is not allowed, Use .loc with labels or .iloc with positions instead."
+ "INFO: ---Hydropower Actual has finished successfully: 44.70871639251709 seconds ------\n",
+ "INFO: ---Start Diagnostics:\n",
+ "INFO: ---Diagnostics has finished successfully: 0.309828519821167 seconds ------\n",
+ "INFO: ---Output simulation results:\n",
+ "DEBUG: Outputting data annually\n",
+ "DEBUG: Unit is km3peryear\n",
+ "DEBUG: pet output dimension is (67420, 31)\n",
+ "DEBUG: aet output dimension is (67420, 31)\n",
+ "DEBUG: q output dimension is (67420, 31)\n",
+ "DEBUG: soilmoisture output dimension is (67420, 31)\n",
+ "DEBUG: avgchflow output dimension is (67420, 31)\n",
+ "INFO: Aggregating by Basin\n",
+ "INFO: Aggregating by Country\n",
+ "INFO: Aggregating by GCAM Region\n",
+ "INFO: Aggregated unit is km3peryear\n",
+ "INFO: ---Output finished: 18.99467396736145 seconds ---\n",
+ "INFO: End of pm_abcd_mrtm_watch_1971_2001\n"
]
}
],
@@ -1095,7 +1087,7 @@
}
},
"source": [
- "User can use any `Xantho` module individually by providing required input. The following example shows how to calculate accessible water using the `AccessibleWater` module. `AccessibleWater` module requires three inputs: \n",
+ "User can use any `Xanthos` module individually by providing required input. The following example shows how to calculate accessible water using the `AccessibleWater` module. `AccessibleWater` module requires three inputs: \n",
"1. Configuration object: use xanthos module `ConfigReader` to load\n",
"2. Loaded data object: use xanthos module `DataLoader` to load\n",
"3. Monthly runoff in each grid cell\n",
@@ -1107,9 +1099,28 @@
},
{
"cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
+ "execution_count": 7,
+ "metadata": {
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:49:50.513494200Z",
+ "start_time": "2024-07-23T19:49:49.713354200Z"
+ }
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "[[0.23729078 0.71997664 0.45756271 ... 0.79573858 0.29277064 0.9525083 ]\n",
+ " [0.32170624 0.49582591 0.34552159 ... 0.73339921 0.12001792 0.59031343]\n",
+ " [0.01633928 0.15829089 0.43590904 ... 0.95639094 0.27692173 0.21690385]\n",
+ " ...\n",
+ " [0.88268806 0.82792796 0.37548677 ... 0.3336255 0.47045483 0.40491021]\n",
+ " [0.72703159 0.24711897 0.25971312 ... 0.38736996 0.31333512 0.36965065]\n",
+ " [0.38352199 0.10856003 0.16274492 ... 0.19349333 0.17382684 0.95832028]]\n"
+ ]
+ }
+ ],
"source": [
"import numpy as np\n",
"\n",
@@ -1126,13 +1137,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 8,
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:02.052008500Z",
+ "start_time": "2024-07-23T19:49:52.739249300Z"
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stderr",
+ "output_type": "stream",
+ "text": [
+ "C:\\Users\\knig694\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\xanthos\\data_reader\\data_load.py:359: UserWarning: Reading `.npy` or `.npz` file required additional header parsing as it was created on Python 2. Save the file again to speed up loading and avoid this warning.\n",
+ " data = np.load(fn)\n"
+ ]
+ }
+ ],
"source": [
"from xanthos import ConfigReader\n",
"from xanthos.data_reader.data_load import DataLoader\n",
@@ -1200,10 +1224,14 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 9,
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:20.617303900Z",
+ "start_time": "2024-07-23T19:50:18.752328200Z"
}
},
"outputs": [],
@@ -1460,10 +1488,14 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 10,
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:26.859013700Z",
+ "start_time": "2024-07-23T19:50:25.834109800Z"
}
},
"outputs": [],
@@ -1518,13 +1550,33 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 11,
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:27.825400Z",
+ "start_time": "2024-07-23T19:50:27.775959200Z"
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(67420, 372)\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": "array([[-18.89531555, -21.55454102, -20.30705872, ..., -5.4663147 ,\n -12.67459717, -17.27277222],\n [-19.6915802 , -22.49143066, -21.08751526, ..., -5.88968506,\n -13.20639648, -17.82964172],\n [-21.00528564, -24.10410156, -23.00447693, ..., -7.36795654,\n -14.70386353, -19.22087708],\n [-21.81871643, -25.10942688, -23.81903687, ..., -7.96378174,\n -15.2135376 , -19.83913269]])"
+ },
+ "execution_count": 11,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# input climate data format requirement 2D array [67420 grid cells, year-month, ...]\n",
"print(tas.shape)\n",
@@ -1533,13 +1585,40 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 12,
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:31.326960300Z",
+ "start_time": "2024-07-23T19:50:28.333538900Z"
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "ename": "OSError",
+ "evalue": "'seaborn-white' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)",
+ "output_type": "error",
+ "traceback": [
+ "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
+ "\u001B[1;31mFileNotFoundError\u001B[0m Traceback (most recent call last)",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\style\\core.py:137\u001B[0m, in \u001B[0;36muse\u001B[1;34m(style)\u001B[0m\n\u001B[0;32m 136\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 137\u001B[0m style \u001B[38;5;241m=\u001B[39m _rc_params_in_file(style)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mOSError\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m err:\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\__init__.py:866\u001B[0m, in \u001B[0;36m_rc_params_in_file\u001B[1;34m(fname, transform, fail_on_error)\u001B[0m\n\u001B[0;32m 865\u001B[0m rc_temp \u001B[38;5;241m=\u001B[39m {}\n\u001B[1;32m--> 866\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m _open_file_or_url(fname) \u001B[38;5;28;01mas\u001B[39;00m fd:\n\u001B[0;32m 867\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\contextlib.py:137\u001B[0m, in \u001B[0;36m_GeneratorContextManager.__enter__\u001B[1;34m(self)\u001B[0m\n\u001B[0;32m 136\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 137\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mnext\u001B[39m(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mgen)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mStopIteration\u001B[39;00m:\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\__init__.py:843\u001B[0m, in \u001B[0;36m_open_file_or_url\u001B[1;34m(fname)\u001B[0m\n\u001B[0;32m 842\u001B[0m fname \u001B[38;5;241m=\u001B[39m os\u001B[38;5;241m.\u001B[39mpath\u001B[38;5;241m.\u001B[39mexpanduser(fname)\n\u001B[1;32m--> 843\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[38;5;28mopen\u001B[39m(fname, encoding\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mutf-8\u001B[39m\u001B[38;5;124m'\u001B[39m) \u001B[38;5;28;01mas\u001B[39;00m f:\n\u001B[0;32m 844\u001B[0m \u001B[38;5;28;01myield\u001B[39;00m f\n",
+ "\u001B[1;31mFileNotFoundError\u001B[0m: [Errno 2] No such file or directory: 'seaborn-white'",
+ "\nThe above exception was the direct cause of the following exception:\n",
+ "\u001B[1;31mOSError\u001B[0m Traceback (most recent call last)",
+ "Cell \u001B[1;32mIn[12], line 3\u001B[0m\n\u001B[0;32m 1\u001B[0m \u001B[38;5;66;03m# input climate data time series\u001B[39;00m\n\u001B[0;32m 2\u001B[0m dfx \u001B[38;5;241m=\u001B[39m arr_to_df(arr\u001B[38;5;241m=\u001B[39mtas, stat\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mmean\u001B[39m\u001B[38;5;124m'\u001B[39m)\n\u001B[1;32m----> 3\u001B[0m plot_single_line(dfx\u001B[38;5;241m=\u001B[39mdfx,\n\u001B[0;32m 4\u001B[0m title\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mGlobal Mean Temperature\u001B[39m\u001B[38;5;124m'\u001B[39m,\n\u001B[0;32m 5\u001B[0m y_label\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mDegree C\u001B[39m\u001B[38;5;124m'\u001B[39m)\n",
+ "Cell \u001B[1;32mIn[9], line 153\u001B[0m, in \u001B[0;36mplot_single_line\u001B[1;34m(dfx, title, x_label, y_label)\u001B[0m\n\u001B[0;32m 143\u001B[0m \u001B[38;5;250m\u001B[39m\u001B[38;5;124;03m\"\"\"\u001B[39;00m\n\u001B[0;32m 144\u001B[0m \u001B[38;5;124;03mPlot a single time series.\u001B[39;00m\n\u001B[0;32m 145\u001B[0m \n\u001B[1;32m (...)\u001B[0m\n\u001B[0;32m 149\u001B[0m \u001B[38;5;124;03m:param y_label: string for y axis label\u001B[39;00m\n\u001B[0;32m 150\u001B[0m \u001B[38;5;124;03m\"\"\"\u001B[39;00m\n\u001B[0;32m 152\u001B[0m \u001B[38;5;66;03m# plt.figure()\u001B[39;00m\n\u001B[1;32m--> 153\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m plt\u001B[38;5;241m.\u001B[39mstyle\u001B[38;5;241m.\u001B[39mcontext(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mseaborn-white\u001B[39m\u001B[38;5;124m\"\u001B[39m):\n\u001B[0;32m 154\u001B[0m fig, ax \u001B[38;5;241m=\u001B[39m plt\u001B[38;5;241m.\u001B[39msubplots(figsize\u001B[38;5;241m=\u001B[39m(\u001B[38;5;241m16\u001B[39m, \u001B[38;5;241m8\u001B[39m), constrained_layout\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mFalse\u001B[39;00m)\n\u001B[0;32m 155\u001B[0m dfx\u001B[38;5;241m.\u001B[39mplot(kind\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mline\u001B[39m\u001B[38;5;124m'\u001B[39m, legend\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mFalse\u001B[39;00m, title\u001B[38;5;241m=\u001B[39mtitle, colormap\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mcubehelix\u001B[39m\u001B[38;5;124m\"\u001B[39m, ax\u001B[38;5;241m=\u001B[39max)\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\contextlib.py:137\u001B[0m, in \u001B[0;36m_GeneratorContextManager.__enter__\u001B[1;34m(self)\u001B[0m\n\u001B[0;32m 135\u001B[0m \u001B[38;5;28;01mdel\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39margs, \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mkwds, \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mfunc\n\u001B[0;32m 136\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 137\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mnext\u001B[39m(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mgen)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mStopIteration\u001B[39;00m:\n\u001B[0;32m 139\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mRuntimeError\u001B[39;00m(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mgenerator didn\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mt yield\u001B[39m\u001B[38;5;124m\"\u001B[39m) \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\style\\core.py:194\u001B[0m, in \u001B[0;36mcontext\u001B[1;34m(style, after_reset)\u001B[0m\n\u001B[0;32m 192\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m after_reset:\n\u001B[0;32m 193\u001B[0m mpl\u001B[38;5;241m.\u001B[39mrcdefaults()\n\u001B[1;32m--> 194\u001B[0m use(style)\n\u001B[0;32m 195\u001B[0m \u001B[38;5;28;01myield\u001B[39;00m\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\style\\core.py:139\u001B[0m, in \u001B[0;36muse\u001B[1;34m(style)\u001B[0m\n\u001B[0;32m 137\u001B[0m style \u001B[38;5;241m=\u001B[39m _rc_params_in_file(style)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mOSError\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m err:\n\u001B[1;32m--> 139\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mOSError\u001B[39;00m(\n\u001B[0;32m 140\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mstyle\u001B[38;5;132;01m!r}\u001B[39;00m\u001B[38;5;124m is not a valid package style, path of style \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 141\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mfile, URL of style file, or library style name (library \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 142\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mstyles are listed in `style.available`)\u001B[39m\u001B[38;5;124m\"\u001B[39m) \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01merr\u001B[39;00m\n\u001B[0;32m 143\u001B[0m filtered \u001B[38;5;241m=\u001B[39m {}\n\u001B[0;32m 144\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m k \u001B[38;5;129;01min\u001B[39;00m style: \u001B[38;5;66;03m# don't trigger RcParams.__getitem__('backend')\u001B[39;00m\n",
+ "\u001B[1;31mOSError\u001B[0m: 'seaborn-white' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)"
+ ]
+ }
+ ],
"source": [
"# input climate data time series\n",
"dfx = arr_to_df(arr=tas, stat='mean')\n",
@@ -1554,6 +1633,10 @@
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:31.360699Z",
+ "start_time": "2024-07-23T19:50:31.332862900Z"
}
},
"outputs": [],
@@ -1571,6 +1654,9 @@
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "start_time": "2024-07-23T19:50:31.336735200Z"
}
},
"outputs": [],
@@ -1603,13 +1689,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 13,
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:31.928230400Z",
+ "start_time": "2024-07-23T19:50:31.829270600Z"
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The output is in the unit of km3peryear\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": " id 1971 1972 1973 1974 1975 1976 \\\n0 1 3.499196 3.760416 3.766999 3.724275 3.745087 3.712290 \n1 2 0.157544 0.200485 0.193464 0.137926 0.126463 0.127689 \n2 3 0.184983 0.263882 0.258217 0.182754 0.203782 0.204118 \n3 4 0.184133 0.271089 0.266833 0.192981 0.213800 0.222940 \n4 5 0.200232 0.237005 0.283622 0.205184 0.211821 0.224929 \n... ... ... ... ... ... ... ... \n67415 67416 0.276856 0.230575 0.319425 0.230290 0.216269 0.233404 \n67416 67417 0.333894 0.231086 0.314473 0.217021 0.203969 0.206759 \n67417 67418 0.362545 0.223098 0.306808 0.200619 0.195623 0.180217 \n67418 67419 0.087033 0.077437 0.072118 0.067343 0.061348 0.056464 \n67419 67420 0.086055 0.077431 0.083825 0.073113 0.068327 0.061251 \n\n 1977 1978 1979 ... 1992 1993 1994 \\\n0 3.690238 3.742392 3.716898 ... 3.843989 3.821417 3.761283 \n1 0.204124 0.189099 0.211875 ... 0.292241 0.284102 0.264102 \n2 0.326984 0.254326 0.284734 ... 0.469218 0.403013 0.397171 \n3 0.353349 0.247773 0.286880 ... 0.532720 0.430720 0.424207 \n4 0.347473 0.297400 0.290753 ... 0.421585 0.374972 0.399300 \n... ... ... ... ... ... ... ... \n67415 0.345167 0.368692 0.344930 ... 0.312442 0.325180 0.325299 \n67416 0.319439 0.360415 0.371743 ... 0.239296 0.263845 0.248965 \n67417 0.301064 0.349075 0.381330 ... 0.197147 0.225100 0.199643 \n67418 0.052715 0.056154 0.045560 ... 0.016711 0.015452 0.014502 \n67419 0.069717 0.074754 0.051832 ... 0.028929 0.029637 0.028621 \n\n 1995 1996 1997 1998 1999 2000 2001 \n0 3.817701 3.832962 3.805191 3.765942 3.946684 3.925090 3.846125 \n1 0.241170 0.436688 0.361689 0.449874 0.284137 0.351251 0.305943 \n2 0.346177 0.615426 0.515592 0.569435 0.396938 0.458813 0.400961 \n3 0.357292 0.682819 0.556121 0.552876 0.409109 0.458233 0.393148 \n4 0.348260 0.645637 0.534486 0.490197 0.395247 0.447426 0.388745 \n... ... ... ... ... ... ... ... \n67415 0.308772 0.445227 0.457679 0.381021 0.341855 0.388078 0.360437 \n67416 0.245447 0.308560 0.375105 0.318961 0.268726 0.317965 0.303970 \n67417 0.203029 0.223627 0.319138 0.276843 0.215057 0.273210 0.269356 \n67418 0.015947 0.013887 0.013692 0.021735 0.011097 0.010065 0.009489 \n67419 0.041677 0.037166 0.043611 0.049997 0.021938 0.019615 0.019289 \n\n[67420 rows x 32 columns]",
+ "text/html": "
\n\n
\n \n \n | \n id | \n 1971 | \n 1972 | \n 1973 | \n 1974 | \n 1975 | \n 1976 | \n 1977 | \n 1978 | \n 1979 | \n ... | \n 1992 | \n 1993 | \n 1994 | \n 1995 | \n 1996 | \n 1997 | \n 1998 | \n 1999 | \n 2000 | \n 2001 | \n
\n \n \n \n 0 | \n 1 | \n 3.499196 | \n 3.760416 | \n 3.766999 | \n 3.724275 | \n 3.745087 | \n 3.712290 | \n 3.690238 | \n 3.742392 | \n 3.716898 | \n ... | \n 3.843989 | \n 3.821417 | \n 3.761283 | \n 3.817701 | \n 3.832962 | \n 3.805191 | \n 3.765942 | \n 3.946684 | \n 3.925090 | \n 3.846125 | \n
\n \n 1 | \n 2 | \n 0.157544 | \n 0.200485 | \n 0.193464 | \n 0.137926 | \n 0.126463 | \n 0.127689 | \n 0.204124 | \n 0.189099 | \n 0.211875 | \n ... | \n 0.292241 | \n 0.284102 | \n 0.264102 | \n 0.241170 | \n 0.436688 | \n 0.361689 | \n 0.449874 | \n 0.284137 | \n 0.351251 | \n 0.305943 | \n
\n \n 2 | \n 3 | \n 0.184983 | \n 0.263882 | \n 0.258217 | \n 0.182754 | \n 0.203782 | \n 0.204118 | \n 0.326984 | \n 0.254326 | \n 0.284734 | \n ... | \n 0.469218 | \n 0.403013 | \n 0.397171 | \n 0.346177 | \n 0.615426 | \n 0.515592 | \n 0.569435 | \n 0.396938 | \n 0.458813 | \n 0.400961 | \n
\n \n 3 | \n 4 | \n 0.184133 | \n 0.271089 | \n 0.266833 | \n 0.192981 | \n 0.213800 | \n 0.222940 | \n 0.353349 | \n 0.247773 | \n 0.286880 | \n ... | \n 0.532720 | \n 0.430720 | \n 0.424207 | \n 0.357292 | \n 0.682819 | \n 0.556121 | \n 0.552876 | \n 0.409109 | \n 0.458233 | \n 0.393148 | \n
\n \n 4 | \n 5 | \n 0.200232 | \n 0.237005 | \n 0.283622 | \n 0.205184 | \n 0.211821 | \n 0.224929 | \n 0.347473 | \n 0.297400 | \n 0.290753 | \n ... | \n 0.421585 | \n 0.374972 | \n 0.399300 | \n 0.348260 | \n 0.645637 | \n 0.534486 | \n 0.490197 | \n 0.395247 | \n 0.447426 | \n 0.388745 | \n
\n \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n
\n \n 67415 | \n 67416 | \n 0.276856 | \n 0.230575 | \n 0.319425 | \n 0.230290 | \n 0.216269 | \n 0.233404 | \n 0.345167 | \n 0.368692 | \n 0.344930 | \n ... | \n 0.312442 | \n 0.325180 | \n 0.325299 | \n 0.308772 | \n 0.445227 | \n 0.457679 | \n 0.381021 | \n 0.341855 | \n 0.388078 | \n 0.360437 | \n
\n \n 67416 | \n 67417 | \n 0.333894 | \n 0.231086 | \n 0.314473 | \n 0.217021 | \n 0.203969 | \n 0.206759 | \n 0.319439 | \n 0.360415 | \n 0.371743 | \n ... | \n 0.239296 | \n 0.263845 | \n 0.248965 | \n 0.245447 | \n 0.308560 | \n 0.375105 | \n 0.318961 | \n 0.268726 | \n 0.317965 | \n 0.303970 | \n
\n \n 67417 | \n 67418 | \n 0.362545 | \n 0.223098 | \n 0.306808 | \n 0.200619 | \n 0.195623 | \n 0.180217 | \n 0.301064 | \n 0.349075 | \n 0.381330 | \n ... | \n 0.197147 | \n 0.225100 | \n 0.199643 | \n 0.203029 | \n 0.223627 | \n 0.319138 | \n 0.276843 | \n 0.215057 | \n 0.273210 | \n 0.269356 | \n
\n \n 67418 | \n 67419 | \n 0.087033 | \n 0.077437 | \n 0.072118 | \n 0.067343 | \n 0.061348 | \n 0.056464 | \n 0.052715 | \n 0.056154 | \n 0.045560 | \n ... | \n 0.016711 | \n 0.015452 | \n 0.014502 | \n 0.015947 | \n 0.013887 | \n 0.013692 | \n 0.021735 | \n 0.011097 | \n 0.010065 | \n 0.009489 | \n
\n \n 67419 | \n 67420 | \n 0.086055 | \n 0.077431 | \n 0.083825 | \n 0.073113 | \n 0.068327 | \n 0.061251 | \n 0.069717 | \n 0.074754 | \n 0.051832 | \n ... | \n 0.028929 | \n 0.029637 | \n 0.028621 | \n 0.041677 | \n 0.037166 | \n 0.043611 | \n 0.049997 | \n 0.021938 | \n 0.019615 | \n 0.019289 | \n
\n \n
\n
67420 rows × 32 columns
\n
"
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# runoff at xanthos grid cells (67420 cells)\n",
"print('The output is in the unit of', config.OutputUnitStr)\n",
@@ -1618,13 +1725,34 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 14,
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:33.153594900Z",
+ "start_time": "2024-07-23T19:50:32.971774Z"
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "The output is in the unit of km3peryear\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": " id name 1971 1972 1973 \\\n0 1 Arctic Ocean Islands 1145.443069 1492.093804 1341.364639 \n1 2 Northwest Territories 469.631837 447.138534 493.543565 \n2 3 Siberia North Coast 223.945993 187.136077 229.684111 \n3 4 Siberia West Coast 573.950826 687.219762 671.607608 \n4 5 Kara Sea Coast 207.648901 186.920652 188.909038 \n.. ... ... ... ... ... \n230 231 Rio Grande River Basin 44.405257 44.556657 53.256264 \n231 232 New England Basin 197.621204 230.945894 228.404529 \n232 233 Mid Atlantic Basin 94.360120 121.093517 100.414981 \n233 234 Hawaii 90.403138 77.594370 66.516706 \n234 235 Narmada 61.144840 45.171273 92.011860 \n\n 1974 1975 1976 1977 1978 ... \\\n0 1283.306010 1309.683258 1554.225743 1292.289969 1327.371862 ... \n1 482.018603 491.983189 498.414040 530.325685 504.877059 ... \n2 224.855858 201.784275 194.420405 187.759836 166.803275 ... \n3 583.058739 608.450929 589.507306 679.343756 688.283673 ... \n4 164.723636 209.486800 165.103240 178.278467 210.304230 ... \n.. ... ... ... ... ... ... \n230 51.244645 43.600788 50.194872 35.516325 56.910455 ... \n231 212.221180 219.280223 226.989342 233.455606 207.845080 ... \n232 92.973803 115.326554 97.045582 103.381721 105.590279 ... \n233 93.649276 86.486023 78.496287 69.912493 84.934176 ... \n234 44.935243 64.526522 59.572589 66.228176 64.804183 ... \n\n 1992 1993 1994 1995 1996 \\\n0 1356.734930 1283.146873 1105.302948 1025.685607 1411.992644 \n1 587.163087 582.698290 606.134769 671.532510 663.248651 \n2 211.759195 212.053449 186.432140 220.133729 195.835677 \n3 606.992752 564.961654 660.606833 634.878320 773.765837 \n4 222.135195 211.970378 177.499458 224.490936 196.564751 \n.. ... ... ... ... ... \n230 55.004094 40.182020 31.831690 33.789996 35.450004 \n231 206.401141 217.257088 215.243915 208.941643 237.527955 \n232 106.948161 118.389437 120.473958 104.168004 146.788234 \n233 71.548693 60.613099 96.407296 60.833836 66.526985 \n234 35.549612 48.900342 74.924598 47.474215 44.530489 \n\n 1997 1998 1999 2000 2001 \n0 1349.929359 1209.309484 1215.290811 1328.376808 1260.970057 \n1 651.753698 646.523186 650.577042 659.182835 678.125821 \n2 187.776636 178.747630 227.802098 187.472609 182.356354 \n3 692.618981 661.542572 677.126880 680.739008 673.986572 \n4 198.169245 215.550297 212.244437 184.431571 222.321162 \n.. ... ... ... ... ... \n230 46.154355 37.325743 34.568666 31.458995 31.634092 \n231 207.858317 220.956140 218.375845 219.229009 188.477995 \n232 109.409213 126.943563 109.572289 121.343027 104.509961 \n233 84.758768 35.183624 65.133219 60.502970 53.162302 \n234 53.208262 53.958317 61.340541 34.424744 39.168144 \n\n[235 rows x 33 columns]",
+ "text/html": "\n\n
\n \n \n | \n id | \n name | \n 1971 | \n 1972 | \n 1973 | \n 1974 | \n 1975 | \n 1976 | \n 1977 | \n 1978 | \n ... | \n 1992 | \n 1993 | \n 1994 | \n 1995 | \n 1996 | \n 1997 | \n 1998 | \n 1999 | \n 2000 | \n 2001 | \n
\n \n \n \n 0 | \n 1 | \n Arctic Ocean Islands | \n 1145.443069 | \n 1492.093804 | \n 1341.364639 | \n 1283.306010 | \n 1309.683258 | \n 1554.225743 | \n 1292.289969 | \n 1327.371862 | \n ... | \n 1356.734930 | \n 1283.146873 | \n 1105.302948 | \n 1025.685607 | \n 1411.992644 | \n 1349.929359 | \n 1209.309484 | \n 1215.290811 | \n 1328.376808 | \n 1260.970057 | \n
\n \n 1 | \n 2 | \n Northwest Territories | \n 469.631837 | \n 447.138534 | \n 493.543565 | \n 482.018603 | \n 491.983189 | \n 498.414040 | \n 530.325685 | \n 504.877059 | \n ... | \n 587.163087 | \n 582.698290 | \n 606.134769 | \n 671.532510 | \n 663.248651 | \n 651.753698 | \n 646.523186 | \n 650.577042 | \n 659.182835 | \n 678.125821 | \n
\n \n 2 | \n 3 | \n Siberia North Coast | \n 223.945993 | \n 187.136077 | \n 229.684111 | \n 224.855858 | \n 201.784275 | \n 194.420405 | \n 187.759836 | \n 166.803275 | \n ... | \n 211.759195 | \n 212.053449 | \n 186.432140 | \n 220.133729 | \n 195.835677 | \n 187.776636 | \n 178.747630 | \n 227.802098 | \n 187.472609 | \n 182.356354 | \n
\n \n 3 | \n 4 | \n Siberia West Coast | \n 573.950826 | \n 687.219762 | \n 671.607608 | \n 583.058739 | \n 608.450929 | \n 589.507306 | \n 679.343756 | \n 688.283673 | \n ... | \n 606.992752 | \n 564.961654 | \n 660.606833 | \n 634.878320 | \n 773.765837 | \n 692.618981 | \n 661.542572 | \n 677.126880 | \n 680.739008 | \n 673.986572 | \n
\n \n 4 | \n 5 | \n Kara Sea Coast | \n 207.648901 | \n 186.920652 | \n 188.909038 | \n 164.723636 | \n 209.486800 | \n 165.103240 | \n 178.278467 | \n 210.304230 | \n ... | \n 222.135195 | \n 211.970378 | \n 177.499458 | \n 224.490936 | \n 196.564751 | \n 198.169245 | \n 215.550297 | \n 212.244437 | \n 184.431571 | \n 222.321162 | \n
\n \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n ... | \n
\n \n 230 | \n 231 | \n Rio Grande River Basin | \n 44.405257 | \n 44.556657 | \n 53.256264 | \n 51.244645 | \n 43.600788 | \n 50.194872 | \n 35.516325 | \n 56.910455 | \n ... | \n 55.004094 | \n 40.182020 | \n 31.831690 | \n 33.789996 | \n 35.450004 | \n 46.154355 | \n 37.325743 | \n 34.568666 | \n 31.458995 | \n 31.634092 | \n
\n \n 231 | \n 232 | \n New England Basin | \n 197.621204 | \n 230.945894 | \n 228.404529 | \n 212.221180 | \n 219.280223 | \n 226.989342 | \n 233.455606 | \n 207.845080 | \n ... | \n 206.401141 | \n 217.257088 | \n 215.243915 | \n 208.941643 | \n 237.527955 | \n 207.858317 | \n 220.956140 | \n 218.375845 | \n 219.229009 | \n 188.477995 | \n
\n \n 232 | \n 233 | \n Mid Atlantic Basin | \n 94.360120 | \n 121.093517 | \n 100.414981 | \n 92.973803 | \n 115.326554 | \n 97.045582 | \n 103.381721 | \n 105.590279 | \n ... | \n 106.948161 | \n 118.389437 | \n 120.473958 | \n 104.168004 | \n 146.788234 | \n 109.409213 | \n 126.943563 | \n 109.572289 | \n 121.343027 | \n 104.509961 | \n
\n \n 233 | \n 234 | \n Hawaii | \n 90.403138 | \n 77.594370 | \n 66.516706 | \n 93.649276 | \n 86.486023 | \n 78.496287 | \n 69.912493 | \n 84.934176 | \n ... | \n 71.548693 | \n 60.613099 | \n 96.407296 | \n 60.833836 | \n 66.526985 | \n 84.758768 | \n 35.183624 | \n 65.133219 | \n 60.502970 | \n 53.162302 | \n
\n \n 234 | \n 235 | \n Narmada | \n 61.144840 | \n 45.171273 | \n 92.011860 | \n 44.935243 | \n 64.526522 | \n 59.572589 | \n 66.228176 | \n 64.804183 | \n ... | \n 35.549612 | \n 48.900342 | \n 74.924598 | \n 47.474215 | \n 44.530489 | \n 53.208262 | \n 53.958317 | \n 61.340541 | \n 34.424744 | \n 39.168144 | \n
\n \n
\n
235 rows × 33 columns
\n
"
+ },
+ "execution_count": 14,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
"source": [
"# runoff at basin scale (235 basins)\n",
"print('The output is in the unit of', config.OutputUnitStr)\n",
@@ -1644,13 +1772,40 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 15,
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:35.294164800Z",
+ "start_time": "2024-07-23T19:50:35.148561800Z"
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "ename": "OSError",
+ "evalue": "'seaborn-white' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)",
+ "output_type": "error",
+ "traceback": [
+ "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
+ "\u001B[1;31mFileNotFoundError\u001B[0m Traceback (most recent call last)",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\style\\core.py:137\u001B[0m, in \u001B[0;36muse\u001B[1;34m(style)\u001B[0m\n\u001B[0;32m 136\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 137\u001B[0m style \u001B[38;5;241m=\u001B[39m _rc_params_in_file(style)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mOSError\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m err:\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\__init__.py:866\u001B[0m, in \u001B[0;36m_rc_params_in_file\u001B[1;34m(fname, transform, fail_on_error)\u001B[0m\n\u001B[0;32m 865\u001B[0m rc_temp \u001B[38;5;241m=\u001B[39m {}\n\u001B[1;32m--> 866\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m _open_file_or_url(fname) \u001B[38;5;28;01mas\u001B[39;00m fd:\n\u001B[0;32m 867\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\contextlib.py:137\u001B[0m, in \u001B[0;36m_GeneratorContextManager.__enter__\u001B[1;34m(self)\u001B[0m\n\u001B[0;32m 136\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 137\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mnext\u001B[39m(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mgen)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mStopIteration\u001B[39;00m:\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\__init__.py:843\u001B[0m, in \u001B[0;36m_open_file_or_url\u001B[1;34m(fname)\u001B[0m\n\u001B[0;32m 842\u001B[0m fname \u001B[38;5;241m=\u001B[39m os\u001B[38;5;241m.\u001B[39mpath\u001B[38;5;241m.\u001B[39mexpanduser(fname)\n\u001B[1;32m--> 843\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[38;5;28mopen\u001B[39m(fname, encoding\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mutf-8\u001B[39m\u001B[38;5;124m'\u001B[39m) \u001B[38;5;28;01mas\u001B[39;00m f:\n\u001B[0;32m 844\u001B[0m \u001B[38;5;28;01myield\u001B[39;00m f\n",
+ "\u001B[1;31mFileNotFoundError\u001B[0m: [Errno 2] No such file or directory: 'seaborn-white'",
+ "\nThe above exception was the direct cause of the following exception:\n",
+ "\u001B[1;31mOSError\u001B[0m Traceback (most recent call last)",
+ "Cell \u001B[1;32mIn[15], line 7\u001B[0m\n\u001B[0;32m 1\u001B[0m \u001B[38;5;66;03m# Compare time series of simulation and observation for an individual basin\u001B[39;00m\n\u001B[0;32m 2\u001B[0m df_plot \u001B[38;5;241m=\u001B[39m format_data(sim\u001B[38;5;241m=\u001B[39mrunoff_basin,\n\u001B[0;32m 3\u001B[0m obs\u001B[38;5;241m=\u001B[39mrunoff_obs,\n\u001B[0;32m 4\u001B[0m \u001B[38;5;28mid\u001B[39m\u001B[38;5;241m=\u001B[39m[\u001B[38;5;241m217\u001B[39m],\n\u001B[0;32m 5\u001B[0m from_yr\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m1972\u001B[39m,\n\u001B[0;32m 6\u001B[0m through_yr\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m2001\u001B[39m)\n\u001B[1;32m----> 7\u001B[0m plot_comparison(df_plot\u001B[38;5;241m=\u001B[39mdf_plot,\n\u001B[0;32m 8\u001B[0m y_label\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mAnnual Runoff ($km^3$/year)\u001B[39m\u001B[38;5;124m'\u001B[39m)\n",
+ "Cell \u001B[1;32mIn[9], line 174\u001B[0m, in \u001B[0;36mplot_comparison\u001B[1;34m(df_plot, y_label)\u001B[0m\n\u001B[0;32m 171\u001B[0m title \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mstr\u001B[39m(df_plot[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mbasin_id\u001B[39m\u001B[38;5;124m'\u001B[39m]\u001B[38;5;241m.\u001B[39munique()[\u001B[38;5;241m0\u001B[39m]) \u001B[38;5;241m+\u001B[39m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m - \u001B[39m\u001B[38;5;124m'\u001B[39m \u001B[38;5;241m+\u001B[39m df_plot[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mbasin_name\u001B[39m\u001B[38;5;124m'\u001B[39m]\u001B[38;5;241m.\u001B[39munique()[\u001B[38;5;241m0\u001B[39m]\n\u001B[0;32m 173\u001B[0m \u001B[38;5;66;03m# Plot\u001B[39;00m\n\u001B[1;32m--> 174\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m plt\u001B[38;5;241m.\u001B[39mstyle\u001B[38;5;241m.\u001B[39mcontext(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mseaborn-white\u001B[39m\u001B[38;5;124m\"\u001B[39m):\n\u001B[0;32m 175\u001B[0m fig, ax \u001B[38;5;241m=\u001B[39m plt\u001B[38;5;241m.\u001B[39msubplots(figsize\u001B[38;5;241m=\u001B[39m(\u001B[38;5;241m10\u001B[39m, \u001B[38;5;241m6\u001B[39m), constrained_layout\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mFalse\u001B[39;00m)\n\u001B[0;32m 176\u001B[0m df_plot\u001B[38;5;241m.\u001B[39mplot(x \u001B[38;5;241m=\u001B[39m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mtime\u001B[39m\u001B[38;5;124m'\u001B[39m, y\u001B[38;5;241m=\u001B[39m[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mobs\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124msim\u001B[39m\u001B[38;5;124m'\u001B[39m], kind\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mline\u001B[39m\u001B[38;5;124m'\u001B[39m, color\u001B[38;5;241m=\u001B[39m[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mblack\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mdodgerblue\u001B[39m\u001B[38;5;124m'\u001B[39m],\n\u001B[0;32m 177\u001B[0m lw\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m3\u001B[39m, legend\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m, ax\u001B[38;5;241m=\u001B[39max)\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\contextlib.py:137\u001B[0m, in \u001B[0;36m_GeneratorContextManager.__enter__\u001B[1;34m(self)\u001B[0m\n\u001B[0;32m 135\u001B[0m \u001B[38;5;28;01mdel\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39margs, \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mkwds, \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mfunc\n\u001B[0;32m 136\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 137\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mnext\u001B[39m(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mgen)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mStopIteration\u001B[39;00m:\n\u001B[0;32m 139\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mRuntimeError\u001B[39;00m(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mgenerator didn\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mt yield\u001B[39m\u001B[38;5;124m\"\u001B[39m) \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\style\\core.py:194\u001B[0m, in \u001B[0;36mcontext\u001B[1;34m(style, after_reset)\u001B[0m\n\u001B[0;32m 192\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m after_reset:\n\u001B[0;32m 193\u001B[0m mpl\u001B[38;5;241m.\u001B[39mrcdefaults()\n\u001B[1;32m--> 194\u001B[0m use(style)\n\u001B[0;32m 195\u001B[0m \u001B[38;5;28;01myield\u001B[39;00m\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\style\\core.py:139\u001B[0m, in \u001B[0;36muse\u001B[1;34m(style)\u001B[0m\n\u001B[0;32m 137\u001B[0m style \u001B[38;5;241m=\u001B[39m _rc_params_in_file(style)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mOSError\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m err:\n\u001B[1;32m--> 139\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mOSError\u001B[39;00m(\n\u001B[0;32m 140\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mstyle\u001B[38;5;132;01m!r}\u001B[39;00m\u001B[38;5;124m is not a valid package style, path of style \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 141\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mfile, URL of style file, or library style name (library \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 142\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mstyles are listed in `style.available`)\u001B[39m\u001B[38;5;124m\"\u001B[39m) \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01merr\u001B[39;00m\n\u001B[0;32m 143\u001B[0m filtered \u001B[38;5;241m=\u001B[39m {}\n\u001B[0;32m 144\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m k \u001B[38;5;129;01min\u001B[39;00m style: \u001B[38;5;66;03m# don't trigger RcParams.__getitem__('backend')\u001B[39;00m\n",
+ "\u001B[1;31mOSError\u001B[0m: 'seaborn-white' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)"
+ ]
+ }
+ ],
"source": [
"# Compare time series of simulation and observation for an individual basin\n",
"df_plot = format_data(sim=runoff_basin,\n",
@@ -1664,13 +1819,40 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 16,
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:37.148652400Z",
+ "start_time": "2024-07-23T19:50:37.006367900Z"
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "ename": "OSError",
+ "evalue": "'seaborn-white' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)",
+ "output_type": "error",
+ "traceback": [
+ "\u001B[1;31m---------------------------------------------------------------------------\u001B[0m",
+ "\u001B[1;31mFileNotFoundError\u001B[0m Traceback (most recent call last)",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\style\\core.py:137\u001B[0m, in \u001B[0;36muse\u001B[1;34m(style)\u001B[0m\n\u001B[0;32m 136\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 137\u001B[0m style \u001B[38;5;241m=\u001B[39m _rc_params_in_file(style)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mOSError\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m err:\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\__init__.py:866\u001B[0m, in \u001B[0;36m_rc_params_in_file\u001B[1;34m(fname, transform, fail_on_error)\u001B[0m\n\u001B[0;32m 865\u001B[0m rc_temp \u001B[38;5;241m=\u001B[39m {}\n\u001B[1;32m--> 866\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m _open_file_or_url(fname) \u001B[38;5;28;01mas\u001B[39;00m fd:\n\u001B[0;32m 867\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\contextlib.py:137\u001B[0m, in \u001B[0;36m_GeneratorContextManager.__enter__\u001B[1;34m(self)\u001B[0m\n\u001B[0;32m 136\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 137\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mnext\u001B[39m(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mgen)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mStopIteration\u001B[39;00m:\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\__init__.py:843\u001B[0m, in \u001B[0;36m_open_file_or_url\u001B[1;34m(fname)\u001B[0m\n\u001B[0;32m 842\u001B[0m fname \u001B[38;5;241m=\u001B[39m os\u001B[38;5;241m.\u001B[39mpath\u001B[38;5;241m.\u001B[39mexpanduser(fname)\n\u001B[1;32m--> 843\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m \u001B[38;5;28mopen\u001B[39m(fname, encoding\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mutf-8\u001B[39m\u001B[38;5;124m'\u001B[39m) \u001B[38;5;28;01mas\u001B[39;00m f:\n\u001B[0;32m 844\u001B[0m \u001B[38;5;28;01myield\u001B[39;00m f\n",
+ "\u001B[1;31mFileNotFoundError\u001B[0m: [Errno 2] No such file or directory: 'seaborn-white'",
+ "\nThe above exception was the direct cause of the following exception:\n",
+ "\u001B[1;31mOSError\u001B[0m Traceback (most recent call last)",
+ "Cell \u001B[1;32mIn[16], line 7\u001B[0m\n\u001B[0;32m 1\u001B[0m \u001B[38;5;66;03m# Compare time series of simulation and observation for all basins together\u001B[39;00m\n\u001B[0;32m 2\u001B[0m df_plot \u001B[38;5;241m=\u001B[39m format_data(sim\u001B[38;5;241m=\u001B[39mrunoff_basin,\n\u001B[0;32m 3\u001B[0m obs\u001B[38;5;241m=\u001B[39mrunoff_obs,\n\u001B[0;32m 4\u001B[0m \u001B[38;5;28mid\u001B[39m\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mglobal\u001B[39m\u001B[38;5;124m'\u001B[39m,\n\u001B[0;32m 5\u001B[0m from_yr\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m1972\u001B[39m,\n\u001B[0;32m 6\u001B[0m through_yr\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m2001\u001B[39m)\n\u001B[1;32m----> 7\u001B[0m plot_comparison(df_plot\u001B[38;5;241m=\u001B[39mdf_plot,\n\u001B[0;32m 8\u001B[0m y_label\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mAnnual Runoff ($km^3$/year)\u001B[39m\u001B[38;5;124m'\u001B[39m)\n",
+ "Cell \u001B[1;32mIn[9], line 174\u001B[0m, in \u001B[0;36mplot_comparison\u001B[1;34m(df_plot, y_label)\u001B[0m\n\u001B[0;32m 171\u001B[0m title \u001B[38;5;241m=\u001B[39m \u001B[38;5;28mstr\u001B[39m(df_plot[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mbasin_id\u001B[39m\u001B[38;5;124m'\u001B[39m]\u001B[38;5;241m.\u001B[39munique()[\u001B[38;5;241m0\u001B[39m]) \u001B[38;5;241m+\u001B[39m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124m - \u001B[39m\u001B[38;5;124m'\u001B[39m \u001B[38;5;241m+\u001B[39m df_plot[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mbasin_name\u001B[39m\u001B[38;5;124m'\u001B[39m]\u001B[38;5;241m.\u001B[39munique()[\u001B[38;5;241m0\u001B[39m]\n\u001B[0;32m 173\u001B[0m \u001B[38;5;66;03m# Plot\u001B[39;00m\n\u001B[1;32m--> 174\u001B[0m \u001B[38;5;28;01mwith\u001B[39;00m plt\u001B[38;5;241m.\u001B[39mstyle\u001B[38;5;241m.\u001B[39mcontext(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mseaborn-white\u001B[39m\u001B[38;5;124m\"\u001B[39m):\n\u001B[0;32m 175\u001B[0m fig, ax \u001B[38;5;241m=\u001B[39m plt\u001B[38;5;241m.\u001B[39msubplots(figsize\u001B[38;5;241m=\u001B[39m(\u001B[38;5;241m10\u001B[39m, \u001B[38;5;241m6\u001B[39m), constrained_layout\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mFalse\u001B[39;00m)\n\u001B[0;32m 176\u001B[0m df_plot\u001B[38;5;241m.\u001B[39mplot(x \u001B[38;5;241m=\u001B[39m \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mtime\u001B[39m\u001B[38;5;124m'\u001B[39m, y\u001B[38;5;241m=\u001B[39m[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mobs\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124msim\u001B[39m\u001B[38;5;124m'\u001B[39m], kind\u001B[38;5;241m=\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mline\u001B[39m\u001B[38;5;124m'\u001B[39m, color\u001B[38;5;241m=\u001B[39m[\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mblack\u001B[39m\u001B[38;5;124m'\u001B[39m, \u001B[38;5;124m'\u001B[39m\u001B[38;5;124mdodgerblue\u001B[39m\u001B[38;5;124m'\u001B[39m],\n\u001B[0;32m 177\u001B[0m lw\u001B[38;5;241m=\u001B[39m\u001B[38;5;241m3\u001B[39m, legend\u001B[38;5;241m=\u001B[39m\u001B[38;5;28;01mTrue\u001B[39;00m, ax\u001B[38;5;241m=\u001B[39max)\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\contextlib.py:137\u001B[0m, in \u001B[0;36m_GeneratorContextManager.__enter__\u001B[1;34m(self)\u001B[0m\n\u001B[0;32m 135\u001B[0m \u001B[38;5;28;01mdel\u001B[39;00m \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39margs, \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mkwds, \u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mfunc\n\u001B[0;32m 136\u001B[0m \u001B[38;5;28;01mtry\u001B[39;00m:\n\u001B[1;32m--> 137\u001B[0m \u001B[38;5;28;01mreturn\u001B[39;00m \u001B[38;5;28mnext\u001B[39m(\u001B[38;5;28mself\u001B[39m\u001B[38;5;241m.\u001B[39mgen)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mStopIteration\u001B[39;00m:\n\u001B[0;32m 139\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mRuntimeError\u001B[39;00m(\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mgenerator didn\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mt yield\u001B[39m\u001B[38;5;124m\"\u001B[39m) \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;28;01mNone\u001B[39;00m\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\style\\core.py:194\u001B[0m, in \u001B[0;36mcontext\u001B[1;34m(style, after_reset)\u001B[0m\n\u001B[0;32m 192\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m after_reset:\n\u001B[0;32m 193\u001B[0m mpl\u001B[38;5;241m.\u001B[39mrcdefaults()\n\u001B[1;32m--> 194\u001B[0m use(style)\n\u001B[0;32m 195\u001B[0m \u001B[38;5;28;01myield\u001B[39;00m\n",
+ "File \u001B[1;32m~\\AppData\\Local\\miniconda3\\envs\\xanthos\\Lib\\site-packages\\matplotlib\\style\\core.py:139\u001B[0m, in \u001B[0;36muse\u001B[1;34m(style)\u001B[0m\n\u001B[0;32m 137\u001B[0m style \u001B[38;5;241m=\u001B[39m _rc_params_in_file(style)\n\u001B[0;32m 138\u001B[0m \u001B[38;5;28;01mexcept\u001B[39;00m \u001B[38;5;167;01mOSError\u001B[39;00m \u001B[38;5;28;01mas\u001B[39;00m err:\n\u001B[1;32m--> 139\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m \u001B[38;5;167;01mOSError\u001B[39;00m(\n\u001B[0;32m 140\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;132;01m{\u001B[39;00mstyle\u001B[38;5;132;01m!r}\u001B[39;00m\u001B[38;5;124m is not a valid package style, path of style \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 141\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mfile, URL of style file, or library style name (library \u001B[39m\u001B[38;5;124m\"\u001B[39m\n\u001B[0;32m 142\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m\"\u001B[39m\u001B[38;5;124mstyles are listed in `style.available`)\u001B[39m\u001B[38;5;124m\"\u001B[39m) \u001B[38;5;28;01mfrom\u001B[39;00m \u001B[38;5;21;01merr\u001B[39;00m\n\u001B[0;32m 143\u001B[0m filtered \u001B[38;5;241m=\u001B[39m {}\n\u001B[0;32m 144\u001B[0m \u001B[38;5;28;01mfor\u001B[39;00m k \u001B[38;5;129;01min\u001B[39;00m style: \u001B[38;5;66;03m# don't trigger RcParams.__getitem__('backend')\u001B[39;00m\n",
+ "\u001B[1;31mOSError\u001B[0m: 'seaborn-white' is not a valid package style, path of style file, URL of style file, or library style name (library styles are listed in `style.available`)"
+ ]
+ }
+ ],
"source": [
"# Compare time series of simulation and observation for all basins together\n",
"df_plot = format_data(sim=runoff_basin,\n",
@@ -1684,13 +1866,26 @@
},
{
"cell_type": "code",
- "execution_count": null,
+ "execution_count": 17,
"metadata": {
"pycharm": {
"name": "#%%\n"
+ },
+ "ExecuteTime": {
+ "end_time": "2024-07-23T19:50:40.732496600Z",
+ "start_time": "2024-07-23T19:50:38.064521500Z"
}
},
- "outputs": [],
+ "outputs": [
+ {
+ "data": {
+ "text/plain": "