我的水文学课的作业是关于输出结果以进行频率分析。给出了数十年的日降水量数据,我提取了年度最大日降水量。因此,现在我必须估计参数并输出概率分布。但是,我花了很长时间才学会Python,因此即使我用Google搜索,也很难为我找到引用。
# Extracting annual max value of the data
from openpyxl import load_workbook
from openpyxl import Workbook
from operator import itemgetter
fileUrl = r"C:\Users\DW\Desktop\rainfall.xlsx"
wb = load_workbook(fileUrl)
ws = wb.active
all_data = []
for row in ws.iter_rows(min_row=2,max_row=16072,max_col=64):
temp = []
for cell in row:
temp.append(cell.value)
all_data.append(temp)
j = 0
for i in range(1975,2019):
temp = []
while True:
if (j < len(all_data) and i == all_data[j][0]):
temp.append(all_data[j])
else:
max_list.append(max(temp, key = itemgetter(3,63)))
break
j += 1
print('max_list ', str(max_list))
wb2 = Workbook()
sheet1 = wb2.active
filename = 'max90.xlsx'
for i in max_list:
print(i)
sheet1.append(i)
wb2.save(filename=filename)
# to estimate parameters of distribution
import pandas as pd
import numpy as np
import scipy as sp
import scipy.stats as sps
import seaborn as sns
import matplotlib.pyplot as plt
%matplotlib inline
max90 = pd.read_excel(r"C:\Users\DW\Desktop\max90.xlsx")