Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
17 views
6 pages
Code
code to plot rainfall data
Uploaded by
lencewedi.chingwena
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save code For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
17 views
6 pages
Code
code to plot rainfall data
Uploaded by
lencewedi.chingwena
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save code For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 6
Search
Fullscreen
import pandas as pd import matplotlib.pyplot as plt # Load the CHIRPS data data = pd.read_csv('C:\\Users\\Lenovo\ \Desktop\\Rainfall_data\\Nyamudeza.csv') # Repla # Convert date to datetime format data['Date'] = pd.to_datetime(data[ Date" )) # Group by month and calculate mean rainfall monthly_rainfall = data.groupby(data[ ‘Date’ ].dt.month)[ ‘Rainfall’ ].mean() # Plotting plt.figure(figsize=(10, 5)) plt.plot (monthly rainfall.index, monthly rainfall.values, marker='o') plt.title('mean Monthly Total Rainfall") plt.xlabel(‘Month”) plt.ylabel('Mean Rainfall (mm)") plt.xticks (monthly rainfall.index, [‘Jan', ‘Feb’, ‘Mar’, ‘Apr’, ‘May’, ‘Jun, "Jul", ‘A plt.grid() plt.show() Mean Monthly Total Rainfall jen Feb Morar May onslSCA)SSep tN Month # Group by year and calculate total rainfall data['year’] = data[ ‘Date’ ].dt.year annual_rainfall = data.groupby("year')(‘Rainfall' }.sum() # Plotting plt.figure(figsize=(10, 5)) plt.plot (annual_rainfall.index, annual_rainfall.values, marke plt.title(‘'Mean Annual Total Rainfall’) plt.xlabel(‘Year") plt.ylabel('Total Rainfall (mm)') plt.grid() plt.show() 10")Mean Annual Total Rainfall 1400 3200 E 1000 800 00 400 a import pandas as pd import numpy as np 4 Load the CHIRPS rainfall data (assuming it is in a CSV format) # The CSV should have columns: ‘date’ and ‘rainfall’ chirps_data = pd.read_csv("C:\Users\\Lenovo\\Desktop\\Rainfall_data\\Nyamudeza.csv") # Convert ‘date’ to datetime chirps_data[‘Date’] = pd.to_datetime(chirps_data[ ‘Date’ ]) # Define catchment area in square meters catchment_area = 414496444.64869976 # Example: 100 hectares # Define runoff coefficient (8.9 for 96% runoff) runoff_coefficient = 0.9 # Calculate annual rainfall chirps_data['year’] = chirps_data[ ‘Date’ ].dt.year annual_rainfall = chirps_data-groupby(*year')[‘Rainfall" ].sum().reset_index() # Calculate annual runoff volume annual_rainfall['‘runoff_volune_m3') = annual_rainfall['Rainfall'] * runoff_coefficient # Display results print (annual_rainfall([ "year", ‘runoff_volune_n’3"}]) year runoff_volume_n3 @ 1984 1.279192e+08 1 1985 5.1778566+08 2 1986 3,503260e+08 3 1987 2.901551e+08 4 1988 3.903353¢+08 5 1989 3.908132e+08 6 1998 3.508307e+08 7 1991 2.4028286+08 8 1992 2.414445e+08 9 1993 3.4550400+0816 1994 3.100675e+08 11 1995 2.800015e+08 12° 1996 3. 63RAdGeOR 13 1997 5.11aRs3e+08 14 1998, 4.33624R0+08 15. 1999 3.716057e+08 16 2008 4,669748¢+08 17 2001 4,962429¢+08 18 2002 2.060140e+08 19 2003 2.873180e+08 20 2004 4.168600¢+08 21 2005 3.305777e+08 22 2886 2. 988400e+08 23. 2887 5.157085e+08 24 2068 4,331734¢+08 25 2869 3.784914e+08 26 2610 2.797004e+08 27, 2e11 3.859770e+08 28 2812 3.067485e+08 29° 2813 3.10d6ade+08 30 2814 4,338195¢+08 31 2815 2.209845e+08 32. 2616 2,919524e+08 33. 2617 4.422578¢+08 34 2018 3.464023e+08 35. 2819 3.196907e+08 36 2020 3.99951 7e+08 37. 2821 2.974522e+08 38 2822 4,542923¢+08 39° 2823 3,534585e+08 40 2024 1.263136¢+08 Amport nunpy as np import math def mitchel1_mpf (area): # Calculate MPF for a 10,000-year return period MPF_10000 = math.exp(((1.175 * math.log(area + 1)**0.755) + 3.133)) - 1 return MPF_10000 def calculate_return_levels(area): MPF_10008 = mitchel1_mpf (area) 4 Define scaling factors for different return periods scaling factors = {508: 0.497, 1000: 0.600, 5000: 0.870, 10000: 1.000, } # Calculate return Levels using the scaling factors return_levels = (period: MPF_10000 * scaling factors{period] for period in scaling_ return return_levels # Catchment area catchment_area = 414.9 # Calculate return Levels return_levels = calculate_retur_levels(catchnent_area) # Display return Levels with units print(“Return Levels (in cubic meters per second):") for period, level in return_levels.itens(): print(f*Return Level for {period}-yrs return period = {level:.2f} m/s") Return Levels (in cubic meters per second): Return Level for 580-yrs return period = 1092.11 m*/s Return Level for 1000-yrs return period = 1318.44 m*/s Return Level for 5800-yrs return period = 1911.74 m*/s Return Level for 10000-yrs return period = 2197.40 m?/s cH#a*(125/3942) print(Q, ‘m3") 10595.039642947742 m3 MITCHELL’ CALCULATION wmitchell’s Formula import. math mpf =[] Az414.9 mitchell= (‘Seeyears" 0.497, "10eeyears* [MPF 10000 yr] for key, value in mitchell.items(): MPFie0eeyr = math.exp(((1-175 * math.log(A+l)**0.755)+3.133)) - 2 return_period= value * MPF1@000yr print(key,’ - ',int(return_period)) mpf.append(return_period) -688, "S000years" 878, '1e0¢eyears':1) S0dyears - 1092 100eyears - 1318 Seeeyears - 1911 100eeyears - 2197 mpf1092. 109709824371, 1318.442305622983, 1911.7413431533255, 2197.403842704972] period=(500, 108, 5000,10000) strx= [] sdx = [] SCS UNIT HYDROGRAPH for i in pf: for x in period: intensity= ((i/(A*1*#6))*6.87) ‘SD=int (((2@50*nath. 1ogi@ ((x*1006. 41115) ~380) )/intensity)/(6e*6e*24)) strx-append( SD) sdx.append(So) print (intensity, Sb) 1,8083378420085394e-05 9188 2.1831040346179544e-05 7616 3. 165500850196034e-05 5248 3.6385067243632576e-05 4566 # Example discharge hydrograph data import numpy as np storm_duration = 20 # Number of time intervals in the storm event normalized_discharge = np.array(mpf) / max(mpf) ‘time_increnent = stormduration / (len(mpf) - 1) unit_hydrograph = np.zeros(1en(mpf)) for i, discharge_value in enunerate(nornalized_discharge): unit_hydrograph[i] = discharge_value * time_increment noralized_unit_hydrograph = unit_hydrograph / sum(unit_hydrograph) ‘time = np.arange(@, storm_duration + tine_increment, time_increnent) plt.plot(tine, normalized_unit_hydrograph) plt.xlabel(‘Time') plt.ylabel( ‘Normalized Discharge’) plt.title( ‘Unit Hydrograph') plt.grid(True) pit-show()In [4 Unit Hydrograph 0325 3 0250 0225 Normalized Discharge 0200 017s oo 25 50 75 100 m5 180 175 200 Time SYNDER METHOD. te = 7 # Time of concentration (in time intervals) n= 20 # Number of time intervals for the unit hydrograph unit_hydrograph2 = np.zeros(n) c= int(te / time_increnent) # Number of time intervals for time of concentration for g in range(n): if g c= c: unit_hydrograph2(g] = (g + 1) / (¢ + 1) else: unit_hydrograph2[i] = (n - g) / (n - ¢ #1) normalized_unit_hydrograph2 = unit_hydrograph2 / sum(unit_hydrograph2) ‘time = np.arange(@, storm_duration + time_increment, time_increment) plt.plot(time, normalized_unit_hydrograph) plt.xlabel(‘Tine") plt.ylabel( ‘Normalized Discharge’) plt.title('Scs Unit Hydrograph" ) plt.grid(True) plt.show() SCS Unit Hydrograph 0325 3 0250 0225 Normalized Discharge 0200 017s oo 25 50 75 100 m5 180 175 200 Time
You might also like
035 Assignment PDF
PDF
No ratings yet
035 Assignment PDF
14 pages
Dam Design PDF
PDF
100% (1)
Dam Design PDF
70 pages
Data Exploration and Visualization Laboratory - AD3301 - Lab Manual
PDF
No ratings yet
Data Exploration and Visualization Laboratory - AD3301 - Lab Manual
55 pages
Hands On Data Visualization Using Matplotlib
PDF
100% (1)
Hands On Data Visualization Using Matplotlib
7 pages
Depurador Clicom
PDF
No ratings yet
Depurador Clicom
790 pages
House Price Data Project
PDF
No ratings yet
House Price Data Project
382 pages
Unit Hydro
PDF
No ratings yet
Unit Hydro
12 pages
SIDI2
PDF
No ratings yet
SIDI2
28 pages
Introduction To Matplotlib
PDF
No ratings yet
Introduction To Matplotlib
58 pages
Erroe Metrics
PDF
No ratings yet
Erroe Metrics
4 pages
Crop Yield Prediction
PDF
No ratings yet
Crop Yield Prediction
11 pages
Web Scraping Weather Data Using Python - by Abhishek Khatri - Medium
PDF
No ratings yet
Web Scraping Weather Data Using Python - by Abhishek Khatri - Medium
8 pages
Simulation Plots
PDF
No ratings yet
Simulation Plots
3 pages
MLRecord
PDF
No ratings yet
MLRecord
24 pages
Upto Conditional CDF Using Gumbel
PDF
No ratings yet
Upto Conditional CDF Using Gumbel
2 pages
Ex-13 Data Science
PDF
No ratings yet
Ex-13 Data Science
11 pages
195-Student - Jupyter Notebook
PDF
No ratings yet
195-Student - Jupyter Notebook
9 pages
Vagizov 2021 IOP Conf. Ser. Earth Environ. Sci. 876 012078
PDF
No ratings yet
Vagizov 2021 IOP Conf. Ser. Earth Environ. Sci. 876 012078
9 pages
Rain Fall
PDF
No ratings yet
Rain Fall
4 pages
Imd Python Code
PDF
No ratings yet
Imd Python Code
2 pages
C ML2
PDF
No ratings yet
C ML2
6 pages
ERA5RAIN
PDF
No ratings yet
ERA5RAIN
2 pages
Final Report Hyd
PDF
No ratings yet
Final Report Hyd
64 pages
Sheet Thesis
PDF
No ratings yet
Sheet Thesis
8 pages
Problem1:: #Import Pyqt5
PDF
No ratings yet
Problem1:: #Import Pyqt5
9 pages
Program 2 Hierarchical Cluestring
PDF
No ratings yet
Program 2 Hierarchical Cluestring
5 pages
Poojitha 6
PDF
No ratings yet
Poojitha 6
3 pages
Prac 2
PDF
No ratings yet
Prac 2
3 pages
Choropleth Mapping Population Density With Log and Exp - Py
PDF
No ratings yet
Choropleth Mapping Population Density With Log and Exp - Py
1 page
'Forestfires - CSV': Import As Import
PDF
No ratings yet
'Forestfires - CSV': Import As Import
3 pages
3rd Semester DDM AI DAA DEV Print Pages For Spiral Record 25-1-24 - Removed
PDF
No ratings yet
3rd Semester DDM AI DAA DEV Print Pages For Spiral Record 25-1-24 - Removed
28 pages
12425-9 Missing Rainfall Data and Average Areal Rainfall, Salares LG
PDF
No ratings yet
12425-9 Missing Rainfall Data and Average Areal Rainfall, Salares LG
23 pages
Python Project Final Report Dinesh
PDF
No ratings yet
Python Project Final Report Dinesh
19 pages
FDS Lab Question Bank
PDF
No ratings yet
FDS Lab Question Bank
11 pages
Total Rainfall
PDF
No ratings yet
Total Rainfall
4 pages
GEO 2010 Surface Hydrology Spring 2017 Exercise 1 Date: 2017-01-16
PDF
No ratings yet
GEO 2010 Surface Hydrology Spring 2017 Exercise 1 Date: 2017-01-16
7 pages
Exp 2 SDK Ok
PDF
No ratings yet
Exp 2 SDK Ok
18 pages
Deancil E Zinyengere R202004C Outlet m3s
PDF
No ratings yet
Deancil E Zinyengere R202004C Outlet m3s
5 pages
Practical-Data Science: Delhi Public School Bangalore - East Artificial Intelligence Advance Python
PDF
No ratings yet
Practical-Data Science: Delhi Public School Bangalore - East Artificial Intelligence Advance Python
4 pages
Deancil E Zinyengere R202004C Nosa m3s
PDF
No ratings yet
Deancil E Zinyengere R202004C Nosa m3s
5 pages
Class 10 Ai Practical
PDF
No ratings yet
Class 10 Ai Practical
7 pages
Python Note 3
PDF
No ratings yet
Python Note 3
11 pages
Creategeostatlyr Export2pts Predicted Zval Py
PDF
No ratings yet
Creategeostatlyr Export2pts Predicted Zval Py
2 pages
Srfwatex
PDF
No ratings yet
Srfwatex
4 pages
DAVL PR1.2 Mit
PDF
No ratings yet
DAVL PR1.2 Mit
10 pages
Civl 322 Coursework
PDF
No ratings yet
Civl 322 Coursework
13 pages
Fds QB
PDF
No ratings yet
Fds QB
6 pages
Python Crash Course by Ehmatthes 16
PDF
No ratings yet
Python Crash Course by Ehmatthes 16
1 page
Exercise 5: Frequency Analysis:) Against
PDF
No ratings yet
Exercise 5: Frequency Analysis:) Against
9 pages
Surface Hydrology: GEO2010 Spring 2017
PDF
No ratings yet
Surface Hydrology: GEO2010 Spring 2017
8 pages
Python - Working With Data - Text Formats
PDF
No ratings yet
Python - Working With Data - Text Formats
23 pages
197104-SNOWY MOUNTAINS MEDIAN ANNUAL RAINFALL - Elevation+runoff
PDF
No ratings yet
197104-SNOWY MOUNTAINS MEDIAN ANNUAL RAINFALL - Elevation+runoff
9 pages
Institute of Technology Management & Research
PDF
No ratings yet
Institute of Technology Management & Research
10 pages
As 2
PDF
No ratings yet
As 2
10 pages
Estimating Flood Frequency
PDF
No ratings yet
Estimating Flood Frequency
7 pages
Clustering Documentation Python Code
PDF
No ratings yet
Clustering Documentation Python Code
8 pages
Department of Statistics Course STATS 330 Model Answer For Assignment 3, 2005
PDF
No ratings yet
Department of Statistics Course STATS 330 Model Answer For Assignment 3, 2005
8 pages
Getting Started Data Tidying Basic Summary Statistics: Function Usage
PDF
No ratings yet
Getting Started Data Tidying Basic Summary Statistics: Function Usage
2 pages