sierra-pywr
Code base for modeling the central Sierra Nevada hydropower systems and implementing said models to optimize performance and make predictions of future scenarios
Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
Installation
A step by step series of examples that tell you how to get a development env running
Linux:
Get your environment set up, depending on your Operating System, as well as IDE, install Pywr
$ sudo apt-get install libgmp3-dev libglpk-dev glpk
- If you choose to use Anaconda environment for OS X or Linux and remove the installation file:
$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ bash Miniconda3-latest-Linux-x86_64.sh
$ source ~/.bashrc
$ rm Miniconda3-latest-Linux-x86_64.sh
- Check the version of Conda you have installed
$ conda --version
$ conda update conda
- Create and activate new environment
$ conda create --name *environment_name*
$ conda activate *environment_name*
- Add channels and install packages
$ conda config --add channels conda-forge
$ conda config --add channels pywr
$ conda install pywr
- Once on the repository, install the requirements
$ pip install -r requirements.txt
Windows
You can use either Anaconda or Python PIP. As follows:
Anaconda
- Install Anaconda Environment here and check what version
conda --version
conda update conda
- Create and activate new environment
conda create --name *environment_name*
conda activate *environment_name*
- Add channels and install packages
conda config --add channels conda-forge
conda config --add channels pywr
conda install pywr
Python PIP
- Install GLPK and add it to your environment path.
Download v4.65 from: http://ftp.gnu.org/gnu/glpk/
Note that GLPK is in tarzip (.tar.gz) format, so you can use 7-zip to extract.
Save the resulting glpk-4.65 folder in a good place. Copy the full path to glpk-4.65\w64 to your environment path.
E.g.: add C:\glpk-4.65\w64
to your global (or local) path.
- Download/clone this repository
We recommend using PyCharm or Visual Studio Code for integrated VCS and IDE.
-
Download & install Python! Version 3.7, 64-bit should work.
-
Create and activate a Python environment
Note that env
is in .gitignore, so you can save the environment as "env" in sierra-pywr.
- Install Python packages
From within the Python environment, install all requirements from requirements.txt
.
e.g.: pip install -r requirements.txt
Running the Models
Running the models involves several steps, depending on the type of run.
All model runs will require three general steps.
-
Copy/sync data folder to the local computer.
-
Specify the data folder as an environment variable
SIERRA_PYWR_DATA
-
Run the model from the command line.
As a simple example, the following will run the baseline Merced model:
python main.py -b merced
Data preparation
For data preparation, see
Scenario setup
Running
conda activate *environment_name*
Flags
- "-b", "--basin"
- "-nk", "--network_key"
- "-d", "--debug"
- "-p", "--include_planning"
- "-n", "--run_name"
- "-mp", "--multiprocessing"
For only daily models (Merced & Tuolomne):
python main.py -b *network* -n "development" -d d
For both daily and monthly models
python main.py -b *network* -p -n "development" -d dm
Postprocessing
Built With
- Pywr - The main library used
- Python Flask - Dependency Management
Authors
- David Rheinheimer - rheinheimer
- Aditya Sood - asood12
- Dan Tran - GateauXD
- Lorenzo Scaturchio - gr8monk3ys
See also the list of contributors who participated in this project.