Skip to content

Commit

Permalink
Merge branch 'geo-smart:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
JYOSHREDDY authored Aug 26, 2024
2 parents d0bfd49 + 2014a16 commit 3e0e951
Show file tree
Hide file tree
Showing 9 changed files with 1,715 additions and 3,681 deletions.
106 changes: 89 additions & 17 deletions book/chapters/Predictions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,80 @@
"Finally, we are at the final Chapter where we see the end-product of the model created. As we venture into this critical phase, the model_predict script emerges, guiding the way toward understanding and anticipating the future of snow water equivalent (SWE) through the ExtraTree model. This chapter delves into the intricacies of this script, unraveling the processes that transforms raw, unprocessed data into precise predictions that illuminate the path forward."
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"import joblib\n",
"import pandas as pd\n",
"from sklearn.preprocessing import MinMaxScaler, StandardScaler\n",
"import numpy as np\n",
"import os\n",
"import random\n",
"import string\n",
"import shutil\n",
"\n",
"\n",
"def generate_random_string(length):\n",
" # Define the characters that can be used in the random string\n",
" characters = string.ascii_letters + string.digits # You can customize this to include other characters if needed\n",
"\n",
" # Generate a random string of the specified length\n",
" random_string = ''.join(random.choice(characters) for _ in range(length))\n",
"\n",
" return random_string\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"homedir = os.path.expanduser('~')\n",
"work_dir = f\"{homedir}/gridmet_test_run\"\n",
"\n",
"test_start_date = ''\n",
"\n",
"selected_columns = [\n",
" 'swe_value',\n",
" 'SWE',\n",
" 'cumulative_SWE',\n",
"# 'cumulative_relative_humidity_rmin',\n",
"# 'cumulative_air_temperature_tmmx', \n",
"# 'cumulative_air_temperature_tmmn',\n",
"# 'cumulative_relative_humidity_rmax',\n",
"# 'cumulative_potential_evapotranspiration',\n",
"# 'cumulative_wind_speed',\n",
" #'cumulative_fsca',\n",
" 'fsca',\n",
" 'air_temperature_tmmx', \n",
" 'air_temperature_tmmn', \n",
" 'potential_evapotranspiration', \n",
" 'relative_humidity_rmax', \n",
" 'Elevation',\t\n",
" 'Slope',\t\n",
" 'Curvature',\t\n",
" 'Aspect',\t\n",
" 'Eastness',\t\n",
" 'Northness',\n",
"]\n",
"\n",
"\n",
"def month_to_season(month):\n",
" if 3 <= month <= 5:\n",
" return 1\n",
" elif 6 <= month <= 8:\n",
" return 2\n",
" elif 9 <= month <= 11:\n",
" return 3\n",
" else:\n",
" return 4"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -43,7 +117,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 35,
"metadata": {
"id": "LkzaZTCtgJ5R"
},
Expand Down Expand Up @@ -71,7 +145,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 36,
"metadata": {
"id": "wXQ-4JBdgjdG"
},
Expand Down Expand Up @@ -125,7 +199,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 37,
"metadata": {
"id": "d7EsL7aVhltv"
},
Expand Down Expand Up @@ -157,7 +231,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 38,
"metadata": {
"id": "Uv3nAmw-h3EO"
},
Expand Down Expand Up @@ -202,7 +276,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 39,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -279,7 +353,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 40,
"metadata": {
"id": "aa_il7YriZlE"
},
Expand Down Expand Up @@ -339,6 +413,13 @@
"## 9.5 Results"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"![SWE MAP](../img/SWE_Map.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down Expand Up @@ -384,7 +465,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 42,
"metadata": {
"id": "qMeBEobUoJcW"
},
Expand Down Expand Up @@ -435,7 +516,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 43,
"metadata": {
"id": "7h9706LXVba2"
},
Expand Down Expand Up @@ -589,15 +670,6 @@
"\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "JHTfd_L9UkBt"
},
"source": [
"![SWE MAP](../img/SWE_Map.png)"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
Loading

0 comments on commit 3e0e951

Please sign in to comment.