Skip to content
forked from wentac4/RAPID_py

This is the python version river routing simulation based on RAPID model (Parallel computatIon of Discharge)

Notifications You must be signed in to change notification settings

yyyu-syf/RAPID_py

 
 

Repository files navigation

Original README

Getting Started

Prerequisites

As in the original instructions, ensure you have Conda installed on your system to manage the environment and dependencies.

Installation

Before beginning, navigate to the repository's requirements.txt file. The package versions listed here weren't all compatible for me, so I had to alter them slightly; what worked for me was to modify the matplotlib-base version to 3.6.2.

Then, as in the original instructions:

  1. Create a Conda environment:

    conda create --name <env_name>
    conda activate <env_name>
  2. Install the required libraries:

    Navigate to the repository's root directory.

    For me, using pip install -r requirements.txt to install the required packages as per the original instructions didn't work; instead I used:

    conda install --file requirements.txt --channel conda-forge

    Alternatively, you can perform both steps 1 and 2 above at the same time using:

    From the root directory:

    conda create --name <env_name> --file requirements.txt --channel conda-forge
    conda activate <env_name>

Data Preparation

As mentioned in the original instructions, before executing any scripts, we must first prepare/obtain the data.

As the original instructions explain, the official dataset is available from Zenodo, but it is highly recommended to use the quick access data provided by the original author(s) of this repository, as it allows for (almost; more on this later) all of the files required by the scripts to be quickly downloaded all at once for immediate use:

Download this entire Google Drive folder provided by this repository's author(s), unzip the contents into a folder/directory named rapid_data, and place this folder/directory in the root directory of the repository. It's important that this folder/directory is exactly named rapid_data.

Usage

There are a few more things we must do before we can successfuly run the scripts.

  1. First, there are references in the code to a file in the dataset named m3_d_riv.csv. However, no such file exists, neither in the quick access data provided by the repository's author(s) nor in the official dataset on Zenodo. Thus, to be able to execute the code, we remove / comment out all references to this file (and references to objects that reference this file) in the code:

    • In the file rapid_python.py, comment out line 111.
    • In the file utility.py, comment out lines 32, 50, 67, and 73.
  2. Ensure that in line 285 of rapid_python.py, load_mode is set to 0, so that the data load mode is set to file (=0), rather than pickle (=1) or both (=2).

  3. Finally, in line 286 of rapid_python.py, set sim_mode to either 0 or 1, to set the simulation mode to open loop (=0) or Kalman Filter estimation (=1).

Now, we can finally execute the scripts.

As per the original instructions, there is currently only one Kalman Filter implementation / modeling approach (more are being developed):

  1. Original Kalman Filter Implementation:

    • Description: Directly follows the methodology outlined in the referenced paper, with the state variable representing lateral inflows.
    • Execution: Run python rapid_python.py to perform the simulation.

The output generated by the execution of this rapid_python.py script will be located in a new directory in the root directory, named model_saved_3hour. Note: one of the files generated is load_coef.pkl, which, if we like, we can use to run rapid_python.py with load_mode set to 1 (pickle) or 2 (both file and pickle)!

Visualizing River Networks

After completing the execution of rapid_python.py above, to be able to plot the geographical river network, create a directory named model_saved in the root directory, and place the file discharge_est.csv (located in the model_saved_3hour directory generated by the execution of rapid_python.py) into this model_saved directory.

Now, as per the original instructions, to plot the geographical river network, use the following command:

python visualize_with_shp.py

The output of the execution of this visualize_with_shp.py script will be in the model_saved directory.

Finally, if you'd like to (graphically) plot the changes in river flow, as per the original instructions, use this command to visualize the estimation discharge_est.csv:

python evaluate_open_loop.py

The output of the execution of this evaluate_open_loop.py script will be in a new directory in the root directory, named figure.

About

This is the python version river routing simulation based on RAPID model (Parallel computatIon of Discharge)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 96.6%
  • R 3.4%