python -- 计算有效波高、平均波高

简介: 通过python计算有效波高,平均波高,平均周期,有效周期

通过python计算有效波高,平均波高,平均周期,有效周期



现有波面数据如下图所示,采用频率为20Hz,需要根据波面数据计算得到平均波高、有效波高等信息。111eecbd0de64e94a9933283285ca4b1.png

python代码如下所示,绘图部分仅展示了概率分布


# -*- coding: utf-8 -*-
"""
Created on %(date)s
@author: %(jixianpu)s
Email : 211311040008@hhu.edu.cn
introduction : keep learning althongh walk slowly
"""
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
path=r'D:/data.xlsx'
data=pd.read_excel(path)
high=data['波面数据(m)']
da=np.array(high)
da=da
a=[]
for i in range(len(da)-1):
    if (da[i]<0)&(da[i+1]>0):
        print(i)
        a.append(i)
wh=[]
tm=[]
for j in range(len(a)-1):
    x=da[a[j]:a[j+1]]
    x_max=np.max(x)
    x_min=np.min(x)
    h=x_max-x_min
    t=a[j+1]-a[j]
    tr=0.05*t
    tm.append(tr)
    wh.append(h)
### mean time \mean wave high            
h_mean=np.mean(wh)
t_mean=np.mean(tm)
### 
h_s=sorted(wh,reverse=True)
hs_3=h_s[0:int(len(h_s)/3)+1]
hs3_mean=np.mean((hs_3))
t_s=sorted(tm,reverse=True)
ts_3=t_s[0:int(len(h_s)/3)+1]
ts3_mean=np.mean(ts_3)
####f
hist, x, y= np.histogram2d(wh,tm,bins=10)
############################################################################
fig=plt.figure(figsize=(10,10))
ax = fig.add_subplot(111)
# ax.plot(da[0:1000])
# plt.axhline(y=0, color='r', linestyle='--')
ax.imshow(hist)
ax.set_xlabel('H(m)',fontsize=20)
ax.set_ylabel('T(s)',fontsize=20)
ax.set_ylim(0,10)
ax.pcolor(hist)
# ax.bar(x,y)
plt.show()


d2bf517f968f4b15a59df4cad50fe840.png


相关文章
|
1月前
|
算法 索引 Python
使用Python实现PageRank计算
使用Python实现PageRank计算
|
1月前
|
存储 Python
python计算两个数的和
python计算两个数的和
|
1月前
|
存储 自然语言处理 数据挖掘
Python:计算字符串中每个单词出现的次数
Python:计算字符串中每个单词出现的次数
|
11天前
|
算法 Python
78: 计算生日是星期几(python)
78: 计算生日是星期几(python)
|
29天前
|
Python
Python函数之计算规则图形的面积
Python函数之计算规则图形的面积
15 0
|
1月前
|
Python
Python小技巧:计算素数个数
Python小技巧:计算素数个数
|
1月前
|
机器学习/深度学习 人工智能 BI
Python计算余弦相似度
Python计算余弦相似度
|
1月前
|
索引 Python
Python阶乘计算
Python阶乘计算
|
1月前
|
存储 Python
Python计算三角形的面积
Python计算三角形的面积
|
1月前
|
数据挖掘 Python
Python计算平均值
Python计算平均值

热门文章

最新文章