Background

Background#

Streamflow timeseries are widely used in hydrologic research, water resource management, and flood forecasting, but they are difficult to measure directly. In nearly all timeseries applications, streamflow is estimated from rating curves or ``ratings’’ that describe the relationship between streamflow and an easy-to-measure predictor like stage. The shape of the rating is specific to each streamgage and is governed by channel conditions at or downstream from the gage, referred to as controls. Section controls, like riffles or weirs, occur downstream of the gage, whereas channel controls, like the geometry of the banks, occur at the gage. Regardless of the type, the behavior of each control is often well-approximated with standard hydrologic equations that take the general form of a power law with a location parameter

(1)#\[\begin{equation} Q = C(h - h_0)^{b} \end{equation}\]

where $Q$ is the discharge (streamflow); $h$ is the height of the water above some datum (stage); $h_0$ is the stage of zero flow (the location or offset parameter); $(h-h_0)$ is the hydraulic head [ISO18320202020]; $b$ is the slope of the rating curve when plotted in log-log space; $C$ is a scale factor equal to the discharge when the head is equal to one; When multiple controls are present, the rating curve is divided into segments with one power-law corresponding to each control resulting in a multi-segment or compound rating.

Though several automated methods exist, most ratings are still fit by hand using a graphical method of plotting stage and discharge in log-log space. With the appropriate location parameter, each control can be fit to a straight-line segment in log space [Ken84, ISO18320202020]. Variants of this method have been used for decades, first with pencil and log paper and now with computer-aided software, though fitting is still done by manually adjusting parameters until an acceptable fit is achieved.

While single-segment ratings are relatively easy to fit by automated methods [Ven70], compound ratings are more challenging, because their solution is multimodal, meaning it has multiple optima [RPOverleir06]. As a result, standard optimization algorithms can become stuck in local optima and fail to converge to the global optimum. General function approximators, such as natural splines [Fen18] or neural networks, can be easier to fit but their generality comes at a cost. The form of the power law matches that of the hydrologic equations governing uniform open-channel flow, like the Manning equation [Man91]. Due to that physical basis, power laws are potentially more robust than other generic curve-fitting functions: requiring less data to achieve the same fit and being less prone to overfitting.

This paper describes a basic algorithm for fitting compound ratings and compares its performance against a natural spline. Similar algorithms already exist, notably those of Le Coz et al. [LCRB+14], Reitan and Petersen-Øverleir [RP08], as well as the so-called generalized power law [HSR+21]. Like the algorithm described here, each of these examples is Bayesian, meaning they can utilize prior information to help constrain the solution space and reduce multimodality. Simple examples of priors include constraining the exponent $b$ to a narrow range around the value of 5/3, or constraining the number of rating segments, or constraining the transitions between segments around a particular stage. Being Bayesian, they also inherently estimate uncertainty in the fitted parameters and discharge, which is important for many applications.

Our algorithm differentiates itself in two main ways. First, it minimally reproduces the manual method used by hydrologists for decades while being both robust and fast; the user needs only to provide stage-discharge pairs and specify the number of segments in the rating, but even that can be inferred from the data. Second, it is implemented in Python using a popular community-developed open-source probabilistic programming library. As a result, most of the underlying numerical code is maintained by a broader community of developers, enabling us to focus on the particular nuances of parameterizing a rating curve model, as well as making it easier to extend or modify the algorithm or switch between different approximation algorithms to achieve different tradeoffs of speed and accuracy.

[Fen18]

John D. Fenton. On the generation of stream rating curves. Journal of Hydrology, 564:748–757, sep 2018. URL: https://doi.org/10.1016%2Fj.jhydrol.2018.07.025, doi:10.1016/j.jhydrol.2018.07.025.

[HG14]

Matthew D. Hoffman and Andrew Gelman. The no-u-turn sampler: adaptively setting path lengths in hamiltonian monte carlo. Journal of Machine Learning Research, 15(47):1593–1623, 2014. URL: http://jmlr.org/papers/v15/hoffman14a.html.

[HSR+21]

Birgir Hrafnkelsson, Helgi Sigurdarson, Sölvi Rögnvaldsson, Axel Örn Jansson, Rafael Dan\'ıel Vias, and Sigurdur M. Gardarsson. Generalization of the power-law rating curve using hydrodynamic theory and bayesian hierarchical modeling. Environmetrics, dec 2021. URL: https://doi.org/10.1002%2Fenv.2711, doi:10.1002/env.2711.

[Ken84]

Edward J Kennedy. Discharge ratings at gaging stations. Department of the Interior, US Geological Survey, 1984.

[KTR+17]

Alp Kucukelbir, Dustin Tran, Rajesh Ranganath, Andrew Gelman, and David M. Blei. Automatic differentiation variational inference. Journal of Machine Learning Research, 18(14):1–45, 2017. URL: http://jmlr.org/papers/v18/16-107.html.

[LCRB+14]

J. Le Coz, B. Renard, L. Bonnifait, F. Branger, and R. Le Boursicaud. Combining hydraulic knowledge and uncertain gaugings in the estimation of hydrometric rating curves: a bayesian approach. Journal of Hydrology, 509:573–587, Feb 2014. URL: http://dx.doi.org/10.1016/j.jhydrol.2013.11.016, doi:10.1016/j.jhydrol.2013.11.016.

[Man91]

R. Manning. On the flow of water in open channels and pipes. Transactions of the Institution of Civil Engineers of Ireland, 20:179–207, 1891.

[Mug03]

Vito M. R. Muggeo. Estimating regression models with unknown break-points. Statistics in Medicine, 22(19):3055–3071, 2003. URL: https://onlinelibrary.wiley.com/doi/abs/10.1002/sim.1545, arXiv:https://onlinelibrary.wiley.com/doi/pdf/10.1002/sim.1545, doi:https://doi.org/10.1002/sim.1545.

[POverleir04]

Asgeir Petersen-Øverleir. Accounting for heteroscedasticity in rating curve estimates. Journal of Hydrology, 292(1-4):173–181, jun 2004. URL: https://doi.org/10.1016%2Fj.jhydrol.2003.12.024, doi:10.1016/j.jhydrol.2003.12.024.

[RPOverleir06]

Trond Reitan and Asgeir Petersen-Øverleir. Existence of the frequentistic estimate for power-law regression with a location parameter, with applications for making discharge rating curves. Stochastic Environmental Research and Risk Assessment, 20(6):445–453, jul 2006. URL: https://doi.org/10.1007%2Fs00477-006-0037-6, doi:10.1007/s00477-006-0037-6.

[RP08]

Trond Reitan and Asgeir Petersen-Øverleir. Bayesian methods for estimating multi-segment discharge rating curves. Stochastic Environmental Research and Risk Assessment, 23(5):627–642, Jun 2008. URL: http://dx.doi.org/10.1007/s00477-008-0248-0, doi:10.1007/s00477-008-0248-0.

[SWF16]

John Salvatier, Thomas V. Wiecki, and Christopher Fonnesbeck. Probabilistic programming in python using PyMC3. PeerJ Computer Science, 2:e55, apr 2016. URL: https://doi.org/10.7717%2Fpeerj-cs.55, doi:10.7717/peerj-cs.55.

[Ven70]

C. Venetis. A note on the estimation of the parameters in logarithmic stage-discharge relationships with estimates of their error. International Association of Scientific Hydrology. Bulletin, 15(2):105–111, jun 1970. URL: https://doi.org/10.1080%2F02626667009493957, doi:10.1080/02626667009493957.

[ISO18320202020] (1,2)

ISO 18320:2020. Hydrometry–Measurement of Liquid Flow in Open Channels—Determination of the Stage–Discharge Relationship. International Organization for Standardization, 2020.