hydrating
Overview
hydrating is a python package for fitting hydrological rating curves.
hydrating aims to provide an easy interface to fitting rating curve for any kind of model while giving the user better control on the model parameters (provided through lmfit library). hydrating also aims at providing robust methods for estimating rating curve uncertainty and propagate these to discharge time series.
This initial alpha preview only provides basic powerlaw model fitting, see example below.
Development Status: Pre-Alpha.
Consider the API unstable, it may change at short/no notice.
Requirements and installation
Requirements:
numpy
pandas
lmfit
matplotlib
Install from pypi using pip
pip install hydrating
General description and example usage
Functionality is currently limited to fitting basic powerlaw rating curve, see below for examples showing different ways how once can interact with the hydrating api for basic fitting.
# imports for creating demo data
from numpy.random import SeedSequence, default_rng
import pandas as pd
from lmfit import Parameters
# imports for hydrating
from hydrating import RatingCurve
from hydrating.models import PowerLaw
# demo data for power law rating
a = 0.1
b = 2.5
h0 = 0.65
rng = default_rng(SeedSequence(123))
stage = rng.uniform(1, 10, size=20) #+ rng.normal(0, 0.01, size=20) # uncomment for stage with some noise
discharge_c = PowerLaw().func(stage, a, h0, b)
discharge = discharge_c #+ discharge_c * rng.normal(0, 0.1, size=20) # uncomment for discharge with some noise
data_df = pd.DataFrame({'stage_key': stage,
'discharge_key': discharge})
# fit by passing numpy arrays of the data
rc_c = RatingCurve(PowerLaw)
rc_c.fit(x=stage, y=discharge)
rc_c.fit_summary() # for a fit summary
rc_c.fit_best_parameters
Out: {'a': 0.09999999999999991, 'h0': 0.6499999999999992, 'b': 2.5000000000000004}
# fit by adding a dataframe. In future versions this will allow for more options adding
# other metadata to the rating curve
rc_c = RatingCurve(PowerLaw)
rc_c.add_data(data_df, stage='stage_key', discharge='discharge_key')
rc_c.fit() # will automatically use keys provided in add_data, but can also pass other keys here
# specify parameter bounds and fixed values, using lmfit.Parameters objects
input_parameters = Parameters()
input_parameters.add('a', value=1)
input_parameters.add('b', value=2.6, vary=False)
input_parameters.add('h0', value=0, max=0.4)
rc_c = RatingCurve(PowerLaw, initial_parameters=input_parameters)
rc_c.fit(x=stage, y=discharge)
Out: {'a': 0.07495641841621854, 'b': 2.6, 'h0': 0.3999999978452029}
# one can also let hydrating create the parameters simply by omitting
# initial_parameters keyword, and then modify them
# refer to lmfit documentation
rc_c = RatingCurve(PowerLaw)
rc_c.initial_parameters['b'].value = 2.55
rc_c.initial_parameters['b'].vary = False
rc_c.fit(x=stage, y=discharge)
rc_c.fit_best_parameters
Out: {'a': 0.08681743671415193, 'h0': 0.5320384707736181, 'b': 2.55}
Feedback and issues
Please report issues here: https://github.com/rhkarls/hydrating/issues
General feedback is most welcome, please post that as well under issues.
Metadata
Release files for hydrating 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| hydrating-0.0.5.tar.gz | 126.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hydrating-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 138.6 kB
Release files / hydrating-0.0.5.tar.gz
| Download URL | hydrating-0.0.5.tar.gz |
|---|---|
| Size | 126.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ca98afd855c4bdc947c6d85aa8b554f9e7ca78b5a1840126cf0adf0d9922372
|
|
BLAKE2b-256 checksum How to use checksums |
c3bf8a4b2f22ef69dd0ff1c08799d69781664f2e4573da800f88e19abf28fd7b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / hydrating-0.0.5-py3-none-any.whl
| Download URL | hydrating-0.0.5-py3-none-any.whl |
|---|---|
| Size | 12.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3d06b0af820402e52736d320f394529092baf062cdaae0be1ce176c8bdf8135d
|
|
BLAKE2b-256 checksum How to use checksums |
8332d459a2ae6574cd57805901335f7e9614fe198a9f0770e82b7942b08c4936
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for hydrating 0.0.5
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.