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,1573 @@
1
+ from typing import Optional
2
+
3
+ import numpy as np
4
+ import pandas as pd
5
+ from scipy.signal import find_peaks
6
+
7
+ from ..toolbox_utils.src.toolbox_utils import tsutils
8
+
9
+
10
+ class Indices:
11
+ def __init__(self, data, use_median=False, water_year="A-SEP", drainage_area=1):
12
+ if isinstance(data, pd.DataFrame) and len(data.columns) != 1:
13
+ raise ValueError(
14
+ tsutils.error_wrapper(
15
+ f"""
16
+ Can only calculate indices on 1 series, you gave
17
+ {len(data.columns)}.
18
+ """
19
+ )
20
+ )
21
+
22
+ self.use_median = use_median
23
+ self.water_year = water_year
24
+ self.drainage_area = float(drainage_area)
25
+
26
+ self.data = pd.Series(data.iloc[:, 0].values, index=data.index)
27
+ self.data[self.data < 0] = pd.NA
28
+ self.data = self.data.dropna()
29
+
30
+ self.data_monthly = self.data.groupby(pd.Grouper(freq="M"))
31
+ self.data_yearly = self.data.groupby(pd.Grouper(freq=self.water_year))
32
+
33
+ self.data_monthly_mean = self.data_monthly.mean()
34
+ self.data_yearly_mean = self.data_yearly.mean()
35
+
36
+ self.data_monthly_min = self.data_monthly.min()
37
+ self.data_yearly_min = self.data_yearly.min()
38
+
39
+ self.data_monthly_max = self.data_monthly.max()
40
+ self.data_yearly_max = self.data_yearly.max()
41
+
42
+ def MA1(self):
43
+ """MA1
44
+ Mean of the daily mean flow values for the entire flow record.
45
+ cubic feet per second—temporal"""
46
+ return self.data.mean()
47
+
48
+ def MA2(self):
49
+ """MA2
50
+ Median of the daily mean flow values for the entire flow record.
51
+ cubic feet per second—temporal"""
52
+ return self.data.median()
53
+
54
+ def MA3(self):
55
+ """MA3
56
+ Mean (or median) of the coefficients of variation (standard
57
+ deviation/mean) for each year. Compute the coefficient of variation
58
+ for each year of daily flows. Compute the mean of the annual
59
+ coefficients of variation.
60
+ percent—temporal"""
61
+ group = self.data.groupby(pd.Grouper(freq=self.water_year))
62
+ tmpdata = group.std() / group.mean()
63
+ if self.use_median is True:
64
+ return tmpdata.median() * 100
65
+ return tmpdata.mean() * 100
66
+
67
+ def MA4(self):
68
+ """MA4
69
+ Standard deviation of the percentiles of the logs of the entire flow
70
+ record divided by the mean of percentiles of the logs. Compute the
71
+ log10 of the daily flows for the entire record. Compute the 5th, 10th,
72
+ 15th, 20th, 25th, 30th, 35th, 40th, 45th, 50th, 55th, 60th, 65th, 70th,
73
+ 75th, 80th, 85th, 90th, and 95th percentiles for the logs of the
74
+ entire flow record.
75
+
76
+ Percentiles are computed by interpolating between the ordered
77
+ (ascending) logs of the flow values. Compute the standard deviation
78
+ and mean for the percentile values. Divide the standard deviation by
79
+ the mean.
80
+ percent–spatial"""
81
+ p = [
82
+ 0.05,
83
+ 0.10,
84
+ 0.15,
85
+ 0.20,
86
+ 0.25,
87
+ 0.30,
88
+ 0.35,
89
+ 0.40,
90
+ 0.45,
91
+ 0.50,
92
+ 0.55,
93
+ 0.60,
94
+ 0.65,
95
+ 0.70,
96
+ 0.75,
97
+ 0.80,
98
+ 0.85,
99
+ 0.90,
100
+ 0.95,
101
+ ]
102
+ newp = self.data.quantile(p)
103
+ return newp.std() / newp.mean() * 100
104
+
105
+ def MA5(self):
106
+ """MA5
107
+ The skewness of the entire flow record is computed as the mean for the
108
+ entire flow record (MA1) divided by the median (MA2) for the entire
109
+ flow record.
110
+ dimensionless—spatial"""
111
+ return self.MA1() / self.MA2()
112
+
113
+ def _make_MA_6_8(high: float, low: float):
114
+ def template(self):
115
+ return self.data.quantile(high) / self.data.quantile(low)
116
+
117
+ return template
118
+
119
+ MA6 = _make_MA_6_8(0.9, 0.1)
120
+ MA6.__doc__ = """MA6
121
+ Range in daily flows is the ratio of the 10-percent to 90-percent exceedance
122
+ values for the entire flow record. Compute the 5-percent to 95-percent
123
+ exceedance values for the entire flow record. Exceedance is computed by
124
+ interpolating between the ordered (descending) flow values. Divide the
125
+ 10-percent exceedance value by the 90-percent value.
126
+ dimensionless—spatial"""
127
+ MA7 = _make_MA_6_8(0.8, 0.2)
128
+ MA7.__doc__ = """MA7
129
+ Range in daily flows is computed like MA6, except using the 20 percent and 80
130
+ percent exceedance values. Divide the 20 percent exceedance value by the 80
131
+ percent value.
132
+ dimensionless—spatial"""
133
+ MA8 = _make_MA_6_8(0.75, 0.25)
134
+ MA8.__doc__ = """MA8
135
+ Range in daily flows is computed like MA6, except using the 25-percent and
136
+ 75-percent exceedance values. Divide the 25-percent exceedance value by the
137
+ 75-percent value.
138
+ dimensionless—spatial"""
139
+
140
+ def _make_MA_9_11(high: float, low: float):
141
+ def template(self):
142
+ return (self.data.quantile(high) - self.data.quantile(low)) / self.MA2()
143
+
144
+ return template
145
+
146
+ MA9 = _make_MA_9_11(0.9, 0.1)
147
+ MA9.__doc__ = """MA9
148
+ Spread in daily flows is the ratio of the difference between the 90th and 10th
149
+ percentile of the logs of the flow data to the log of the median of the entire
150
+ flow record. Compute the log10 of the daily flows for the entire record.
151
+ Compute the 5th, 10th, 15th, 20th, 25th, 30th, 35th, 40th, 45th, 50th, 55th,
152
+ 60th, 65th, 70th, 75th, 80th, 85th, 90th, and 95th percentiles for the logs of
153
+ the entire flow record. Percentiles are computed by interpolating between the
154
+ ordered (ascending) logs of the flow values. Compute MA9 as (90th –10th)
155
+ /log10(MA2).
156
+ dimensionless—spatial"""
157
+ MA10 = _make_MA_9_11(0.8, 0.2)
158
+ MA10.__doc__ = """MA10
159
+ Spread in daily flows is computed like MA9, except using the 20th and 80th
160
+ percentiles.
161
+ dimensionless—spatial"""
162
+ MA11 = _make_MA_9_11(0.75, 0.25)
163
+ MA11.__doc__ = """MA11
164
+ Spread in daily flows is computed like MA9, except using the 25th and 75th
165
+ percentiles.
166
+ dimensionless—spatial"""
167
+
168
+ def _make_MA_12_23(month: int):
169
+ def template(self):
170
+ if self.use_median is True:
171
+ return self.data[self.data.index.month == month].median()
172
+ return self.data[self.data.index.month == month].mean()
173
+
174
+ return template
175
+
176
+ MA12 = _make_MA_12_23(1)
177
+ MA12.__doc__ = """MA12
178
+ Means (or medians) of monthly flow values. Compute the means for each. Means
179
+ (or medians) of monthly flow values. Compute the means for each month over the
180
+ entire flow record.
181
+
182
+ MA12 is the mean of all January flow values over the entire record
183
+ (cubic feet per second— temporal)."""
184
+ MA13 = _make_MA_12_23(2)
185
+ MA13.__doc__ = """MA13
186
+ Means (or medians) of monthly flow values. Compute the means for each. Means
187
+ (or medians) of monthly flow values. Compute the means for each month over the
188
+ entire flow record.
189
+
190
+ MA13 is the mean of all February flow values over the entire record
191
+ MA12 is the mean of all January flow values over the entire record
192
+ (cubic feet per second— temporal)."""
193
+ MA14 = _make_MA_12_23(3)
194
+ MA14.__doc__ = """MA14
195
+ Means (or medians) of monthly flow values. Compute the means for each. Means
196
+ (or medians) of monthly flow values. Compute the means for each month over the
197
+ entire flow record.
198
+
199
+ MA14 is the mean of all March flow values over the entire record
200
+ MA12 is the mean of all January flow values over the entire record
201
+ (cubic feet per second— temporal)."""
202
+ MA15 = _make_MA_12_23(4)
203
+ MA15.__doc__ = """MA15
204
+ Means (or medians) of monthly flow values. Compute the means for each. Means
205
+ (or medians) of monthly flow values. Compute the means for each month over the
206
+ entire flow record.
207
+
208
+ MA15 is the mean of all April flow values over the entire record
209
+ MA12 is the mean of all January flow values over the entire record
210
+ (cubic feet per second— temporal)."""
211
+ MA16 = _make_MA_12_23(5)
212
+ MA16.__doc__ = """MA16
213
+ Means (or medians) of monthly flow values. Compute the means for each. Means
214
+ (or medians) of monthly flow values. Compute the means for each month over the
215
+ entire flow record.
216
+
217
+ MA16 is the mean of all May flow values over the entire record
218
+ MA12 is the mean of all January flow values over the entire record
219
+ (cubic feet per second— temporal)."""
220
+ MA17 = _make_MA_12_23(6)
221
+ MA17.__doc__ = """MA17
222
+ Means (or medians) of monthly flow values. Compute the means for each. Means
223
+ (or medians) of monthly flow values. Compute the means for each month over the
224
+ entire flow record.
225
+
226
+ MA17 is the mean of all June flow values over the entire record
227
+ (cubic feet per second— temporal)."""
228
+ MA18 = _make_MA_12_23(7)
229
+ MA18.__doc__ = """MA18
230
+ Means (or medians) of monthly flow values. Compute the means for each. Means
231
+ (or medians) of monthly flow values. Compute the means for each month over the
232
+ entire flow record.
233
+
234
+ MA18 is the mean of all July flow values over the entire record
235
+ (cubic feet per second— temporal)."""
236
+ MA19 = _make_MA_12_23(8)
237
+ MA19.__doc__ = """MA19
238
+ Means (or medians) of monthly flow values. Compute the means for each. Means
239
+ (or medians) of monthly flow values. Compute the means for each month over the
240
+ entire flow record.
241
+
242
+ MA19 is the mean of all August flow values over the entire record
243
+ (cubic feet per second— temporal)."""
244
+ MA20 = _make_MA_12_23(9)
245
+ MA20.__doc__ = """MA20
246
+ Means (or medians) of monthly flow values. Compute the means for each. Means
247
+ (or medians) of monthly flow values. Compute the means for each month over the
248
+ entire flow record.
249
+
250
+ MA20 is the mean of all September flow values over the entire record
251
+ (cubic feet per second— temporal)."""
252
+ MA21 = _make_MA_12_23(10)
253
+ MA21.__doc__ = """MA21
254
+ Means (or medians) of monthly flow values. Compute the means for each. Means
255
+ (or medians) of monthly flow values. Compute the means for each month over the
256
+ entire flow record.
257
+
258
+ MA21 is the mean of all October flow values over the entire record
259
+ (cubic feet per second— temporal)."""
260
+ MA22 = _make_MA_12_23(11)
261
+ MA22.__doc__ = """MA22
262
+ Means (or medians) of monthly flow values. Compute the means for each. Means
263
+ (or medians) of monthly flow values. Compute the means for each month over the
264
+ entire flow record.
265
+
266
+ MA22 is the mean of all November flow values over the entire record
267
+ (cubic feet per second— temporal)."""
268
+ MA23 = _make_MA_12_23(12)
269
+ MA23.__doc__ = """MA23
270
+ Means (or medians) of monthly flow values. Compute the means for each. Means
271
+ (or medians) of monthly flow values. Compute the means for each month over the
272
+ entire flow record.
273
+
274
+ MA23 is the mean of all December flow values over the entire record
275
+ (cubic feet per second— temporal)."""
276
+
277
+ def _make_MA_24_35(month: int):
278
+ def template(self):
279
+ group = self.data.groupby(pd.Grouper(freq="M"))
280
+ tmpdata = group.std() / group.mean()
281
+ if self.use_median is True:
282
+ return tmpdata[tmpdata.index.month == month].median() * 100
283
+ return tmpdata[tmpdata.index.month == month].mean() * 100
284
+
285
+ return template
286
+
287
+ MA24 = _make_MA_24_35(1)
288
+ MA24.__doc__ = """MA24
289
+ Variability (coefficient of variation) of monthly flow values. Compute the
290
+ standard deviation for each. Variability (coefficient of month in each year
291
+ over the entire flow record. Divide the standard deviation by the mean for each
292
+ month. Average (or take median of) these values for each month across all
293
+ years.
294
+
295
+ MA24 is the variability of all January flow values over the entire record.
296
+ percent—temporal"""
297
+ MA25 = _make_MA_24_35(2)
298
+ MA25.__doc__ = """MA25
299
+ Variability (coefficient of variation) of monthly flow values. Compute the
300
+ standard deviation for each. Variability (coefficient of month in each year
301
+ over the entire flow record. Divide the standard deviation by the mean for each
302
+ month. Average (or take median of) these values for each month across all
303
+ years.
304
+
305
+ MA25 is the variability of all February flow values over the entire record.
306
+ percent—temporal"""
307
+ MA26 = _make_MA_24_35(3)
308
+ MA26.__doc__ = """MA26
309
+ Variability (coefficient of variation) of monthly flow values. Compute the
310
+ standard deviation for each. Variability (coefficient of month in each year
311
+ over the entire flow record. Divide the standard deviation by the mean for each
312
+ month. Average (or take median of) these values for each month across all
313
+ years.
314
+
315
+ MA26 is the variability of all March flow values over the entire record.
316
+ percent—temporal"""
317
+ MA27 = _make_MA_24_35(4)
318
+ MA27.__doc__ = """MA27
319
+ Variability (coefficient of variation) of monthly flow values. Compute the
320
+ standard deviation for each. Variability (coefficient of month in each year
321
+ over the entire flow record. Divide the standard deviation by the mean for each
322
+ month. Average (or take median of) these values for each month across all
323
+ years.
324
+
325
+ MA27 is the variability of all April flow values over the entire record.
326
+ percent—temporal"""
327
+ MA28 = _make_MA_24_35(5)
328
+ MA28.__doc__ = """MA28
329
+ Variability (coefficient of variation) of monthly flow values. Compute the
330
+ standard deviation for each. Variability (coefficient of month in each year
331
+ over the entire flow record. Divide the standard deviation by the mean for each
332
+ month. Average (or take median of) these values for each month across all
333
+ years.
334
+
335
+ MA28 is the variability of all May flow values over the entire record.
336
+ percent—temporal"""
337
+ MA29 = _make_MA_24_35(6)
338
+ MA29.__doc__ = """MA29
339
+ Variability (coefficient of variation) of monthly flow values. Compute the
340
+ standard deviation for each. Variability (coefficient of month in each year
341
+ over the entire flow record. Divide the standard deviation by the mean for each
342
+ month. Average (or take median of) these values for each month across all
343
+ years.
344
+
345
+ MA29 is the variability of all June flow values over the entire record.
346
+ percent—temporal"""
347
+ MA30 = _make_MA_24_35(7)
348
+ MA30.__doc__ = """MA30
349
+ Variability (coefficient of variation) of monthly flow values. Compute the
350
+ standard deviation for each. Variability (coefficient of month in each year
351
+ over the entire flow record. Divide the standard deviation by the mean for each
352
+ month. Average (or take median of) these values for each month across all
353
+ years.
354
+
355
+ MA30 is the variability of all July flow values over the entire record.
356
+ percent—temporal"""
357
+ MA31 = _make_MA_24_35(8)
358
+ MA31.__doc__ = """MA31
359
+ Variability (coefficient of variation) of monthly flow values. Compute the
360
+ standard deviation for each. Variability (coefficient of month in each year
361
+ over the entire flow record. Divide the standard deviation by the mean for each
362
+ month. Average (or take median of) these values for each month across all
363
+ years.
364
+
365
+ MA31 is the variability of all August flow values over the entire record.
366
+ percent—temporal"""
367
+ MA32 = _make_MA_24_35(9)
368
+ MA32.__doc__ = """MA32
369
+ Variability (coefficient of variation) of monthly flow values. Compute the
370
+ standard deviation for each. Variability (coefficient of month in each year
371
+ over the entire flow record. Divide the standard deviation by the mean for each
372
+ month. Average (or take median of) these values for each month across all
373
+ years.
374
+
375
+ MA32 is the variability of all September flow values over the entire record.
376
+ percent—temporal"""
377
+ MA33 = _make_MA_24_35(10)
378
+ MA33.__doc__ = """
379
+ Variability (coefficient of variation) of monthly flow values. Compute the
380
+ standard deviation for each. Variability (coefficient of month in each year
381
+ over the entire flow record. Divide the standard deviation by the mean for each
382
+ month. Average (or take median of) these values for each month across all
383
+ years.
384
+
385
+ MA33 is the variability of all October flow values over the entire record.
386
+ percent—temporal"""
387
+ MA34 = _make_MA_24_35(11)
388
+ MA34.__doc__ = """MA34
389
+ Variability (coefficient of variation) of monthly flow values. Compute the
390
+ standard deviation for each. Variability (coefficient of month in each year
391
+ over the entire flow record. Divide the standard deviation by the mean for each
392
+ month. Average (or take median of) these values for each month across all
393
+ years.
394
+
395
+ MA34 is the variability of all November flow values over the entire record.
396
+ percent—temporal"""
397
+ MA35 = _make_MA_24_35(12)
398
+ MA35.__doc__ = """MA35
399
+ Variability (coefficient of variation) of monthly flow values. Compute the
400
+ standard deviation for each. Variability (coefficient of month in each year
401
+ over the entire flow record. Divide the standard deviation by the mean for each
402
+ month. Average (or take median of) these values for each month across all
403
+ years.
404
+
405
+ MA35 is the variability of all December flow values over the entire record.
406
+ percent—temporal"""
407
+
408
+ def MA36(self):
409
+ """MA36
410
+ Variability across monthly flows. Compute the minimum, maximum, and
411
+ mean flows for each month in the entire flow record. MA36 is the
412
+ maximum monthly flow minus the minimum monthly flow divided by the
413
+ median monthly flow.
414
+ dimensionless-spatial"""
415
+ return (
416
+ max(self.data_monthly_mean) - min(self.data_monthly_mean)
417
+ ) / self.data_monthly_mean.median()
418
+
419
+ def _make_MA_37_38(high: float, low: float):
420
+ def template(self):
421
+ return (
422
+ self.data_monthly_mean.quantile(high)
423
+ - self.data_monthly_mean.quantile(low)
424
+ ) / self.data_monthly_mean.median()
425
+
426
+ return template
427
+
428
+ MA37 = _make_MA_37_38(0.75, 0.25)
429
+ MA37.__doc__ = """MA37
430
+ Variability across monthly flows. Compute the first (25th percentile) and the
431
+ third (75th percentile) quartiles (every month in dimensionless— the flow
432
+ record). MA37 is the third quartile minus the first quartile divided by the
433
+ median of the monthly means.
434
+ dimensionless-spatial"""
435
+ MA38 = _make_MA_37_38(0.9, 0.1)
436
+ MA38.__doc__ = """MA38
437
+ Variability across monthly flows. Compute the 10th and 90th percentiles for the
438
+ monthly means (every month in the flow record). MA38 is the 90th percentile
439
+ minus the 10th percentile divided by the median of the monthly means.
440
+ dimensionless—spatial"""
441
+
442
+ def MA39(self):
443
+ """MA39
444
+ Variability across monthly flows. Compute the standard deviation for
445
+ the monthly means. MA39 is the standard deviation times 100 divided by
446
+ the mean of the monthly means.
447
+ percent—spatial"""
448
+ return self.data_monthly_mean.std() / self.data_monthly_mean.mean() * 100
449
+
450
+ def MA40(self):
451
+ """MA40
452
+ Skewness in the monthly flows. MA40 is the mean of the monthly flow
453
+ means minus the median of the monthly means divided by the median of
454
+ the monthly means.
455
+ dimensionles-sspatial"""
456
+ return (
457
+ self.data_monthly_mean.mean() - self.data_monthly_mean.median()
458
+ ) / self.data_monthly_mean.median()
459
+
460
+ def MA41(self):
461
+ """MA41
462
+ Annual runoff. Compute the annual mean daily flows. MA41 is the mean of
463
+ the annual means divided by the drainage area.
464
+ cubic feet per second/ square mile—temporal"""
465
+ return self.data_yearly_mean.mean() / self.drainage_area
466
+
467
+ def MA42(self):
468
+ """MA42
469
+ Variability across annual flows. MA42 is the maximum annual flow minus
470
+ the minimum annual flow divided by the median annual flow.
471
+ dimensionless-spatial"""
472
+ return (
473
+ max(self.data_yearly_mean) - min(self.data_yearly_mean)
474
+ ) / self.data_yearly_mean.median()
475
+
476
+ def _make_MA_43_44(high: float, low: float):
477
+ def template(self):
478
+ return (
479
+ self.data_yearly_mean.quantile(high)
480
+ - self.data_yearly_mean.quantile(low)
481
+ ) / self.data_yearly_mean.median()
482
+
483
+ return template
484
+
485
+ MA43 = _make_MA_43_44(0.75, 0.25)
486
+ MA43.__doc__ = """MA43
487
+ Variability across annual flows. Compute the first (25th percentile) and third
488
+ (75th percentile) quartiles for the annual means (every year in the flow
489
+ record).
490
+
491
+ MA43 is the third quartile minus the first quartile divided by the median of
492
+ the annual means.
493
+ dimensionless-spatial"""
494
+ MA44 = _make_MA_43_44(0.9, 0.1)
495
+ MA44.__doc__ = """MA44
496
+ Variability across annual flows. Compute the 10th and 90th percentiles for the
497
+ annual means (every year in the flow record).
498
+
499
+ MA44 is the 90th percentile minus the 10th percentile divided by the median of
500
+ the annual means.
501
+ dimensionless-spatial"""
502
+
503
+ def MA45(self):
504
+ """MA45
505
+ Skewness in the annual flows. MA45 is the mean of the annual flow means
506
+ minus the median of the annual means divided by the median of the
507
+ annual means.
508
+ dimensionless-spatial"""
509
+ return (
510
+ self.data_yearly_mean.mean() - self.data_yearly_mean.median()
511
+ ) / self.data_yearly_mean.median()
512
+
513
+ def _make_ML_1_12(month: int):
514
+ def template(self):
515
+ if self.use_median is True:
516
+ return self.data_monthly_min[
517
+ self.data_monthly_min.index.month == month
518
+ ].median()
519
+ return self.data_monthly_min[
520
+ self.data_monthly_min.index.month == month
521
+ ].mean()
522
+
523
+ return template
524
+
525
+ ML1 = _make_ML_1_12(1)
526
+ ML1.__doc__ = """ML1
527
+ Mean (or median) of minimum flows for each month across all years. Compute the
528
+ minimums for each month over the entire flow record.
529
+
530
+ ML1 is the mean of the minimums of all January flow values over the entire
531
+ record.
532
+ cubic feet per second—temporal"""
533
+ ML2 = _make_ML_1_12(2)
534
+ ML2.__doc__ = """ML2
535
+ Mean (or median) of minimum flows for each month across all years. Compute the
536
+ minimums for each month over the entire flow record.
537
+
538
+ ML2 is the mean of the minimums of all February flow values over the entire
539
+ record.
540
+ cubic feet per second—temporal"""
541
+ ML3 = _make_ML_1_12(3)
542
+ ML3.__doc__ = """ML3
543
+ Mean (or median) of minimum flows for each month across all years. Compute the
544
+ minimums for each month over the entire flow record.
545
+
546
+ ML3 is the mean of the minimums of all March flow values over the entire
547
+ record.
548
+ cubic feet per second—temporal"""
549
+ ML4 = _make_ML_1_12(4)
550
+ ML4.__doc__ = """ML4
551
+ Mean (or median) of minimum flows for each month across all years. Compute the
552
+ minimums for each month over the entire flow record.
553
+
554
+ ML4 is the mean of the minimums of all April flow values over the entire
555
+ record.
556
+ cubic feet per second—temporal"""
557
+ ML5 = _make_ML_1_12(5)
558
+ ML5.__doc__ = """ML5
559
+ Mean (or median) of minimum flows for each month across all years. Compute the
560
+ minimums for each month over the entire flow record.
561
+
562
+ ML5 is the mean of the minimums of all May flow values over the entire
563
+ record.
564
+ cubic feet per second—temporal"""
565
+ ML6 = _make_ML_1_12(6)
566
+ ML6.__doc__ = """ML6
567
+ Mean (or median) of minimum flows for each month across all years. Compute the
568
+ minimums for each month over the entire flow record.
569
+
570
+ ML6 is the mean of the minimums of all June flow values over the entire
571
+ record.
572
+ cubic feet per second—temporal"""
573
+ ML7 = _make_ML_1_12(7)
574
+ ML7.__doc__ = """ML7
575
+ Mean (or median) of minimum flows for each month across all years. Compute the
576
+ minimums for each month over the entire flow record.
577
+
578
+ ML7 is the mean of the minimums of all July flow values over the entire
579
+ record.
580
+ cubic feet per second—temporal"""
581
+ ML8 = _make_ML_1_12(8)
582
+ ML8.__doc__ = """ML8
583
+ Mean (or median) of minimum flows for each month across all years. Compute the
584
+ minimums for each month over the entire flow record.
585
+
586
+ ML8 is the mean of the minimums of all August flow values over the entire
587
+ record.
588
+ cubic feet per second—temporal"""
589
+ ML9 = _make_ML_1_12(9)
590
+ ML9.__doc__ = """ML9
591
+ Mean (or median) of minimum flows for each month across all years. Compute the
592
+ minimums for each month over the entire flow record.
593
+
594
+ ML9 is the mean of the minimums of all September flow values over the entire
595
+ record.
596
+ cubic feet per second—temporal"""
597
+ ML10 = _make_ML_1_12(10)
598
+ ML10.__doc__ = """ML10
599
+ Mean (or median) of minimum flows for each month across all years. Compute the
600
+ minimums for each month over the entire flow record.
601
+
602
+ ML10 is the mean of the minimums of all October flow values over the entire
603
+ record.
604
+ cubic feet per second—temporal"""
605
+ ML11 = _make_ML_1_12(11)
606
+ ML11.__doc__ = """ML11
607
+ Mean (or median) of minimum flows for each month across all years. Compute the
608
+ minimums for each month over the entire flow record.
609
+
610
+ ML11 is the mean of the minimums of all November flow values over the entire
611
+ record.
612
+ cubic feet per second—temporal"""
613
+ ML12 = _make_ML_1_12(12)
614
+ ML12.__doc__ = """ML12
615
+ Mean (or median) of minimum flows for each month across all years. Compute the
616
+ minimums for each month over the entire flow record.
617
+
618
+ ML12 is the mean of the minimums of all December flow values over the entire
619
+ record.
620
+ cubic feet per second—temporal"""
621
+
622
+ def ML13(self):
623
+ """ML13
624
+ Variability (coefficient of variation) across minimum monthly flow
625
+ values. Compute the mean and standard deviation for the minimum monthly
626
+ flows over the entire flow record. ML13 is the standard deviation times
627
+ 100 divided by the mean minimum monthly flow for all years.
628
+ percent—spatial"""
629
+ return self.data_monthly_min.std() / self.data_monthly_min.mean() * 100
630
+
631
+ def ML14(self):
632
+ """ML14
633
+ Compute the minimum annual flow for each year. ML14 is the mean of the
634
+ ratios of minimum annual flows to the median flow for each year.
635
+ dimensionless—temporal"""
636
+ return (
637
+ self.data_yearly_min
638
+ / self.data.groupby(pd.Grouper(freq=self.water_year)).median()
639
+ ).mean()
640
+
641
+ def ML15(self):
642
+ """ML15
643
+ Low-flow index. ML15 is the mean of the ratios of minimum annual flows
644
+ to the mean flow for each year.
645
+ dimensionless—temporal"""
646
+ return (self.data_yearly_min / self.data_yearly_mean).mean()
647
+
648
+ def ML16(self):
649
+ """ML16
650
+ Median of annual minimum flows. ML16 is the median of the ratios of
651
+ minimum annual flows to the median flow for each year.
652
+ dimensionless— temporal"""
653
+ return (self.data_yearly_min / self.data_yearly.median()).median()
654
+
655
+ def ML17(self):
656
+ """ML17
657
+ Base flow. Compute the mean annual flows. Compute the minimum of
658
+ a 7-day moving average flows for each year and divide them by the mean
659
+ annual flow for that year. ML17 is the mean (or median if use_median is
660
+ set) of those ratios.
661
+ dimensionless—temporal"""
662
+ stat = (
663
+ self.data.rolling(7).mean().groupby(pd.Grouper(freq=self.water_year)).min()
664
+ / self.data_yearly_mean
665
+ )
666
+ return stat.median() if self.use_median is True else stat.mean()
667
+
668
+ def ML18(self):
669
+ """ML18
670
+ Variability in base flow. Compute the standard deviation for the ratios
671
+ of 7-day moving average flows to mean annual flows for each year. ML18
672
+ is the standard deviation times 100 divided by the mean of the ratios.
673
+ percent—spatial"""
674
+ ratios = (
675
+ self.data.rolling(7).mean().groupby(pd.Grouper(freq=self.water_year))
676
+ ).min() / self.data_yearly_mean
677
+ return ratios.std() / ratios.mean() * 100
678
+
679
+ def ML19(self):
680
+ """ML19
681
+ Base flow. Compute the ratios of the minimum annual flow to mean annual
682
+ flow for each year. ML19 is the mean (or median) of these ratios times
683
+ 100.
684
+ dimensionless—temporal"""
685
+ if self.use_median is True:
686
+ return (self.data_yearly_min / self.data_yearly_mean).median() * 100
687
+ return (self.data_yearly_min / self.data_yearly_mean).mean() * 100
688
+
689
+ def ML20(self):
690
+ """ML20
691
+ Base flow. Divide the daily flow record into 5-day blocks. Find the
692
+ minimum flow for each block. Assign the minimum flow as a base flow for
693
+ that block if 90 percent of that minimum flow is less than the minimum
694
+ flows for the blocks on either side. Otherwise, set it to zero. Fill in
695
+ the zero values using linear interpolation. Compute the total flow for
696
+ the entire record and the total base flow for the entire record. ML20
697
+ is the ratio of total flow to total base flow.
698
+ dimensionless—spatial"""
699
+ from ..baseflow_sep import five_day
700
+
701
+ newq = five_day(self.data)
702
+ return (newq.sum() / self.data.sum()).iloc[0]
703
+
704
+ def ML21(self):
705
+ """ML21
706
+ Variability across annual minimum flows. Compute the mean and standard
707
+ deviation for the annual minimum flows. ML21 is the standard deviation
708
+ times 100 divided by the mean.
709
+ percent—spatial"""
710
+ return self.data_yearly_min.std() / self.data_yearly_min.mean() * 100
711
+
712
+ def ML22(self):
713
+ """ML22
714
+ Specific mean annual minimum flow. ML22 is the mean (or median) of the
715
+ annual minimum flows divided by the drainage area.
716
+ cubic feet per second/square mile—temporal"""
717
+ return self.data_yearly_min.mean() / self.drainage_area
718
+
719
+ def _make_MH_1_12(month: int):
720
+ def template(self):
721
+ stat = self.data_monthly_max[self.data_monthly_max.index.month == month]
722
+ return stat.median() if self.use_median is True else stat.mean()
723
+
724
+ return template
725
+
726
+ MH1 = _make_MH_1_12(1)
727
+ MH1.__doc__ = """MH1
728
+ Mean (or median) maximum flows for each month across all years. Compute the
729
+ maximums for each month over the entire cubic feet per flow record.
730
+
731
+ MH1 is the mean of the maximums of all January flow values over the entire
732
+ record.
733
+ second—temporal"""
734
+ MH2 = _make_MH_1_12(2)
735
+ MH2.__doc__ = """MH2
736
+ Mean (or median) maximum flows for each month across all years. Compute the
737
+ maximums for each month over the entire cubic feet per flow record.
738
+
739
+ MH2 is the mean of the maximums of all February flow values over the entire
740
+ record.
741
+ second—temporal"""
742
+ MH3 = _make_MH_1_12(3)
743
+ MH3.__doc__ = """MH3
744
+ Mean (or median) maximum flows for each month across all years. Compute the
745
+ maximums for each month over the entire cubic feet per flow record.
746
+
747
+ MH3 is the mean of the maximums of all March flow values over the entire
748
+ record.
749
+ second—temporal"""
750
+ MH4 = _make_MH_1_12(4)
751
+ MH4.__doc__ = """MH4
752
+ Mean (or median) maximum flows for each month across all years. Compute the
753
+ maximums for each month over the entire cubic feet per flow record.
754
+
755
+ MH4 is the mean of the maximums of all April flow values over the entire
756
+ record.
757
+ second—temporal"""
758
+ MH5 = _make_MH_1_12(5)
759
+ MH5.__doc__ = """MH5
760
+ Mean (or median) maximum flows for each month across all years. Compute the
761
+ maximums for each month over the entire cubic feet per flow record.
762
+
763
+ MH5 is the mean of the maximums of all May flow values over the entire
764
+ record.
765
+ second—temporal"""
766
+ MH6 = _make_MH_1_12(6)
767
+ MH6.__doc__ = """MH6
768
+ Mean (or median) maximum flows for each month across all years. Compute the
769
+ maximums for each month over the entire cubic feet per flow record.
770
+
771
+ MH6 is the mean of the maximums of all June flow values over the entire
772
+ record.
773
+ second—temporal"""
774
+ MH7 = _make_MH_1_12(7)
775
+ MH7.__doc__ = """MH7
776
+ Mean (or median) maximum flows for each month across all years. Compute the
777
+ maximums for each month over the entire cubic feet per flow record.
778
+
779
+ MH7 is the mean of the maximums of all July flow values over the entire
780
+ record.
781
+ second—temporal"""
782
+ MH8 = _make_MH_1_12(8)
783
+ MH8.__doc__ = """MH8
784
+ Mean (or median) maximum flows for each month across all years. Compute the
785
+ maximums for each month over the entire cubic feet per flow record.
786
+
787
+ MH8 is the mean of the maximums of all August flow values over the entire
788
+ record.
789
+ second—temporal"""
790
+ MH9 = _make_MH_1_12(9)
791
+ MH9.__doc__ = """MH9
792
+ Mean (or median) maximum flows for each month across all years. Compute the
793
+ maximums for each month over the entire cubic feet per flow record.
794
+
795
+ MH9 is the mean of the maximums of all September flow values over the entire
796
+ record.
797
+ second—temporal"""
798
+ MH10 = _make_MH_1_12(10)
799
+ MH10.__doc__ = """MH10
800
+ Mean (or median) maximum flows for each month across all years. Compute the
801
+ maximums for each month over the entire cubic feet per flow record.
802
+
803
+ MH10 is the mean of the maximums of all October flow values over the entire
804
+ record.
805
+ second—temporal"""
806
+ MH11 = _make_MH_1_12(11)
807
+ MH11.__doc__ = """MH11
808
+ Mean (or median) maximum flows for each month across all years. Compute the
809
+ maximums for each month over the entire cubic feet per flow record.
810
+
811
+ MH11 is the mean of the maximums of all November flow values over the entire
812
+ record.
813
+ second—temporal"""
814
+ MH12 = _make_MH_1_12(12)
815
+ MH12.__doc__ = """MH12
816
+ Mean (or median) maximum flows for each month across all years. Compute the
817
+ maximums for each month over the entire cubic feet per flow record.
818
+
819
+ MH12 is the mean of the maximums of all December flow values over the entire
820
+ record.
821
+ second—temporal"""
822
+
823
+ def MH13(self):
824
+ """MH13
825
+ Variability (coefficient of variation) across maximum monthly flow
826
+ values. Compute the mean and standard deviation for the maximum monthly
827
+ flows over the entire flow record. MH13 is the standard deviation times
828
+ 100 divided by the mean maximum monthly flow for all years.
829
+ percent—spatial"""
830
+ return self.data_monthly_max.std() / self.data_monthly_max.mean() * 100
831
+
832
+ def MH14(self):
833
+ """MH14
834
+ Median of annual maximum flows. Compute the annual maximum flows from
835
+ monthly maximum flows. Compute the ratio of annual maximum flow to
836
+ median annual flow for each year. MH14 is the median of these ratios.
837
+ dimensionless—temporal"""
838
+ return (self.data_yearly_max / self.data_yearly.median()).median()
839
+
840
+ def _MH_15_17(quant: float):
841
+ def template(self):
842
+ return self.data.quantile(quant) / self.MA2()
843
+
844
+ return template
845
+
846
+ MH15 = _MH_15_17(0.99)
847
+ MH15.__doc__ = """MH15
848
+ High flow discharge index. Compute the 1-percent exceedance value for the
849
+ entire data record.
850
+
851
+ MH15 is the 1-percent exceedance value divided by the median flow for the
852
+ entire record.
853
+ dimensionless—spatial"""
854
+ MH16 = _MH_15_17(0.90)
855
+ MH16.__doc__ = """MH16
856
+ High flow discharge index. Compute the 1-percent exceedance value for the
857
+ entire data record.
858
+
859
+ MH16 is the 10-percent exceedance value divided by the median flow for the
860
+ entire record.
861
+ dimensionless—spatial"""
862
+ MH17 = _MH_15_17(0.75)
863
+ MH17.__doc__ = """MH17
864
+ High flow discharge index. Compute the 1-percent exceedance value for the
865
+ entire data record.
866
+
867
+ MH17 is the 25-percent exceedance value divided by the median flow for the
868
+ entire record.
869
+ dimensionless—spatial"""
870
+
871
+ def MH18(self):
872
+ """MH18
873
+ Variability across annual maximum flows. Compute the logs (log10) of
874
+ the maximum annual flows. Find the standard percent—spatial deviation
875
+ and mean for these values. MH18 is the standard deviation times 100
876
+ divided by the mean."""
877
+ log10 = np.log10(self.data_yearly_max)
878
+ return log10.std() / log10.mean() * 100
879
+
880
+ def MH19(self):
881
+ qm = np.log10(self.data_yearly_max)
882
+ N = self.data_yearly_max.count()
883
+ S = qm.std()
884
+ return (
885
+ N**2 * (qm**3).sum()
886
+ - 3 * N * qm.sum() * (qm**2).sum()
887
+ + 2 * (qm.sum()) ** 3
888
+ ) / (N * (N - 1) * (N - 2) * S**3)
889
+
890
+ def MH20(self):
891
+ if self.use_median:
892
+ return self.data_yearly_max.median() / self.drainage_area
893
+ return self.data_yearly_max.mean() / self.drainage_area
894
+
895
+ def _make_MH_21_23(med_mult: int):
896
+ def template(self):
897
+ med = self.MA2()
898
+ flow = self.data - (med_mult * med)
899
+
900
+ flow[flow < 0] = 0.0
901
+ if flow[flow > 0].count() == 0:
902
+ return None
903
+
904
+ # Mean of the yearly volume (sum of flows) above the median
905
+ # * med_mult
906
+ qmean = flow.groupby(pd.Grouper(freq=self.water_year)).sum().mean()
907
+
908
+ nevents = (flow > 0) & (flow.shift(-1) == 0)
909
+ nevents = nevents.groupby(pd.Grouper(freq=self.water_year)).sum().mean()
910
+
911
+ return qmean / nevents / med
912
+
913
+ return template
914
+
915
+ MH21 = _make_MH_21_23(1)
916
+ MH22 = _make_MH_21_23(3)
917
+ MH23 = _make_MH_21_23(7)
918
+
919
+ def _make_MH_24_26(med_mult: int = 1, quantile: Optional[float] = None):
920
+ def template(self):
921
+ if quantile is not None:
922
+ medm = self.data.quantile(quantile)
923
+ else:
924
+ medm = self.MA2() * med_mult
925
+
926
+ peaks, _ = find_peaks(self.data, height=medm)
927
+ return self.data[peaks].mean() / self.MA2()
928
+
929
+ return template
930
+
931
+ MH24 = _make_MH_24_26(med_mult=1)
932
+ MH25 = _make_MH_24_26(med_mult=3)
933
+ MH26 = _make_MH_24_26(med_mult=7)
934
+ MH27 = _make_MH_24_26(quantile=0.75)
935
+
936
+ def event_statistics(self, thresh, than):
937
+ """Event statistics.
938
+
939
+ Parameters
940
+ ----------
941
+ thresh : float
942
+ Threshold value.
943
+ than : str
944
+ Comparison operator.
945
+
946
+ Returns
947
+ -------
948
+ Given threshold and comparison, returns number of matching events per
949
+ year, average duration of events, count of all matching days for each
950
+ year.
951
+ """
952
+ nnp = {}
953
+ lfdur = {}
954
+ allnp = {}
955
+ for group_name, group_df in self.data_yearly:
956
+ nnp[group_name] = 0
957
+ lfdur[group_name] = 0
958
+ allnp[group_name] = 0
959
+ pdur = 0
960
+ flag = 0
961
+ for index, value in group_df.items():
962
+ if eval(f"value {than} thresh"):
963
+ pdur = pdur + 1
964
+ flag = flag + 1
965
+ allnp[group_name] += 1
966
+ if flag == 1:
967
+ nnp[group_name] += 1
968
+ else:
969
+ flag = 0
970
+ if nnp[group_name] > 0:
971
+ lfdur[group_name] = pdur / nnp[group_name]
972
+ lfdur = pd.Series(data=lfdur.values())
973
+ lfdur = lfdur[lfdur > 0]
974
+ return pd.Series(data=nnp.values()), lfdur, pd.Series(data=allnp.values())
975
+
976
+ def FL1(self):
977
+ thresh = self.data.quantile(0.25)
978
+ nnp, _, _ = self.event_statistics(thresh, "<")
979
+ return nnp.median() if self.use_median is True else nnp.mean()
980
+
981
+ def FL2(self):
982
+ thresh = self.data.quantile(0.25)
983
+ nnp, _, _ = self.event_statistics(thresh, "<")
984
+ return nnp.std() / nnp.mean() * 100
985
+
986
+ def FL3(self):
987
+ thresh = self.data.mean() * 0.05
988
+ nnp, _, _ = self.event_statistics(thresh, "<")
989
+ return nnp.median() if self.use_median is True else nnp.mean()
990
+
991
+ def FH1(self):
992
+ thresh = self.data.quantile(0.75)
993
+ nnp, _, _ = self.event_statistics(thresh, ">")
994
+ return nnp.median() if self.use_median is True else nnp.mean()
995
+
996
+ def FH2(self):
997
+ thresh = self.data.quantile(0.75)
998
+ nnp, _, _ = self.event_statistics(thresh, ">")
999
+ return nnp.std() / nnp.mean() * 100
1000
+
1001
+ def _make_FH_3_4(med_mult: int):
1002
+ def template(self):
1003
+ thresh = med_mult * self.MA2()
1004
+ _, _, pdur = self.event_statistics(thresh, ">")
1005
+ return pdur.median() if self.use_median is True else pdur.mean()
1006
+
1007
+ return template
1008
+
1009
+ FH3 = _make_FH_3_4(3)
1010
+ FH4 = _make_FH_3_4(7)
1011
+
1012
+ def _make_FH_5_7(med_mult: int):
1013
+ def template(self):
1014
+ thresh = self.MA2() * med_mult
1015
+ nnp, _, _ = self.event_statistics(thresh, ">")
1016
+ return nnp.median() if self.use_median is True else nnp.mean()
1017
+
1018
+ return template
1019
+
1020
+ FH5 = _make_FH_5_7(1)
1021
+ FH6 = _make_FH_5_7(3)
1022
+ FH7 = _make_FH_5_7(7)
1023
+
1024
+ def _make_FH_8_9(quant: float):
1025
+ def template(self):
1026
+ thresh = self.data.quantile(quant)
1027
+ nnp, _, _ = self.event_statistics(thresh, ">")
1028
+ return nnp.median() if self.use_median is True else nnp.mean()
1029
+
1030
+ return template
1031
+
1032
+ FH8 = _make_FH_8_9(0.75)
1033
+ FH9 = _make_FH_8_9(0.25)
1034
+
1035
+ def FH10(self):
1036
+ thresh = self.data_yearly.min().median()
1037
+ nnp, _, _ = self.event_statistics(thresh, ">")
1038
+ return nnp.median() if self.use_median is True else nnp.mean()
1039
+
1040
+ def FH11(self):
1041
+ return None
1042
+
1043
+ def DL1(self):
1044
+ stat = self.data_yearly.min()
1045
+ return stat.median() if self.use_median is True else stat.mean()
1046
+
1047
+ def _preroll(self, days, stattype):
1048
+ stats = []
1049
+ for _, vals in self.data_yearly:
1050
+ rmean = vals.rolling(days).mean()
1051
+ if stattype == "min":
1052
+ stats.append(rmean.min())
1053
+ elif stattype == "max":
1054
+ stats.append(rmean.max())
1055
+ return pd.Series(data=stats, index=range(len(stats)))
1056
+
1057
+ def _roll(self, days, stattype):
1058
+ stat = self._preroll(days, stattype)
1059
+ return stat.median() if self.use_median is True else stat.mean()
1060
+
1061
+ def _make_DL_2_5_DH_2_5(days: int, stat):
1062
+ def template(self):
1063
+ return self._roll(days, stat)
1064
+
1065
+ return template
1066
+
1067
+ DL2 = _make_DL_2_5_DH_2_5(3, "min")
1068
+ DL3 = _make_DL_2_5_DH_2_5(7, "min")
1069
+ DL4 = _make_DL_2_5_DH_2_5(30, "min")
1070
+ DL5 = _make_DL_2_5_DH_2_5(90, "min")
1071
+
1072
+ def _make_DL_6_10_DH_6_10(days: int, instat):
1073
+ def template(self):
1074
+ stat = self._preroll(days, instat)
1075
+ return stat.std() / stat.mean() * 100
1076
+
1077
+ return template
1078
+
1079
+ DL6 = _make_DL_6_10_DH_6_10(1, "min")
1080
+ DL7 = _make_DL_6_10_DH_6_10(3, "min")
1081
+ DL8 = _make_DL_6_10_DH_6_10(7, "min")
1082
+ DL9 = _make_DL_6_10_DH_6_10(30, "min")
1083
+ DL10 = _make_DL_6_10_DH_6_10(90, "min")
1084
+
1085
+ def DL11(self):
1086
+ return self.data_yearly_min.mean() / self.MA2()
1087
+
1088
+ def _make_DL_12_13_DH_12_13(days: int, instat: str):
1089
+ def template(self):
1090
+ stat = self._preroll(days, instat)
1091
+ return stat.mean() / self.MA2()
1092
+
1093
+ return template
1094
+
1095
+ DL12 = _make_DL_12_13_DH_12_13(7, "min")
1096
+ DL13 = _make_DL_12_13_DH_12_13(30, "min")
1097
+
1098
+ def DL14(self):
1099
+ return self.data.quantile(0.25) / self.MA2()
1100
+
1101
+ def DL15(self):
1102
+ return self.data.quantile(0.1) / self.MA2()
1103
+
1104
+ def DL16(self):
1105
+ thresh = self.data.quantile(0.25)
1106
+ _, lfdur, _ = self.event_statistics(thresh, "<")
1107
+ return lfdur.median()
1108
+
1109
+ def DL17(self):
1110
+ thresh = self.data.quantile(0.25)
1111
+ _, lfdur, _ = self.event_statistics(thresh, "<")
1112
+ return lfdur.std() / lfdur.mean() * 100
1113
+
1114
+ def DL18(self):
1115
+ stat = (
1116
+ self.data[self.data == 0].groupby(pd.Grouper(freq=self.water_year)).count()
1117
+ )
1118
+ if any(stat):
1119
+ return stat.median() if self.use_median is True else stat.mean()
1120
+ return 0
1121
+
1122
+ def DL19(self):
1123
+ stat = (
1124
+ self.data[self.data == 0].groupby(pd.Grouper(freq=self.water_year)).count()
1125
+ )
1126
+ ret = stat.std() / stat.mean() * 100
1127
+ try:
1128
+ return ret.fillna(0)
1129
+ except AttributeError:
1130
+ return 0 if isinstance(ret, type(pd.NA)) else ret
1131
+
1132
+ def DL20(self):
1133
+ return self.data_monthly_mean[self.data_monthly_mean == 0].count()
1134
+
1135
+ def DH1(self):
1136
+ stat = self.data_yearly.max()
1137
+ stat = stat.median() if self.use_median else stat.mean()
1138
+ return stat
1139
+
1140
+ DH2 = _make_DL_2_5_DH_2_5(3, "max")
1141
+ DH3 = _make_DL_2_5_DH_2_5(7, "max")
1142
+ DH4 = _make_DL_2_5_DH_2_5(30, "max")
1143
+ DH5 = _make_DL_2_5_DH_2_5(90, "max")
1144
+
1145
+ DH6 = _make_DL_6_10_DH_6_10(1, "max")
1146
+ DH7 = _make_DL_6_10_DH_6_10(3, "max")
1147
+ DH8 = _make_DL_6_10_DH_6_10(7, "max")
1148
+ DH9 = _make_DL_6_10_DH_6_10(30, "max")
1149
+ DH10 = _make_DL_6_10_DH_6_10(90, "max")
1150
+
1151
+ def DH11(self):
1152
+ return self.data_yearly_max.mean() / self.MA2()
1153
+
1154
+ DH12 = _make_DL_12_13_DH_12_13(7, "max")
1155
+ DH13 = _make_DL_12_13_DH_12_13(30, "max")
1156
+
1157
+ def DH14(self):
1158
+ return self.data_monthly_mean.quantile(0.95) / self.data_monthly_mean.mean()
1159
+
1160
+ def DH15(self):
1161
+ thresh = self.data.quantile(0.75)
1162
+ _, lfdur, _ = self.event_statistics(thresh, ">")
1163
+ return lfdur.median()
1164
+
1165
+ def DH16(self):
1166
+ thresh = self.data.quantile(0.75)
1167
+ _, lfdur, _ = self.event_statistics(thresh, ">")
1168
+ return lfdur.std() / lfdur.mean() * 100
1169
+
1170
+ def DH17(self):
1171
+ thresh = self.MA2()
1172
+ _, lfdur, _ = self.event_statistics(thresh, ">")
1173
+ return lfdur.median() if self.use_median else lfdur.mean()
1174
+
1175
+ def DH18(self):
1176
+ thresh = self.MA2() * 3
1177
+ _, lfdur, _ = self.event_statistics(thresh, ">")
1178
+ return lfdur.median() if self.use_median else lfdur.mean()
1179
+
1180
+ def DH19(self):
1181
+ thresh = self.MA2() * 7
1182
+ _, lfdur, _ = self.event_statistics(thresh, ">")
1183
+ return lfdur.median() if self.use_median else lfdur.mean()
1184
+
1185
+ def DH20(self):
1186
+ thresh = self.data.quantile(0.75)
1187
+ _, lfdur, _ = self.event_statistics(thresh, ">")
1188
+ return lfdur.median() if self.use_median else lfdur.mean()
1189
+
1190
+ def DH21(self):
1191
+ thresh = self.data.quantile(0.25)
1192
+ _, lfdur, _ = self.event_statistics(thresh, ">")
1193
+ return lfdur.median() if self.use_median else lfdur.mean()
1194
+
1195
+ def DH22(self):
1196
+ return None
1197
+
1198
+ def DH23(self):
1199
+ return None
1200
+
1201
+ def DH24(self):
1202
+ return None
1203
+
1204
+ def _pre_ta1_ta2(self):
1205
+ nrows = 11
1206
+ lq = self.data.apply(np.log10)
1207
+ lma1 = np.log10(self.MA1())
1208
+
1209
+ lq[self.data == 0.0] = np.log10(0.01)
1210
+
1211
+ table = [
1212
+ lq[lq < 0.1 * lma1],
1213
+ lq[(lq >= 0.1 * lma1) & (lq < 0.25 * lma1)],
1214
+ lq[(lq >= 0.25 * lma1) & (lq < 0.5 * lma1)],
1215
+ lq[(lq >= 0.5 * lma1) & (lq < 0.75 * lma1)],
1216
+ lq[(lq >= 0.75 * lma1) & (lq < lma1)],
1217
+ lq[(lq >= lma1) & (lq < 1.25 * lma1)],
1218
+ lq[(lq >= 1.25 * lma1) & (lq < 1.5 * lma1)],
1219
+ lq[(lq >= 1.5 * lma1) & (lq < 1.75 * lma1)],
1220
+ lq[(lq >= 1.75 * lma1) & (lq < 2.0 * lma1)],
1221
+ lq[(lq >= 2.0 * lma1) & (lq < 2.25 * lma1)],
1222
+ lq[lq >= 2.25 * lma1],
1223
+ ]
1224
+
1225
+ ndf = pd.DataFrame()
1226
+ for indx, df in enumerate(table):
1227
+ if df.empty:
1228
+ ndf = pd.concat(
1229
+ [
1230
+ ndf,
1231
+ pd.DataFrame(
1232
+ data=[0] * 365, index=range(1, 366), columns=[indx]
1233
+ ),
1234
+ ],
1235
+ axis="columns",
1236
+ )
1237
+ continue
1238
+ ldf = [df[df.index.dayofyear == day].count() for day in range(1, 366)]
1239
+ ndf = pd.concat(
1240
+ [ndf, pd.DataFrame(data=ldf, index=range(1, 366), columns=[indx])],
1241
+ axis="columns",
1242
+ )
1243
+ Z = ndf.sum().sum()
1244
+ XJ = ndf.T.sum()
1245
+ YI = ndf.sum()
1246
+ HX = -(XJ / Z * np.log10(XJ / Z)).sum()
1247
+ HY = -(YI / Z * np.log10(YI / Z)).sum()
1248
+ HXY = -(ndf / Z * np.log10(ndf / Z)).sum().sum()
1249
+ HXY = HXY - HX
1250
+ return nrows, HY, HXY
1251
+
1252
+ def TA1(self):
1253
+ nrows, HY, _ = self._pre_ta1_ta2()
1254
+ return 1 - (HY / np.log10(nrows))
1255
+
1256
+ def TA2(self):
1257
+ nrows, _, HXY = self._pre_ta1_ta2()
1258
+ return 100 * (1 - (HXY / np.log10(nrows)))
1259
+
1260
+ def TA3(self):
1261
+ return None
1262
+
1263
+ def _min_max_doy(self, stat):
1264
+ if stat == "min":
1265
+ jd = (
1266
+ self.data.groupby(pd.Grouper(freq=self.water_year))
1267
+ .idxmin()
1268
+ .dt.dayofyear
1269
+ )
1270
+ if stat == "max":
1271
+ jd = (
1272
+ self.data.groupby(pd.Grouper(freq=self.water_year))
1273
+ .idxmax()
1274
+ .dt.dayofyear
1275
+ )
1276
+ jd[jd > 365.25] = jd[jd > 365.25] - 365.25
1277
+ jd = jd * 2 * np.pi / 365.25
1278
+ xbar = np.cos(jd).mean()
1279
+ ybar = np.sin(jd).mean()
1280
+ return xbar, ybar
1281
+
1282
+ def TL1(self):
1283
+ """TL1
1284
+ Julian date of annual minimum. Determine the Julian date of the minimum
1285
+ flow for each water year. Transform the dates to relative values on
1286
+ a circular scale (radians or degrees). Compute the x and y components
1287
+ for each year, and average them across all years. Compute the mean
1288
+ angle as the arc tangent of y-mean divided by x-mean. Transform the
1289
+ resultant angle back to Julian date.
1290
+ Julian day—spatial"""
1291
+ xbar, ybar = self._min_max_doy("min")
1292
+ TL1 = np.arctan2(ybar, xbar) * 180.0 / np.pi
1293
+ if TL1 < 0.0:
1294
+ TL1 = TL1 + 360.0
1295
+ TL1 = TL1 * 365.25 / 360.0
1296
+ return TL1
1297
+
1298
+ def TL2(self):
1299
+ """TL2
1300
+ Variability in Julian date of annual minima. Compute the coefficient of
1301
+ variation for the mean x and y components, and convert to a date.
1302
+ Julian day—spatial"""
1303
+ xbar, ybar = self._min_max_doy("min")
1304
+ temp = np.sqrt(xbar * xbar + ybar * ybar)
1305
+ temp = np.sqrt(2 * (1 - temp))
1306
+ return temp * 180 / np.pi / 360 * 365.25
1307
+
1308
+ def TL3(self):
1309
+ return None
1310
+
1311
+ def TL4(self):
1312
+ return None
1313
+
1314
+ def TH1(self):
1315
+ """TH1
1316
+ Julian date of annual maximum. Determine the Julian date of the maximum
1317
+ flow for each year. Transform the dates to relative values on a circular
1318
+ scale (radians or degrees). Compute the x and y components for each
1319
+ year, and average them across all years. Compute the mean angle as the
1320
+ arc tangent of y-mean divided by x-mean. Transform the resultant angle
1321
+ back to Julian date. Julian day—spatial"""
1322
+ xbar, ybar = self._min_max_doy("max")
1323
+ TH1 = np.arctan2(ybar, xbar) * 180.0 / np.pi
1324
+ if TH1 < 0.0:
1325
+ TH1 = TH1 + 360.0
1326
+ TH1 = TH1 * 365.25 / 360.0
1327
+ return TH1
1328
+
1329
+ def TH2(self):
1330
+ """TH2
1331
+ Variability in Julian date of annual maxima. Compute the coefficient of
1332
+ variation for the mean x and y components and convert to a date.
1333
+ Julian days—spatial"""
1334
+ xbar, ybar = self._min_max_doy("max")
1335
+ temp = np.sqrt(xbar * xbar + ybar * ybar)
1336
+ temp = np.sqrt(2 * (1 - temp))
1337
+ return temp * 180 / np.pi / 360 * 365.25
1338
+
1339
+ def TH3(self):
1340
+ return None
1341
+
1342
+ def _rise_rate(self):
1343
+ delt = self.data.shift(1) - self.data
1344
+ return delt[delt < 0]
1345
+
1346
+ def _fall_rate(self):
1347
+ delt = self.data.shift(1) - self.data
1348
+ return delt[delt > 0]
1349
+
1350
+ def RA1(self):
1351
+ if self.use_median:
1352
+ return -self._rise_rate().median()
1353
+ return -self._rise_rate().mean()
1354
+
1355
+ def RA2(self):
1356
+ rr = self._rise_rate()
1357
+ return -rr.std() / rr.mean() * 100
1358
+
1359
+ def RA3(self):
1360
+ if self.use_median:
1361
+ return self._fall_rate().median()
1362
+ return self._fall_rate().mean()
1363
+
1364
+ def RA4(self):
1365
+ rr = self._fall_rate()
1366
+ return rr.std() / rr.mean() * 100
1367
+
1368
+ def RA5(self):
1369
+ rr = self._rise_rate()
1370
+ return len(rr) / len(self.data)
1371
+
1372
+ def RA6(self):
1373
+ log = self.data.apply(np.log)
1374
+ log = log.shift(1) - log
1375
+ log = -log[log < 0]
1376
+ return log.median()
1377
+
1378
+ def RA7(self):
1379
+ log = self.data.apply(np.log)
1380
+ log = log.shift(1) - log
1381
+ log = log[log > 0]
1382
+ return log.median()
1383
+
1384
+ def _changes(self):
1385
+ peaks = find_peaks(self.data)[0]
1386
+ valleys = find_peaks(-self.data)[0]
1387
+ changes = np.append(peaks, valleys)
1388
+ changes = pd.DataFrame(self.data[changes])
1389
+ df = pd.DataFrame(range(len(changes.index)), index=changes.index)
1390
+ df = df.groupby(pd.Grouper(freq=self.water_year)).count()
1391
+ return df
1392
+
1393
+ def RA8(self):
1394
+ df = self._changes()
1395
+ return df.median()[0] if self.use_median else df.mean()[0]
1396
+
1397
+ def RA9(self):
1398
+ df = self._changes()
1399
+ return (df.std() / df.mean())[0] * 100
1400
+
1401
+
1402
+ if __name__ == "__main__":
1403
+ df = pd.read_csv(
1404
+ # "../../../tests/data_02239501.csv", index_col="Datetime", parse_dates=True
1405
+ "../../../tests/data_percentile_test.csv",
1406
+ index_col="Datetime",
1407
+ parse_dates=True,
1408
+ )
1409
+ ndf = df.iloc[:, 0]
1410
+ ind = Indices(ndf)
1411
+ print("MA1 = ", ind.MA1())
1412
+ print("MA2 = ", ind.MA2())
1413
+ print("MA3 = ", ind.MA3())
1414
+ print("MA4 = ", ind.MA4())
1415
+ print("MA5 = ", ind.MA5())
1416
+ print("MA6 = ", ind.MA6())
1417
+ print("MA7 = ", ind.MA7())
1418
+ print("MA8 = ", ind.MA8())
1419
+ print("MA9 = ", ind.MA9())
1420
+ print("MA10 = ", ind.MA10())
1421
+ print("MA11 = ", ind.MA11())
1422
+ print("MA12 = ", ind.MA12())
1423
+ print("MA13 = ", ind.MA13())
1424
+ print("MA14 = ", ind.MA14())
1425
+ print("MA15 = ", ind.MA15())
1426
+ print("MA16 = ", ind.MA16())
1427
+ print("MA17 = ", ind.MA17())
1428
+ print("MA18 = ", ind.MA18())
1429
+ print("MA19 = ", ind.MA19())
1430
+ print("MA20 = ", ind.MA20())
1431
+ print("MA21 = ", ind.MA21())
1432
+ print("MA22 = ", ind.MA22())
1433
+ print("MA23 = ", ind.MA23())
1434
+ print("MA24 = ", ind.MA24())
1435
+ print("MA25 = ", ind.MA25())
1436
+ print("MA26 = ", ind.MA26())
1437
+ print("MA27 = ", ind.MA27())
1438
+ print("MA28 = ", ind.MA28())
1439
+ print("MA29 = ", ind.MA29())
1440
+ print("MA30 = ", ind.MA30())
1441
+ print("MA31 = ", ind.MA31())
1442
+ print("MA32 = ", ind.MA32())
1443
+ print("MA33 = ", ind.MA33())
1444
+ print("MA34 = ", ind.MA34())
1445
+ print("MA35 = ", ind.MA35())
1446
+ print("MA36 = ", ind.MA36())
1447
+ print("MA37 = ", ind.MA37())
1448
+ print("MA38 = ", ind.MA38())
1449
+ print("MA39 = ", ind.MA39())
1450
+ print("MA40 = ", ind.MA40())
1451
+ print("MA41 = ", ind.MA41())
1452
+ print("MA42 = ", ind.MA42())
1453
+ print("MA43 = ", ind.MA43())
1454
+ print("MA44 = ", ind.MA44())
1455
+ print("MA45 = ", ind.MA45())
1456
+ print("ML1 = ", ind.ML1())
1457
+ print("ML2 = ", ind.ML2())
1458
+ print("ML3 = ", ind.ML3())
1459
+ print("ML4 = ", ind.ML4())
1460
+ print("ML5 = ", ind.ML5())
1461
+ print("ML6 = ", ind.ML6())
1462
+ print("ML7 = ", ind.ML7())
1463
+ print("ML8 = ", ind.ML8())
1464
+ print("ML9 = ", ind.ML9())
1465
+ print("ML10 = ", ind.ML10())
1466
+ print("ML11 = ", ind.ML11())
1467
+ print("ML12 = ", ind.ML12())
1468
+ print("ML13 = ", ind.ML13())
1469
+ print("ML14 = ", ind.ML14())
1470
+ print("ML15 = ", ind.ML15())
1471
+ print("ML16 = ", ind.ML16())
1472
+ print("ML17 = ", ind.ML17())
1473
+ print("ML18 = ", ind.ML18())
1474
+ print("ML19 = ", ind.ML19())
1475
+ print("ML20 = ", ind.ML20())
1476
+ print("ML21 = ", ind.ML21())
1477
+ print("ML22 = ", ind.ML22())
1478
+ print("MH1 = ", ind.MH1())
1479
+ print("MH2 = ", ind.MH2())
1480
+ print("MH3 = ", ind.MH3())
1481
+ print("MH4 = ", ind.MH4())
1482
+ print("MH5 = ", ind.MH5())
1483
+ print("MH6 = ", ind.MH6())
1484
+ print("MH7 = ", ind.MH7())
1485
+ print("MH8 = ", ind.MH8())
1486
+ print("MH9 = ", ind.MH9())
1487
+ print("MH10 = ", ind.MH10())
1488
+ print("MH11 = ", ind.MH11())
1489
+ print("MH12 = ", ind.MH12())
1490
+ print("MH13 = ", ind.MH13())
1491
+ print("MH14 = ", ind.MH14())
1492
+ print("MH15 = ", ind.MH15())
1493
+ print("MH16 = ", ind.MH16())
1494
+ print("MH17 = ", ind.MH17())
1495
+ print("MH18 = ", ind.MH18())
1496
+ print("MH19 = ", ind.MH19())
1497
+ print("MH20 = ", ind.MH20())
1498
+ print("MH21 = ", ind.MH21())
1499
+ print("MH22 = ", ind.MH22())
1500
+ print("MH23 = ", ind.MH23())
1501
+ print("MH24 = ", ind.MH24())
1502
+ print("MH25 = ", ind.MH25())
1503
+ print("MH26 = ", ind.MH26())
1504
+ print("MH27 = ", ind.MH27())
1505
+ print("FL1 = ", ind.FL1())
1506
+ print("FL2 = ", ind.FL2())
1507
+ print("FL3 = ", ind.FL3())
1508
+ print("FH1 = ", ind.FH1())
1509
+ print("FH2 = ", ind.FH2())
1510
+ print("FH3 = ", ind.FH3())
1511
+ print("FH4 = ", ind.FH4())
1512
+ print("FH5 = ", ind.FH5())
1513
+ print("FH6 = ", ind.FH6())
1514
+ print("FH7 = ", ind.FH7())
1515
+ print("FH8 = ", ind.FH8())
1516
+ print("FH9 = ", ind.FH9())
1517
+ print("FH10 = ", ind.FH10())
1518
+ print("DL1 = ", ind.DL1())
1519
+ print("DL2 = ", ind.DL2())
1520
+ print("DL3 = ", ind.DL3())
1521
+ print("DL4 = ", ind.DL4())
1522
+ print("DL5 = ", ind.DL5())
1523
+ print("DL6 = ", ind.DL6())
1524
+ print("DL7 = ", ind.DL7())
1525
+ print("DL8 = ", ind.DL8())
1526
+ print("DL9 = ", ind.DL9())
1527
+ print("DL10 = ", ind.DL10())
1528
+ print("DL11 = ", ind.DL11())
1529
+ print("DL12 = ", ind.DL12())
1530
+ print("DL13 = ", ind.DL13())
1531
+ print("DL14 = ", ind.DL14())
1532
+ print("DL15 = ", ind.DL15())
1533
+ print("DL16 = ", ind.DL16())
1534
+ print("DL17 = ", ind.DL17())
1535
+ print("DL18 = ", ind.DL18())
1536
+ print("DL19 = ", ind.DL19())
1537
+ print("DL20 = ", ind.DL20())
1538
+ print("DH1 = ", ind.DH1())
1539
+ print("DH2 = ", ind.DH2())
1540
+ print("DH3 = ", ind.DH3())
1541
+ print("DH4 = ", ind.DH4())
1542
+ print("DH5 = ", ind.DH5())
1543
+ print("DH6 = ", ind.DH6())
1544
+ print("DH7 = ", ind.DH7())
1545
+ print("DH8 = ", ind.DH8())
1546
+ print("DH9 = ", ind.DH9())
1547
+ print("DH10 = ", ind.DH10())
1548
+ print("DH11 = ", ind.DH11())
1549
+ print("DH12 = ", ind.DH12())
1550
+ print("DH13 = ", ind.DH13())
1551
+ print("DH14 = ", ind.DH14())
1552
+ print("DH15 = ", ind.DH15())
1553
+ print("DH16 = ", ind.DH16())
1554
+ print("DH17 = ", ind.DH17())
1555
+ print("DH18 = ", ind.DH18())
1556
+ print("DH19 = ", ind.DH19())
1557
+ print("DH20 = ", ind.DH20())
1558
+ print("DH21 = ", ind.DH21())
1559
+ print("TA1 = ", ind.TA1())
1560
+ print("TA2 = ", ind.TA2())
1561
+ print("TL1 = ", ind.TL1())
1562
+ print("TL2 = ", ind.TL2())
1563
+ print("TH1 = ", ind.TH1())
1564
+ print("TH2 = ", ind.TH2())
1565
+ print("RA1 = ", ind.RA1())
1566
+ print("RA2 = ", ind.RA2())
1567
+ print("RA3 = ", ind.RA3())
1568
+ print("RA4 = ", ind.RA4())
1569
+ print("RA5 = ", ind.RA5())
1570
+ print("RA6 = ", ind.RA6())
1571
+ print("RA7 = ", ind.RA7())
1572
+ print("RA8 = ", ind.RA8())
1573
+ print("RA9 = ", ind.RA9())