Skip to main content

A comprehensive Python toolkit for baseflow separation

Project description

baseflowx

A comprehensive Python toolkit for baseflow separation from streamflow hydrographs.

baseflowx implements 17 baseflow separation methods spanning four paradigms: recursive digital filters, graphical/interval methods, recession-based methods, and tracer-based methods. It also provides parameter estimation, USGS data retrieval, and a CMB-to-Eckhardt calibration bridge.

This project builds on the baseflow package by Xie et al. (2020), which implemented methods described in "Evaluation of typical methods for baseflow separation in the contiguous United States" (Journal of Hydrology, 583, 124628). baseflowx extends that work with new methods (PART, CMB, BFlow, IHACRES), a unified filter architecture, modern packaging, and USGS data integration.

This project is funded by CIROH.

Install

pip install baseflowx

Quick Start

import baseflowx

# Load bundled sample data (USGS 01013500, Fish River, Maine)
data = baseflowx.load_sample_data()
Q = data['Q']

# Run a single method
b = baseflowx.eckhardt(Q, a=0.98, BFImax=0.8)

# Or fetch your own data from USGS NWIS
from baseflowx.io import fetch_usgs
data = fetch_usgs('01013500', '2019-01-01', '2020-12-31')

Methods

Recursive Digital Filters

All recursive digital filters share a generalized core: b[t] = alpha * b[t-1] + beta * (Q[t] + gamma * Q[t-1])

gamma=0 family (linear reservoir based):

Method Function Reference
Boughton boughton(Q, a, C) Boughton, 1993
Chapman-Maxwell chapman_maxwell(Q, a) Chapman & Maxwell, 1996
Eckhardt eckhardt(Q, a, BFImax) Eckhardt, 2005
EWMA ewma(Q, e) Tularam & Ilahee, 2008
Furey-Gupta furey(Q, a, A) Furey & Gupta, 2001
WHAT what(Q, BFImax, a) Lim et al., 2005 (alias for Eckhardt)

gamma=1 family (signal processing based):

Method Function Reference
Lyne-Hollick lh(Q) / lh_multi(Q, num_pass=3) Lyne & Hollick, 1979; Nathan & McMahon, 1990
Chapman chapman(Q, a) Chapman, 1991
Willems willems(Q, a, w) Willems, 2009

Variable gamma (hybrid):

Method Function Reference
IHACRES ihacres(Q, a, C, alpha_s) Jakeman & Hornberger, 1993

Graphical / Recession-Based Methods

Method Function Reference
UKIH ukih(Q, b_LH) UKIH, 1980
Local minimum local(Q, b_LH, area) Sloto & Crouse, 1996
Fixed interval fixed(Q, area) Sloto & Crouse, 1996
Sliding interval slide(Q, area) Sloto & Crouse, 1996
PART part(Q, area) Rutledge, 1998

Tracer-Based Methods

Method Function Reference
Conductivity Mass Balance cmb(Q, SC) Stewart et al., 2007

Recession Analysis

Function Description
bflow(Q) BFlow 3-pass filter + recession analysis (Arnold & Allen, 1999)
bn77(Q, ...) Brutsaert-Nieber drought flow identification (Cheng et al., 2016)

Parameter Estimation

import baseflowx

data = baseflowx.load_sample_data()
Q = data['Q']

# Estimate recession coefficient from the hydrograph
strict = baseflowx.strict_baseflow(Q)
a = baseflowx.recession_coefficient(Q, strict)

# Use the estimated recession coefficient with any filter
b = baseflowx.eckhardt(Q, a, BFImax=0.8)
b = baseflowx.chapman_maxwell(Q, a)
b = baseflowx.willems(Q, a, w=0.5)

CMB Calibration Bridge

Use specific conductance data to calibrate Eckhardt's BFImax:

from baseflowx.tracer import calibrate_eckhardt_from_cmb

cal = calibrate_eckhardt_from_cmb(Q, SC)
b = baseflowx.eckhardt(Q, cal['a'], cal['BFImax'])

BFlow / SWAT Integration

result = baseflowx.bflow(Q)
print(f"ALPHA_BF = {result['alpha_factor']:.4f}")  # for SWAT calibration
print(f"BFI = {result['BFI']:.3f}")
print(f"Baseflow days = {result['baseflow_days']:.1f}")

USGS Data Retrieval

from baseflowx.io import fetch_usgs

# Fetch daily discharge
data = fetch_usgs('01013500', '2015-01-01', '2020-12-31')
Q = data['values']

# Fetch specific conductance (for CMB)
sc_data = fetch_usgs('01013500', '2015-01-01', '2020-12-31', parameter='sc')

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

baseflowx-0.2.1.tar.gz (24.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

baseflowx-0.2.1-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file baseflowx-0.2.1.tar.gz.

File metadata

  • Download URL: baseflowx-0.2.1.tar.gz
  • Upload date:
  • Size: 24.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for baseflowx-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7940a04b3ec7fc8da4d5ddc5fbe39790a3ed1dfe34d0c4538a24c433156130cd
MD5 c3ebd86a529ea02a53057898c54551b5
BLAKE2b-256 8a45adf5c321abe35aaa4b9571c48bb0645bf04aabbf56077ccec0e852539d48

See more details on using hashes here.

File details

Details for the file baseflowx-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: baseflowx-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.12

File hashes

Hashes for baseflowx-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26f84ee692d7fda95eb7b6603b330b29ec8b4410225f529ed0ada87c45a49676
MD5 f47a1a39f8c633925250960f7b0198ab
BLAKE2b-256 a736a4b3ded38361fba1163a57d666c377d43e958f9c2a78d8db2a80f3316888

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page