GustavoFacincani / sierra-pywr

Code base for modeling the central Sierra Nevada hydropower systems

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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
  1. 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
  1. Check the version of Conda you have installed
$ conda --version
$ conda update conda
  1. Create and activate new environment
$ conda create --name *environment_name*
$ conda activate *environment_name*
  1. Add channels and install packages
$ conda config --add channels conda-forge
$ conda config --add channels pywr
$ conda install pywr
  1. Once on the repository, install the requirements
$ pip install -r requirements.txt

Windows

You can use either Anaconda or Python PIP. As follows:

Anaconda

  1. Install Anaconda Environment here and check what version
conda --version
conda update conda
  1. Create and activate new environment
conda create --name *environment_name*
conda activate *environment_name*
  1. Add channels and install packages
conda config --add channels conda-forge
conda config --add channels pywr
conda install pywr

Python PIP

  1. 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.

  1. Download/clone this repository

We recommend using PyCharm or Visual Studio Code for integrated VCS and IDE.

  1. Download & install Python! Version 3.7, 64-bit should work.

  2. Create and activate a Python environment

Note that env is in .gitignore, so you can save the environment as "env" in sierra-pywr.

  1. 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.

  1. Copy/sync data folder to the local computer.

  2. Specify the data folder as an environment variable SIERRA_PYWR_DATA

  3. 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

Authors

See also the list of contributors who participated in this project.

About

Code base for modeling the central Sierra Nevada hydropower systems


Languages

Language:Python 65.3%Language:Jupyter Notebook 34.1%Language:R 0.4%Language:CSS 0.2%