|
@@ -4,10 +4,9 @@ import datetime
|
|
|
import bisect
|
|
|
import matplotlib.pyplot as plt
|
|
|
from LIB.MIDDLE.CellStateEstimation.Common import BatParam
|
|
|
-from LIB.MIDDLE.CellStateEstimation.Common import DBDownload
|
|
|
|
|
|
class BatSoh:
|
|
|
- def __init__(self,sn,celltype,df_bms,df_accum, host, port, db, user, password, tablename): #参数初始化
|
|
|
+ def __init__(self,sn,celltype,df_bms,df_accum,df_soh): #参数初始化
|
|
|
|
|
|
self.sn=sn
|
|
|
self.celltype=celltype
|
|
@@ -23,12 +22,7 @@ class BatSoh:
|
|
|
self.df_accum=df_accum
|
|
|
self.accumtime=pd.to_datetime(df_accum['时间戳'], format='%Y-%m-%d %H:%M:%S')
|
|
|
|
|
|
- self.host=host
|
|
|
- self.port=port
|
|
|
- self.db=db
|
|
|
- self.user=user
|
|
|
- self.password=password
|
|
|
- self.tablename=tablename
|
|
|
+ self.df_soh=df_soh
|
|
|
|
|
|
def batsoh(self):
|
|
|
if self.celltype==1 or self.celltype==2 or self.celltype==3 or self.celltype==4:
|
|
@@ -42,12 +36,6 @@ class BatSoh:
|
|
|
else:
|
|
|
return pd.DataFrame()
|
|
|
|
|
|
- #获取预算结果库的结果....................................................................................................................
|
|
|
- def getdata(self):
|
|
|
- DBManager=DBDownload.DBDownload(self.host, self.port, self.db, self.user, self.password)
|
|
|
- with DBManager as DBManager:
|
|
|
- self.df_soh=DBManager.getdata('time_st','time_sp','sn','method','soh','cellsoh', tablename='cellstateestimation_soh', sn=self.sn)
|
|
|
-
|
|
|
#定义滑动滤波函数.........................................................................................................................
|
|
|
def _np_move_avg(self,a, n, mode="same"):
|
|
|
return (np.convolve(a, np.ones((n,)) / n, mode=mode))
|
|
@@ -83,7 +71,7 @@ class BatSoh:
|
|
|
self.tempweight=0.5
|
|
|
self.StandardStandingTime=3600
|
|
|
elif min(celltemp)>=5:
|
|
|
- self.tempweight=0
|
|
|
+ self.tempweight=0.2
|
|
|
self.StandardStandingTime=7200
|
|
|
else:
|
|
|
self.tempweight=0
|
|
@@ -91,16 +79,16 @@ class BatSoh:
|
|
|
else:
|
|
|
if min(celltemp)>=20:
|
|
|
self.tempweight=1
|
|
|
- self.StandardStandingTime=900
|
|
|
+ self.StandardStandingTime=1200
|
|
|
elif min(celltemp)>=10:
|
|
|
self.tempweight=0.8
|
|
|
- self.StandardStandingTime=1200
|
|
|
+ self.StandardStandingTime=1800
|
|
|
elif min(celltemp)>=5:
|
|
|
self.tempweight=0.3
|
|
|
- self.StandardStandingTime=1800
|
|
|
+ self.StandardStandingTime=3600
|
|
|
else:
|
|
|
self.tempweight=0.1
|
|
|
- self.StandardStandingTime=3600
|
|
|
+ self.StandardStandingTime=7200
|
|
|
|
|
|
#获取SOC差对应的SOH权重值...................................................................................................................
|
|
|
def _deltsoc_weight(self,deltsoc):
|
|
@@ -234,7 +222,6 @@ class BatSoh:
|
|
|
#NCM充电数据soh计算.........................................................................................................................
|
|
|
def _ncmsoh_chrg(self):
|
|
|
self._chrgdata()
|
|
|
- self.getdata()
|
|
|
ChgStartValid=[]
|
|
|
ChgEndValid=[]
|
|
|
tempweightlist=[]
|
|
@@ -303,7 +290,7 @@ class BatSoh:
|
|
|
standingtime=0
|
|
|
for i in range(3,len(self.df_bms)-3):
|
|
|
|
|
|
- if abs(self.packcrnt[i]) < 0.1 and abs(self.packcrnt[i-1]) < 0.1: #电流为0
|
|
|
+ if abs(self.packcrnt[i]) < 0.1 and abs(self.packcrnt[i-1]) < 0.1 and abs(self.packcrnt[i+1]) < 0.1: #电流为0
|
|
|
delttime=(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
|
|
|
standingtime=standingtime+delttime
|
|
|
self._celltemp_weight(i) #获取不同温度对应的静置时间
|
|
@@ -363,7 +350,6 @@ class BatSoh:
|
|
|
|
|
|
#计算SOH......................................................................................................................
|
|
|
if standingpoint_sp:
|
|
|
- self.getdata() #获取已计算的soh
|
|
|
column_name=['time_st','time_sp','sn','method','soh','cellsoh']
|
|
|
df_res=pd.DataFrame(columns=column_name)
|
|
|
|
|
@@ -483,7 +469,7 @@ class BatSoh:
|
|
|
for i in range(3,len(self.df_bms)-3):
|
|
|
|
|
|
#获取两点法法所需数据-开始.................................................................................................................
|
|
|
- if abs(self.packcrnt[i]) < 0.1 and abs(self.packcrnt[i-1]) < 0.1: #判断非平台区静置状态
|
|
|
+ if abs(self.packcrnt[i]) < 0.1 and abs(self.packcrnt[i-1]) < 0.1 and abs(self.packcrnt[i+1]) < 0.1: #判断非平台区静置状态
|
|
|
delttime=(self.bmstime[i]-self.bmstime[i-1]).total_seconds()
|
|
|
standingtime=standingtime+delttime
|
|
|
self._celltemp_weight(i) #获取不同温度对应的静置时间
|
|
@@ -599,7 +585,6 @@ class BatSoh:
|
|
|
|
|
|
#开始计算SOH.............................................................................................................................................
|
|
|
if standingpoint_sp or chrg_end:
|
|
|
- self.getdata() #获取已计算的soh
|
|
|
column_name=['time_st','time_sp','sn','method','soh','cellsoh','weight']
|
|
|
df_res=pd.DataFrame(columns=column_name)
|
|
|
|
|
@@ -711,6 +696,7 @@ class BatSoh:
|
|
|
cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
else:
|
|
|
cellsoh_cal=cellsoh_init*soh_weight+100*(1-soh_weight)
|
|
|
+ cellsoh_cal=eval(format(cellsoh_cal,'.1f'))
|
|
|
if 60<cellsoh_cal<115:
|
|
|
df_res.loc[i,'soh']=cellsoh_cal
|
|
|
df_res.loc[i,'cellsoh']=str(cellsoh_cal)
|
|
@@ -723,6 +709,7 @@ class BatSoh:
|
|
|
cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
else:
|
|
|
cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
+ cellsoh_cal=eval(format(cellsoh_cal,'.1f'))
|
|
|
if 60<cellsoh_cal<115:
|
|
|
df_res.loc[i,'soh']=cellsoh_cal
|
|
|
df_res.loc[i,'cellsoh']=str(cellsoh_cal)
|