python中雨流计数模型包
需要传入rainflow模型包
下面是使用python实现雨流计数
__author__ = 'SunXQ'
# -*- coding: UTF-8 -*-
import rainflow
import pandas as pd
import math
signal = [1,2,3,1,3]
def rainflow111():
a = pd.DataFrame(rainflow.count_cycles(signal))
print(rainflow.count_cycles(signal))
print(a[1].sum())
print(format(math.ceil(a[1].sum())))
print(format(math.floor(a[1].sum())))
if __name__ == "__main__":
rainflow111()
使用sql实现雨流计数
使用雨流计数的思想利用sql实现
-- 停车次数
select
vin
,trip_id
,count(a2) brkpedalcnt
from(
select
vin
,trip_id
,rcv_time
,if(disbrakepedsts>=0 and nextdisbrakepedsts<0 ,brakepedsts,null) as a2
from(
select
vin
,trip_id
,rcv_time
,brakepedsts
,disbrakepedsts
,lead(disbrakepedsts,1,0) over(partition by vin,trip_id order by rcv_time asc) nextdisbrakepedsts
f