Chapter 5 figures

Figure 5.1

[1]:
%load_ext autoreload
%autoreload 2
[2]:
import pandas as pd
import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
[3]:
from context import RiverNetwork
from RiverNetwork import RiverNetwork
[4]:
structure2 = RiverNetwork('../data/single-segment-karahan.xlsx',dt=6)
[5]:
inflow = np.array(pd.read_excel('../data/example-inflow-karahan.xlsx').Inflow)
structure2.set_shape('S.1',21,inflow-22)
structure2.calc_flow_propagation(22)
[6]:
import seaborn as sns
import pickle
import matplotlib.pyplot as plt
sns.set()
sns.set_context("paper", rc={"font.size":8.0,
                             'lines.linewidth':1,
                             'patch.linewidth':0.5,
                             "axes.titlesize":8,
                             "axes.labelsize":8,
                             'xtick.labelsize':8,
                             'ytick.labelsize':8,
                             'legend.fontsize':8 ,
                             'pgf.rcfonts' : False})
(fig,ax) = structure2.draw_Qin(figsize=(5,2))
#fig.set_size_inches(5,3)
fig.set_dpi(150)
fig.patch.set_alpha(0)
#plt.title('Single reach example')
plt.tight_layout()
#plt.savefig('../../thesis/report/figs/karahan.pgf', bbox_inches = 'tight')
_images/A-chapter-5-figs_7_0.svg

Figure 5.3

[7]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from context import fit_muskingum
from fit_muskingum import getParams
from fit_muskingum import calc_Out
from fit_muskingum import calc_C
[8]:
df = pd.read_excel('../data/example-inflow-karahan-adjusted.xlsx')
df = df.set_index('Time')
[9]:
import seaborn as sns
sns.set()
sns.set_context("paper", rc={"font.size":8.0,
                             'lines.linewidth':1,
                             'patch.linewidth':0.5,
                             "axes.titlesize":8,
                             "axes.labelsize":8,
                             'xtick.labelsize':8,
                             'ytick.labelsize':8,
                             'legend.fontsize':8 ,
                             'pgf.rcfonts' : False})
[10]:
t = df.index.values
I = np.array(df['Inflow'])

fig = plt.figure(figsize=(5,2.5),dpi=150)
fig.patch.set_alpha(0)
ax = fig.add_subplot(111)

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);
plt.tight_layout()
#plt.savefig('../../thesis/report/figs/1reachx.pgf', bbox_inches = 'tight')
_images/A-chapter-5-figs_13_0.svg

Figure 5.4

[11]:
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=(5,2.5),dpi=150)
fig.patch.set_alpha(0)
ax = fig.add_subplot(111)

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();
plt.tight_layout()
#plt.savefig('../../thesis/report/figs/1reachk.pgf', bbox_inches = 'tight')
_images/A-chapter-5-figs_15_0.svg

Figure 5.5

[12]:
df = pd.read_excel('../data/example-inflow-karahan-adjusted.xlsx')
df = df.set_index('Time')
[13]:
t = df.index.values
I = np.array(df['Inflow'])
I2 = np.array(df['Inflow'])*0.4
I2 = np.append(I2[28:37],I2[0:28])
fig = plt.figure(figsize=(5,2.5),dpi=150)
ax = fig.add_subplot(111)
fig.patch.set_alpha(0)

plt.plot(t,I,linewidth = 1 , label = 'outflow reach 3, $Q^{out}_3$')
plt.plot(t,I2,linewidth = 1 , label = 'outflow reach 4, $Q^{out}_4$')
plt.plot(t,I+I2,'--',linewidth = 1 , label = 'inflow after confluence, $Q^{in}_5$')
plt.rcParams.update({'font.size': 8, 'pgf.rcfonts' : False})

x = 0.1
k = 5
dt = 1

C0 = calc_C(k,x,dt) # k,x,dt
O0 = calc_Out(I+I2,C0)
plt.plot(t, O0 ,'r',linewidth = 1, label = 'outflow reach 5, $Q^{out}_5$')

plt.ylabel('Flow, $Q$ [m$^3$/s]')
plt.xlabel('Time [h]')
plt.legend()
# save to file
plt.tight_layout()
#plt.savefig('../../thesis/report/figs/1confluence.pgf', bbox_inches = 'tight')
_images/A-chapter-5-figs_18_0.svg

Figure 5.6

[14]:
df = pd.read_excel('../data/example-inflow-karahan-adjusted.xlsx')
df = df.set_index('Time')
[15]:
t = df.index.values
I = np.array(df['Inflow'])

frac = 0.4
I1 = np.array(df['Inflow'])*frac
I2 = np.array(df['Inflow'])*(1-frac)
fig = plt.figure(figsize=(5,2.5),dpi=150)
ax = fig.add_subplot(111)

fig.patch.set_alpha(0)

plt.plot(t,I,linewidth = 1 , label = 'outflow before bifurcation, $Q^{out}_6$')

plt.plot(t,I1,'--',linewidth = 1 , label = 'inflow 7 after bifurcation, $Q^{in}_7$, $w_{7,6}=0.4$ ')
plt.plot(t,I2,'--',linewidth = 1 , label = 'inflow 8 after bifurcation, $Q^{in}_8$, $w_{8,6}=0.6$ ')

x = 0.1
k = 5
dt = 1
C1 = calc_C(k,x,dt) # k,x,dt
O1 = calc_Out(I1,C1)
plt.plot(t, O1 ,linewidth = 1, label = 'outflow 7, $Q^{out}_7$, $x=0.1$, $k=5$')

x = 0.2
k = 2
dt = 1
C2 = calc_C(k,x,dt) # k,x,dt
O2 = calc_Out(I2,C2)
plt.plot(t, O2 ,linewidth = 1, label = 'outflow 8, $Q^{out}_8$, $x=0.2$, $k=2$')

plt.ylabel('Flow, $Q$ [m$^3$/s]')
plt.xlabel('Time [h]')
plt.legend()
# save to file
plt.tight_layout()
#plt.savefig('../../thesis/report/figs/1bifurcation.pgf', bbox_inches = 'tight')
_images/A-chapter-5-figs_21_0.svg
[ ]: