2 커밋 d0f0c4ac85 ... 5ce1df4b95

작성자 SHA1 메시지 날짜
  zhuxi 5ce1df4b95 Merge branch 'dev' of http://git.fast-fun.cn:92/lmstack/data_analyze_platform into dev 2 년 전
  zhuxi 79d3a77992 core 2 년 전
1개의 변경된 파일36개의 추가작업 그리고 33개의 파일을 삭제
  1. 36 33
      LIB/MIDDLE/ThermoRunaway/V1_0_2/Trunaway.py

+ 36 - 33
LIB/MIDDLE/ThermoRunaway/V1_0_2/Trunaway.py

@@ -209,6 +209,7 @@ def diffmin(res):
 
 def res_output(TestOrg,scaler,model,group,end_time):
     df_res=pd.DataFrame(columns=['product_id', 'start_time', 'end_time', 'diff_min','soc','loss_sum','loss_max','diffV','downV','diffdownV','window_step'])
+    diff=0
     test2=create_dataset(TestOrg)
     test3=cal_dataset(test2)
     newtest=timeserie(test3)
@@ -225,40 +226,42 @@ def res_output(TestOrg,scaler,model,group,end_time):
             res=ref_test[(ref_test['test_loss_diff']>0.03) & (ref_test['test_loss_max']>0.03) & (ref_test['SOC[%]']>15) & (ref_test['window_step']>0) &  (ref_test['最大电压下降']<-3) &((ref_test['test_loss_sum']>3) | (ref_test['SOC[%]']<90))]
         else:
             res=ref_test[(ref_test['test_loss_diff']>0.6) & (ref_test['test_loss_max']>0.6) & (ref_test['SOC[%]']>15) & (ref_test['window_step']>0) &  (ref_test['电压下降低偏']>3.5) &((ref_test['test_loss_sum']>3) | (ref_test['SOC[%]']<90))]
-        res=res.reset_index()
-        for k in range(len(res)):
-            if res.loc[k,'最大电压下降']<-130:
-                sn=res.loc[k,'sn']
-                win=res.loc[k,'window_step']
-                index = res[(res["sn"]== sn)&(res["window_step"]== win)].index.tolist()[0]
-                res=res.drop([index-2,index-1,index])
         
-        maxsum=list(res['test_loss_sum'].groupby(res['n_split']).max())
-        maxmax=list(res['test_loss_max'].groupby(res['n_split']).max())
-        res_start=res.drop_duplicates(subset=['n_split'],keep='first',inplace=False)
-        res_end=res.drop_duplicates(subset=['n_split'],keep='last',inplace=False)
-        start=list(map(lambda x:str(x),list(res_start['时间戳'].values)))
-        end=list(map(lambda x:str(x),list(res_end['时间戳'].values)))
-        product_id=list(res_start['sn'].values)
-        df_res['product_id']=product_id
-        df_res['start_time']=start
-        df_res['end_time']=end
-        df_res['loss_sum']=list(map(lambda x:round(x,3),maxsum))
-        df_res['loss_max']=list(map(lambda x:round(x,3),maxmax))
-        soc=list(res_start['SOC[%]'].values)
-        df_res['SOC']=soc
-        df_res['diffV']=list(res_start['单体压差'].values)
-        df_res['downV']=list(res_start['最大电压下降'].values)
-        df_res['diffdownV']=list(res_start['电压下降低偏'].values)
-        #df_res['window_step']=list(res_start['window_step'].values)
-        diff_min=diffmin(df_res)
-        df_res['diff_min']=diff_min
-        df_res.reset_index(drop=True,inplace=True)
-        end=datetime.datetime.strptime(str(df_res.loc[len(df_res)-1,'end_time']),'%Y-%m-%d %H:%M:%S')
-        end_time=datetime.datetime.strptime(str(end_time),'%Y-%m-%d %H:%M:%S')
-        diff=(end_time-end).total_seconds()
-        if diff<600:
-            df_res.loc[len(df_res)-1,'end_time']='0000-00-00 00:00:00'
+        if len(res)>0:
+            res=res.reset_index()
+            for k in range(len(res)):
+                if res.loc[k,'最大电压下降']<-130:
+                    sn=res.loc[k,'sn']
+                    win=res.loc[k,'window_step']
+                    index = res[(res["sn"]== sn)&(res["window_step"]== win)].index.tolist()[0]
+                    res=res.drop([index-2,index-1,index])
+            
+            maxsum=list(res['test_loss_sum'].groupby(res['n_split']).max())
+            maxmax=list(res['test_loss_max'].groupby(res['n_split']).max())
+            res_start=res.drop_duplicates(subset=['n_split'],keep='first',inplace=False)
+            res_end=res.drop_duplicates(subset=['n_split'],keep='last',inplace=False)
+            start=list(map(lambda x:str(x),list(res_start['时间戳'].values)))
+            end=list(map(lambda x:str(x),list(res_end['时间戳'].values)))
+            product_id=list(res_start['sn'].values)
+            df_res['product_id']=product_id
+            df_res['start_time']=start
+            df_res['end_time']=end
+            df_res['loss_sum']=list(map(lambda x:round(x,3),maxsum))
+            df_res['loss_max']=list(map(lambda x:round(x,3),maxmax))
+            soc=list(res_start['SOC[%]'].values)
+            df_res['SOC']=soc
+            df_res['diffV']=list(res_start['单体压差'].values)
+            df_res['downV']=list(res_start['最大电压下降'].values)
+            df_res['diffdownV']=list(res_start['电压下降低偏'].values)
+            #df_res['window_step']=list(res_start['window_step'].values)
+            diff_min=diffmin(df_res)
+            df_res['diff_min']=diff_min
+            df_res.reset_index(drop=True,inplace=True)
+            end=datetime.datetime.strptime(str(df_res.loc[len(df_res)-1,'end_time']),'%Y-%m-%d %H:%M:%S')
+            end_time=datetime.datetime.strptime(str(end_time),'%Y-%m-%d %H:%M:%S')
+            diff=(end_time-end).total_seconds()
+            if diff<600:
+                df_res.loc[len(df_res)-1,'end_time']='0000-00-00 00:00:00'
     return df_res,diff
 
 ##################################################################################################################