-
Notifications
You must be signed in to change notification settings - Fork 0
/
muskingum_routing.py
85 lines (64 loc) · 1.82 KB
/
muskingum_routing.py
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# -*- coding: utf-8 -*-
"""Assignment for Project Officer (Hydrology)_muskingum routing.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/11ExLzmVj3ib8lSFmqLI3nLvMXFn8IVA1
Import Libraries
"""
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
"""I= inflow (m3/s),
Q= outflow(m3/s),
K= Storage time constant = 12 hour,
X= Weighing factor = 0.5,
Delta-T= 6 hour
Import Dataset
"""
df= pd.read_csv('Input_Dataset.csv')
df.head()
"""Visualizing Dataset"""
fig, ax = plt.subplots(1,1, squeeze= True)
ax.plot(df['Time'],df['I'],label='Inflows(m3/s)')
plt.title("Inflow Hydrograph")
plt.xlabel('Time(hr)')
plt.ylabel('Flow (cumec)')
plt.grid(visible = True, axis = 'y', alpha = 0.6)
plt.legend()
plt.tight_layout()
plt.show()
"""Calculating C1,C2,C3:"""
K=12
X=0.5
delT=6
D = 2*K*(1-X)+ delT
# D
C1= (-(2*K*X)+ delT)/D
# C1
C2= ((2*K*X)+ delT)/D
# C2
C3= ((2*K*(1-X))- delT)/D
# C3
#check:
Z= C1+C2+C3
Z
"""Calculation Outflow,Q (m3/s): Outflow Equation: Qj+1 = C1IJ+1 + C2IJ + C3QJ"""
for index, row in df.iterrows():
print(row['I'])
df["Q"]=np.empty
df.loc[0,'Q'] = 10
for i in range(1,10):
df.loc[i,'Q'] = C1*df. I[i] + C2*df. I[i-1] + C3*df. Q[i-1]
df.head()
df.to_csv("Muskingum_Outflow.csv")
"""Visualizing Inflow VS Outflow"""
fig, ax = plt.subplots(1,1, squeeze= True)
ax.plot(df['Time'],df['I'],'-*',label='Inflow (m3/s)',color='salmon')
ax.plot(df['Time'],df['Q'],'--s',label='Outflow (m3/s)', color='steelblue')
plt.title("Inflow vs Outflow Hydrograph",fontweight = 'semibold')
plt.xlabel('Time(hr)',fontweight = 'semibold')
plt.ylabel('Flow Rate (cumec)',fontweight = 'semibold')
plt.grid(visible = True, axis = 'y', alpha = 0.6)
plt.legend()
plt.savefig("Inflow vs Outflow Hydrograph.png", dpi=150, bbox_inches='tight')
plt.show()