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

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

现有波面数据如下图所示,采用频率为20Hz,需要根据波面数据计算得到平均波高、有效波高等信息。
在这里插入图片描述

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()

在这里插入图片描述

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

简朴-ocean

继续进步

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值