Skip to content

Repository files navigation

Weather Type (WT) Analysis and Streamflow Prediction

This repository contains codes and data for performing Weather Type (WT) analysis, streamflow prediction, and evaluation using Google Colab Notebooks and R scripts.

Note: The required input data files are available on Google Drive and will be pulled from the drive within the notebooks.

Rscripts_and_Data

If you prefer to work in the R environment without any interactions with the notebooks, use the R scripts and data files in Rscripts_and_Data. In this case, other data files in this repository (e.g., Input_Data) are not required.

Input_Data Folder

Contains the Hindcast and reanalysis WT data file 2.WT_combined_data.csv. Download the Input_Data content and store them in your work directory (e.g., Google Drive). This data has been created using the ECMWF and SMYLE model and will pulled from the drive, so it is optional to create it using this notebook.

Other Input Data:

  • ERA_tclw_regional.csv
  • ERA_q_regional.csv
  • ERA_tcwv_regional.csv
  • 5_combined_forecast_variables.csv: Contains pre-processed regional hindcast data from 1984 to 2023.
  • Shapefiles.zip: contains shapefiles of the AZ-West and Az-East regions.

Python in Google Colab (optional): Read_ERA5_v2_BOR.ipynb

This notebook calculates regional ERA reanalysis climate variables (q, tclw, tcwv, tprate). The data is ready to be used and will be pulled from the drive. It extract Shapefiles.zip and pulls ERA5_singleLevel_1940_2024_mon.nc and ERA5_SH_1940_2024_mon.nc from the drive within the notebook.

  • Outputs:
    • ERA_tclw_regional.csv
    • ERA_q_regional.csv
    • ERA_tcwv_regional.csv

R in Google Colab: 2.LCRB_Analog_streamflow_prediction_BOR.ipynb

This notebook uses the k-Nearest Neighbors (kNN) algorithm to identify analog years based on hydroclimate condition and streamflow data and creates metrics plots. The notebook requires:

  • ERA_tclw_regional.csv
  • ERA_q_regional.csv
  • ERA_tcwv_regional.csv
  • 2.WT_combined_data.csv
  • 5_combined_forecast_variables.csv
  • ./obs/BORInterveningFlowsData1971-2022_NFDextensionv2.xlsx It should be noted that the above data files are ready to be used and will be pulled from the drive within the notebook.

Mixed Python and R Notebook (optional): 1.AZ-NAM-Precipitation-S2S-forecast_BOR.ipynb

This notebook downloads sub-daily Q850 data and generates WTs. The R scripts at the bottom of the notebook append new WTs to 2.WT_combined_data.csv. The updated data file can be used in 2.LCRB_Analog_streamflow_prediction_BOR.ipynb to re-predict streamfloe if streamflow data is available for that period in ./obs/BORInterveningFlowsData1971-2022_NFDextensionv2.xlsx. Note: Analog prediction does not forecast streamflow beyond the target years (hindcast WTs).

Figure 1: Work directory content

If the notebook runs successfully, you will see the output files appear in the "Files" dropdown menu, as shown in the figure below. The figure displays the output files generated for the "ECMWF" model, and any files that were downloaded during running the notebook. Based on the configuration setups you may get slightly different output files.

Figure 2: Output files in drive after running the notebook successfully

Execution Guide for Google Colab Notebooks

R in Google Colab:

  • Notebook: 2.LCRB_Analog_streamflow_prediction_BOR.ipynb
    • Open the notebook in Google Colab.
    • Ensure that the notebook kernel is set to R. To do this, click on “Runtime” > “Change runtime type” > “R”.

Python in Google Colab:

  • Notebook: Read_ERA5_v2_BOR.ipynb
    • Ensure that the runtime type is set to "Python". Go to “Runtime” > “Change runtime type” > "Python 3".

Mixed Python and R Notebook:

  • Notebook: 1.AZ-NAM-Precipitation-S2S-forecast_BOR.ipynb
  • Ensure that the runtime type is set to "Python". Go to “Runtime” > “Change runtime type” > "Python 3".

Instructions for Editing Colab Notebooks

Create a Copy in Your Local Google Drive:

  1. Open the Colab notebook you want to edit.
  2. Go to "File" > "Save a copy in Drive..." to create a copy of the notebook in your personal Google Drive.
  3. You will now be working on your copy, so any changes will not affect the original notebook.

Connect to Your Google Drive:

  1. In the notebook, run the following cell to connect to your personal Google Drive.

  2. This will prompt you to authorize access to your Google Drive. Follow the instructions to grant access.

Access Your Copied Notebook:

  1. After mounting, navigate to the copied notebook in your Google Drive (usually located under My Drive).
  2. Make any necessary edits directly in the notebook.

Run and Edit as Needed:

  • Once the notebook is in your drive, you can run, edit, and save your changes.
  • Note: If you don't need to edit the notebooks, you can skip these steps and run the notebooks as they are, using the original versions.

About

Seasonal prediction of lower Colorado Basin intervening inflows during the monsoon season.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages