pybaseflow 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pybaseflow-0.1.0/PKG-INFO +68 -0
- pybaseflow-0.1.0/README.md +45 -0
- pybaseflow-0.1.0/pybaseflow/__init__.py +46 -0
- pybaseflow-0.1.0/pybaseflow/data/README.md +13 -0
- pybaseflow-0.1.0/pybaseflow/data/fish_river.csv +732 -0
- pybaseflow-0.1.0/pybaseflow/estimate.py +302 -0
- pybaseflow-0.1.0/pybaseflow/io.py +112 -0
- pybaseflow-0.1.0/pybaseflow/separation.py +915 -0
- pybaseflow-0.1.0/pybaseflow/tracer.py +131 -0
- pybaseflow-0.1.0/pybaseflow/utils.py +73 -0
- pybaseflow-0.1.0/pybaseflow.egg-info/PKG-INFO +68 -0
- pybaseflow-0.1.0/pybaseflow.egg-info/SOURCES.txt +15 -0
- pybaseflow-0.1.0/pybaseflow.egg-info/dependency_links.txt +1 -0
- pybaseflow-0.1.0/pybaseflow.egg-info/requires.txt +7 -0
- pybaseflow-0.1.0/pybaseflow.egg-info/top_level.txt +1 -0
- pybaseflow-0.1.0/pyproject.toml +44 -0
- pybaseflow-0.1.0/setup.cfg +4 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: pybaseflow
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A comprehensive Python toolkit for baseflow separation
|
|
5
|
+
Author: Nels Jones
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Classifier: Programming Language :: Python
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Topic :: Scientific/Engineering :: Hydrology
|
|
15
|
+
Requires-Python: >=3.9
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
Requires-Dist: numpy
|
|
18
|
+
Requires-Dist: numba
|
|
19
|
+
Requires-Dist: pandas
|
|
20
|
+
Provides-Extra: dev
|
|
21
|
+
Requires-Dist: pytest; extra == "dev"
|
|
22
|
+
Requires-Dist: matplotlib; extra == "dev"
|
|
23
|
+
|
|
24
|
+
# 🌟 baseflow
|
|
25
|
+
baseflow is a Python package that provides a collection of functions for baseflow separation, which is the process of separating the baseflow component from the total streamflow.
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
This project is a copy of the [baseflow repository](https://github.com/xiejx5/baseflow) , which implements various baseflow separation methods described in the paper by Xie et al. (2020): "Evaluation of typical methods for baseflow separation in the contiguous United States" (Journal of Hydrology, 583, 124628. https://doi.org/10.1016/j.jhydrol.2020.124628).
|
|
29
|
+
|
|
30
|
+
This project is funded by [CIROH](https://ciroh.ua.edu/) and aims to extend the functionality of the original baseflow package by adding new features and improvements. Our goal is to continuously enhance and maintain this package, keeping it up-to-date with the latest developments in baseflow separation techniques.
|
|
31
|
+
|
|
32
|
+
For detailed usage instructions and examples, please refer to the [📖 documentation](https://baseflow.readthedocs.io/en/latest/) 🔥.
|
|
33
|
+
|
|
34
|
+
## âš¡ Usage
|
|
35
|
+
|
|
36
|
+
### Install
|
|
37
|
+
```bash
|
|
38
|
+
pip install baseflow
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
### Example
|
|
43
|
+
```python
|
|
44
|
+
import baseflow
|
|
45
|
+
import pandas as pd
|
|
46
|
+
|
|
47
|
+
df = pd.read_csv(baseflow.example, index_col=0)
|
|
48
|
+
df_sta = pd.DataFrame(data=[[30, -28.4, 659], [-109.4, 33, 1611]],
|
|
49
|
+
index=df.columns, columns=['lon', 'lat', 'area'])
|
|
50
|
+
dfs, df_kge = baseflow.separation(df, df_sta, return_kge=True)
|
|
51
|
+
print(f'Best Method:\n{df_kge.idxmax(axis=1)}')
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
## 🚀 Project Structure
|
|
56
|
+
The directory structure of baseflow looks like this:
|
|
57
|
+
```
|
|
58
|
+
├── methods <- implements for 12 baseflow separation methods
|
|
59
|
+
│
|
|
60
|
+
├── separation <- compute baseflow and compare different separation methods
|
|
61
|
+
│
|
|
62
|
+
├── param_estimate <- estimates recession coefficient & backward and calibration approaches to estimate other parameters
|
|
63
|
+
│
|
|
64
|
+
├── comparison <- an evaluation criterion to compare different
|
|
65
|
+
methods (KGE) & compute strict baseflow
|
|
66
|
+
│
|
|
67
|
+
└── utils <- helper functions
|
|
68
|
+
```
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# 🌟 baseflow
|
|
2
|
+
baseflow is a Python package that provides a collection of functions for baseflow separation, which is the process of separating the baseflow component from the total streamflow.
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
This project is a copy of the [baseflow repository](https://github.com/xiejx5/baseflow) , which implements various baseflow separation methods described in the paper by Xie et al. (2020): "Evaluation of typical methods for baseflow separation in the contiguous United States" (Journal of Hydrology, 583, 124628. https://doi.org/10.1016/j.jhydrol.2020.124628).
|
|
6
|
+
|
|
7
|
+
This project is funded by [CIROH](https://ciroh.ua.edu/) and aims to extend the functionality of the original baseflow package by adding new features and improvements. Our goal is to continuously enhance and maintain this package, keeping it up-to-date with the latest developments in baseflow separation techniques.
|
|
8
|
+
|
|
9
|
+
For detailed usage instructions and examples, please refer to the [📖 documentation](https://baseflow.readthedocs.io/en/latest/) 🔥.
|
|
10
|
+
|
|
11
|
+
## âš¡ Usage
|
|
12
|
+
|
|
13
|
+
### Install
|
|
14
|
+
```bash
|
|
15
|
+
pip install baseflow
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Example
|
|
20
|
+
```python
|
|
21
|
+
import baseflow
|
|
22
|
+
import pandas as pd
|
|
23
|
+
|
|
24
|
+
df = pd.read_csv(baseflow.example, index_col=0)
|
|
25
|
+
df_sta = pd.DataFrame(data=[[30, -28.4, 659], [-109.4, 33, 1611]],
|
|
26
|
+
index=df.columns, columns=['lon', 'lat', 'area'])
|
|
27
|
+
dfs, df_kge = baseflow.separation(df, df_sta, return_kge=True)
|
|
28
|
+
print(f'Best Method:\n{df_kge.idxmax(axis=1)}')
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
## 🚀 Project Structure
|
|
33
|
+
The directory structure of baseflow looks like this:
|
|
34
|
+
```
|
|
35
|
+
├── methods <- implements for 12 baseflow separation methods
|
|
36
|
+
│
|
|
37
|
+
├── separation <- compute baseflow and compare different separation methods
|
|
38
|
+
│
|
|
39
|
+
├── param_estimate <- estimates recession coefficient & backward and calibration approaches to estimate other parameters
|
|
40
|
+
│
|
|
41
|
+
├── comparison <- an evaluation criterion to compare different
|
|
42
|
+
methods (KGE) & compute strict baseflow
|
|
43
|
+
│
|
|
44
|
+
└── utils <- helper functions
|
|
45
|
+
```
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"""pybaseflow — a comprehensive Python toolkit for baseflow separation."""
|
|
2
|
+
|
|
3
|
+
__version__ = "0.1.0"
|
|
4
|
+
|
|
5
|
+
import csv
|
|
6
|
+
from datetime import date
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
|
|
11
|
+
from pybaseflow.separation import * # noqa: F401,F403
|
|
12
|
+
from pybaseflow.estimate import * # noqa: F401,F403
|
|
13
|
+
from pybaseflow.utils import * # noqa: F401,F403
|
|
14
|
+
from pybaseflow.tracer import cmb, estimate_endmembers, calibrate_eckhardt_from_cmb # noqa: F401
|
|
15
|
+
|
|
16
|
+
_DATA_DIR = Path(__file__).parent / 'data'
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def load_sample_data():
|
|
20
|
+
"""Load the bundled Fish River sample dataset.
|
|
21
|
+
|
|
22
|
+
Returns daily discharge for USGS site 01013500 (Fish River near Fort Kent,
|
|
23
|
+
Maine) for 2019-2020.
|
|
24
|
+
|
|
25
|
+
Returns:
|
|
26
|
+
dict: Dictionary with keys:
|
|
27
|
+
- 'dates': numpy array of datetime.date objects
|
|
28
|
+
- 'Q': numpy array of discharge in ft³/s
|
|
29
|
+
- 'site_id': '01013500'
|
|
30
|
+
- 'units': 'ft3/s'
|
|
31
|
+
"""
|
|
32
|
+
path = _DATA_DIR / 'fish_river.csv'
|
|
33
|
+
dates = []
|
|
34
|
+
values = []
|
|
35
|
+
with open(path, newline='') as f:
|
|
36
|
+
reader = csv.DictReader(f)
|
|
37
|
+
for row in reader:
|
|
38
|
+
dates.append(date.fromisoformat(row['date']))
|
|
39
|
+
val = row['discharge_cfs']
|
|
40
|
+
values.append(float(val) if val else np.nan)
|
|
41
|
+
return {
|
|
42
|
+
'dates': np.array(dates),
|
|
43
|
+
'Q': np.array(values, dtype=np.float64),
|
|
44
|
+
'site_id': '01013500',
|
|
45
|
+
'units': 'ft3/s',
|
|
46
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Sample Data
|
|
2
|
+
|
|
3
|
+
## fish_river.csv
|
|
4
|
+
|
|
5
|
+
- **USGS Site**: 01013500 — Fish River near Fort Kent, Maine
|
|
6
|
+
- **Period**: 2019-01-01 to 2020-12-31 (731 days)
|
|
7
|
+
- **Parameter**: Daily mean discharge (ft³/s), NWIS parameter code 00060
|
|
8
|
+
- **Source**: USGS National Water Information System (NWIS), https://waterdata.usgs.gov/nwis
|
|
9
|
+
- **License**: US Government public domain
|
|
10
|
+
|
|
11
|
+
This is a clean, unregulated headwater gauge with a strong seasonal signal
|
|
12
|
+
(snowmelt peaks in spring, baseflow-dominated in late summer/fall), making
|
|
13
|
+
it a good test case for baseflow separation methods.
|