corehydro

corehydro is an (unofficial) C++ port of tools developed by the United States Army Corps of Engineers (USACE) Risk Management Center (RMC) for stochastic and computational hydrology including distribution fitting and sampling, timeseries modeling, uncertainty quantification, optimization, machine learning, flood and precip frequency estimation, and a whole lot more.

The motivation behind this porting effort is to increase awareness and accessibility of these amazing software packages which have been released under open-source licenses. Two libraries are in scope, and both are ported: - Numerics (everything portable; file I/O and gauge download are not) - RMC-BestFit (the statistical engine; the desktop application is not)

See the porting status page for the details of what is currently implemented in the core library and in the packages.

What’s inside

  • All 43 univariate distributions of the Numerics library, with moments, density/quantile functions, seeded random generation, and MOM / MLE / L-moment fitting.
  • Bayesian estimation with eight MCMC samplers (RWMH, ARWMH, DEMCz, DEMCzs, HMC, NUTS, Gibbs, SNIS) plus Gelman-Rubin and effective-sample-size diagnostics.
  • The full RMC-BestFit analysis layer: Bayesian frequency analysis, Bulletin 17C, distribution ranking, mixtures, competing risks, point processes, time series, spatial GEV, copulas, rating curves, and predictive checks.
  • Multivariate distributions, copulas, bootstrap uncertainty, and the supporting statistics toolbox (Grubbs-Beck outlier tests, hypothesis tests, Box-Cox and Yeo-Johnson transforms, plotting positions, Latin hypercube sampling).
  • The Numerics time series container: moving windows, missing-value handling, block series and peaks over threshold, seasonal decomposition, and seeded resampling, with dates as POSIXct in R and datetime64 in Python.
  • Fourteen optimizers over an objective you write, ten quadrature rules, root finding, and the eight machine learning methods (k-means, Gaussian mixtures, Jenks breaks, decision trees, random forests, kNN, naive Bayes, GLM).

Install

Both packages are pre-release and install directly from GitHub. They compile the shared core from source, so a C++17 compiler is required (Xcode command-line tools on macOS, gcc/clang on Linux, Rtools on Windows for R).

pip install "git+https://github.com/cameronbracken/corehydro.git#subdirectory=corehydropy"
import corehydropy as ch

d = ch.Distribution("GeneralizedExtremeValue", [10849, 5745, 0.005])
d.quantile(0.99)
# install.packages("pak")
pak::pak("cameronbracken/corehydro/corehydror")
library(corehydror)

d <- distribution("GeneralizedExtremeValue", c(10849, 5745, 0.005))
dist_quantile(d, 0.99)

Releases on PyPI and CRAN are planned; these instructions will switch to plain pip install / install.packages() when they land.

Learn more