Skip to main content

A transcription of the usgs r package wrtds to python

Project description

wrtds-py

A Python implementation of WRTDS (Weighted Regressions on Time, Discharge, and Season), the USGS method for estimating long-term trends in river water quality.

build codecov PyPI version


Documentation: https://mullenkamp.github.io/wrtds-py/

Source Code: https://github.com/mullenkamp/wrtds-py


Overview

This package is a Python transcription of the USGS R package EGRET. It uses pandas DataFrames as the base data structure with scipy for optimization and interpolation and matplotlib for plotting.

Key features:

  • Weighted censored regression — locally weighted MLE with tricube kernels on time, discharge, and season
  • Flow normalization — isolate water-quality trends from discharge variability
  • WRTDS-K — AR(1) residual interpolation for improved daily estimates
  • Trend analysis — pairwise, group, and time-series decomposition (CQTC/QTC)
  • Bootstrap confidence intervals — block resampling with bias correction
  • Plotting — data overview, annual histories, contour surfaces, and diagnostics

Installation

pip install wrtds

Requires Python >= 3.10.

Quick Example

import pandas as pd
from wrtds import WRTDS

daily = pd.read_csv('daily.csv', parse_dates=['Date'])
sample = pd.read_csv('sample.csv', parse_dates=['Date'])

w = WRTDS(daily, sample, info={'station_name': 'Choptank River'})
w.fit()
w.kalman()

print(w.table_results())
print(w.run_pairs(year1=1985, year2=2010))
w.plot_conc_hist()

See the Quickstart for a full walkthrough.

Development

We use uv to manage the development environment.

uv sync            # install dependencies
uv run pytest      # run tests

License

This project is licensed under the terms of the Apache Software License 2.0.

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

wrtds-0.1.0.tar.gz (30.3 kB view details)

Uploaded Source

Built Distribution

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

wrtds-0.1.0-py3-none-any.whl (37.2 kB view details)

Uploaded Python 3

File details

Details for the file wrtds-0.1.0.tar.gz.

File metadata

  • Download URL: wrtds-0.1.0.tar.gz
  • Upload date:
  • Size: 30.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.7

File hashes

Hashes for wrtds-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9976b67a387c1882eb8a48a6de150d6b502949c7fc419d6efa596e1af5c71d61
MD5 bb9942e915dc89e86bbadf7122d1e5b3
BLAKE2b-256 bfef4ff59009254951448def2b065e99eda9c483d3bc375349a27011186e0c03

See more details on using hashes here.

File details

Details for the file wrtds-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wrtds-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 37.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.7

File hashes

Hashes for wrtds-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4454d61afc04e95b6f2498f45d4fe92c2d12d3a6ac26da5ff880bd5caab2437f
MD5 84d4580b3bde2d24dcf0a1e8e9939bb0
BLAKE2b-256 2b9ad5d1b5473ffe956a1fe934895d120c81af5aab62ef11cf7835892c6ad4e7

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