hydrotoolbox 2.0.9__py3-none-any.whl

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.
Files changed (57) hide show
  1. hydrotoolbox/__init__.py +11 -0
  2. hydrotoolbox/baseflow/__init__.py +9 -0
  3. hydrotoolbox/baseflow/comparison.py +72 -0
  4. hydrotoolbox/baseflow/example.csv +34004 -0
  5. hydrotoolbox/baseflow/methods/Boughton.py +29 -0
  6. hydrotoolbox/baseflow/methods/CM.py +21 -0
  7. hydrotoolbox/baseflow/methods/Chapman.py +21 -0
  8. hydrotoolbox/baseflow/methods/EWMA.py +20 -0
  9. hydrotoolbox/baseflow/methods/Eckhardt.py +30 -0
  10. hydrotoolbox/baseflow/methods/Fixed.py +26 -0
  11. hydrotoolbox/baseflow/methods/Furey.py +29 -0
  12. hydrotoolbox/baseflow/methods/LH.py +32 -0
  13. hydrotoolbox/baseflow/methods/Local.py +47 -0
  14. hydrotoolbox/baseflow/methods/Slide.py +25 -0
  15. hydrotoolbox/baseflow/methods/UKIH.py +46 -0
  16. hydrotoolbox/baseflow/methods/Willems.py +31 -0
  17. hydrotoolbox/baseflow/methods/__init__.py +15 -0
  18. hydrotoolbox/baseflow/methods/five_day.py +32 -0
  19. hydrotoolbox/baseflow/methods/ihacres.py +24 -0
  20. hydrotoolbox/baseflow/methods/strict.py +17 -0
  21. hydrotoolbox/baseflow/param_estimate.py +95 -0
  22. hydrotoolbox/baseflow/separation.py +98 -0
  23. hydrotoolbox/baseflow/utils.py +94 -0
  24. hydrotoolbox/baseflow_sep.py +979 -0
  25. hydrotoolbox/hydrotoolbox.py +2132 -0
  26. hydrotoolbox/indices/indices.py +1573 -0
  27. hydrotoolbox/toolbox_utils/docs/conf.py +309 -0
  28. hydrotoolbox/toolbox_utils/setup.py +21 -0
  29. hydrotoolbox/toolbox_utils/src/toolbox_utils/__init__.py +0 -0
  30. hydrotoolbox/toolbox_utils/src/toolbox_utils/readers/__init__.py +0 -0
  31. hydrotoolbox/toolbox_utils/src/toolbox_utils/readers/hbn.py +392 -0
  32. hydrotoolbox/toolbox_utils/src/toolbox_utils/readers/plotgen.py +55 -0
  33. hydrotoolbox/toolbox_utils/src/toolbox_utils/readers/wdm.py +233 -0
  34. hydrotoolbox/toolbox_utils/src/toolbox_utils/tssplit/setup.py +38 -0
  35. hydrotoolbox/toolbox_utils/src/toolbox_utils/tssplit/tssplit/__init__.py +1 -0
  36. hydrotoolbox/toolbox_utils/src/toolbox_utils/tssplit/tssplit/tssplit.py +47 -0
  37. hydrotoolbox/toolbox_utils/src/toolbox_utils/tsutils.py +2605 -0
  38. hydrotoolbox/toolbox_utils/tests/test_asbestfreq.py +72 -0
  39. hydrotoolbox/toolbox_utils/tests/test_common_kwds.py +23 -0
  40. hydrotoolbox/toolbox_utils/tests/test_date_slice.py +98 -0
  41. hydrotoolbox/toolbox_utils/tests/test_dateparse.py +41 -0
  42. hydrotoolbox/toolbox_utils/tests/test_extract.py +80 -0
  43. hydrotoolbox/toolbox_utils/tests/test_hbn.py +79 -0
  44. hydrotoolbox/toolbox_utils/tests/test_make_list.py +92 -0
  45. hydrotoolbox/toolbox_utils/tests/test_period_timestamp.py +136 -0
  46. hydrotoolbox/toolbox_utils/tests/test_plotgen.py +760 -0
  47. hydrotoolbox/toolbox_utils/tests/test_range_to_numlist.py +63 -0
  48. hydrotoolbox/toolbox_utils/tests/test_read.py +106 -0
  49. hydrotoolbox/toolbox_utils/tests/test_tssplit.py +23 -0
  50. hydrotoolbox/toolbox_utils/tests/test_wdm.py +59 -0
  51. hydrotoolbox/utils.py +28 -0
  52. hydrotoolbox-2.0.9.dist-info/LICENSE.txt +24 -0
  53. hydrotoolbox-2.0.9.dist-info/METADATA +158 -0
  54. hydrotoolbox-2.0.9.dist-info/RECORD +57 -0
  55. hydrotoolbox-2.0.9.dist-info/WHEEL +5 -0
  56. hydrotoolbox-2.0.9.dist-info/entry_points.txt +2 -0
  57. hydrotoolbox-2.0.9.dist-info/top_level.txt +1 -0
@@ -0,0 +1,11 @@
1
+ """Define hydrotoolbox package."""
2
+
3
+ from .hydrotoolbox import (
4
+ about,
5
+ baseflow_sep,
6
+ exceedance_time,
7
+ flow_duration,
8
+ indices,
9
+ recession,
10
+ storm_events,
11
+ )
@@ -0,0 +1,9 @@
1
+ import os
2
+
3
+ from .comparison import *
4
+ from .methods import *
5
+ from .param_estimate import *
6
+ from .separation import *
7
+ from .utils import *
8
+
9
+ _path = os.path.dirname(__file__)
@@ -0,0 +1,72 @@
1
+ import numpy as np
2
+
3
+
4
+ def strict_baseflow(Q):
5
+ delta_q = (Q[2:] - Q[:-2]) / 2
6
+
7
+ # 1. Flow data associated with positive and zero values of dQ/dt.
8
+ wet1 = np.concatenate([[True], delta_q >= 0, [True]])
9
+
10
+ # 2. Previous 2 points before points with dQ/dt >= 0, as well as the next
11
+ # three points.
12
+ idx_first = np.where(wet1[1:].astype(int) - wet1[:-1].astype(int) == 1)[0] + 1
13
+ idx_last = np.where(wet1[1:].astype(int) - wet1[:-1].astype(int) == -1)[0]
14
+ idx_before = np.repeat([idx_first], 2) - np.tile(range(1, 3), idx_first.shape)
15
+ idx_next = np.repeat([idx_last], 3) + np.tile(range(1, 4), idx_last.shape)
16
+ idx_remove = np.concatenate([idx_before, idx_next])
17
+ wet2 = np.full(Q.shape, False)
18
+ wet2[idx_remove.clip(min=0, max=Q.shape[0] - 1)] = True
19
+
20
+ # 3. Five data points after major events. A major event is identified as
21
+ # greater than the 90th quantile.
22
+ growing = np.concatenate([[True], (Q[1:] - Q[:-1]) >= 0, [True]])
23
+ idx_major = np.where((Q >= np.quantile(Q, 0.9)) & growing[:-1] & ~growing[1:])[0]
24
+ idx_after = np.repeat([idx_major], 5) + np.tile(range(1, 6), idx_major.shape)
25
+ wet3 = np.full(Q.shape, False)
26
+ wet3[idx_after.clip(min=0, max=Q.shape[0] - 1)] = True
27
+
28
+ # 4. Flow data followed by a data point with a larger value of -dQ/dt.
29
+ wet4 = np.concatenate([[True], delta_q[1:] - delta_q[:-1] < 0, [True, True]])
30
+
31
+ return ~(wet1 + wet2 + wet3 + wet4)
32
+
33
+
34
+ def KGE(simulations, evaluation):
35
+ """Original Kling-Gupta Efficiency (KGE) and its three components
36
+ (r, α, β) as per `Gupta et al., 2009
37
+ <https://doi.org/10.1016/j.jhydrol.2009.08.003>`_.
38
+ Note, all four values KGE, r, α, β are returned, in this order.
39
+ :Calculation Details:
40
+ .. math::
41
+ E_{\\text{KGE}} = 1 - \\sqrt{[r - 1]^2 + [\\alpha - 1]^2
42
+ + [\\beta - 1]^2}
43
+ .. math::
44
+ r = \\frac{\\text{cov}(e, s)}{\\sigma({e}) \\cdot \\sigma(s)}
45
+ .. math::
46
+ \\alpha = \\frac{\\sigma(s)}{\\sigma(e)}
47
+ .. math::
48
+ \\beta = \\frac{\\mu(s)}{\\mu(e)}
49
+ where *e* is the *evaluation* series, *s* is (one of) the
50
+ *simulations* series, *cov* is the covariance, *σ* is the
51
+ standard deviation, and *μ* is the arithmetic mean.
52
+ """
53
+ # calculate error in timing and dynamics r
54
+ # (Pearson's correlation coefficient)
55
+ sim_mean = np.mean(simulations, axis=0, dtype=np.float64)
56
+ obs_mean = np.mean(evaluation, axis=0, dtype=np.float64)
57
+
58
+ r_num = np.sum(
59
+ (simulations - sim_mean) * (evaluation - obs_mean), axis=0, dtype=np.float64
60
+ )
61
+ r_den = np.sqrt(
62
+ np.sum((simulations - sim_mean) ** 2, axis=0, dtype=np.float64)
63
+ * np.sum((evaluation - obs_mean) ** 2, axis=0, dtype=np.float64)
64
+ )
65
+ r = r_num / (r_den + 1e-10)
66
+ # calculate error in spread of flow alpha
67
+ alpha = np.std(simulations, axis=0) / (np.std(evaluation, axis=0) + 1e-10)
68
+ # calculate error in volume beta (bias of mean discharge)
69
+ beta = np.sum(simulations, axis=0, dtype=np.float64) / (
70
+ np.sum(evaluation, axis=0, dtype=np.float64) + 1e-10
71
+ )
72
+ return 1 - np.sqrt((r - 1) ** 2 + (alpha - 1) ** 2 + (beta - 1) ** 2)