Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

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:

  1. Following our HSP2 Installation Instructions.

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

Metadata

Release files for hsp2 0.11.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hsp2 0.11.0a1
File Size Uploaded Provenance Actions
hsp2-0.11.0a1.tar.gz 260.8 kB Without provenance Details for hsp2-0.11.0a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hsp2 0.11.0a1
File Interpreter ABI Platform Actions
hsp2-0.11.0a1-py3-none-any.whl Python 3 none any Details for hsp2-0.11.0a1-py3-none-any.whl

Total release size: 533.6 kB

Release files / hsp2-0.11.0a1.tar.gz

Download URL hsp2-0.11.0a1.tar.gz
Size 260.8 kB
Tags Source
SHA-256 checksum
How to use checksums
53b53f623f0e6c96bb9dbcb23d85377fd39486c9889eac7ecd6d3227cd063a74
BLAKE2b-256 checksum
How to use checksums
02c1582ff9eee14dbafa82d1ec3f0ff222b1e4bd57bb82734eb3d9f731c14b21
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.5

Release files / hsp2-0.11.0a1-py3-none-any.whl

Download URL hsp2-0.11.0a1-py3-none-any.whl
Size 272.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
99e5d8905fbd64fd7def89bec8389a7773091eef60a9f79f251350ba0dad00bf
BLAKE2b-256 checksum
How to use checksums
84034921cd985ab4e7980f2f88c4bc7c1af8d2a7a393ac411f20d423a5979e85
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.11.5

Security for hsp2 0.11.0a1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page