You are on page 1of 9

9/26/2020 Jupyter Notebook Viewer

Course-work-and-data-analysis (/github/bikasbhattarai/Course-work-and-data-analysis/tree/master)
/ Hydrology-Course (/github/bikasbhattarai/Course-work-and-data-analysis/tree/master/Hydrology-Course)
/
GEO4310_2015 (/github/bikasbhattarai/Course-work-and-data-analysis/tree/master/Hydrology-Course/GEO4310_2015)
/
EX5 (/github/bikasbhattarai/Course-work-and-data-analysis/tree/master/Hydrology-Course/GEO4310_2015/EX5)

In [1]:

%%html
<style>
table {float:left}
</style>

Exercise 5: Frequency Analysis


This exercise is due October, 05 2015. Please save this notebook as a .pdf and .ipynb file and upload both files to
the folder "GEO4310/Resources/Exercises/Hand-in of exercises" in Fronter. The report should answer all questions
given in the exercise text and contain the relevant plots and output. For each python command given in this
notebook, write a comment (a line starting with #) to demonstrate that you understand what it does.

Name: Bikas Chandra Bhattarai

Date: 2015/10/05

Question 1:

Vägverket (the Swedish Road Administration) plans to build a new bridge and they ask you to provide some
information about the frequency and magnitude of the discharges in the river. Of course, you are a very
careful consultant, so you are going to apply different statistical methods. Yearly peak flows can be found
in the file Qyearly.dat.

1) Calculate the magnitude of a 100-year flood by using

A) Graphic method:

(i) Compute the empirical probability for a certain flow to be exceeded, P(X>=xm), using the Weibull equation
m
P (X >= xm) = ...................(1)
n+1

where m is the rank number and n is the number of years.

(ii) plot P (X > x m ) against Q max on the normal probability paper and fit a linear line by hand.

(iii) read QT =100 from the plot

B) Analytical methods assuming the yearly peak flow follows the

i) Normal distribution

ii) Log-normal distribution : - Do this by two methods:

https://nbviewer.jupyter.org/github/bikasbhattarai/Course-work-and-data-analysis/blob/master/Hydrology-Course/GEO4310_201… 1/9
9/26/2020 Jupyter Notebook Viewer

1) transform the data into lognormal and find mean and standard deviation
2) apply the formula on page62. in the compendium (2013).

iii) Extreme-value type I distribution (Gumble)

iv) Pearson III distribution

v) Log-Pearson III distribution

Use

¯
Q T = Q + K T . SQ .........................(2)

KT (for normal distribution and Pearson distribution) can be obtained from tables, for Extreme value type I
(Gumbel) distribution the equation is

√6 T
KT = KT = {0.5772 + ln [ln ( )]} .................(3)
π T −1

Solution:

In [1]:

%matplotlib inline
import scipy
import numpy as np
import pandas as pd
from scipy import stats
from scipy.stats import pearson3
from __future__ import division

ams = pd.read_table('Qyearly.dat') # ams = annual maximum series: annual maximum disc


N = len(ams) # len is the number of rows in ams, that is, 37 ye
ams['sorted'] = sorted(ams['Q(m3/s)'])
#ams ['Rank'] = range(1,(N+1),1)

ams ['Rank'] = range(1,N+1,1)

ams ['Weibull_prob'] = (ams['Rank']/(N+1)).round(2)


ams.head(3)

Out[1]:

Year Q(m3/s) sorted Rank Weibull_prob

0 1924 99.1 20.6 1 0.03

1 1925 79.2 28.4 2 0.05

2 1926 62.6 32.3 3 0.08

In [3]:

scipy.stats.norm.ppf(0.01)

Out[3]:

-2.3263478740408408

https://nbviewer.jupyter.org/github/bikasbhattarai/Course-work-and-data-analysis/blob/master/Hydrology-Course/GEO4310_201… 2/9
9/26/2020 Jupyter Notebook Viewer

In [3]:

# Plot P(X>= xm) against Qmax on normal probability paper and fit a linear line.
from scipy import stats
import matplotlib.pyplot as plt
Qmax = ams['sorted']
prob = ams['Weibull_prob']

Note: Graph is plotted manually and is provided in saperate sheet.

1B: Solution:

We will calculate the magnitude of a flood with a 100 year return period (T = 100 by using the normal distribution.
The mean discharge for the data period ( is 66. 3 m³/s with a standard deviation (s) of 21.3 m³ /s.

Calculating in normal distribution

In [4]:

# Calculating the mean and standard deviation

mean = (np.mean(ams['Q(m3/s)']))
print 'Mean :%.2f' % mean

std = (np.std(ams['Q(m3/s)']))

print 'Standard deviation :%.2f' % std

Mean :66.25
Standard deviation :21.00

So,

¯
Q = 66.3m³/s

SQ = 21m³/s

A hundred year flood has the probability of exceedance:

1
P (Q > Q T ) = = 0.01
100

P (Q < Q T ) = (1 − P (Q > Q T )) = 0.99

z = KT = scipy.stats.norm.ppf(0.99)

Rrarranging the equation (2)

¯
Q T =100 = Q + K T SQ

so calculating the above equation:

https://nbviewer.jupyter.org/github/bikasbhattarai/Course-work-and-data-analysis/blob/master/Hydrology-Course/GEO4310_201… 3/9
9/26/2020 Jupyter Notebook Viewer

In [5]:

Qt = mean + (scipy.stats.norm.ppf(0.99)*std)
print '100 year flood in normal distribution = %.2f' % Qt

100 year flood in normal distribution = 115.10

So the 100 year flood in normal distribution is 115.1 m³/s.

Calculation in log-normal distribution

In [6]:

ams_lognorm = pd.read_table('Qyearly.dat') # ams = annual maximum series: annual maxim


N = len(ams_lognorm) # len is the number of rows in ams, that i
ams_lognorm['sorted'] = sorted(ams_lognorm['Q(m3/s)'])
#ams ['Rank'] = range(1,(N+1),1)

ams_lognorm['lognorm'] = np.log(ams_lognorm['sorted'])
ams_lognorm ['Rank'] = range(1,N+1,1)

ams_lognorm ['Weibull_prob'] = (ams_lognorm['Rank']/(N+1)) # don't round until th


ams_lognorm.head(3)

Out[6]:

Year Q(m3/s) sorted lognorm Rank Weibull_prob

0 1924 99.1 20.6 3.025291 1 0.026316

1 1925 79.2 28.4 3.346389 2 0.052632

2 1926 62.6 32.3 3.475067 3 0.078947

In [7]:

# Calculating the mean and standard deviation

mean_lognorm = (np.mean(ams_lognorm['lognorm']))
print 'Mean_lognorm : %.2f' % mean_lognorm

std_lognorm = (np.std(ams_lognorm['lognorm']))

print 'Standard deviation_lognorm : %.2f' %std_lognorm

Mean_lognorm : 4.13
Standard deviation_lognorm : 0.37

In [8]:

Qt = mean_lognorm + (scipy.stats.norm.ppf(0.99)*std_lognorm)
print '100 year flood in lognormal distribution : %.2f' % Qt

100 year flood in lognormal distribution : 4.99

In [9]:

(np.exp(5)).round(2)

Out[9]:

148.41

https://nbviewer.jupyter.org/github/bikasbhattarai/Course-work-and-data-analysis/blob/master/Hydrology-Course/GEO4310_201… 4/9
9/26/2020 Jupyter Notebook Viewer

Conclusion: So the probability for 100 years flood in lognormal distribution is 148.41 m³/sec.

Extreme-value type I distribution (Gumbel)

for Extreme-Value distribution:

√6 T
KT = − {0.5772 + ln [ln ( )]}
π T −1

Here, T = 100 then

using the python cell as calculator:

In [10]:

from __future__ import division


K_T = ((-np.sqrt(6)/(np.pi))*(0.5772 + np.log(np.log(100/(100-1))))).round(3)

print 'K_T =', K_T


print 'std =', std
print 'mean=', mean

K_T = 3.137
std = 20.9990427275
mean= 66.2513513514

In [11]:

#So,
Q_T = (mean +std *K_T).round(1)
print Q_T

132.1

Conclusion: So the probability for 100 years flood in Gumble distribution is 132.2 m³/sec.

Pearson III distribution


The Pearson type III distribution is a three parameter gama distribution. The three parameters are β , λ and ε

here, mean = λ

standard deviation = β

coefficient of skewness = ε

2 1 3 2 2 3 4 1 5
then KT = K T = z + (z − 1)k +
3
(z − 6z)k − (z − 1)k + zk +
3
k

ε
where, k =
6

2
2.516+0.8029w+0.01033w
z = w −
1+1.4328w+0.1893w2 +0.00131w3

1/2
1
w = [ln ( )]
2
p

1
P = = 0.01
T

https://nbviewer.jupyter.org/github/bikasbhattarai/Course-work-and-data-analysis/blob/master/Hydrology-Course/GEO4310_201… 5/9
9/26/2020 Jupyter Notebook Viewer

In [12]:

skewness = scipy.stats.skew(ams['sorted'])
k = skewness/6
w = (np.log(1/((0.01)**2))**0.5 )
z = w-((2.516+0.8029*w+0.01033*w**2)/(1+1.4328*w+0.1893*w**2 +0.00131*w**3))
K_T = z+(z**2-1)*k + (1/3)*(z**3 - 6*z)*k**2 - (z**2-1)*k**3 +z*k**4 +(1/3)*k**5

Q_T = (mean + std *K_T).round(2)


print Q_T

112.64

Conclusion: So the probability for 100 years flood in Pearson III distribution is 112.64 m³/sec.

Log-Pearson III distribution

In [13]:

# Calculating the mean and standard deviation in lognormal scale

mean_lognorm = (np.mean(ams_lognorm['lognorm']))
print 'Mean_lognorm : %.2f' % mean_lognorm

std_lognorm = (np.std(ams_lognorm['lognorm']))

print 'Standard deviation_lognorm : %.2f' % std_lognorm

Mean_lognorm : 4.13
Standard deviation_lognorm : 0.37

In [14]:

skewness = scipy.stats.skew(ams_lognorm['lognorm'])
k = skewness/6
w = (np.log(1/((0.01)**2))**0.5 )
z = w-((2.516+0.8029*w+0.01033*w**2)/(1+1.4328*w+0.1893*w**2 +0.00131*w**3))
K_T = z+(z**2-1)*k + (1/3)*(z**3 - 6*z)*k**2 - (z**2-1)*k**3 +z*k**4 +(1/3)*k**5

Q_T = (mean_lognorm + std_lognorm *K_T).round(2)


print Q_T

4.73

In [15]:

(np.exp(4.73)).round(2)

Out[15]:

113.3

Conclusion: So the probability for 100 years flood in Log-Pearson III distribution is 113.3 m³/sec.

In summary: From the table below it is clear that the probability for 100 year flood is higher in Lognormal
distribution while the Lower in Pearsom III distibution.

Distribution discharge(m³/s)

https://nbviewer.jupyter.org/github/bikasbhattarai/Course-work-and-data-analysis/blob/master/Hydrology-Course/GEO4310_201… 6/9
9/26/2020 Jupyter Notebook Viewer

Distribution discharge(m³/s)

Normal 115.10

Log-Normal 148.41

Gumbel 132.1

Pearson III distribution 112.69

Log-Pearson III distribution 113.3

2) Calculate the probability that the annual peak flood is larger than 80 m³/s for any given year (assume
normal distribution)

A hundred year flood has the probability of exceedance (Q > Q T ) = 0.01 and P (Q < Q T ) = 0.99

¯
X T −X
from the normal distribution table: KT =
std

80−66.25
P (Q > 80m³/s) = P Q >
20.99

From the normal distribution table probability we got the probability of

From the normal distribution table probability we got the probability of P (Z > 0.655) = 0.7437

so the exceedance probability = (1-0.7437) = 0.26 or 26%

Hence, the probability that the annual peak flood is larger than 80 m³/s for any given year is 26%.

3) In order to be 90% sure that a design flood is not exceeded in a 50 year period (design life), what shall be
the design return period?

The exceedence probability for a certain return period (T) with n value is given by the following equation:

1 n
Pe = 1 − [1 − (
T
)] ...............(4)

The equation is rearranged to find T:

1
T = −
1

(1−Pe ) n −1

In this situation the Pe is 0.1, i.e the probability of exceedence is 1-P (no exceedence) = 1-0.9 = 0.1. The n is 50
years.

1
T = −
1

(1−0.1) 50 −1

solving the above problem by using the python cell below:

In [16]:

T= (-1/((1-0.1)**(1/50)-1))
print ('T : %.2f' % T)

T : 475.06

Conclusion:The design return period should be 475 years

4) Calculate the magnitude of the flow that with a probability of 0.9 is not exceeded in 5 years. (assume
normal distribution)

https://nbviewer.jupyter.org/github/bikasbhattarai/Course-work-and-data-analysis/blob/master/Hydrology-Course/GEO4310_201… 7/9
9/26/2020 Jupyter Notebook Viewer

Using the equation 4 from the problem 3: T can be calculated as shown below:

In [17]:

T= (-1/((1-0.1)**(1/5)-1))
print ('T : %.1f' % T)

T : 48.0

1 1
The return period (T) is 48 year. The probability is given by P =
T
=
48
= 0.0208

Since our distribution is normal so the value of z = KT

In [18]:

z = np.abs(scipy.stats.norm.ppf(0.0208))
# QT can be calculated by using the equation :
# mean+Kt*standard deviation which is given in equation 2

QT = (mean + z*std).round(2)
print QT

109.04

Conclusion: The magnitude of the flow that with a probability of 0.9 is not exceeded in 5 years is calculated to be
109. 04 m³/s

5)

a) Define and explain the return period.

A return period, also known as a recurrence interval is an estimate of the likelihood of an event to occur. It is a
statistical measurement typically based on historic data denoting the average recurrence interval over an extended
period of time. The return period wil be expressed in the same units as the sampling interval. For example, if we are
analyzing the annual peak floods then the return period will be in years. Some of the plotting position formulae
which are commonly used in hydrology are given below. In all these formula P [X ⩽ x m ]

California formula:
n
Exceedence probability =1 − P (x m ) =
m

m
Return period = T =
n

Hazen's formula,

m−0.5 2m−1
1 − P (x m ) = =
n 2n

2n
Return period = T = − 1
2m

Weibull's formula
m
1 − P (x m ) =
n+1

n+1
Return period = T =
m

Where, m = rank, n = number of observation

https://nbviewer.jupyter.org/github/bikasbhattarai/Course-work-and-data-analysis/blob/master/Hydrology-Course/GEO4310_201… 8/9
9/26/2020 Jupyter Notebook Viewer

b) In a small brook, we have estimated that the discharge 5 m³/s corresponds to the flow that is exceeded
with a return period of 10 years. What is the probability that this value is not exceeded five years in a
row?

Solution:

1
P (Q > q) = = 0.1
10

P (Q < q) = (1 − 0.1) = 0.99

5 5
so, Q(Q < q) = [0.99] = 0.95

Hence the probability that the discharge is not exceeded in five years in that small broke is o.95.

c) For a different river, the relationship between the duration of periods without precipitation, t (days) and
the lowest low-flow is given by this equation, Qt = 25.0 exp(−t/20) [m3 /s], (the recession of the flow) t
is a stochastic variable that can be described with a Gumbel F (t) = exp(−exp(−a(t − u)))with the
parameters u = 18 and a = 0.150. What is the probability that Qt reaches a lower value than 10 m3 /s?

Here, Qt = 25 exp(−t/20)

Replace Qt with 10

10 = 25 exp(−t/20)

Switch right and left side

−t
exp = 10/25
20

Take the logarithm

t
= log(10/25)
−20

Solve for t

10
t = −20 ⋅ log
25

t = 18.3

F (t) = exp(−exp(−a(t − u)))

F (t) = exp(−exp(−0.15(18.3 − 18.0)))

F (t) = exp(−exp(−0.045)) = 0.384

Conclusion: Hence the probability that the Qt reaches a lower value than 10 m³/s is 0.385.

In [ ]:

https://nbviewer.jupyter.org/github/bikasbhattarai/Course-work-and-data-analysis/blob/master/Hydrology-Course/GEO4310_201… 9/9

You might also like