Last updated:
0 purchases
hsp2 0.11.0a1
Hydrologic Simulation Program - Python (HSP2)
The Hydrologic Simulation Program–Python (HSP2) watershed model is is a port
of the well-established Hydrological Simulation Program - FORTRAN (HSPF),
re-coded with modern scientific Python and data formats.
HSP2 (pronouced “HSP-squared”) is being developed by an open source team
launched and led by RESPEC with internal funding. Our list of collaborators is
growing, now including LimnoTech and with additional support from the U.S. Army
Corps of Engineers (Engineer Research and Development Center (ERDC),
Environmental Laboratory), modelers at the Virginia Department of Environmental
Quality, and others.
HSP2 currently supports all HSPF hydrology and detailed water quality modules.
Support for specialty modules is currently in progress. See our Release
Notes for up-to-date details.
Read our wiki for more information on our motivation and goals for HSP2:
- Wiki Home & HSP2 Goals
- About-HSPF
- Why-HSP2?
- HSP2 Design Details
The HSPF Conversion Project slides (January 2017) and the Introduction to
HSP2 by Jason Love (RESPEC) video (December 2017) provide additional
background on the initial release.
HSPsquared is released under the GNU Affero General Public License (AGPL),
copyrighted 2017 by RESPEC.
Source Code Directories
HSP2 contains the hydrology and water quality code modules converted from
HSPF, along with the main programs to run HSP2.
HSP2tools contains supporting software modules such as the code to
convert legacy WDM and UCI files to HDF5 files for HSP2, and to provide
additional new and legacy capabilities.
HSP2IO is new in v0.10 and contains an abstracted approach to getting
data in and out of HSP2 for flexibility and performance and also to support
future automation and model coupling. - NOTE: With v0.10 the I/O abstraction
classes provide an alternate approach to running HSP2. Our plan is to migrate
solely using the I/O abstracted methods, but we will maintain both approaches
for for several more releases for backward compatibility.
docs contains relevant reference documentation.
examples contains examples of how to use HSP2, organized as interactive
Jupyter Notebook tutorials.
tests contains HSPF use cases, their input files, code to compare HSP2 vs
HSPF model outputs and code to test for performance.
Getting Started
We recommend getting started by:
Following our HSP2 Installation Instructions.
Opening our interactive JupyterLab HSP2 tutorials in the examples
sub-directory.
HSP2 Installation
We recommend Python 3.10.
Install From Pre-built Packages
Python Package Index (PyPI)
Starting with version 0.11.0a1 we provide a PyPI wheel package for HSP2 which
should work on any supported platform for Python 3.10, 3.11, and 3.12.
python -m pip install hsp2
Windows Executable
On the Releases page, we provide a Windows package in the zip file named
HSP2_Driver_MonthYear.zip. HSP2_Driver_MonthYear.zip contains an .exe for
running HSP2, enabling a user to run HSP2 without needing to do anything with
Python code or Jupyter notebooks. The driver uses a file dialog to prompt for
the name of the HDF5 file to run, or if that doesn’t exist yet you can give it
the name of a UCI or WDM file to import. It also runs with the H5 file name on
the command line.
Install From Source
Clone or Download the HSPsquared Repository
From the HSP2squared Github page, download and extract the code using one of
the options found by clicking on the green “Code” drop down button near the
upper right of the page, or by downloading one of the compressed source files
from the Releases page.
Place your copy of the HSPsquared folder in any convenient location on your
computer.
For the rest of the installation steps, let’s call this location
/path/to/module/hsp2.
Create a Python Environment
We provide two options to installing HSP2, yet recommend option 1.
Install using only one of these options.
Option 1: Install using “conda”
Follow these steps to install using the conda package manager.
1. Install the Anaconda Python Distribution
Install the latest release of the Anaconda Distribution, which includes the
conda package manager, a complete Python (and R) data science stack, and the
Anaconda Navigator GUI. Follow Anaconda Installation documentation.
A lighter-weight alternative is to install Miniconda.
2. Create a Conda Environment for HSP2 Modeling (optional)
Although HSP2 can be run from the default base environment created by
Anaconda, we recommend creating a custom environment that includes the exact
combination of software dependencies that we’ve in development and testing.
Use the following conda create command in your terminal or console:
conda create -c conda-forge -n hsp2_310 python=3.10
Install the necessary and optional packages for HSP2 in the new environment:
conda install -c conda-forge -n hsp2_310 cltoolbox numba pandas pytables
conda install -c conda-forge -n hsp2_310 h5py jupyterlab matplotlib notebook
conda activate hsp2_310
cd /path/to/module/hsp2
pip install . # or "pip install -e ." to install in editable mode
You should now be able to run the Tutorials and create your own Jupyter
Notebooks!
Option 2: Install From Source Code Using pip
Installing HSP2 using pip, the Package Installer for Python
is an alternative method to installing with conda.
1. Install Python
Instructions for downloading Python to your computer based on your operating
system can be found in this helpful wiki.
2. Create a Python Environment for HSP2 Modeling (optional)
Create a custom Python virtual environment for using HSP2, following the venv
— Creation of virtual environments package documentation to create and
activate a new environment for running HSP2.
python -m venv hsp2_env /path/to/python/virtual/environments/hsp2_env
3. PIP install HSP2
Navigate to your copy of the HSPsquared folder (for these instructions
/path/to/module/hsp2) on your computer in the command
line.
To install using pip:
source /path/to/python/virtual/environments/hsp2_env/bin/activate
cd /path/to/module/hsp2
pip install . # or "pip install -e ." to install in editable mode
4. Run PIP Installed HSP2 from the Command Line
The pip installed ‘hsp2’ command has help created from the function docstrings
in HSP2tools/HSP2_CLI.py.
Command Line Usage
Use the help to learn how to use the model and each sub-command:
hsp2 --help
hsp2 import_uci --help
hsp2 run --help
Intended workflow from the command line:
hsp2 import_uci import_test.uci new_model.h5
hsp2 run new_model.h5
API Usage
The HSP2 API is designed to be used in Python scripts and Jupyter notebooks.
from HSP2 import HSP2
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.