qingfeng 3 years ago
parent
commit
06a99a6fd7
1 changed files with 16 additions and 15 deletions
  1. 16 15
      LIB/FRONTEND/deltsoc/LFPDeltSoc20210804.py

+ 16 - 15
LIB/FRONTEND/deltsoc/LFPDeltSoc20210804.py

@@ -52,21 +52,22 @@ def cal_deltsoc(sn, end_time, start_time):
             ChgEnd.append(len(time)-1)
 
     # 筛选充电起始Soc<46%,电芯温度>15℃的数据
-    ChgStartValid = []
-    ChgEndValid = []
-
-    for i in range(min(len(ChgStart),len(ChgEnd))):
-        # 获取最小温度值
-        celltemp = []
-        for j in range(1, CellTempNums + 1):
-            s = str(j)
-            temp = df_bms['单体温度' + s]
-            celltemp.append(temp[ChgEnd[i]])
-
-        if SOC[ChgStart[i]] < 46 and SOC[ChgEnd[i]]>80 and min(celltemp) > 10:
-            if ((time[ChgEnd[i]]-time[ChgStart[i]]).total_seconds())/(ChgEnd[i]-ChgStart[i])<30:
-                ChgStartValid.append(ChgStart[i])
-                ChgEndValid.append(ChgEnd[i])
+    if ChgStart:
+        ChgStartValid = []
+        ChgEndValid = []
+
+        for i in range(min(len(ChgStart),len(ChgEnd))):
+            # 获取最小温度值
+            celltemp = []
+            for j in range(1, CellTempNums + 1):
+                s = str(j)
+                temp = df_bms['单体温度' + s]
+                celltemp.append(temp[ChgEnd[i]])
+
+            if SOC[ChgStart[i]] < 46 and SOC[ChgEnd[i]]>80 and min(celltemp) > 10:
+                if ((time[ChgEnd[i]]-time[ChgStart[i]]).total_seconds())/(ChgEnd[i]-ChgStart[i])<30:
+                    ChgStartValid.append(ChgStart[i])
+                    ChgEndValid.append(ChgEnd[i])
 
     # 计算充电每个单体到达DVDQ峰值的Ah差
     # 定义滑动平均滤波函数