|
@@ -52,7 +52,7 @@ for k in range(l):
|
|
try:
|
|
try:
|
|
sn = fileNames[k]
|
|
sn = fileNames[k]
|
|
df_diag_ram_sn=df_diag_ram[df_diag_ram['product_id']==sn]
|
|
df_diag_ram_sn=df_diag_ram[df_diag_ram['product_id']==sn]
|
|
- df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time, data_groups=['bms'])
|
|
|
|
|
|
+ df_data = dbManager.get_data(sn=sn, start_time=start_time, end_time=end_time ,data_groups=['bms'])
|
|
data_test = df_data['bms']
|
|
data_test = df_data['bms']
|
|
data_test=data_test[data_test['SOC[%]']>20]
|
|
data_test=data_test[data_test['SOC[%]']>20]
|
|
if len(data_test)>15:
|
|
if len(data_test)>15:
|
|
@@ -61,6 +61,8 @@ for k in range(l):
|
|
res1 = pd.read_csv('res1_'+sn+'.csv',encoding='gbk')
|
|
res1 = pd.read_csv('res1_'+sn+'.csv',encoding='gbk')
|
|
res2 = pd.read_csv('res2_'+sn+'.csv',encoding='gbk')
|
|
res2 = pd.read_csv('res2_'+sn+'.csv',encoding='gbk')
|
|
pred1,pred2=prediction(data_test,pca1,pca2)
|
|
pred1,pred2=prediction(data_test,pca1,pca2)
|
|
|
|
+ pred1=pred1.reset_index()
|
|
|
|
+ pred2=pred2.reset_index()
|
|
outliers1=detect_outliers(res1,pred1,threshold=30)
|
|
outliers1=detect_outliers(res1,pred1,threshold=30)
|
|
outliers2=detect_outliers(res2,pred2,threshold=16)
|
|
outliers2=detect_outliers(res2,pred2,threshold=16)
|
|
if (len(outliers1)>0) & (len(outliers2)>0):
|
|
if (len(outliers1)>0) & (len(outliers2)>0):
|
|
@@ -69,14 +71,18 @@ for k in range(l):
|
|
outliers['sn']=sn
|
|
outliers['sn']=sn
|
|
outliers=outliers.reset_index()
|
|
outliers=outliers.reset_index()
|
|
anomalies=anomalies.append(outliers)
|
|
anomalies=anomalies.append(outliers)
|
|
|
|
+ u_th=boxplot_fill(res2)
|
|
|
|
+ outliers3=pred2[pred2['低压差']>u_th]
|
|
if df_diag_ram_sn.empty:
|
|
if df_diag_ram_sn.empty:
|
|
product_id=sn
|
|
product_id=sn
|
|
start_time=outliers.loc[0,'时间']
|
|
start_time=outliers.loc[0,'时间']
|
|
- start_time=start_time[:14]+start_time[16]+'0:00'
|
|
|
|
- if outliers.loc[-1,'时间'] == pred1.loc[-1,'时间']:
|
|
|
|
|
|
+ start_time=start_time+'0:00'
|
|
|
|
+ if outliers.loc[outliers.index[-1],'时间'] == pred1.loc[pred1.index[-1],'时间']:
|
|
|
|
+ end_time='0000-00-00 00:00:00'
|
|
|
|
+ elif outliers1.loc[outliers1.index[-1],'时间'] == outliers3.loc[outliers3.index[-1],'时间']:
|
|
end_time='0000-00-00 00:00:00'
|
|
end_time='0000-00-00 00:00:00'
|
|
else:
|
|
else:
|
|
- end_time=outliers.loc[-1,'时间']
|
|
|
|
|
|
+ end_time=outliers.loc[outliers.index[-1],'时间']
|
|
code='C493'
|
|
code='C493'
|
|
level=4
|
|
level=4
|
|
info='热失控预警'
|
|
info='热失控预警'
|
|
@@ -85,10 +91,12 @@ for k in range(l):
|
|
with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\06BatSafetyAlarm\热失控报警.txt','a') as file:
|
|
with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\06BatSafetyAlarm\热失控报警.txt','a') as file:
|
|
file.write(str(tuple(df_res.iloc[-1]))+'\n')
|
|
file.write(str(tuple(df_res.iloc[-1]))+'\n')
|
|
else:
|
|
else:
|
|
- if outliers.loc[-1,'时间'] == pred1.loc[-1,'时间']:
|
|
|
|
|
|
+ if outliers.loc[outliers.index[-1],'时间'] == pred1.loc[pred1.index[-1],'时间']:
|
|
|
|
+ end_time='0000-00-00 00:00:00'
|
|
|
|
+ elif outliers1.loc[outliers1.index[-1],'时间'] == outliers3.loc[outliers3.index[-1],'时间']:
|
|
end_time='0000-00-00 00:00:00'
|
|
end_time='0000-00-00 00:00:00'
|
|
else:
|
|
else:
|
|
- end_time=outliers.loc[-1,'时间']
|
|
|
|
|
|
+ end_time=outliers.loc[outliers.index[-1],'时间']
|
|
df_diag_ram_sn['end_time']=end_time
|
|
df_diag_ram_sn['end_time']=end_time
|
|
with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\06BatSafetyAlarm\热失控报警.txt','a') as file:
|
|
with open(r'D:\Platform\platform_python\data_analyze_platform\USER\spf\01qixiang\06BatSafetyAlarm\热失控报警.txt','a') as file:
|
|
file.write(str(tuple(df_diag_ram_sn.iloc[-1]))+'\n')
|
|
file.write(str(tuple(df_diag_ram_sn.iloc[-1]))+'\n')
|
|
@@ -97,4 +105,4 @@ for k in range(l):
|
|
except Exception as e:
|
|
except Exception as e:
|
|
print(repr(e))
|
|
print(repr(e))
|
|
mylog.logopt(sn,e)
|
|
mylog.logopt(sn,e)
|
|
- pass
|
|
|
|
|
|
+ pass
|