demo.py 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # 获取数据
  2. import sys
  3. import CONFIGURE.PathSetting as PathSetting
  4. sys.path.append(PathSetting.backend_path)
  5. import DBManager
  6. dbManager = DBManager.DBManager()
  7. df_bms, df_gps = dbManager.get_data(sn='PK50201A000002005', start_time='2021-04-01 00:00:00',
  8. end_time='2021-04-05 00:00:00', gps_switch=True, mode=0)
  9. # 下载数据 7255
  10. import sys
  11. import CONFIGURE.PathSetting as PathSetting
  12. sys.path.append(PathSetting.backend_path)
  13. import Tools
  14. tools = Tools.Tools()
  15. write_path = r'D:\Platform\Users\CJH\Download\data'
  16. st = '2021-06-01 00:00:00'
  17. et = '2021-06-03 00:00:00'
  18. tools.data_download(write_path=write_path, sn='UD02030118B4C0010', start_time=st,
  19. end_time=et, mode=1)
  20. # 下载数据 非7255
  21. import sys
  22. import CONFIGURE.PathSetting as PathSetting
  23. sys.path.append(PathSetting.backend_path)
  24. import Tools
  25. tools = Tools.Tools()
  26. write_path = r'D:\Platform\Users\WLM\data_ana\Data_Files'
  27. tools.data_download(write_path=write_path, sn='PK504B00100004017', start_time='2021-04-01 00:00:00',
  28. end_time='2021-04-05 00:00:00', gps_switch=True, mode=0)
  29. # 数据预处理
  30. import sys
  31. import CONFIGURE.PathSetting as PathSetting
  32. sys.path.append(PathSetting.backend_path)
  33. import DataPreProcess
  34. importlib.reload(DataPreProcess)
  35. dataPrePro = DataPreProcess.DataPreProcess()
  36. # 时间完全相同的数据仅保留一行
  37. df_bms_pro, df_gps_pro = dataPrePro.time_filter(df_bms, df_gps)
  38. # bms数据按照电流和状态分段, 然后在状态分段内部,根据时间跳变继续分段(解决段内数据丢失)
  39. df_bms_pro = dataPrePro.data_split_by_status(df_bms_pro)
  40. df_bms_pro = dataPrePro.data_split_by_time(df_bms_pro)
  41. # bms数据将两次充电间的状态合并
  42. df_bms_pro = dataPrePro.combine_drive_stand(df_bms_pro)
  43. # bms 数据计算行车和充电开始前后的静置时间
  44. df_bms_pro = dataPrePro.cal_stand_time(df_bms_pro)
  45. # gps 数据可靠性判断, 并增加里程和速度至gps数据(根据未合并的数据段判断)
  46. df_bms_pro, df_gps_pro, res_record= dataPrePro.gps_data_judge(df_bms_pro, df_gps_pro)
  47. # gps 数据可靠性判断, 并增加里程和速度至gps数据(根据已合并的数据段判断)
  48. df_bms_pro, df_gps_pro, res_record= dataPrePro.data_gps_judge_after_combine(df_bms_pro, df_gps_pro)
  49. # 单cycle指标统计
  50. import sys
  51. import CONFIGURE.PathSetting as PathSetting
  52. sys.path.append(PathSetting.middle_path)
  53. #import IndexStaByOneCycle
  54. import importlib
  55. importlib.reload(IndexStaByOneCycle)
  56. indexSta = IndexStaByOneCycle.IndexStaByOneCycle()
  57. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status'])))
  58. for data_number in data_number_list[:]:
  59. df_sel_bms = df_bms[df_bms['data_split_by_status'] == data_number]
  60. df_sel_bms = df_sel_bms.reset_index(drop=True)
  61. df_sel_gps = df_gps[(df_gps['时间戳']>df_sel_bms.loc[0,'时间戳']) & (df_gps['时间戳']<df_sel_bms.loc[len(df_sel_bms)-1,'时间戳'])]
  62. df_sel_gps = df_sel_gps.reset_index(drop=True)
  63. print(indexSta.odo_sta(np.array(df_sel_gps['odo'])))
  64. print(indexSta.capacity_sta(40, np.array(df_sel_bms['SOC[%]']), np.array(df_sel_bms['SOH[%]'])))
  65. print(indexSta.energy_sta(40, np.array(df_sel_bms['SOC[%]']), np.array(df_sel_bms['SOH[%]']),np.array(df_sel_bms['总电压[V]'])))
  66. print(indexSta.acc_time_sta(np.array(df_sel_bms['时间戳'])))
  67. print(indexSta.mean_temp_sta(np.array(df_sel_bms['单体温度1'])))
  68. print(indexSta.temp_change_rate_sta(np.array(df_sel_bms['时间戳']), np.array(df_sel_bms['单体温度1'])))
  69. print(indexSta.dischrg_max_pwr_sta(np.array(df_sel_bms['总电压[V]']), np.array(df_sel_bms['总电流[A]'])))
  70. print(indexSta.chrg_max_pwr_sta(np.array(df_sel_bms['总电压[V]']), np.array(df_sel_bms['总电流[A]'])))
  71. print(indexSta.speed_sta(indexSta.odo_sta(np.array(df_sel_gps['odo'])), indexSta.acc_time_sta(np.array(df_sel_gps['时间戳'])), np.array(df_sel_gps['speed'])))
  72. break