Muskingum routing in the IJssel

Script to verify code generating flows in the IJssel, or multiple river segments in sequence. Output of this script corresponds to verfication model.

[1]:
import sys
import os
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
import generate_network
[3]:
G, dike_list = generate_network.get_network()
[4]:
for x in dike_list:
    print(G.node[x])
{'id': 1, 'pnode': 'A.0', 'type': 'dike', 'C1': 0.7037044883065382, 'C2': 0.07822399739748591, 'C3': 0.2180715142959759}
{'id': 2, 'pnode': 'A.1', 'type': 'dike', 'C1': 0.8976112018759458, 'C2': 0.1099915720737832, 'C3': -0.007602773949729169}
{'id': 3, 'pnode': 'A.2', 'type': 'dike', 'C1': 0.8159335544521713, 'C2': 0.1571571140947814, 'C3': 0.0269093314530472}
{'id': 4, 'pnode': 'A.3', 'type': 'dike', 'C1': 0.6240289660529375, 'C2': 0.6138997464211343, 'C3': -0.2379287124740719}
{'id': 5, 'pnode': 'A.4', 'type': 'dike', 'C1': 0.6240289660529375, 'C2': 0.6138997464211343, 'C3': -0.2379287124740719}
[5]:
G.node['A.0']['Qout'] = 2000 * G.node['A.0']['Qevents_shape'].loc[0]
[6]:
Qin = 2000 * G.node['A.0']['Qevents_shape'].loc[0]
[7]:
df = pd.DataFrame({'Qin':Qin})
[8]:
x = -1.055501123
k = 0.378929169
dt = 1

C1 = calc_C(k,x,dt)
QA1 = calc_Out(Qin,C1)
#df['A.1test'] = QA1
[9]:
params = pd.read_excel('../../data/params.xlsx',index_col=0)
params
[9]:
K X C1 C2 C3
A.0 0.378929 -1.055501 0.703704 0.078224 0.218072
A.1 0.101616 -3.846220 0.897611 0.109992 -0.007603
A.2 0.189157 -1.789507 0.815934 0.157157 0.026909
A.3 0.303710 -0.013471 0.624029 0.613900 -0.237929
A.5 0.779782 0.074716 0.361629 0.457023 0.181347
A.4 0.303710 -0.013471 0.624029 0.613900 -0.237929
[10]:
params.loc['A.0']['K']
[10]:
0.3789291694964745
[11]:
Qin = 2000 * G.node['A.0']['Qevents_shape'].loc[0]

nodes = ['A.0','A.1','A.2','A.3','A.4']
nodes_title = ['A.1','A.2','A.3','A.4','A.5']
i=0
for node in nodes:
    k = params.loc[node]['K']
    x = params.loc[node]['X']
    dt = 1
    C = calc_C(k,x,dt)
    Qin = calc_Out(Qin,C)
    df[nodes_title[i]] = Qin
    i = i+1
[12]:
df
[12]:
Qin A.1 A.2 A.3 A.4 A.5
0 449.789315 449.789315 449.789315 449.789315 449.789315 449.789315
1 428.608569 434.884329 436.410432 438.873036 442.977241 445.538383
2 448.566119 444.021351 443.074220 441.913907 439.794119 440.381511
3 460.705731 456.117734 454.886401 452.680952 449.137213 445.484723
4 438.468008 444.056434 445.300738 447.005789 449.982643 450.533818
5 407.024353 417.559643 420.263158 424.917618 432.513852 438.950471
6 382.125718 391.800518 394.417410 399.299993 407.124116 415.138465
7 374.944239 379.181877 380.453989 383.155573 387.363824 392.886278
8 448.863039 427.885339 422.888978 415.150818 402.120269 395.258323
9 650.612166 586.260166 570.082344 542.780756 497.895938 463.519715
10 967.408445 859.509791 831.655087 782.773655 703.222663 634.204853
11 1247.376736 1140.893765 1112.294971 1059.323219 974.276058 888.789152
12 1562.398600 1445.838133 1414.832676 1357.720201 1265.766741 1176.514477
13 1841.356795 1733.284216 1704.088685 1649.309501 1561.558739 1471.585192
14 1972.873757 1910.338320 1892.431930 1856.290187 1799.349871 1731.354583
15 2000.000000 1978.325419 1971.500439 1955.974030 1932.043529 1898.332588
16 1952.257016 1961.676439 1963.432997 1964.500137 1966.988321 1961.870892
17 1836.171355 1872.621123 1881.726035 1896.794261 1921.657699 1939.918283
18 1635.558763 1702.948030 1720.251431 1750.378964 1799.511149 1841.089996
19 1424.241434 1501.549490 1522.038890 1559.333880 1619.471340 1677.268291
20 1196.013888 1280.495371 1302.973060 1344.299312 1410.837652 1475.526321
21 975.827326 1059.490621 1081.948139 1123.743472 1190.834698 1258.158144
22 832.736179 893.378025 910.215355 942.950282 994.960356 1052.585254
23 704.739634 755.888695 769.838052 796.557678 839.222367 884.064722
24 597.517524 640.441107 652.155593 674.535992 710.261457 748.077740
25 530.017304 559.377727 567.588646 583.756825 609.387049 638.315325
26 463.353857 489.508609 496.599998 510.101701 531.695728 554.022547
27 439.228066 452.080036 455.858388 463.720873 476.020882 491.640820
28 418.041637 427.121729 429.648454 434.684398 442.674746 451.495496
29 398.997576 406.620356 408.700256 412.691631 419.059141 425.839215
30 381.892728 388.623129 390.450030 393.916690 399.460510 405.215853
[13]:
df.plot(figsize=(20,10))
[13]:
<matplotlib.axes._subplots.AxesSubplot at 0x7f1629700320>
../_images/A-ijssel_ijssel_muskingum_14_1.svg
[14]:
#%qtconsole

Figure 5.2 for thesis

[15]:
import seaborn as sns
sns.set_context("paper", rc={"font.size":8.0,
                             'lines.linewidth':0.5,
                             'patch.linewidth':0.5,
                             "axes.titlesize":8,
                             "axes.labelsize":8,
                             'xtick.labelsize':8,
                             'ytick.labelsize':8,
                             'legend.fontsize':8 ,
                             'pgf.rcfonts' : False})
[16]:
fig = plt.figure(figsize=(3,2.5),dpi=150)
ax = fig.add_subplot(111)

#fig.set_size_inches(6,3)
fig.patch.set_alpha(0)
fig.set_dpi(150)

#plt.plot(t,I,linewidth = 1 , label = 'inflow')
df.plot(ax=ax, linewidth = 0.5)

plt.ylabel('Flow, $Q$ [m$^3$/s]')
plt.xlabel('Time [h]')
plt.legend()
#plt.tight_layout()
# save to file
#plt.savefig('../../../thesis/report/figs/ijssel.pdf', bbox_inches = 'tight')
#plt.savefig('../../../thesis/report/figs/ijssel.pgf', bbox_inches = 'tight')
[16]:
<matplotlib.legend.Legend at 0x7f161bfadf28>
../_images/A-ijssel_ijssel_muskingum_18_1.svg