Skip to content
Snippets Groups Projects
create_daily_snow.ipynb 3.45 MiB
Newer Older
{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "e3a39119",
   "metadata": {},
   "source": [
    "### CREATE DAILY INPUT FOR THE ML MODEL"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d36f5f34",
   "metadata": {},
   "source": [
    "Input:\n",
    "- the measured runoff at the gauging station,\n",
    "- the catchment area of the gauging station,\n",
    "- the ERA5 datasets for Potential Evapotranspiration, Temperature and Precipitation.\n",
    "\n",
    "Output:\n",
    "    - a .csv file is saved in conda/daily_input folder."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "889e3048",
   "metadata": {},
   "outputs": [],
   "source": [
    "from create_daily_csv import interpolate_df,readnetcdf_in_shp,xarray2df,check_data_gap,readnetcdf_in_shp_db,get_discharge_from_DB\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import os\n",
    "import xarray as xr"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "7d68f919",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<module 'create_daily_csv' from 'C:\\\\Users\\\\mmazzolini\\\\OneDrive - Scientific Network South Tyrol\\\\Documents\\\\conda\\\\Runoff_prediction\\\\create_daily_csv.py'>"
      ]
     },
     "execution_count": 21,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import sys, importlib\n",
    "importlib.reload(sys.modules['create_daily_csv'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "3049b409",
   "metadata": {},
   "outputs": [],
   "source": [
    "STAT_CODE = 'ADO_DSC_FRK2_0041'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "id": "409b5677",
   "metadata": {},
   "outputs": [],
   "source": [
    "runoff=get_discharge_from_DB(STAT_CODE)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 79,
   "id": "2f981ca5",
   "metadata": {},
   "outputs": [
    {
     "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>Q</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>date</th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1910-01-01</th>\n",
       "      <td>24.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1910-01-02</th>\n",
       "      <td>22.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1910-01-03</th>\n",
       "      <td>21.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1910-01-04</th>\n",
       "      <td>18.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1910-01-05</th>\n",
       "      <td>16.6</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-27</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-28</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-29</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-30</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2021-12-31</th>\n",
       "      <td>NaN</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>40908 rows × 1 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "               Q\n",
       "date            \n",
       "1910-01-01  24.4\n",
       "1910-01-02  22.6\n",
       "1910-01-03  21.0\n",
       "1910-01-04  18.6\n",
       "1910-01-05  16.6\n",
       "...          ...\n",
       "2021-12-27   NaN\n",
       "2021-12-28   NaN\n",
       "2021-12-29   NaN\n",
       "2021-12-30   NaN\n",
       "2021-12-31   NaN\n",
       "\n",
       "[40908 rows x 1 columns]"
      ]
     },
     "execution_count": 79,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "runoff"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c5bbf842",
   "metadata": {
    "scrolled": false
   },
   "source": [
    "shp_catchment_path = r'C:\\Users\\mmazzolini\\OneDrive - Scientific Network South Tyrol\\Documents\\qgis\\final_delineation'\n",
    "shp_catchment_fileName =shp_catchment_path + r'\\DONAU_Korneuburg.shp'"
Loading
Loading full blame...