ソースを参照

Merge remote-tracking branch 'origin/dev' into pro

lmstack 3 年 前
コミット
1f17945580

+ 81 - 37
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/V1_0_1/CBMSBatInterShort.py

@@ -1,6 +1,7 @@
 import pandas as pd
 import numpy as np
 import matplotlib.pyplot as plt
+import datetime
 # from pymysql import paramstyle
 from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam
 
@@ -16,12 +17,13 @@ class BatInterShort():
         self.sn=sn
         self.celltype=celltype
         self.param=BatParam.BatParam(celltype)
-        self.df_bms=df_bms
         self.packcrnt=df_bms['总电流[A]']*self.param.PackCrntDec
         self.packvolt=df_bms['总电压[V]']
         self.bms_soc=df_bms['SOC[%]']
-        self.bmstime= pd.to_datetime(df_bms['时间戳'], format='%Y-%m-%d %H:%M:%S')
+        df_bms['time']=pd.to_datetime(df_bms['时间戳'], format='%Y-%m-%d %H:%M:%S')
+        self.bmstime= df_bms['time']
 
+        self.df_bms=df_bms
         self.df_soh=df_soh
         self.df_last=df_last
         self.df_last1=df_last1
@@ -49,12 +51,12 @@ class BatInterShort():
     #寻找当前行数据的最小温度值.............................................................................
     def _celltemp_weight(self,num):   
         celltemp = list(self.df_bms.loc[num,self.celltemp_name])
-        celltemp=np.mean(celltemp)
+        celltemp=min(celltemp)
         self.celltemp=celltemp
         if self.celltype==99:
             if celltemp>=25:
                 self.tempweight=1
-                self.StandardStandingTime=3600
+                self.StandardStandingTime=4800
             elif celltemp>=15:
                 self.tempweight=0.6
                 self.StandardStandingTime=7200
@@ -65,12 +67,12 @@ class BatInterShort():
                 self.tempweight=0.1
                 self.StandardStandingTime=10800
         else:
-            if celltemp>=20:
+            if celltemp>=25:
                 self.tempweight=1
-                self.StandardStandingTime=3600
-            elif celltemp>=10:
+                self.StandardStandingTime=4800
+            elif celltemp>=15:
                 self.tempweight=0.8
-                self.StandardStandingTime=3600
+                self.StandardStandingTime=7200
             elif celltemp>=5:
                 self.tempweight=0.6
                 self.StandardStandingTime=7200
@@ -78,8 +80,28 @@ class BatInterShort():
                 self.tempweight=0.2
                 self.StandardStandingTime=10800
 
+    #获取前半个小时每个电压的平均值........................................................................................
+    def _avgvolt_get(self,num): 
+        time_now=self.df_bms.loc[num, 'time']
+        time_last=time_now-datetime.timedelta(seconds=1800)
+        df_volt=self.df_bms[(self.df_bms['time']>=time_last) & (self.df_bms['time']<=time_now)]
+        df_volt=df_volt[self.cellvolt_name]
+        if len(df_volt)>2:
+            cellvolt_sum=df_volt.sum(0)-df_volt.max(0)-df_volt.min(0)
+            cellvolt_mean=cellvolt_sum/(len(df_volt)-2)
+            cellvolt=cellvolt_mean/1000
+        elif len(df_volt)==2:
+            # df_volt=pd.DataFrame(df_volt,dtype=np.float)
+            if max(abs(df_volt.iloc[1]-df_volt.iloc[0]))<3:
+                cellvolt=df_volt.mean(0)/1000
+            else:
+                cellvolt=pd.DataFrame()
+        else:
+            cellvolt=df_volt.iloc[0]
+        return cellvolt
+
     #获取当前行所有电压数据........................................................................................
-    def _cellvolt_get(self,num): 
+    def _cellvolt_get(self,num):
         cellvolt = np.array(self.df_bms.loc[num,self.cellvolt_name])/1000
         return cellvolt
 
@@ -109,6 +131,20 @@ class BatInterShort():
                 else:
                     celldeltsoc.append(cellsoc[j]-cellsocmean2)
             return np.array(celldeltsoc), np.array(cellsoc)
+        
+        elif self.celltype==99:
+            consum_num=10
+            cellsoc1=cellsoc[:self.param.CellVoltNums-consum_num]    #切片,将bms耗电的电芯和非耗电的电芯分离开
+            cellsocmean1=(sum(cellsoc1)-max(cellsoc1)-min(cellsoc1))/(len(cellsoc1)-2)
+            cellsoc2=cellsoc[self.param.CellVoltNums-consum_num:]
+            cellsocmean2=(sum(cellsoc2)-max(cellsoc2)-min(cellsoc2))/(len(cellsoc2)-2)
+            
+            for j in range(len(cellsoc)):   #计算每个电芯的soc差
+                if j<self.param.CellVoltNums-consum_num:
+                    celldeltsoc.append(cellsoc[j]-cellsocmean1)
+                else:
+                    celldeltsoc.append(cellsoc[j]-cellsocmean2)
+            return np.array(celldeltsoc), np.array(cellsoc)
 
         else:
             cellsocmean=(sum(cellsoc)-max(cellsoc)-min(cellsoc))/(len(cellsoc)-2)
@@ -277,13 +313,15 @@ class BatInterShort():
                 if firsttime==1:    
                     if standingtime>self.StandardStandingTime*2:      #静置时间满足要求
                         standingtime=0
-                        cellvolt_now=self._cellvolt_get(i)
+                        cellvolt_now=self._avgvolt_get(i)
                         cellvolt_min=min(cellvolt_now)
                         cellvolt_max=max(cellvolt_now)
-                        cellvolt_last=self._cellvolt_get(i-1)
-                        deltvolt=max(abs(cellvolt_now-cellvolt_last))
+                        # cellvolt_last=self._avgvolt_get(i-1)
+                        # deltvolt=max(abs(cellvolt_now-cellvolt_last))
+                        cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
+                        cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
 
-                        if 2<cellvolt_min<4.5 and 2<cellvolt_max<4.5 and deltvolt<0.005: 
+                        if (not cellvolt_now.empty) and 2<cellvolt_min<4.5 and 2<cellvolt_max<4.5 and (45<cellsoc_max or cellsoc_max<30) and (45<cellsoc_min or cellsoc_min<30): 
                             dict_baltime={}   #获取每个电芯的均衡时间
                             deltsoc_last, cellsoc_last=self._celldeltsoc_get(i,dict_baltime,capacity)
                             time_last=self.bmstime[i]
@@ -291,15 +329,15 @@ class BatInterShort():
                             df_ram_last.loc[0]=[self.sn,time_last,deltsoc_last,cellsoc_last]   #更新RAM信息
                     else:
                         pass                
-                elif standingtime>3600*10:
+                elif standingtime>3600*12:
                     standingtime=0
-                    cellvolt_now=self._cellvolt_get(i)
+                    cellvolt_now=self._avgvolt_get(i)
                     cellvolt_min=min(cellvolt_now)
                     cellvolt_max=max(cellvolt_now)
-                    cellvolt_last=self._cellvolt_get(i-1)
-                    deltvolt=max(abs(cellvolt_now-cellvolt_last))
+                    # cellvolt_last=self._avgvolt_get(i-1)
+                    # deltvolt=max(abs(cellvolt_now-cellvolt_last))
                     
-                    if 2<cellvolt_min<4.5 and 2<cellvolt_max<4.5 and deltvolt<0.005:
+                    if (not cellvolt_now.empty) and 2<cellvolt_min<4.5 and 2<cellvolt_max<4.5:
                         dict_baltime=self._bal_time(dict_bal)   #获取每个电芯的均衡时间
                         deltsoc_now, cellsoc_now=self._celldeltsoc_get(i,dict_baltime,capacity)
                         time_now=self.bmstime[i]
@@ -337,14 +375,14 @@ class BatInterShort():
                 #满电静置法计算内短路-开始.....................................................................................................................................................
                 if self.StandardStandingTime<standingtime1:  
                     standingtime1=0
-                    cellvolt_now1=self._cellvolt_get(i)
+                    cellvolt_now1=self._avgvolt_get(i)
                     cellvolt_max1=max(cellvolt_now1)
                     cellvolt_min1=min(cellvolt_now1)
-                    cellvolt_last1=self._cellvolt_get(i-1)
-                    deltvolt1=max(abs(cellvolt_now1-cellvolt_last1))
+                    # cellvolt_last1=self._avgvolt_get(i-1)
+                    # deltvolt1=max(abs(cellvolt_now1-cellvolt_last1))
                     cellsoc_now1=np.interp(cellvolt_max1,self.param.LookTab_OCV,self.param.LookTab_SOC)
 
-                    if cellsoc_now1>=self.param.FullChrgSoc-10 and 2<cellvolt_min1<4.5 and 2<cellvolt_max1<4.5 and deltvolt1<0.005:
+                    if (not cellvolt_now1.empty) and cellsoc_now1>=self.param.FullChrgSoc-10 and 2<cellvolt_min1<4.5 and 2<cellvolt_max1<4.5:
                         if firsttime1==1:
                             dict_baltime1={}   #获取每个电芯的均衡时间
                             deltsoc_last1, cellsoc_last1=self._celldeltsoc_get(i,dict_baltime1,capacity)
@@ -354,7 +392,7 @@ class BatInterShort():
                         else:
                             dict_baltime1=self._bal_time(dict_bal1)   #获取每个电芯的均衡时间
                             time_now1=self.bmstime[i]
-                            if (time_now1-time_last1).total_seconds()>3600*12:
+                            if (time_now1-time_last1).total_seconds()>3600*20:
                                 deltsoc_now1, cellsoc_now1=self._celldeltsoc_get(i,dict_baltime1,capacity)
                                 df_ram_last1.loc[0]=[self.sn,time_now1,deltsoc_now1] #更新RAM信息
 
@@ -483,13 +521,15 @@ class BatInterShort():
                 if firsttime==1:    
                     if standingtime>self.StandardStandingTime:      #静置时间满足要求
                         standingtime=0
-                        cellvolt_now=self._cellvolt_get(i)
+                        cellvolt_now=self._avgvolt_get(i)
                         cellvolt_min=min(cellvolt_now)
                         cellvolt_max=max(cellvolt_now)
-                        cellvolt_last=self._cellvolt_get(i-1)
-                        deltvolt=max(abs(cellvolt_now-cellvolt_last))
+                        # cellvolt_last=self._avgvolt_get(i-1)
+                        # deltvolt=max(abs(cellvolt_now-cellvolt_last))
+                        cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
+                        cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
 
-                        if 2<cellvolt_max<self.param.OcvInflexionBelow-0.002 and 2<cellvolt_min<4.5 and abs(deltvolt)<0.003:
+                        if (not cellvolt_now.empty)  and cellsoc_max<self.param.SocInflexion1-2 and 12<cellsoc_min:
                             dict_baltime={}  #获取每个电芯的均衡时间
                             deltsoc_last, cellsoc_last=self._celldeltsoc_get(i,dict_baltime,capacity)
                             time_last=self.bmstime[i]
@@ -499,15 +539,17 @@ class BatInterShort():
                             pass
                     else:
                         pass                
-                elif standingtime>3600*10:
+                elif standingtime>3600*12:
                     standingtime=0
-                    cellvolt_now=np.array(self._cellvolt_get(i))
+                    cellvolt_now=np.array(self._avgvolt_get(i))
                     cellvolt_min=min(cellvolt_now)
                     cellvolt_max=max(cellvolt_now)
-                    cellvolt_last=np.array(self._cellvolt_get(i-1))
-                    deltvolt=max(abs(cellvolt_now-cellvolt_last))
+                    # cellvolt_last=np.array(self._avgvolt_get(i-1))
+                    # deltvolt=max(abs(cellvolt_now-cellvolt_last))
+                    cellsoc_max=np.interp(cellvolt_max,self.param.LookTab_OCV,self.param.LookTab_SOC)
+                    cellsoc_min=np.interp(cellvolt_min,self.param.LookTab_OCV,self.param.LookTab_SOC)
 
-                    if 2<cellvolt_max<self.param.OcvInflexionBelow-0.002 and 2<cellvolt_min<4.5  and abs(deltvolt)<0.003:
+                    if (not cellvolt_now.empty)  and cellsoc_max<self.param.SocInflexion1-2 and 12<cellsoc_min:
                         dict_baltime=self._bal_time(dict_bal)   #获取每个电芯的均衡时间
                         deltsoc_now, cellsoc_now=self._celldeltsoc_get(i, dict_baltime,capacity)    #获取每个电芯的SOC差
                         time_now=self.bmstime[i]
@@ -547,13 +589,15 @@ class BatInterShort():
                 #非平台区间静置法计算内短路-开始.....................................................................................................................................................
                 if standingtime1>self.StandardStandingTime: 
                     standingtime1=0
-                    cellvolt_now1=self._cellvolt_get(i)
+                    cellvolt_now1=self._avgvolt_get(i)
                     cellvolt_max1=max(cellvolt_now1)
                     cellvolt_min1=min(cellvolt_now1)
-                    cellvolt_last1=self._cellvolt_get(i-1)
-                    deltvolt1=max(abs(cellvolt_now1-cellvolt_last1))
+                    # cellvolt_last1=self._avgvolt_get(i-1)
+                    # deltvolt1=max(abs(cellvolt_now1-cellvolt_last1))
+                    cellsoc_max1=np.interp(cellvolt_max1,self.param.LookTab_OCV,self.param.LookTab_SOC)
+                    cellsoc_min1=np.interp(cellvolt_min1,self.param.LookTab_OCV,self.param.LookTab_SOC)
                 
-                    if 2<cellvolt_max1<self.param.OcvInflexionBelow-0.002 and 2<cellvolt_min1<4.5 and deltvolt1<0.005:
+                    if (not cellvolt_now1.empty)  and cellsoc_max1<self.param.SocInflexion1-2 and 12<cellsoc_min1:
                         if firsttime1==1:
                             dict_baltime1=self._bal_time(dict_bal1)   #获取每个电芯的均衡时间
                             deltsoc_last1, cellsoc_last1=self._celldeltsoc_get(i,dict_baltime1,capacity)
@@ -628,7 +672,7 @@ class BatInterShort():
                         continue
                     elif min(cellvolt_now)>self.param.CellFullChrgVolt-0.13:   #电压>满充电压-0.13V,即3.37V
                         self._celltemp_weight(i)
-                        if i-chrg_start>10 and self.celltemp>15:
+                        if i-chrg_start>10 and self.celltemp>20:
                             chrg_end=i+1
                             charging=0
 

+ 1 - 1
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/V1_0_1/CBMSBatUniform.py

@@ -484,7 +484,7 @@ class BatUniform():
                         cellsoc_diff=peaksoc_max-peaksoc_min
                         cellsoc_diff=eval(format(cellsoc_diff,'.1f'))
                         if not df_res.empty:
-                            cellvolt_rank=df_res.loc[-1]['cellvolt_rank']
+                            cellvolt_rank=df_res.iloc[-1]['cellvolt_rank']
                             df_res.loc[len(df_res)]=[self.bmstime[chrg_start[i]], self.sn, cellsoc_diff, 0, peaksoc_minnum, peaksoc_maxnum, cellvolt_rank]
                         elif not self.df_uniform.empty:
                             cellvolt_rank=self.df_uniform.iloc[-1]['cellvolt_rank']

+ 57 - 42
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/V1_0_1/CBMSSafetyWarning.py

@@ -6,15 +6,15 @@ from matplotlib import pyplot as plt
 from LIB.MIDDLE.CellStateEstimation.Common.V1_0_1 import BatParam
 
 class SafetyWarning:
-    def __init__(self,sn,celltype,df_short,df_liplated,df_uniform,OutLineVol_Rate):  #参数初始化
+    def __init__(self,sn,celltype,df_short,df_uniform,OutLineVol_Rate,df_soh):  #参数初始化
 
         self.sn=sn
         self.celltype=celltype
         self.param=BatParam.BatParam(celltype)
         self.df_short=df_short
-        self.df_liplated=df_liplated
-        self.df_uniform=df_uniform.dropna(axis=0,how='any')
+        self.df_uniform=df_uniform
         self.OutLineVol_Rate=OutLineVol_Rate
+        self.df_soh=df_soh
     
     def diag(self):
         if self.celltype<=50:
@@ -35,7 +35,6 @@ class SafetyWarning:
 
         #参数初始化.......................................
         shortfault=0
-        liplatedfault=0
         uniformfault=0
         volt_rate=[]
 
@@ -50,25 +49,31 @@ class SafetyWarning:
             self.OutLineVol_Rate['VolChng_Uni']=self.OutLineVol_Rate['VolChng_Uni'].str.replace("]","")
             self.OutLineVol_Rate['VolOl_Uni']=self.OutLineVol_Rate['VolOl_Uni'].str.replace("[","")
             self.OutLineVol_Rate['VolOl_Uni']=self.OutLineVol_Rate['VolOl_Uni'].str.replace("]","")
-            VoltChangeOutLine_Rate=self.OutLineVol_Rate['VolChng_Uni'].str.split(',',expand=True)
             Volt_3Sigma=self.OutLineVol_Rate['VolOl_Uni'].str.split(',',expand=True)
-            VoltChangeOutLine_Rate.columns=volt_column
             Volt_3Sigma.columns=volt_column
-            VoltChangeOutLine_Rate['time']=self.OutLineVol_Rate['time']
-            time0=time.mktime(VoltChangeOutLine_Rate.loc[0,'time'].timetuple())
-            for i in range(0,len(VoltChangeOutLine_Rate)):
-                VoltChangeOutLine_Rate.loc[i,'time']=(time.mktime(VoltChangeOutLine_Rate.loc[i,'time'].timetuple())-time0)/60000
-        
-        if not self.df_liplated.empty:
-            liplated=self.df_liplated['liplated_amount']
-            liplated=liplated.str.replace("[", '')
-            liplated=liplated.str.replace("]", '')
+
+            #电压变化率
+            VoltChange=self.OutLineVol_Rate['VolChng_Uni'].str.split(',',expand=True)
+            VoltChange.columns=volt_column
+            VoltChange['time']=self.OutLineVol_Rate['time']
+            VoltChange = VoltChange.reset_index(drop=True)
+            xtime1=VoltChange['time']
+            time0=time.mktime(VoltChange.loc[0,'time'].timetuple())
+            for i in range(0,len(VoltChange)):
+                VoltChange.loc[i,'time']=(time.mktime(VoltChange.loc[i,'time'].timetuple())-time0)/36000
+            
+    
+        # if not self.df_liplated.empty:
+        #     liplated=self.df_liplated['liplated_amount']
+        #     liplated=liplated.str.replace("[", '')
+        #     liplated=liplated.str.replace("]", '')
         
         if not self.df_uniform.empty:
             cellvolt_rank=self.df_uniform['cellvolt_rank']
             cellvolt_rank=cellvolt_rank.str.replace("[", '')
             cellvolt_rank=cellvolt_rank.str.replace("]", '')
 
+        # plt.figure()
         for i in range(self.param.CellVoltNums):
 
             #漏电流故障判断...........................................................................
@@ -77,38 +82,39 @@ class SafetyWarning:
 
                 cellshort=self.df_short['cellshort'+str(i+1)]
                 index_list=cellshort[cellshort<self.param.LeakCurrentLv2].index
-                if len(index_list)==2 and (index_list[1]-index_list[0])==1:
-                    shortfault=1
-                elif len(index_list)>3:
-                    shortfault=1
+                if len(index_list)>1:
+                    for j in range(1,len(index_list)):
+                        if index_list[j]-index_list[j-1]==1:
+                            shortfault=1
+                            break
+                        else:
+                            shortfault=0
                 else:
                     shortfault=0
             
             #电压变化率及电压离群度.................................................................................
-            if not self.OutLineVol_Rate.empty and VoltChangeOutLine_Rate.iloc[-1]['time']*60000>24*3600 and len(VoltChangeOutLine_Rate)>10:
-                VoltChangeOutLine_Rate[volt_column[i]]=VoltChangeOutLine_Rate[volt_column[i]].map(lambda x:eval(x))
+            if not self.OutLineVol_Rate.empty and VoltChange.iloc[-1]['time']*36000>18*3600 and len(VoltChange)>5:
+
                 volt3sigma=np.array(Volt_3Sigma[volt_column[i]].map(lambda x:eval(x)))
                 volt3sigma_sum=np.sum(volt3sigma<-3)
-                a1,b1=np.polyfit(VoltChangeOutLine_Rate['time'].tolist(),VoltChangeOutLine_Rate[volt_column[i]].tolist(),1)
-                y=a1*VoltChangeOutLine_Rate['time']+b1
+
+                #电压变化率
+                VoltChange[volt_column[i]]=VoltChange[volt_column[i]].map(lambda x:eval(x))
+                a1,b1=np.polyfit(VoltChange['time'].tolist(),VoltChange[volt_column[i]].tolist(),1)
+                y=a1*VoltChange['time']+b1
                 volt_rate.append(a1)
-                # plt.plot(VoltChangeOutLine_Rate['time'],y,label=volt_column[i])
-                # plt.scatter( VoltChangeOutLine_Rate['time'],VoltChangeOutLine_Rate[volt_column[i]],marker='o')
+                # plt.plot(xtime1,y,label=a1)
+                # plt.scatter( xtime1,VoltChange[volt_column[i]],marker='o')
                 # plt.legend(loc='best')
+                # # plt.title(str(a1))
                 # plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签
                 # plt.rcParams['axes.unicode_minus']=False #用来正常显示负号  
-                # plt.show()
                 
-                if a1<self.param.TrwVoltRate:
-                    voltratefault=1
-                else:
-                    voltratefault=0
                 if volt3sigma_sum>len(self.OutLineVol_Rate)/2:
                     voltsigmafault=1
                 else:
                     voltsigmafault=0
             else:
-                voltratefault=0
                 voltsigmafault=0
             
             #析锂故障判断...............................................................................
@@ -133,28 +139,37 @@ class SafetyWarning:
             else:
                 uniformfault=0
             
-            #电池热安全预警...............................................................................
-            if (shortfault==1 or voltratefault==1)and (voltsigmafault==1 or uniformfault==1):
+            #电池内短路热失控预警...............................................................................
+            if shortfault==1 and (voltsigmafault==1 or uniformfault==1):
                 faultcode=110
                 faultlv=4
                 faultinfo='电芯{}发生热失控安全预警'.format(i+1)
                 faultadvice='1联系用户远离电池,立刻召回电池'
                 df_res.loc[0]=[time_now, time_sp, self.sn, faultcode, faultlv, faultinfo, faultadvice]
-            elif voltratefault==1:
+            else:
+                pass
+        
+        #电池电压变化率热失控预警...............................................................................
+        volt_rate_std=np.std(volt_rate)
+        volt_rate_mean=np.mean(volt_rate)
+        volt_rate_3sigma=(np.array(volt_rate)-volt_rate_mean)/volt_rate_std
+        if not self.df_soh.empty and self.celltype<50:
+            cellsoh=eval(self.df_soh.loc[0,'cellsoh'])
+            cellsoh_std=np.std(cellsoh)
+            cellsoh_mean=np.mean(cellsoh)
+            cellsoh_3sigma=((np.array(cellsoh)-cellsoh_mean)/cellsoh_std)
+        else:
+            cellsoh_3sigma=[0]*self.param.CellVoltNums
+        for i in range(len(volt_rate)):
+            if volt_rate[i]<self.param.TrwVoltRate and volt_rate_3sigma[i]<-3 and abs(cellsoh_3sigma[i])<3:
                 faultcode=110
                 faultlv=4
                 faultinfo='电芯{}发生热失控安全预警'.format(i+1)
                 faultadvice='2联系用户远离电池,立刻召回电池'
                 df_res.loc[0]=[time_now, time_sp, self.sn, faultcode, faultlv, faultinfo, faultadvice]
-            elif shortfault==1:
-                faultcode=110
-                faultlv=4
-                faultinfo='电芯{}发生热失控安全预警'.format(i+1)
-                faultadvice='3联系用户远离电池,立刻召回电池'
-                df_res.loc[0]=[time_now, time_sp, self.sn, faultcode, faultlv, faultinfo, faultadvice]
             else:
                 pass
         
-        # print(volt_rate)
-            
+        # plt.show()
+
         return df_res

+ 66 - 52
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/V1_0_1/VoltStray.py

@@ -1,3 +1,4 @@
+from re import X
 import pandas as pd
 import numpy as np
 from pandas.core.frame import DataFrame
@@ -8,25 +9,25 @@ def preprocess(df):
     # 滤除前后电压存在一增一减的情况(采样异常)
     pass
 
-# 计算电压的偏离度    
-def cal_volt_uniform(dfin, volt_column, window=10, step=5, threshold=3):
+# 计算SOC变化率  
+def cal_volt_change(dfin, volt_column):
     
     df = dfin.copy()
-    # time_list = dfin['time'].tolist()
-
-    # # 电压滤波
-    # df_volt = df[volt_column] 
-    # df_volt_rolling = df_volt.rolling(window).mean()[window-1::step]  # 滑动平均值
-    # time_list = time_list[window-1::step]
     df_volt_rolling = df[volt_column] 
 
-    # 电压偏离度
     df_volt_rolling_sum=df_volt_rolling.sum(1)-df_volt_rolling.max(1)
     df_volt_rolling_sum=df_volt_rolling_sum-df_volt_rolling.min(1)
-    mean = df_volt_rolling_sum/(len(volt_column)-2)
-    df_volt_rolling_norm = df_volt_rolling.sub(mean, axis=0)#.div(std,axis=0)
+    mean1 = df_volt_rolling_sum/(len(volt_column)-2)
+    df_volt_rolling_norm = df_volt_rolling.sub(mean1, axis=0)#.div(std,axis=0)
     df_volt_rolling_norm = df_volt_rolling_norm.reset_index(drop=True)#和均值的距离
+
+    return df_volt_rolling_norm
+
+# 计算电压离群  
+def cal_volt_sigma(dfin, volt_column):
     
+    df = dfin.copy()
+    df_volt_rolling = df[volt_column] 
     
     mean1=df_volt_rolling.mean(axis=1)
     std = df_volt_rolling.std(axis=1)
@@ -34,7 +35,7 @@ def cal_volt_uniform(dfin, volt_column, window=10, step=5, threshold=3):
     df_volt_rolling = df_volt_rolling.sub(mean1, axis=0).div(std,axis=0)
     df_volt_rolling = df_volt_rolling.reset_index(drop=True)#分布
 
-    return df_volt_rolling_norm,df_volt_rolling
+    return df_volt_rolling
 
 
 # # 计算电压变化量的偏离度    
@@ -73,56 +74,69 @@ def cal_volt_uniform(dfin, volt_column, window=10, step=5, threshold=3):
 #     return df_voltdiff_rolling_norm, time_list
 def main(sn,df_bms,celltype):
     param=BatParam.BatParam(celltype)
+    df_bms['总电流[A]']=df_bms['总电流[A]']*param.PackCrntDec
+    df_bms.rename(columns = {'总电流[A]':'PackCrnt'}, inplace=True)
+    df_bms['time']=pd.to_datetime(df_bms['时间戳'], format='%Y-%m-%d %H:%M:%S')
     volt_column = ['单体电压'+str(i) for i in range(1,param.CellVoltNums+1)]
-    columns=['时间戳']+volt_column
-    df_bms=df_bms[df_bms['SOC[%]']>15]
-    df_ori = df_bms[columns]
-    df_ori.rename(columns = {'时间戳':'time'}, inplace=True)
-    df_ori['time']=pd.to_datetime(df_ori['time'], format='%Y-%m-%d %H:%M:%S')
-    df = df_ori.drop_duplicates(subset=['time']) # 删除时间相同的数据
-    df= df.set_index('time')
-    df=df[(df[volt_column]>2000) & (df[volt_column]<4500)]
-    time_list=df.index.tolist()
-    df = df.reset_index(drop=True)
-
-    window = 50
-    step = 10
-    window2 = 5
-    step2 = 3
-    OutLineVol=DataFrame(columns=['time','sn','VolOl_Uni','VolChng_Uni'])
-    #df_result_1,time_list_1 = cal_voltdiff_uniform(df,volt_column, window=window, step=step, window2=window2, step2=step2)
-    VolChng_Uni,VolOl_Uni= cal_volt_uniform(df,volt_column, window=window, step=step)
+    columns=['time']+volt_column
+    df_bms=df_bms[df_bms['SOC[%]']>10]
+    # df_standing=df_bms[(df_bms['PackCrnt']>-0.1) & (df_bms['PackCrnt']<0.1)]
+    # df_chrg=df_bms[(df_bms['PackCrnt']<-1)]
+
+    #电压/SOC变化率计算
+    if celltype<50:
+        df_ori = df_bms[columns]
+        df = df_ori.drop_duplicates(subset=['time']) # 删除时间相同的数据
+        df= df.set_index('time')
+        df=df[(df[volt_column]>2000) & (df[volt_column]<4500)]
+        df[volt_column]=pd.DataFrame(df[volt_column],dtype=np.float)
+        df=df.resample('H').mean()  #取一个小时的平均值
+        df=df.dropna(how='any')
+        time_list1=df.index.tolist()
     
-    if len(VolChng_Uni)>10 and len(VolOl_Uni)>10:
-        #df_result_1['time'] = time_list_1
-        VolChng_Uni['time'] = time_list
-        # VolChng_Uni['time']=pd.to_datetime(VolChng_Uni['time'], format='%Y-%m-%d %H:%M:%S')
-        # df_result_1['time'].apply(lambda x: x.datetime.strptime('%Y-%m-%d %H:%M:%S'))
-        VolChng_Uni= VolChng_Uni.set_index('time')
-        VolChng_Uni[volt_column]=pd.DataFrame(VolChng_Uni[volt_column],dtype=np.float)
-        VolChng_Uni=VolChng_Uni.resample('H').mean()
-        VolChng_Uni=VolChng_Uni.dropna(how='any')#改
-        VolChng_Uni_result=VolChng_Uni.values.tolist()#改
-        
-        VolOl_Uni['time'] = time_list
-        VolOl_Uni= VolOl_Uni.set_index('time')
-        VolOl_Uni.index = pd.to_datetime(VolOl_Uni.index)
-        VolOl_Uni[volt_column]=pd.DataFrame(VolOl_Uni[volt_column],dtype=np.float)
-        VolOl_Uni=VolOl_Uni.resample('H').mean()
-        VolOl_Uni=VolOl_Uni.dropna(how='any')#改
-        VolOl_Uni_result=VolOl_Uni.values.tolist()#改
-        #df_result_VoltDif_Uni=str(df_result_VoltDif_Uni.tolist())
-        
+        fun=lambda x: np.interp(x/1000, param.LookTab_OCV, param.LookTab_SOC)
+        df_soc=df.applymap(fun)
+
+        VolChng = cal_volt_change(df_soc,volt_column)
+    else:
+        df_bms=df_bms[df_bms['SOC[%]']<95]
+        # df_bms=df_bms[(df_bms['PackCrnt']>-0.1) & (df_bms['PackCrnt']<0.1)]
+        df_ori = df_bms[columns]
+        df = df_ori.drop_duplicates(subset=['time']) # 删除时间相同的数据
+        df= df.set_index('time')
+        df=df[(df[volt_column]>3200) & (df[volt_column]<3400)]
+        df[volt_column]=pd.DataFrame(df[volt_column],dtype=np.float)
+        df=df.resample('H').mean()  #取一个小时的平均值
+        df=df.dropna(how='any')
+        time_list1=df.index.tolist()
+
+        VolChng = cal_volt_change(df,volt_column)
+    
+
+    VolSigma = cal_volt_sigma(df,volt_column)
+
+    OutLineVol=DataFrame(columns=['time','sn','VolOl_Uni','VolChng_Uni'])
+
+    #静置电压变化率和离群度计算
+    if len(VolChng)>5 and len(VolSigma)>5:
+        VolChng['time'] = time_list1
+        VolChng= VolChng.set_index('time')
+        VolChng_Uni_result=VolChng.values.tolist()#改
         
-        for i in range(0,len(VolChng_Uni)):
+        VolSigma['time'] = time_list1
+        VolSigma= VolSigma.set_index('time')
+        VolOl_Uni_result=VolSigma.values.tolist()#改
+       
+        for i in range(0,len(VolChng)):
             OutLineVol.loc[i,'VolOl_Uni']=str(list(np.around(VolOl_Uni_result[i],decimals=2)))
             OutLineVol.loc[i,'VolChng_Uni']=str(list(np.around(VolChng_Uni_result[i],decimals=2)))
         OutLineVol=OutLineVol[~OutLineVol['VolOl_Uni'].str.contains('nan')]
         OutLineVol=OutLineVol[~OutLineVol['VolChng_Uni'].str.contains('nan')]
         OutLineVol=OutLineVol.applymap((lambda x:''.join(x.split()) if type(x) is str else x)) 
         OutLineVol=OutLineVol.reset_index(drop=True) 
-        OutLineVol['time']= VolOl_Uni.index
+        OutLineVol['time']= VolSigma.index
         OutLineVol['sn']=sn
+
     return(OutLineVol)
     # this_alarm = {}
     # df_alarm = df_voltdiff_rolling_norm[abs(df_voltdiff_rolling_norm)>threshold].dropna(how='all')

+ 10 - 13
LIB/MIDDLE/CellStateEstimation/BatSafetyWarning/main.py

@@ -26,10 +26,10 @@ def saftywarning_cal():
     
     # start=time.time()
     now_time=datetime.datetime.now()
-    start_time=now_time-datetime.timedelta(hours=12)
+    start_time=now_time-datetime.timedelta(hours=6)
     start_time1=now_time-datetime.timedelta(days=7)
-    start_time2=now_time-datetime.timedelta(days=90)
-    start_time3=now_time-datetime.timedelta(days=3)
+    start_time2=now_time-datetime.timedelta(days=3)
+    start_time3=now_time-datetime.timedelta(days=1)
     start_time=start_time.strftime('%Y-%m-%d %H:%M:%S')
     start_time1=start_time1.strftime('%Y-%m-%d %H:%M:%S')
     start_time2=start_time2.strftime('%Y-%m-%d %H:%M:%S')
@@ -127,11 +127,10 @@ def saftywarning_cal():
                     file.write(str(df_rank_res)+'\n')
             
             #电压离群.....................................................................................................................................................
-            OutLineVol=VoltStray.main(sn,df_bms,celltype)
-            if not OutLineVol.empty:
-                df_voltsigma=OutLineVol
+            df_voltsigma=VoltStray.main(sn,df_bms,celltype)
+            if not df_voltsigma.empty:
                 with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\07BatSafetyWarning\电压离群.txt','a') as file:
-                    file.write(str(OutLineVol)+'\n')
+                    file.write(str(df_voltsigma)+'\n')
 
             #ram处理................................................................................................................
             df_warning_ram=df_warning_ram.drop(df_warning_ram[df_warning_ram.sn==sn].index)
@@ -156,14 +155,12 @@ def saftywarning_cal():
         db='qx_cas'
         mode=2
         tablename1='cellstateestimation_intershort'
-        tablename2='mechanism_liplated'   #析锂表单
         tablename3='cellstateestimation_uniform_socvoltdiff'
-        tablename4=''   #电压离群表单
+        tablename4='outlier_voltchangeratio'   #电压离群表单
         DBRead=DBDownload.DBDownload(host, port, db, user, password,mode)
         with DBRead as DBRead:
             df_short=DBRead.getdata('time_sp,sn,short_current', tablename=tablename1, sn=sn, timename='time_sp', st=start_time1, sp=end_time)
-            df_liplated=DBRead.getdata('time,sn,liplated,liplated_amount', tablename=tablename2, sn=sn, timename='time', st=start_time2, sp=end_time)
-            df_uniform=DBRead.getdata('time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank', tablename=tablename3, sn=sn, timename='time', st=start_time3, sp=end_time)
+            df_uniform=DBRead.getdata('time,sn,cellsoc_diff,cellvolt_diff,cellmin_num,cellmax_num,cellvolt_rank', tablename=tablename3, sn=sn, timename='time', st=start_time2, sp=end_time)
             df_voltsigma=DBRead.getdata('time,sn,VolOl_Uni,VolChng_Uni', tablename=tablename4, sn=sn, timename='time', st=start_time3, sp=end_time)
 
         #获取sn的故障RAM
@@ -171,7 +168,7 @@ def saftywarning_cal():
         
         #热安全预警
         if df_fault_ram_sn.empty:
-            BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_liplated,df_uniform,df_voltsigma)
+            BatWarning=CBMSSafetyWarning.SafetyWarning(sn,celltype,df_short,df_uniform,df_voltsigma)
             df_warning_res=BatWarning.diag()
             #当前热失控故障写入数据库
             if not df_warning_res.empty:
@@ -220,7 +217,7 @@ if __name__ == "__main__":
 
     #定时任务.......................................................................................................................................................................
     scheduler = BlockingScheduler()
-    scheduler.add_job(saftywarning_cal, 'interval', hours=12)
+    scheduler.add_job(saftywarning_cal, 'interval', hours=6)
 
     try:  
         scheduler.start()

+ 16 - 5
LIB/MIDDLE/CellStateEstimation/Common/V1_0_1/BatParam.py

@@ -16,7 +16,6 @@ class BatParam:
         self.TrwCellVoltFall=1
         self.TrwCellVoltLow=1.5
         self.TrwPackVoltFall=1.5
-        self.TrwVoltRate=-6
 
         self.SocJump=10
         self.SocClamp=0.1
@@ -76,6 +75,8 @@ class BatParam:
             self.CellTempLowLv2=-25
             self.CellTempDiffLv1=10
             self.CellTempDiffLv2=15
+
+            self.TrwVoltRate=-0.5
         elif celltype==2: #4840
             self.Capacity = 41
             self.PackFullChrgVolt=69.99
@@ -113,6 +114,8 @@ class BatParam:
             self.CellTempLowLv2=-25
             self.CellTempDiffLv1=10
             self.CellTempDiffLv2=15
+
+            self.TrwVoltRate=-0.5
         elif celltype==3:   #力信50ah三元电芯
             self.Capacity = 51
             self.PackFullChrgVolt=80
@@ -149,7 +152,9 @@ class BatParam:
             self.CellTempLowLv1=-20
             self.CellTempLowLv2=-25
             self.CellTempDiffLv1=10
-            self.CellTempDiffLv2=15            
+            self.CellTempDiffLv2=15  
+
+            self.TrwVoltRate=-0.5          
         elif celltype==4:   #CATL 50ah三元电芯
             self.Capacity = 50
             self.PackFullChrgVolt=80
@@ -187,7 +192,9 @@ class BatParam:
             self.CellTempLowLv1=-20
             self.CellTempLowLv2=-25
             self.CellTempDiffLv1=10
-            self.CellTempDiffLv2=15            
+            self.CellTempDiffLv2=15   
+
+            self.TrwVoltRate=-0.5         
         elif celltype==99:   #60ah磷酸铁锂电芯
             self.Capacity = 54
             self.PackFullChrgVolt=69.99
@@ -235,7 +242,9 @@ class BatParam:
             self.CellTempLowLv1=-20
             self.CellTempLowLv2=-25
             self.CellTempDiffLv1=10
-            self.CellTempDiffLv2=15                       
+            self.CellTempDiffLv2=15   
+
+            self.TrwVoltRate=-8                    
         elif celltype==100:
             self.Capacity = 228*2
             self.PackFullChrgVolt=3.65*192
@@ -279,7 +288,9 @@ class BatParam:
             self.CellTempLowLv1=-30
             self.CellTempLowLv2=-35
             self.CellTempDiffLv1=28
-            self.CellTempDiffLv2=32                            
+            self.CellTempDiffLv2=32   
+
+            self.TrwVoltRate=-8                         
             
         else:
             print('未找到对应电池编号!!!')

+ 30 - 30
LIB/MIDDLE/SaftyCenter/DataDiag_Static/CBMSBatDiag.py

@@ -132,37 +132,37 @@ class BatDiag:
                     else:
                         pass
 
-                #温升判断
-                time2=self.bmstime[i]
-                delttime=(time2-time1).total_seconds()
-                if delttime>20:
-                    temp2=np.array(self._celltemp_get(i))
-                    celltemp_rate=round((max(temp2-temp1)*60)/delttime,2)    #计算最大温升速率
-                    temp1=temp2 #更新初始温度
-                    time1=time2 #更新初始时间
-                    if not 9 in list(self.df_diag_ram['code']):#当前故障中没有该故障,则判断是否发生该故障
-                        if celltemp_rate>self.param.CellTempRate:
-                            temprate_cnt=temprate_cnt+1
-                            if temprate_cnt>2:  #温升故障进入
-                                time=self.bmstime[i]
-                                code=9
-                                faultlv=3
-                                faultinfo='温升速率过快:{}℃/min'.format(celltemp_rate)
-                                faultadvice='技术介入诊断'
-                                self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
-                            else:
-                                pass
-                        else:   #ram当前故障中有该故障,则判断是否退出该故障
-                           pass
-                    else:
-                        if celltemp_rate<self.param.CellTempRate-1: #温升故障恢复
-                            time=self.bmstime[i]
-                            self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==9].index, 'end_time'] = time
-                else:
-                    pass
+            #     #温升判断
+            #     time2=self.bmstime[i]
+            #     delttime=(time2-time1).total_seconds()
+            #     if delttime>20:
+            #         temp2=np.array(self._celltemp_get(i))
+            #         celltemp_rate=round((max(temp2-temp1)*60)/delttime,2)    #计算最大温升速率
+            #         temp1=temp2 #更新初始温度
+            #         time1=time2 #更新初始时间
+            #         if not 9 in list(self.df_diag_ram['code']):#当前故障中没有该故障,则判断是否发生该故障
+            #             if celltemp_rate>self.param.CellTempRate:
+            #                 temprate_cnt=temprate_cnt+1
+            #                 if temprate_cnt>2:  #温升故障进入
+            #                     time=self.bmstime[i]
+            #                     code=9
+            #                     faultlv=3
+            #                     faultinfo='温升速率过快:{}℃/min'.format(celltemp_rate)
+            #                     faultadvice='技术介入诊断'
+            #                     self.df_diag_ram.loc[len(self.df_diag_ram)]=[time, end_time, self.sn, code, faultlv, faultinfo, faultadvice]
+            #                 else:
+            #                     pass
+            #             else:   #ram当前故障中有该故障,则判断是否退出该故障
+            #                pass
+            #         else:
+            #             if celltemp_rate<self.param.CellTempRate-1: #温升故障恢复
+            #                 time=self.bmstime[i]
+            #                 self.df_diag_ram.loc[self.df_diag_ram[self.df_diag_ram['code']==9].index, 'end_time'] = time
+            #     else:
+            #         pass
             
-            else:
-                pass
+            # else:
+            #     pass
             
             #电压诊断功能.................................................................................................
             cellvolt0=self._cellvolt_get(i-1)

+ 13 - 12
LIB/MIDDLE/SaftyCenter/Liplated/Li_plated.py

@@ -96,7 +96,7 @@ class Liplated_test:
                     df_test_rest_volt_diff_temp = np.diff(df_rest_volt_smooth,axis=0)
                     df_test_rest_time_dif = pd.DataFrame(df_rest_time_dif_temp)
                     df_test_rest_volt_diff = pd.DataFrame(df_test_rest_volt_diff_temp)
-                    df_test_rest_volt_diffdt_temp = np.divide(df_test_rest_volt_diff,df_test_rest_time_dif)
+                    df_test_rest_volt_diffdt_temp = np.divide(df_test_rest_volt_diff,df_test_rest_time_dif)#电压的一次微分
                     df_test_rest_volt_diffdt = pd.DataFrame(df_test_rest_volt_diffdt_temp)
                     df_test_rest_volt_diffdt = df_test_rest_volt_diffdt.append(df_test_rest_volt_diffdt.iloc[len(df_test_rest_volt_diffdt)-1])
                     df_test_rest_volt_diffdt.columns = cellvolt_list
@@ -117,12 +117,9 @@ class Liplated_test:
                 df_check_liplated_temp = df_rest_volt_diffdt.loc[df_rest_volt_diffdt['chrgr_rest'] == item].reset_index(drop = True)
                 df_lipltd_volt_temp = df_check_liplated_temp[cellvolt_list]
                 df_lipltd_volt_len = len(df_lipltd_volt_temp)
-                df_data_temp_add = df_lipltd_volt_temp.iloc[df_lipltd_volt_len-4:df_lipltd_volt_len-1]
-                df_lipltd_volt_temp_add = df_lipltd_volt_temp.append(df_data_temp_add)
-                df_lipltd_volt_temp_dif = np.diff(df_lipltd_volt_temp_add,axis=0)#电压一次微分,计算dv/dt
-                df_lipltd_volt_temp_dif = pd.DataFrame(df_lipltd_volt_temp_dif)
-                df_lipltd_volt_temp_dif.columns = cellvolt_list
-                df_lipltd_volt_temp_difdif = np.diff(df_lipltd_volt_temp_dif,axis=0)#电压二次微分,判断升降
+                df_data_temp_add = df_lipltd_volt_temp.iloc[df_lipltd_volt_len-3:df_lipltd_volt_len-1]
+                df_lipltd_volt_temp_dif = df_lipltd_volt_temp.append(df_data_temp_add)
+                df_lipltd_volt_temp_difdif = np.diff(df_lipltd_volt_temp_dif,axis=0)#电压二次微分,判断电压微分曲线上升沿或下降沿
                 df_lipltd_volt_temp_difdif = pd.DataFrame(df_lipltd_volt_temp_difdif)
                 df_lipltd_volt_temp_difdif.columns = cellvolt_list
                 df_lipltd_volt_temp_difdif_temp = df_lipltd_volt_temp_difdif
@@ -140,18 +137,22 @@ class Liplated_test:
                     peak_pos = np.where(df_check_plated_data == -2)
                     bot_pos = np.where(df_check_plated_data == 2)
                     if len(peak_pos[0]) & len(bot_pos[0]):
-                        peak_hight = df_lipltd_volt_temp_dif[cell_name][peak_pos[0][0] + 1] - df_lipltd_volt_temp_dif[cell_name][0]
-                        peak_bot_hight = df_lipltd_volt_temp_dif[cell_name][peak_pos[0][0] + 1] - df_lipltd_volt_temp_dif[cell_name][bot_pos[0][0] + 1]
-                        if (peak_pos[0][0] > bot_pos[0][0]) & (df_lipltd_volt_temp_dif[cell_name][peak_pos[0][0] + 1] < 0) & (peak_bot_hight > 0.2*peak_hight):
+                        ini_dvdt = df_check_liplated_temp[cell_name][0]
+                        peak_dvdt = df_check_liplated_temp[cell_name][peak_pos[0][0] + 1]
+                        bot_dvdt = df_check_liplated_temp[cell_name][bot_pos[0][0] + 1]
+                        peak_hight = peak_dvdt - ini_dvdt
+                        peak_bot_hight = peak_dvdt - bot_dvdt
+                        liplted_amount_temp = (df_check_liplated_temp['时间戳'][bot_pos[0][0] + 1] - df_check_liplated_temp['时间戳'][0])/pd.Timedelta(1, 'min')
+                        if ((bot_pos[0][0] - peak_pos[0][0]) > 3) & (df_check_liplated_temp[cell_name][peak_pos[0][0] + 1] < 0) & (peak_bot_hight > 0.05*peak_hight) & (liplted_amount_temp > 15):
                             lipltd_confirm.append(1)#1为析锂,0为非析锂
-                            lipltd_amount.append((df_check_liplated_temp['时间戳'][bot_pos[0][0] + 2] - df_check_liplated_temp['时间戳'][0])/pd.Timedelta(1, 'min'))
+                            lipltd_amount.append(liplted_amount_temp)
                         else:
                             lipltd_confirm.append(0)
                             lipltd_amount.append(0)
                     else:
                         lipltd_confirm.append(0)
                         lipltd_amount.append(0)
-                if any(lipltd_confirm) & (max(lipltd_amount) > 5):
+                if any(lipltd_confirm):
                     df_lipltd_confir_temp = pd.DataFrame({"sn":[self.sn], "time":[df_check_liplated_temp['时间戳'][0]], "liplated":[str(lipltd_confirm)], "liplated_amount":[str(lipltd_amount)]})
                     df_lipltd_result = df_lipltd_result.append(df_lipltd_confir_temp)
                     df_lipltd_result = df_lipltd_result.reset_index(drop = True)