|
@@ -46,7 +46,7 @@ class BatSoh:
|
|
|
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='soh_result', sn=self.sn)
|
|
|
+ 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"):
|
|
@@ -165,7 +165,7 @@ class BatSoh:
|
|
|
end_time=df_Data1.loc[len(time2)-1,'time']
|
|
|
end_time=end_time-datetime.timedelta(seconds=1200)
|
|
|
if soc2[0]<36:
|
|
|
- df_Data1=df_Data1[(df_Data1['SOC']>39.5) & (df_Data1['SOC']<80)]
|
|
|
+ df_Data1=df_Data1[(df_Data1['SOC']>40) & (df_Data1['SOC']<80)]
|
|
|
else:
|
|
|
df_Data1=df_Data1[(df_Data1['time']>start_time) & (df_Data1['SOC']<80)]
|
|
|
df_Data1=df_Data1[(df_Data1['XVOLT']>self.param.PeakVoltLowLmt) & (df_Data1['XVOLT']<self.param.PeakVoltUpLmt)]
|
|
@@ -600,7 +600,7 @@ class BatSoh:
|
|
|
#开始计算SOH.............................................................................................................................................
|
|
|
if standingpoint_sp or chrg_end:
|
|
|
self.getdata() #获取已计算的soh
|
|
|
- column_name=['time_st','time_sp','sn','method','soh','cellsoh']
|
|
|
+ column_name=['time_st','time_sp','sn','method','soh','cellsoh','weight']
|
|
|
df_res=pd.DataFrame(columns=column_name)
|
|
|
|
|
|
#两点法计算SOH........................................................................................................................................
|
|
@@ -670,32 +670,10 @@ class BatSoh:
|
|
|
cellsoh_init=ah_accum*100/((ocv_soc2-ocv_soc1)*0.01*self.param.Capacity)
|
|
|
|
|
|
if cellsoh_init>60 and cellsoh_init<115: #判断soh值的有效区间
|
|
|
- if len(df_res)<1:
|
|
|
- if not self.df_soh.empty and 60<self.df_soh.loc[len(self.df_soh)-1,'soh']<115:
|
|
|
- cellsoh_last=self.df_soh.loc[len(self.df_soh)-1,'soh']
|
|
|
- if soh_weight>1/abs(cellsoh_init-cellsoh_last):
|
|
|
- soh_weight=1/abs(cellsoh_init-cellsoh_last)
|
|
|
- cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
- else:
|
|
|
- cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
- else:
|
|
|
- cellsoh_cal=cellsoh_init*soh_weight+100*(1-soh_weight)
|
|
|
- else:
|
|
|
- cellsoh_last=df_res.loc[len(df_res)-1,'soh']
|
|
|
- if soh_weight>1/abs(cellsoh_init-cellsoh_last):
|
|
|
- soh_weight=1/abs(cellsoh_init-cellsoh_last)
|
|
|
- cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
- else:
|
|
|
- cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
-
|
|
|
- if 60<cellsoh_cal<115:
|
|
|
- cellsoh_cal=eval(format(cellsoh_cal,'.1f'))
|
|
|
- soh_list=[timepoint_bms_st, timepoint_bms_sp, self.sn, 1, cellsoh_cal, str(cellsoh_cal)]
|
|
|
- df_res.loc[len(df_res)]=soh_list
|
|
|
- else:
|
|
|
- pass
|
|
|
+ soh_list=[timepoint_bms_st, timepoint_bms_sp, self.sn, 1, cellsoh_init, cellsoh_init,soh_weight]
|
|
|
+ df_res.loc[len(df_res)]=soh_list
|
|
|
else:
|
|
|
- continue
|
|
|
+ pass
|
|
|
else:
|
|
|
pass
|
|
|
|
|
@@ -709,39 +687,50 @@ class BatSoh:
|
|
|
|
|
|
soh_weight=tempweightlist2[i]*0.25
|
|
|
if cellsoh_init>60 and cellsoh_init<115: #判断soh值的有效区间
|
|
|
- if len(df_res)<1:
|
|
|
- if not self.df_soh.empty and 60<self.df_soh.loc[len(self.df_soh)-1,'soh']<115:
|
|
|
- cellsoh_last=self.df_soh.loc[len(self.df_soh)-1,'soh']
|
|
|
- if soh_weight>1/abs(cellsoh_init-cellsoh_last):
|
|
|
- soh_weight=1/abs(cellsoh_init-cellsoh_last)
|
|
|
- cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
- else:
|
|
|
- cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
- else:
|
|
|
- cellsoh_cal=cellsoh_init*soh_weight+100*(1-soh_weight)
|
|
|
- else:
|
|
|
- cellsoh_last=df_res.loc[len(df_res)-1,'soh']
|
|
|
+ soh_list=[self.bmstime[chrg_start[i]], self.bmstime[chrg_end[i]], self.sn, 2, cellsoh_init, str(cellsoh_init),soh_weight]
|
|
|
+ df_res.loc[len(df_res)]=soh_list
|
|
|
+ else:
|
|
|
+ pass
|
|
|
+
|
|
|
+ #对SOH结果进行滤波处理................................................................................................................................
|
|
|
+ if df_res.empty:
|
|
|
+ return pd.DataFrame()
|
|
|
+ else:
|
|
|
+ df_res=df_res.sort_values(by='time_st',ascending=True)
|
|
|
+ df_res.index=range(len(df_res))
|
|
|
+ for i in range(len(df_res)):
|
|
|
+ cellsoh_init=df_res.loc[i,'soh']
|
|
|
+ soh_weight=df_res.loc[i,'weight']
|
|
|
+ if i<1:
|
|
|
+ if not self.df_soh.empty and 60<self.df_soh.loc[len(self.df_soh)-1,'soh']<115:
|
|
|
+ cellsoh_last=self.df_soh.loc[len(self.df_soh)-1,'soh']
|
|
|
if soh_weight>1/abs(cellsoh_init-cellsoh_last):
|
|
|
soh_weight=1/abs(cellsoh_init-cellsoh_last)
|
|
|
cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
else:
|
|
|
cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
-
|
|
|
+ else:
|
|
|
+ cellsoh_cal=cellsoh_init*soh_weight+100*(1-soh_weight)
|
|
|
if 60<cellsoh_cal<115:
|
|
|
- cellsoh_cal=eval(format(cellsoh_cal,'.1f'))
|
|
|
- soh_list=[self.bmstime[chrg_start[i]], self.bmstime[chrg_end[i]], self.sn, 2, cellsoh_cal, str(cellsoh_cal)]
|
|
|
- df_res.loc[len(df_res)]=soh_list
|
|
|
+ df_res.loc[i,'soh']=cellsoh_cal
|
|
|
+ df_res.loc[i,'cellsoh']=str(cellsoh_cal)
|
|
|
else:
|
|
|
- pass
|
|
|
+ df_res=df_res.drop(i,axis=0)
|
|
|
else:
|
|
|
- continue
|
|
|
- else:
|
|
|
- pass
|
|
|
-
|
|
|
- if df_res.empty:
|
|
|
- return pd.DataFrame()
|
|
|
- else:
|
|
|
+ cellsoh_last=df_res.loc[i-1,'soh']
|
|
|
+ if soh_weight>1/abs(cellsoh_init-cellsoh_last):
|
|
|
+ soh_weight=1/abs(cellsoh_init-cellsoh_last)
|
|
|
+ cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
+ else:
|
|
|
+ cellsoh_cal=cellsoh_init*soh_weight + cellsoh_last*(1-soh_weight)
|
|
|
+ if 60<cellsoh_cal<115:
|
|
|
+ df_res.loc[i,'soh']=cellsoh_cal
|
|
|
+ df_res.loc[i,'cellsoh']=str(cellsoh_cal)
|
|
|
+ else:
|
|
|
+ df_res=df_res.drop(i,axis=0)
|
|
|
+ df_res=df_res.drop('weight',axis=1)
|
|
|
return df_res
|
|
|
+
|
|
|
return pd.DataFrame()
|
|
|
|
|
|
|