Browse Source

Merge branch 'dev' of http://git.fast-fun.cn:92/lmstack/data_analyze_platform into dev

qingfeng 3 years ago
parent
commit
be0f6c1d60

+ 8 - 3
LIB/MIDDLE/CellStateEstimation/SOH/V1_0_0/BatParam.py → LIB/MIDDLE/CellStateEstimation/Common/BatParam.py

@@ -29,6 +29,7 @@ class BatParam:
             self.CellTempNums=4
             self.FullChrgSoc=98
             self.PeakSoc=57
+            self.PackCrntDec=1
             self.LookTab_SOC = [0,	    3.5348,	8.3581,	13.181,	18.004,	22.827,	27.651,	32.474,	37.297,	42.120,	46.944,	51.767,	56.590,	61.413,	66.237,	71.060,	75.883,	80.707,	85.530,	90.353,	95.176,	100]
             self.LookTab_OCV = [3.3159,	3.4384,	3.4774,	3.5156,	3.5478,	3.5748,	3.6058,	3.6238,	3.638,	3.6535,	3.6715,	3.6951,	3.7279,	3.7757,	3.8126,	3.8529,	3.8969,	3.9446,	3.9946,	4.0491,	4.109,	4.183]
         
@@ -40,10 +41,11 @@ class BatParam:
             self.CellTempNums=4
             self.FullChrgSoc=98
             self.PeakSoc=57
+            self.PackCrntDec=1
             self.LookTab_SOC = [0,	    3.5348,	8.3581,	13.181,	18.004,	22.827,	27.651,	32.474,	37.297,	42.120,	46.944,	51.767,	56.590,	61.413,	66.237,	71.060,	75.883,	80.707,	85.530,	90.353,	95.176,	100]
             self.LookTab_OCV = [3.3159,	3.4384,	3.4774,	3.5156,	3.5478,	3.5748,	3.6058,	3.6238,	3.638,	3.6535,	3.6715,	3.6951,	3.7279,	3.7757,	3.8126,	3.8529,	3.8969,	3.9446,	3.9946,	4.0491,	4.109,	4.183]
         
-        elif celltype==3:
+        elif celltype==3:   #力信50ah三元电芯
             self.Capacity = 51
             self.PackFullChrgVolt=80
             self.CellFullChrgVolt=4.2
@@ -51,17 +53,19 @@ class BatParam:
             self.CellTempNums=4
             self.FullChrgSoc=98
             self.PeakSoc=57
+            self.PackCrntDec=1
             self.LookTab_SOC = [0,	    5,	    10,	    15,	    20,	    25,	    30,	    35,	    40,	    45,	    50,	    55,	    60,	    65,	    70,	    75,	    80,	    85,	    90,	    95,	    100]
             self.LookTab_OCV = [3.357, 	3.455, 	3.493, 	3.540, 	3.577, 	3.605, 	3.622, 	3.638, 	3.655, 	3.677, 	3.707, 	3.757, 	3.815, 	3.866, 	3.920, 	3.976, 	4.036, 	4.099, 	4.166, 	4.237, 	4.325]
         
-        elif celltype==4:
+        elif celltype==4:   #CATL 50ah三元电芯
             self.Capacity = 50
             self.PackFullChrgVolt=80
             self.CellFullChrgVolt=4.2
             self.CellVoltNums=20
-            self.CellTempNums=4
+            self.CellTempNums=2
             self.FullChrgSoc=98
             self.PeakSoc=57
+            self.PackCrntDec=-1
             self.LookTab_SOC = [0,	    5,	    10,	    15,	    20,	    25,	    30,	    35,	    40,	    45,	    50,	    55,	    60,	    65,	    70,	    75,	    80,	    85,	    90,	    95,	    100]
             self.LookTab_OCV = [3.152, 	3.397, 	3.438, 	3.481, 	3.523, 	3.560, 	3.586, 	3.604, 	3.620, 	3.638, 	3.661, 	3.693, 	3.748, 	3.803, 	3.853, 	3.903, 	3.953, 	4.006, 	4.063, 	4.121, 	4.183]
         
@@ -77,6 +81,7 @@ class BatParam:
             self.CellTempNums=4
             self.FullChrgSoc=98
             self.PeakSoc=60.5
+            self.PackCrntDec=1
             self.LookTab_SOC = [0.00, 	2.40, 	6.38, 	10.37, 	14.35, 	18.33, 	22.32, 	26.30, 	30.28, 	35.26, 	40.24, 	45.22, 	50.20, 	54.19, 	58.17, 	60.16, 	65.14, 	70.12, 	75.10, 	80.08, 	84.06, 	88.05, 	92.03, 	96.02, 	100.00]
             self.LookTab_OCV = [2.7151,	3.0298,	3.1935,	3.2009,	3.2167,	3.2393,	3.2561,	3.2703,	3.2843,	3.2871,	3.2874,	3.2868,	3.2896,	3.2917,	3.2967,	3.3128,	3.3283,	3.3286,	3.3287,	3.3288,	3.3289,	3.3296,	3.3302,	3.3314,	3.3429]
         

+ 0 - 0
LIB/MIDDLE/CellStateEstimation/SOH/V1_0_0/DBDownload.py → LIB/MIDDLE/CellStateEstimation/Common/DBDownload.py


+ 0 - 0
LIB/MIDDLE/CellStateEstimation/SOH/V1_0_0/log.py → LIB/MIDDLE/CellStateEstimation/Common/log.py


+ 125 - 123
LIB/MIDDLE/CellStateEstimation/SOH/V1_0_0/CBMSBatSoh.py

@@ -3,10 +3,8 @@ import numpy as np
 import datetime
 import bisect
 import matplotlib.pyplot as plt
-from LIB.MIDDLE.CellStateEstimation.SOH.V1_0_0 import BatParam
-from LIB.MIDDLE.CellStateEstimation.SOH.V1_0_0 import DBDownload
-import BatParam
-import DBDownload
+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):  #参数初始化
@@ -15,11 +13,10 @@ class BatSoh:
         self.celltype=celltype
         self.param=BatParam.BatParam(celltype)
         self.df_bms=df_bms
-        self.packcrnt=df_bms['总电流[A]']
+        self.packcrnt=df_bms['总电流[A]']*self.param.PackCrntDec
         self.packvolt=df_bms['总电压[V]']
         self.bms_soc=df_bms['SOC[%]']
         self.bms_soh=df_bms['SOH[%]']
-        self.bmsstat=df_bms['充电状态']
         self.bmstime= pd.to_datetime(df_bms['时间戳'], format='%Y-%m-%d %H:%M:%S')
 
         self.df_accum=df_accum
@@ -120,6 +117,107 @@ class BatSoh:
             s = str(j)
             cellvolt.append(self.df_bms.loc[num,'单体电压' + s]/1000)
         return cellvolt
+    
+    def _dvdq_soh(self, chrg_st, chrg_end,cellvolt):    #dvdq方法计算soh
+        Ah = 0  #参数赋初始值
+        Volt = cellvolt[chrg_st]
+        DV_Volt=[]
+        DQ_Ah = []
+        DVDQ = []
+        time2 = []
+        soc2 = []
+        Ah_tatal=[0]
+        xvolt=[]
+        #计算DV和DQ值
+        for j in range(chrg_st,chrg_end):
+            Step=(self.bmstime[j+1]-self.bmstime[j]).total_seconds()
+            Ah=Ah-self.packcrnt[j]*Step/3600
+            if (cellvolt[j]-Volt)>0.0009 and Ah>0:
+                Ah_tatal.append(Ah_tatal[-1]+Ah)
+                DQ_Ah.append(Ah)
+                DV_Volt.append(cellvolt[j]-Volt)
+                DVDQ.append((DV_Volt[-1])/DQ_Ah[-1])
+                xvolt.append(cellvolt[j])
+                Volt=cellvolt[j]
+                Ah = 0
+                time2.append(self.bmstime[j])
+                soc2.append(self.bms_soc[j])
+
+        #切片,去除前后10min的数据
+        df_Data1 = pd.DataFrame({'time': time2,
+                                'SOC': soc2,
+                                'DVDQ': DVDQ,
+                                'Ah_tatal': Ah_tatal[:-1],
+                                'DQ_Ah':DQ_Ah,
+                                'DV_Volt':DV_Volt,
+                                'XVOLT':xvolt})
+        start_time=df_Data1.loc[0,'time']
+        start_time=start_time+datetime.timedelta(seconds=900)
+        end_time=df_Data1.loc[len(time2)-1,'time']
+        end_time=end_time-datetime.timedelta(seconds=1200)
+        if soc2[0]<40:
+            df_Data1=df_Data1[(df_Data1['SOC']>43) & (df_Data1['time']<end_time)]
+        else:
+            df_Data1=df_Data1[(df_Data1['time']>start_time) & (df_Data1['time']<end_time)]
+
+        # ax1 = plt.subplot(3, 1, 1)
+        # plt.plot(df_Data1['XVOLT'],df_Data1['DVDQ'],'r*-')
+        # plt.xlabel('Volt/V')
+        # plt.ylabel('DV/DQ')
+        # plt.legend()
+        # ax1 = plt.subplot(3, 1, 2)
+        # plt.plot(df_Data1['SOC'],df_Data1['XVOLT'],'y*-')
+        # plt.xlabel('SOC/%')
+        # plt.ylabel('Volt/V')
+        # plt.legend()
+        # ax1 = plt.subplot(3, 1, 3)
+        # plt.plot(df_Data1['SOC'], df_Data1['DVDQ'], 'r*-')
+        # plt.xlabel('SOC/%')
+        # plt.ylabel('DV/DQ')
+        # plt.legend()
+        # plt.show()
+
+        #寻找峰值并计算Soh
+        if len(df_Data1)>1:
+            PeakIndex=df_Data1['DVDQ'].idxmax()
+            #筛选峰值点附近±0.5%SOC内的数据
+            df_Data2=df_Data1[(df_Data1['SOC']>(df_Data1['SOC'][PeakIndex]-0.5)) & (df_Data1['SOC']<(df_Data1['SOC'][PeakIndex]+0.5))]
+            if len(df_Data2)>2:
+                Ah_tatal1 = df_Data1['Ah_tatal']
+                DVDQ = df_Data1['DVDQ']
+                soc2 = df_Data1['SOC']
+                xvolt = df_Data1['XVOLT']
+                if soc2[PeakIndex]>43 and soc2[PeakIndex]<90:
+                    cellsoh_init=(Ah_tatal[-1]-Ah_tatal1[PeakIndex]) * 100 / ((self.param.FullChrgSoc - self.param.PeakSoc) * 0.01 * self.param.Capacity)
+                    if cellsoh_init<95:
+                        cellsoh_init=cellsoh_init*0.3926+58.14
+                        return cellsoh_init
+                    else:
+                        return cellsoh_init
+                else:
+                    return 0
+            else:
+                df_Data1=df_Data1.drop([PeakIndex])
+                PeakIndex = df_Data1['DVDQ'].idxmax()
+                df_Data2 = df_Data1[(df_Data1['SOC'] > (df_Data1['SOC'][PeakIndex] - 0.5)) & (df_Data1['SOC'] < (df_Data1['SOC'][PeakIndex] + 0.5))]
+                if len(df_Data2) > 2:
+                    Ah_tatal1 = df_Data1['Ah_tatal']
+                    DVDQ = df_Data1['DVDQ']
+                    soc2 = df_Data1['SOC']
+                    xvolt = df_Data1['XVOLT']
+                    if soc2[PeakIndex]>40 and soc2[PeakIndex]<90:
+                        cellsoh_init=(Ah_tatal[-1]-Ah_tatal1[PeakIndex]) * 100 / ((self.param.FullChrgSoc - self.param.PeakSoc) * 0.01 * self.param.Capacity)
+                        if cellsoh_init<95:
+                            cellsoh_init=cellsoh_init*0.3926+58.14
+                            return cellsoh_init
+                        else:
+                            return cellsoh_init
+                    else:
+                        return 0
+                else:
+                    return 0
+        else:
+            return 0
                 
     def _ncmsoh_chrg(self):     #NCM充电数据soh计算 
         self._chrgdata()
@@ -587,129 +685,33 @@ class BatSoh:
             if chrg_end:
                 for i in range(len(chrg_end)):
                     cellvolt_max = self.df_bms['单体电压' + str(cellmaxvolt_number2[i]+1)] / 1000     #获取最大电压
-                    cellvolt=self._np_move_avg(cellvolt_max, 3, mode="same")     #对电压进行滑动平均滤波
-                    
-                    Ah = 0  #参数赋初始值
-                    Volt = cellvolt[chrg_start[i]]
-                    DV_Volt=[]
-                    DQ_Ah = []
-                    DVDQ = []
-                    time2 = []
-                    soc2 = []
-                    Ah_tatal=[0]
-                    xvolt=[]
-                    #计算DV和DQ值
-                    for j in range(chrg_start[i],chrg_end[i]):
-                        Step=(self.bmstime[j+1]-self.bmstime[j]).total_seconds()
-                        Ah=Ah-self.packcrnt[j]*Step/3600
-                        if (cellvolt[j]-Volt)>0.0009 and Ah>0:
-                            Ah_tatal.append(Ah_tatal[-1]+Ah)
-                            DQ_Ah.append(Ah)
-                            DV_Volt.append(cellvolt[j]-Volt)
-                            DVDQ.append((DV_Volt[-1])/DQ_Ah[-1])
-                            xvolt.append(cellvolt[j])
-                            Volt=cellvolt[j]
-                            Ah = 0
-                            time2.append(self.bmstime[j])
-                            soc2.append(self.bms_soc[j])
-
-                    #切片,去除前后10min的数据
-                    df_Data1 = pd.DataFrame({'time': time2,
-                                            'SOC': soc2,
-                                            'DVDQ': DVDQ,
-                                            'Ah_tatal': Ah_tatal[:-1],
-                                            'DQ_Ah':DQ_Ah,
-                                            'DV_Volt':DV_Volt,
-                                            'XVOLT':xvolt})
-                    start_time=df_Data1.loc[0,'time']
-                    start_time=start_time+datetime.timedelta(seconds=900)
-                    end_time=df_Data1.loc[len(time2)-1,'time']
-                    end_time=end_time-datetime.timedelta(seconds=1200)
-                    if soc2[0]<40:
-                        df_Data1=df_Data1[(df_Data1['SOC']>43) & (df_Data1['time']<end_time)]
-                    else:
-                        df_Data1=df_Data1[(df_Data1['time']>start_time) & (df_Data1['time']<end_time)]
-            
-                    # ax1 = plt.subplot(3, 1, 1)
-                    # plt.plot(df_Data1['XVOLT'],df_Data1['DVDQ'],'r*-')
-                    # plt.xlabel('Volt/V')
-                    # plt.ylabel('DV/DQ')
-                    # plt.legend()
-                    # ax1 = plt.subplot(3, 1, 2)
-                    # plt.plot(df_Data1['SOC'],df_Data1['XVOLT'],'y*-')
-                    # plt.xlabel('SOC/%')
-                    # plt.ylabel('Volt/V')
-                    # plt.legend()
-                    # ax1 = plt.subplot(3, 1, 3)
-                    # plt.plot(df_Data1['SOC'], df_Data1['DVDQ'], 'r*-')
-                    # plt.xlabel('SOC/%')
-                    # plt.ylabel('DV/DQ')
-                    # plt.legend()
-                    # plt.show()
-
-                    #寻找峰值并计算Soh和置信度
-                    if len(df_Data1)>1:
-                        PeakIndex=df_Data1['DVDQ'].idxmax()
-                        #筛选峰值点附近±0.5%SOC内的数据
-                        df_Data2=df_Data1[(df_Data1['SOC']>(df_Data1['SOC'][PeakIndex]-0.5)) & (df_Data1['SOC']<(df_Data1['SOC'][PeakIndex]+0.5))]
-                        if len(df_Data2)>2:
-                            Ah_tatal1 = df_Data1['Ah_tatal']
-                            DVDQ = df_Data1['DVDQ']
-                            soc2 = df_Data1['SOC']
-                            xvolt = df_Data1['XVOLT']
-                            if soc2[PeakIndex]>43 and soc2[PeakIndex]<90:
-                                cellsoh_init=(Ah_tatal[-1]-Ah_tatal1[PeakIndex]) * 100 / ((self.param.FullChrgSoc - self.param.PeakSoc) * 0.01 * self.param.Capacity)
-                                if cellsoh_init<95:
-                                    cellsoh_init=cellsoh_init*0.3926+58.14
-                                else:
-                                    pass
-                            else:
-                                continue
-                        else:
-                            df_Data1=df_Data1.drop([PeakIndex])
-                            PeakIndex = df_Data1['DVDQ'].idxmax()
-                            df_Data2 = df_Data1[(df_Data1['SOC'] > (df_Data1['SOC'][PeakIndex] - 0.5)) & (df_Data1['SOC'] < (df_Data1['SOC'][PeakIndex] + 0.5))]
-                            if len(df_Data2) > 2:
-                                Ah_tatal1 = df_Data1['Ah_tatal']
-                                DVDQ = df_Data1['DVDQ']
-                                soc2 = df_Data1['SOC']
-                                xvolt = df_Data1['XVOLT']
-                                if soc2[PeakIndex]>40 and soc2[PeakIndex]<90:
-                                    cellsoh_init=(Ah_tatal[-1]-Ah_tatal1[PeakIndex]) * 100 / ((self.param.FullChrgSoc - self.param.PeakSoc) * 0.01 * self.param.Capacity)
-                                    if cellsoh_init<95:
-                                        cellsoh_init=cellsoh_init*0.3926+58.14
-                                    else:
-                                        pass
-                                else:
-                                    continue
-                            else:
-                                continue
-                        
-                        soh_weight=tempweightlist2[i]*0.25
-                        if cellsoh_init>65 and cellsoh_init<115:    #判断soh值的有效区间
-                            if len(df_res)<1:
-                                if not self.df_soh.empty:
-                                    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']
+                    cellvolt=self._np_move_avg(cellvolt_max, 3, mode="same")     #对电压进行滑动平均滤
+
+                    cellsoh_init=self._dvdq_soh(chrg_start[i],chrg_end[i],cellvolt)     #dvdq计算soh
+
+                    soh_weight=tempweightlist2[i]*0.25
+                    if cellsoh_init>65 and cellsoh_init<115:    #判断soh值的有效区间
+                        if len(df_res)<1:
+                            if not self.df_soh.empty:
+                                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)
-                            
-                            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
+                            else:
+                                cellsoh_cal=cellsoh_init*soh_weight+100*(1-soh_weight)
                         else:
-                            continue
+                            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)
+                        
+                        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
                     else:
                         continue
             else:

+ 0 - 86
LIB/MIDDLE/CellStateEstimation/Uniform/V1_0_0/BatParam.py

@@ -1,86 +0,0 @@
-
-#定义电池参数
-from types import CellType
-import sys
-
-class BatParam:
-
-    def __init__(self,celltype):
-
-        # if 'PK500' in sn:
-        #     self.celltype=1 #6040三元电芯
-        # elif 'PK502' in sn:
-        #     self.celltype=2 #4840三元电芯
-        # elif 'PK504' in sn:
-        #     self.celltype=99    #60ah林磷酸铁锂电芯
-        # elif 'MGMLXN750' in sn:
-        #     self.celltype=3 #力信50ah三元电芯
-        # elif 'MGMCLN750' in sn: 
-        #     self.celltype=4 #CATL 50ah三元电芯
-        # else:
-        #     print('未找到对应电池编号!!!')
-        #     sys.exit()
-
-        if celltype==1: #6040
-            self.Capacity = 41
-            self.PackFullChrgVolt=69.99
-            self.CellFullChrgVolt=4.2
-            self.CellVoltNums=17
-            self.CellTempNums=4
-            self.FullChrgSoc=98
-            self.PeakSoc=57
-            self.LookTab_SOC = [0,	    3.5348,	8.3581,	13.181,	18.004,	22.827,	27.651,	32.474,	37.297,	42.120,	46.944,	51.767,	56.590,	61.413,	66.237,	71.060,	75.883,	80.707,	85.530,	90.353,	95.176,	100]
-            self.LookTab_OCV = [3.3159,	3.4384,	3.4774,	3.5156,	3.5478,	3.5748,	3.6058,	3.6238,	3.638,	3.6535,	3.6715,	3.6951,	3.7279,	3.7757,	3.8126,	3.8529,	3.8969,	3.9446,	3.9946,	4.0491,	4.109,	4.183]
-        
-        elif celltype==2: #4840
-            self.Capacity = 41
-            self.PackFullChrgVolt=69.99
-            self.CellFullChrgVolt=4.2
-            self.CellVoltNums=14
-            self.CellTempNums=4
-            self.FullChrgSoc=98
-            self.PeakSoc=57
-            self.LookTab_SOC = [0,	    3.5348,	8.3581,	13.181,	18.004,	22.827,	27.651,	32.474,	37.297,	42.120,	46.944,	51.767,	56.590,	61.413,	66.237,	71.060,	75.883,	80.707,	85.530,	90.353,	95.176,	100]
-            self.LookTab_OCV = [3.3159,	3.4384,	3.4774,	3.5156,	3.5478,	3.5748,	3.6058,	3.6238,	3.638,	3.6535,	3.6715,	3.6951,	3.7279,	3.7757,	3.8126,	3.8529,	3.8969,	3.9446,	3.9946,	4.0491,	4.109,	4.183]
-        
-        elif celltype==3:
-            self.Capacity = 51
-            self.PackFullChrgVolt=80
-            self.CellFullChrgVolt=4.2
-            self.CellVoltNums=20
-            self.CellTempNums=4
-            self.FullChrgSoc=98
-            self.PeakSoc=57
-            self.LookTab_SOC = [0,	    5,	    10,	    15,	    20,	    25,	    30,	    35,	    40,	    45,	    50,	    55,	    60,	    65,	    70,	    75,	    80,	    85,	    90,	    95,	    100]
-            self.LookTab_OCV = [3.357, 	3.455, 	3.493, 	3.540, 	3.577, 	3.605, 	3.622, 	3.638, 	3.655, 	3.677, 	3.707, 	3.757, 	3.815, 	3.866, 	3.920, 	3.976, 	4.036, 	4.099, 	4.166, 	4.237, 	4.325]
-        
-        elif celltype==4:
-            self.Capacity = 50
-            self.PackFullChrgVolt=80
-            self.CellFullChrgVolt=4.2
-            self.CellVoltNums=20
-            self.CellTempNums=4
-            self.FullChrgSoc=98
-            self.PeakSoc=57
-            self.LookTab_SOC = [0,	    5,	    10,	    15,	    20,	    25,	    30,	    35,	    40,	    45,	    50,	    55,	    60,	    65,	    70,	    75,	    80,	    85,	    90,	    95,	    100]
-            self.LookTab_OCV = [3.152, 	3.397, 	3.438, 	3.481, 	3.523, 	3.560, 	3.586, 	3.604, 	3.620, 	3.638, 	3.661, 	3.693, 	3.748, 	3.803, 	3.853, 	3.903, 	3.953, 	4.006, 	4.063, 	4.121, 	4.183]
-        
-        elif celltype==99:   #60ah磷酸铁锂电芯
-            self.Capacity = 54
-            self.PackFullChrgVolt=69.99
-            self.CellFullChrgVolt=3.5
-            self.OcvInflexionBelow=3.285
-            self.OcvInflexion2=3.296
-            self.OcvInflexion3=3.328
-            self.OcvInflexionAbove=3.4
-            self.CellVoltNums=20
-            self.CellTempNums=4
-            self.FullChrgSoc=98
-            self.PeakSoc=60.5
-            self.LookTab_SOC = [0.00, 	2.40, 	6.38, 	10.37, 	14.35, 	18.33, 	22.32, 	26.30, 	30.28, 	35.26, 	40.24, 	45.22, 	50.20, 	54.19, 	58.17, 	60.16, 	65.14, 	70.12, 	75.10, 	80.08, 	84.06, 	88.05, 	92.03, 	96.02, 	100.00]
-            self.LookTab_OCV = [2.7151,	3.0298,	3.1935,	3.2009,	3.2167,	3.2393,	3.2561,	3.2703,	3.2843,	3.2871,	3.2874,	3.2868,	3.2896,	3.2917,	3.2967,	3.3128,	3.3283,	3.3286,	3.3287,	3.3288,	3.3289,	3.3296,	3.3302,	3.3314,	3.3429]
-        
-        else:
-            print('未找到对应电池编号!!!')
-            # sys.exit()
-

+ 2 - 3
LIB/MIDDLE/CellStateEstimation/Uniform/V1_0_0/CBMSBatUniform.py

@@ -3,8 +3,7 @@ import numpy as np
 import datetime
 import bisect
 import matplotlib.pyplot as plt
-import BatParam
-from LIB.MIDDLE.CellStateEstimation.SOH.V1_0_0 import BatParam
+from LIB.MIDDLE.CellStateEstimation.Common import BatParam
 
 class BatUniform:
     def __init__(self,sn,celltype,df_bms):  #参数初始化
@@ -13,7 +12,7 @@ class BatUniform:
         self.celltype=celltype
         self.param=BatParam.BatParam(celltype)
         self.df_bms=df_bms
-        self.packcrnt=df_bms['总电流[A]']
+        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')

+ 0 - 24
LIB/MIDDLE/CellStateEstimation/Uniform/V1_0_0/log.py

@@ -1,24 +0,0 @@
-import logging
-import traceback
-
-class Mylog:
-
-    def __init__(self,log_name,log_level):
-        self.name=log_name
-        self.level=log_level
-    
-    def logcfg(self):
-        if len(self.level) > 0:
-            if self.level == 'debug':
-                Level=logging.DEBUG
-            elif self.level == 'info':
-                Level=logging.INFO
-            elif self.level == 'warning':
-                Level=logging.WARNING
-            else:
-                Level=logging.ERROR
-        logging.basicConfig(filename=self.name, level=Level,format='%(asctime)s - %(levelname)s - %(message)s')
-
-    def logopt(self,*info):
-        logging.error(info)
-        logging.error(traceback.format_exc())

+ 0 - 73
LIB/MIDDLE/CellStateEstimation/Uniform/V1_0_0/main.py

@@ -1,73 +0,0 @@
-import CBMSBatUniform
-import log
-
-#coding=utf-8
-import os
-import sys
-import datetime
-import pandas as pd
-from LIB.BACKEND import DBManager, Log
-# from LIB.MIDDLE import SignalMonitor
-from sqlalchemy import create_engine
-from sqlalchemy.orm import sessionmaker
-import time, datetime
-from LIB.MIDDLE.soh import NCMSoh_20210716 as NCMSoh
-from LIB.MIDDLE.soh import LFPSoh_20210711 as LFPSoh
-from urllib import parse
-
-dbManager = DBManager.DBManager()
-if __name__ == "__main__":
-    SNdata_6040 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6040骑享')
-    SNdata_6060 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='6060')
-    SNdata_4840 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='4840骑享')
-    SNdata_7250 = pd.read_excel('骑享资产梳理-20210621.xlsx', sheet_name='7250')
-    SNnums_6060=SNdata_6060['SN号']
-    SNnums_6040=SNdata_6040['SN号']
-    SNnums_4840=SNdata_4840['SN号']
-    SNnums_7250=SNdata_7250['SN号']
-
-    SNnums=SNnums_6040.tolist()+SNnums_6060.tolist()+SNnums_4840.tolist()+SNnums_7250.tolist()
-    now_time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
-    now_time=datetime.datetime.strptime(now_time,'%Y-%m-%d %H:%M:%S')
-    start_time=now_time-datetime.timedelta(days=5)
-    end_time=str(now_time)
-    start_time=str(start_time)
-
-    #log信息配置
-    mylog=log.Mylog('log.txt','error')
-    mylog.logcfg()
-
-    for sn in SNnums:
-        try:
-            if 'PK500' in sn:
-                celltype=1 #6040三元电芯
-            elif 'PK502' in sn:
-                celltype=2 #4840三元电芯
-            elif 'PK504' in sn:
-                celltype=99    #60ah林磷酸铁锂电芯
-            elif 'MGMLXN750' in sn:
-                celltype=3 #力信50ah三元电芯
-            elif 'MGMCLN750' in sn: 
-                celltype=4 #CATL 50ah三元电芯
-            else:
-                print('未找到对应电池编号!!!')
-                sys.exit()
-            
-            # sn='PK50001A100000035'
-            # start_time='2021-08-10 9:49:37'
-            # end_time='2021-08-29 19:49:37'
-
-            dbManager = DBManager.DBManager()
-            df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
-            df_bms = df_data['bms']
-            # df_bms.to_csv('BMS_'+sn+'.csv',encoding='GB18030')
-
-            BatUniform=CBMSBatUniform.BatUniform(sn,celltype,df_bms)
-            df_res=BatUniform.batuniform()
-            df_res.to_csv('CBMS_Uniform_'+sn+'.csv',encoding='GB18030')
-        
-        
-        except IndexError as e:
-            print(repr(e))
-            mylog.logopt(sn,e)
-            pass