-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreturn_period.R
More file actions
69 lines (56 loc) · 1.91 KB
/
return_period.R
File metadata and controls
69 lines (56 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# Return period based on gage data
library(dplyr)
library(readr)
library(lubridate)
library(e1071)
library(devtools)
install_github("LimpopoLab/hydrostats", force = TRUE)
library(hydrostats)
## ANNUAL MAXIMUM PRECIPITATION EXAMPLE
# This is an example from Chow, Maidment, and Mays, 1988, Applied Hydrology
x <- read_csv("ChowMaidmentMays_Ex12_2_1.csv")
T_R <- 50 # return period in years (in this case)
Fx <- 1 - (1/T_R)
y <- evi(x$max_precip_in,Fx)
## ANNUAL FLOOD EXAMPLE 1
# This is an example from Chow, Maidment, and Mays, 1988, Applied Hydrology
z <- read_csv("ChowMaidmentMays_Ex12_3_3.csv")
z <- rename(z, q = AnnualMaxDischarge_cfs) # remember, units are cfs
# Compare data and log-transformed data
hist(z$q)
z$log_q <- log(z$q, 10) # this is log base 10
hist(z$log_q) # this is much closer to a normal distribution
## LOGNORMAL ANALYSIS
m <- mean(z$log_q)
s <- sd(z$log_q)
c <- skewness(z$log_q)
c <- skew(z$log_q) # uses built-in skewness calculation. there is a difference between methods.
# Note, the reason the distribution is so important is because
# the probabilities and return period are taken from the
# distribution given the statistics, m and s ONLY.
T_R <- 50 # return period in years (in this case)
Fx <- 1 - (1/T_R)
# the random variable (mean 0, standard deviation 1) that
# produces a cummulative probability, or probability of
# non-exceedence, of Fx.
x <- qnorm(Fx)
y <- (x * s) + m
z <- 10^y # this is the T_R flood level
## log-Pearson type III analysis
# For this distribution, we use the skewness to determine the
# inverse CDF.
T_R <- 50 # return period in years (in this case)
Fx <- 1 - (1/T_R)
x <- pt3(c,Fx)
y <- (x * s) + m
z <- 10^y # this is the T_R flood level
## EXAMPLE 2
z <- read_csv("mon_annual_peaks.csv")
x <- z$q # random variable, peak flow
y <- log(x) # log of data
m <- mean(y)
s <- sd(y)
c <- skewness(y)
yn <- (y-m)/s # normalized log variables
cdf <- pnorm(yn,0,1)
plot(x,cdf)