Single Reach

In this notebook the effect of different parameter settings of \(x\) and \(k\) is shown.

Note

This is written in old code and will be replaced later using the network model class. The other parts already use the network model class.

Initialising model

[1]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
[2]:
from context import fit_muskingum
from fit_muskingum import getParams
from fit_muskingum import calc_Out
from fit_muskingum import calc_C
[3]:
df = pd.read_excel('../data/example-inflow-karahan-adjusted.xlsx')
df = df.set_index('Time')
[4]:
t = df.index.values
I = np.array(df['Inflow'])
fig = plt.figure(figsize=(7,2.5),dpi=150)
fig.patch.set_alpha(0)


ax = fig.add_subplot(111)
for axis in ['top','bottom','left','right']:
    ax.spines[axis].set_linewidth(0.5)

plt.plot(t,I,linewidth = 1 , label = 'inflow')
plt.rcParams.update({'font.size': 8, 'pgf.rcfonts' : False})

x = 0.2
k = 2
dt = 1

C0 = calc_C(k,x,dt) # k,x,dt
O0 = calc_Out(I,C0)
plt.plot(t, O0 ,'g',linewidth = 1, label = 'outflow')

plt.ylabel('Flow, $Q$ [m$^3$/s]')
plt.xlabel('Time [h]')
plt.legend();
# save to file
#plt.savefig('../thesis/report/figs/1reach.pdf', bbox_inches = 'tight')
#plt.savefig('../thesis/report/figs/1reach.pgf', bbox_inches = 'tight')
_images/A-single-reach_7_0.svg

The blue line is the inflow to the reach. The reach has parameters \(x = 0.2\), \(k = 2\) and \(\Delta t = 1\) The resulting outflow is shown in green.

Understanding \(k\)

To understand what happens the effect is of \(k\), it is varied while keeping \(x\) constant. \(x\) is fixed to 0.01 while \(k\) takes the values: 1, 3, 5, 10, 25, 50. Again \(\Delta t\) is set to 1.

[5]:
t = df.index.values
I = np.array(df['Inflow'])

length = 50
t = range(0,length,1)
I = np.append(I,np.full((1,length - len(I)),22))

fig = plt.figure(figsize=(7,2.5),dpi=150)
fig.patch.set_alpha(0)
ax = fig.add_subplot(111)
for axis in ['top','bottom','left','right']:
    ax.spines[axis].set_linewidth(0.5)
plt.rcParams.update({'font.size': 8, 'pgf.rcfonts' : False})

plt.plot(t,I,linewidth = 1 , label = 'inflow')

klist = [1,3,5,10,25,50]
for k in klist:
    x = 0.01
    dt = 1
    out = calc_Out(I,calc_C(k,x,dt))
    plt.plot(t, out,linewidth = 1, label = 'outflow $k$ = ' + '{:02d}'.format(k))

plt.ylabel('Flow, $Q$ [m$^3$/s]')
plt.xlabel('Time [h]')
plt.legend();
_images/A-single-reach_11_0.svg

It is clear that k is related to the delay or lag of the peak. The peaks shift to the right with increasing \(k\). While the peaks shift, also the attenuation increases. Meanwhile, flow the total volume passed by, the area under the graph, remains the same.

Understanding \(x\)

In the following section we do the same for \(x\). It will take the values: 0, 0.25, 0.5. Both \(k\) and \(\Delta t\) are kept constant at 1

[6]:
t = df.index.values
I = np.array(df['Inflow'])

fig = plt.figure(figsize=(7,2.5),dpi=150)
fig.patch.set_alpha(0)
ax = fig.add_subplot(111)
for axis in ['top','bottom','left','right']:
    ax.spines[axis].set_linewidth(0.5)
plt.rcParams.update({'font.size': 8, 'pgf.rcfonts' : False})

plt.plot(t,I,linewidth = 1 , label = 'inflow')

for x in [0,0.25,0.5]:
    k = 1
    dt = 1
    out = calc_Out(I,calc_C(k,x,dt))
    plt.plot(t, out,linewidth = 1, label = 'outflow $x$ = ' + '{:1.2f}'.format(x))


plt.ylabel('Flow, $Q$ [m$^3$/s]')
plt.xlabel('Time [h]')
plt.legend()
plt.xlim(2,20);
_images/A-single-reach_15_0.svg

As a result we can see that the \(x\) behaves as the attenuation parameter. All graphs have the peak at the same timestep, so no shift in time has occurred. What differs is the height of each peak. For \(x = 0.5\) no attenuation occurs, while for \(x = 0\) maximum attenuation occurs.