INF Phyton
INF Phyton
NATIONAL
AGRARIAN
UNIVERSITY
”
FACULTY OF SCIENCES
DEPARTMENT OF PHYSICS AND METEOROLOGY
COURSE: HYDROMETEOROLOGY
TEACHER: MSC. EVER MENACHO CASIMIRO
STUDENT: RONY PAUL PILLACA QUISPE
CODE: 20141076
CYCLE: 2019 I
LIMA – PERU
I. INTRODUCTION
Without a doubt, the world of programming is growing and growing without taking a break
because the world is like that, it grows and does not stop growing. The Python programming
language is used in many activities, including the study of water distribution at different
scales, depending on the interests that are to be achieved. In this context, there is a need to
establish tools that generate support and decision-making, which will allow us to improve
our understanding of the behavior of natural water systems and future dams that will supply
the essential resource for the daily life of humans and other species that inhabit this planet.
This paper shows examples of this modeling using the Python programming language,
which through the application of different libraries has been able to establish the direct flow
hydrographs at the outlet of different basins in order to replicate and thus execute those free
software to calculate the separation of effective precipitation and the transformation of rain
into runoff. Next, in this report, we will present codes generated on the Spyder platform
with the purpose of generating hydrograph estimates that allow us to evaluate the behavior
of flows at the level of a basin or other study areas.
II. GOALS
- Generate codes in the Spyder platform of the Python programming language to solve
hydrological problems.
III. BACKGROUND
Python is a scripting programming language. Scripting languages are those languages that
use an interpreter instead of being compiled. It is the opposite of Perl, a language with
which it competes in friendship. Most Python users consider it to be a cleaner and more
elegant language for programming. This type of source code allows us to separate the
program into modules, this language has a wide variety of standard modules that can be
used for programming, or even as a basis for learning to program in Python.
Advantages of Python
• Concise syntax for arrays and non-arrays allows us to have a clearer program.
• Interpreted language makes development easier.
• Object-oriented programming makes code more robust.
• Internal data sets are very easy to manage and provide highly competent tools.
(example. dictionaries).
• Large number of users and developers in industry and science (Google, NOAA,
ECMWF, etc.)
Disadvantages of Python
• It runs much slower than compiled code (but there are tools to far overcome this).
• Libraries and multiple versions can conflict (this can be avoided with the correct use
of development environments).
- Python software, in addition to the use of the free distribution of Anaconda (Spyder
platform).
- An operating system (computer or laptop).
- Hydrology problems.
4.2.PROCEDURE
1. Using a script solve the following problem. Given a basin with an area of 100 km2, and a
concentration time of 6 h, the following is requested:
a) Determine and draw the synthetic unit hydrograph of 2 h duration according to the SCS
method (Dimensionless hydrograph).
b) Determine the composite hydrograph of the flood produced by a rainfall whose net
hyetograph is shown in the figure.
DIMENSIONAL HYDROGRAM
t/tp Q/Qp
0 0
0.2 0.1
0.4 0.31
0.6 0.66
0.8 0.93
1 1
1.2 0.93
1.4 0.78
1.6 0.56
1.8 0.39
2 0.28
2.2 0.21
2.4 0.15
2.6 0.11
2.8 0.08
3 0.05
3.5 0.02
4 0.01
4.5 0.005
5 0
2 4 6 Time (hours)
HUe = np . append(He,m1)
HUI = np . append(m2,np . append(Hltm2))
HU2 = np . append(H2,m1)
Time(h) 28 32 36 40 44 48 52
Time(h) 56 60 64 68 72 76 80
Q(m3/s/cm) 42 33 24 18 12 6 0
Development of script No2. for your
solution
Created on Sat Jul 20 14:41:00 2019 import pandas as pd packages that will be used, in addition to
@author: Paul
indicating where our data table is located
import numpy as np (Table No. 2).
- Data
3. Present the solution to this problem using a script. The following flood arrives at a section of a
river, with transit parameters K = 10 hours and x = 0.08.
Table No. 3.
Hydrograph
data.
T(h) 0 3 6 9 12 15 18 21 24
T(h) 30 33 36 39 42 45 48 51
Created on Sun Jul 21 16:45:20 2019 In this section we import the packages that
^author: Paul will be used (pandas and numpy), in
addition to indicating where our data table
is located (Table No. 3).
import pandas as pd import
numpy as np
We name our matrix as 'exercise_3', which
xls = pd.ExcelFile('E:\\TFN\problemasHU.xlsx') print(xls . s represents Sheet 3 of the Excel workbook
heet_names ) (file problemasHU.xlsx) that has the path
'E:/TF/problemaHU.xlsx'
exercise_3 = xls . parsef 1 exercise_3 1 ) print
(exercise_3)
Next, a dataframe called 'df' is created to
df = pd . DataFrame(exercise_3) facilitate working with matrices.
- Data
4. Solve this problem by using a script. There are two sub-basins A and B, which converge at a point
downstream of them. The following effective precipitation events occur in these sub-basins.
Table No. 4. Hyetograph data for each sub-basin.
T(h) Precipitation in A (mm) Precipitation in B (mm)
0.5 5
1 3
1.5 4
2 2
2.5 3
Up to the point of confluence, the Muskingum parameters for both basins are:
Table No. 5. Parameters for applying the Muskingun method for each sub-basin.
Sub-basin A Sub-basin B
K value (hours) 10 6
It is requested to calculate the resulting direct runoff hydrograph at the confluence of both
- Development of a script to solve problem 4
^author: Paul
In this section we import the packages that
import pandas as pd ______________________________
will be used (pandas and numpy), in
import numpy as np------------------- addition to indicating where our data table
is located (Table No. 4).
xls = pd.ExcelFile('E:\TF\problemasHU.xlsx') print(xls .
sheet_names) We name our matrix as 'exercise_4', which
exercise_4 = xls . parse( 'exercise_4' ) --------------------- represents Sheet 4 of the Excel workbook
print (ex er cicio_4) (file problemasHU.xlsx) that has the path
'E:/TF/problemaHU.xlsx'
df = pd . DataFrame(exercise_4) ------------------------
Next, a dataframe called 'df' is created to
#Inflow rate
df = pd . DataFrame(exercise_4) facilitate working with matrices.
Q = df [ 'Q(m3/s/mm) ' ]
U = np.array(Q)
print(U)
SUB-BASIN A
#SUB-BASIN A = 5
tl = 4 t2 = 3
DIRECT FLOW
QBe = tbe*U QB1 = tbl*U
mbl = np.zeros(1)
mb2 = np.zeros(3)
QDb® = np.append(np.append(mb1,QB0),m1)
QDb1 = np.append(mb2,QB1) QRB = QDbe + QDb1
^Pluskingum parameters kb = 6
xb = 0.03 t = 0.5
for i in range(1,11):
QSB[i] = B*QRB[i] + B1*QRB[i-1] + B2*QRB[i-1]
t/tp Q (m3/s/cm)
0 0.00
1 83.85
2 282.84
3 365.18
4 253.93
5 129.44
6 64.21
7 30.37
8 13.39
9 6.51
10 3.60
11 1.67
12 0.39
13 0.00
Column Q represents the sum of the hydrographs produced by 2 cm, 3 cm and 4 cm of effective
precipitation recorded by the hyetograph. This resulting hydrograph is also known as the composite
hydrograph (red dashed lines).
5.2. PROBLEM 2
T (h) Qacum
0 0
1 4.8
2 34.8
3 87.6
4 159.6 600
5 243.6 -
6 316.8 500
7 379.2 -
8 433.2 400
■
9 482.8
íü 300
10 521.2 ■
11 556 200
EI
12 582.4 -
T
13 604 100 -
14 620.8
15 634
16 643.6 0 10 20 30 40 50 60 70 80
17 650.8 Time (h)
18 655.6
19 658
20 658
Curve S represents the total direct runoff generated by a continuous rainstorm, that is, of infinite
duration, which was calculated from a unit hydrograph (see Table No. 2). Having an approximate
maximum value equal to 658 m3/s.
UNIT HYDROGRAM OF 12h.
Table No. 5. 12H Unit Hydrograph resulting from a 2h hydrograph
In the following results, the table of the resulting hydrograph for the inlet and outlet flow is
presented, which was generated from the Muskingum method with parameters equal to x = 0.08
and k = 10 hours. This method of calculating flood transits helps us determine the hydrograph
produced by a flow at a point in a watercourse using known hydrographs at one or more points
upstream.
- .4.PROBLEM 4
- SUB-BASIN A
The inflow of basin A will be the sum of these 3 flows for the different effective rainfall recorded
by the hyetograph. It is observed that the peak flow of the basin is 420.8 m3/s at approximately
2.5 hours.
- SUB-BASIN B
Table No. 7. Resulting from the accumulated hydrograph method for sub-basin B.
- TRANSIT HYDROGRAM.
Table No. 8. Hydrograph resulting from the Muskingum method.
It is observed that at a certain point the flow becomes practically constant and then begins to
slowly decrease. And that the influence of sub-basin B is much less than that of A.
VI. DISCUSSIONS
If you want to create a unit hydrograph, it is necessary to have a hydrograph measured at the
gauge; it is common that the basin we are studying does not have a hydrometric station. Faced
with this problem, a method was developed to obtain unit hydrographs using only the
physiographic data of the basin: Synthetic Unit Hydrograph. From the results obtained in
problem 1 it was observed that the flow will be positive from 00 hours of the start of the runoff
until approximately 20 hours. Highlighting the peak flow rate of 45.21 m3/s/cm at 5 hours. From
this he obtained a dimensionless hydrograph, dividing the flow scale by the peak flow, as well as
the time scale by the time at which the peak occurs.
On the other hand, to create a composite hydrograph, the time intervals first had to be
homogenized, that is, every 2 hours for this exercise. They were then shifted to a 2-hour interval
for each hydrograph. The relationship K is calculated between the excess durations, that is:
Where “de” is the excess duration for the unit hydrograph used to calculate the S curve, and “de'
“is the excess duration for the unit hydrograph to be obtained. The parameter K will be multiplied
by each value of the previously calculated hydrograph.
Finally, to calculate the output flow of basin A in question 4, it was necessary to multiply the
effective rainfall by the flow given by data and depending on the time of occurrence of the
rainfall, these will be moved, therefore, the input flow of basin A will be the sum of those 3 flows
for the different rainfalls. It is observed that the peak flow of the basin is 420.8 m3/s at
approximately 2.5 hours, another thing that can be said is that there is no base flow. As in sub-
basin A, the total flow in basin B will be the sum of flows for each precipitation, in this case there
are 2 precipitations. The peak flow is 260.4 m3/s at 2 hours. It can be said that compared to the
peak flow of sub-basin A, this sub-basin B contributes approximately half the runoff of A. To
find the outflow of the basin, the Muskingum flood transit equation must be used for each sub-
basin and then a sum is performed to obtain the total outflow of the entire basin.
VII. CONCLUSIONS
- In the first exercise, a peak flow rate of 45.21 m3/s/cm was found at around 4.6
hours for the 2-hour duration hydrograph. Similarly, for the composite hydrograph,
a peak flow rate equal to 365 m3/s was recorded before 4 hours; these hydrographs
were obtained from a dimensionless hydrograph.
- In the second exercise, a constant value was found for the S curve equal to 658 m3/s
which was obtained by the S Hydrogram method for a duration of 2 hours.
Likewise, for statement B, the result was a 12-hour unit hydrograph with a peak
flow rate equal to 376 m3/s, which suffered an attenuation of the hydrograph.
- In the third exercise, the inlet hydrograph showed a peak flow of 545 (m3/s) that
occurs at approximately 6:00 p.m., while the outlet hydrograph found a peak flow of
378.61 m3/s that occurs at 12:00 a.m., accompanied by an intensity of 372 m3/s.
- In the fourth exercise, it can be concluded that only one avenue of traffic could be
considered in sub-basin A towards the basin's gauging point, because in sub-basin B
the traffic is not as strong.