IndexStaByPeriod.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  1. <<<<<<< HEAD
  2. <<<<<<< HEAD
  3. '''
  4. 基于某个周期(一天,一周...)的指标统计库
  5. '''
  6. __author__ = 'lmstack'
  7. import CONFIGURE.PathSetting as PathSetting
  8. import sys
  9. sys.path.append(PathSetting.backend_path)
  10. sys.path.append(PathSetting.middle_path)
  11. import datetime
  12. import Tools
  13. import pandas as pd
  14. import numpy as np
  15. import IndexStaByOneCycle
  16. class IndexStaByPeriod():
  17. def __init__(self):
  18. self.indexStaByOneCycle = IndexStaByOneCycle.IndexStaByOneCycle()
  19. pass
  20. def drive_odo_sta(self, df_bms, df_gps):
  21. '''
  22. 计算周期内行车累积行驶里程
  23. ---------输入参数------------
  24. df_bms : 一段周期内的预处理后的bms数据
  25. df_gps : 一段周期内的预处理后的gps数据
  26. ---------输出参数------------
  27. sum_odo : 累积里程, 如果该周期内gps均无效,则返回None
  28. invalid_rate : 该周期内gps无效的bms数据行所占比例
  29. '''
  30. invalid_count = 0
  31. total_count = 0
  32. sum_odo = 0
  33. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_after_combine'])))
  34. if len(data_number_list) == 0:
  35. return {'sum_odo':0, 'invalid_rate':0}
  36. for data_number in data_number_list[:]:
  37. df_sel_bms = df_bms[df_bms['data_split_by_status_after_combine'] == data_number]
  38. df_sel_bms = df_sel_bms.reset_index(drop=True)
  39. total_count += len(df_sel_bms)
  40. if df_sel_bms.loc[0, 'gps_rely'] != 1:
  41. invalid_count += len(df_sel_bms)
  42. continue
  43. else:
  44. df_sel_gps = df_gps[(df_gps['时间戳']>df_sel_bms.loc[0,'时间戳']) & (df_gps['时间戳']<df_sel_bms.loc[len(df_sel_bms)-1,'时间戳'])]
  45. df_sel_gps = df_sel_gps.reset_index(drop=True)
  46. odo = self.indexStaByOneCycle.odo_sta(np.array(df_sel_gps['odo']))
  47. if not pd.isnull(odo):
  48. sum_odo += odo
  49. invalid_rate = invalid_count/total_count
  50. return {'sum_odo':sum_odo, 'invalid_rate':invalid_rate}
  51. #该函数未完成, TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  52. def _energy_consump_sta(self, cap, df_bms, df_gps):
  53. '''
  54. 计算周期内百公里能耗
  55. ---------输入参数------------
  56. df_bms : 本周期内的bms数据
  57. df_gps : 本周期内的gps数据
  58. ---------输出参数------------
  59. 本周期内的百公里能耗
  60. '''
  61. if not df_bms.empty and not df_gps.empty:
  62. # 计算能耗
  63. energy_sum = 0
  64. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  65. for data_number in data_number_list[:]:
  66. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  67. df_sel_bms = df_sel_bms.reset_index(drop=True)
  68. soc_array = np.array(df_sel_bms['SOC[%]'])
  69. soh_array = np.array(df_sel_bms['SOH[%]'])
  70. volt_array = np.array(df_sel_bms['总电压[V]'])
  71. energy = self.indexStaByOneCycle.energy_sta(cap, soc_array, soh_array, volt_array)
  72. if not pd.isnull(energy):
  73. energy_sum += energy
  74. # 计算里程
  75. pass # TODO!!!!!!!!!!!!!!!!!!!!!
  76. return 0
  77. else:
  78. return None
  79. def drive_soc_sta(self, df_bms):
  80. '''
  81. 计算周期内行车净累积soc
  82. ---------输入参数------------
  83. cap : 标称容量
  84. df_bms : 一段周期内的预处理后的bms数据
  85. df_gps : 一段周期内的预处理后的gps数据
  86. ---------输出参数------------
  87. sum_ah : 本周期的净累积soc
  88. '''
  89. sum_soc = 0
  90. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  91. if len(data_number_list) == 0:
  92. return sum_soc
  93. for data_number in data_number_list[:]:
  94. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  95. df_sel_bms = df_sel_bms.reset_index(drop=True)
  96. sum_soc += abs(df_sel_bms.loc[0, 'SOC[%]'] - df_sel_bms.loc[len(df_sel_bms)-1, 'SOC[%]'])
  97. return sum_soc
  98. def drive_time_sta(self, df_bms):
  99. '''
  100. 计算周期内累计行车时长/h
  101. ---------输入参数------------
  102. cap : 标称容量
  103. df_bms : 一段周期内的预处理后的bms数据
  104. df_gps : 一段周期内的预处理后的gps数据
  105. ---------输出参数------------
  106. sum_ah : 本周期的累计行车时长
  107. '''
  108. sum_time = 0
  109. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  110. if len(data_number_list) == 0:
  111. return sum_time
  112. for data_number in data_number_list[:]:
  113. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  114. df_sel_bms = df_sel_bms.reset_index(drop=True)
  115. sum_time += (df_sel_bms.loc[len(df_sel_bms)-1, '时间戳'] - df_sel_bms.loc[0, '时间戳']).total_seconds()
  116. return sum_time / 3600.0
  117. def drive_capacity_sta(self, cap, df_bms):
  118. '''
  119. 计算周期内行车净累积ah
  120. ---------输入参数------------
  121. cap : 标称容量
  122. df_bms : 一段周期内的预处理后的bms数据
  123. df_gps : 一段周期内的预处理后的gps数据
  124. ---------输出参数------------
  125. sum_ah : 本周期的净累积ah
  126. '''
  127. sum_ah = 0
  128. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  129. if len(data_number_list) == 0:
  130. return sum_ah
  131. for data_number in data_number_list[:]:
  132. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  133. df_sel_bms = df_sel_bms.reset_index(drop=True)
  134. soc_array = np.array(df_sel_bms['SOC[%]'])
  135. soh_array = np.array(df_sel_bms['SOH[%]'])
  136. sum_ah += self.indexStaByOneCycle.capacity_sta(cap, soc_array, soh_array)
  137. return sum_ah
  138. def drive_energy_sta(self, cap, df_bms):
  139. '''
  140. 计算周期内行车净累积能量
  141. ---------输入参数------------
  142. cap : 标称容量
  143. df_bms : 一段周期内的预处理后的bms数据
  144. df_gps : 一段周期内的预处理后的gps数据
  145. ---------输出参数------------
  146. sum_ah : 本周期的净累积能量
  147. '''
  148. sum_energy = 0
  149. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  150. if len(data_number_list) == 0:
  151. return sum_energy
  152. for data_number in data_number_list[:]:
  153. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  154. df_sel_bms = df_sel_bms.reset_index(drop=True)
  155. soc_array = np.array(df_sel_bms['SOC[%]'])
  156. soh_array = np.array(df_sel_bms['SOH[%]'])
  157. volt_array = np.array(df_sel_bms['总电压[V]'])
  158. sum_energy += self.indexStaByOneCycle.energy_sta(cap, soc_array, soh_array, volt_array)
  159. =======
  160. '''
  161. 基于某个周期(一天,一周...)的指标统计库
  162. '''
  163. __author__ = 'lmstack'
  164. import CONFIGURE.PathSetting as PathSetting
  165. import sys
  166. sys.path.append(PathSetting.backend_path)
  167. sys.path.append(PathSetting.middle_path)
  168. import datetime
  169. import Tools
  170. import pandas as pd
  171. import numpy as np
  172. import IndexStaByOneCycle
  173. class IndexStaByPeriod():
  174. def __init__(self):
  175. self.indexStaByOneCycle = IndexStaByOneCycle.IndexStaByOneCycle()
  176. pass
  177. def drive_odo_sta(self, df_bms, df_gps):
  178. '''
  179. 计算周期内行车累积行驶里程
  180. ---------输入参数------------
  181. df_bms : 一段周期内的预处理后的bms数据
  182. df_gps : 一段周期内的预处理后的gps数据
  183. ---------输出参数------------
  184. sum_odo : 累积里程, 如果该周期内gps均无效,则返回None
  185. invalid_rate : 该周期内gps无效的bms数据行所占比例
  186. '''
  187. invalid_count = 0
  188. total_count = 0
  189. sum_odo = 0
  190. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_after_combine'])))
  191. if len(data_number_list) == 0:
  192. return {'sum_odo':0, 'invalid_rate':0}
  193. for data_number in data_number_list[:]:
  194. df_sel_bms = df_bms[df_bms['data_split_by_status_after_combine'] == data_number]
  195. df_sel_bms = df_sel_bms.reset_index(drop=True)
  196. total_count += len(df_sel_bms)
  197. if df_sel_bms.loc[0, 'gps_rely'] != 1:
  198. invalid_count += len(df_sel_bms)
  199. continue
  200. else:
  201. df_sel_gps = df_gps[(df_gps['时间戳']>df_sel_bms.loc[0,'时间戳']) & (df_gps['时间戳']<df_sel_bms.loc[len(df_sel_bms)-1,'时间戳'])]
  202. df_sel_gps = df_sel_gps.reset_index(drop=True)
  203. odo = self.indexStaByOneCycle.odo_sta(np.array(df_sel_gps['odo']))
  204. if not pd.isnull(odo):
  205. sum_odo += odo
  206. invalid_rate = invalid_count/total_count
  207. return {'sum_odo':sum_odo, 'invalid_rate':invalid_rate}
  208. #该函数未完成, TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  209. def _energy_consump_sta(self, cap, df_bms, df_gps):
  210. '''
  211. 计算周期内百公里能耗
  212. ---------输入参数------------
  213. df_bms : 本周期内的bms数据
  214. df_gps : 本周期内的gps数据
  215. ---------输出参数------------
  216. 本周期内的百公里能耗
  217. '''
  218. if not df_bms.empty and not df_gps.empty:
  219. # 计算能耗
  220. energy_sum = 0
  221. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  222. for data_number in data_number_list[:]:
  223. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  224. df_sel_bms = df_sel_bms.reset_index(drop=True)
  225. soc_array = np.array(df_sel_bms['SOC[%]'])
  226. soh_array = np.array(df_sel_bms['SOH[%]'])
  227. volt_array = np.array(df_sel_bms['总电压[V]'])
  228. energy = self.indexStaByOneCycle.energy_sta(cap, soc_array, soh_array, volt_array)
  229. if not pd.isnull(energy):
  230. energy_sum += energy
  231. # 计算里程
  232. pass # TODO!!!!!!!!!!!!!!!!!!!!!
  233. return 0
  234. else:
  235. return None
  236. def drive_soc_sta(self, df_bms):
  237. '''
  238. 计算周期内行车净累积soc
  239. ---------输入参数------------
  240. cap : 标称容量
  241. df_bms : 一段周期内的预处理后的bms数据
  242. df_gps : 一段周期内的预处理后的gps数据
  243. ---------输出参数------------
  244. sum_ah : 本周期的净累积soc
  245. '''
  246. sum_soc = 0
  247. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  248. if len(data_number_list) == 0:
  249. return sum_soc
  250. for data_number in data_number_list[:]:
  251. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  252. df_sel_bms = df_sel_bms.reset_index(drop=True)
  253. sum_soc += abs(df_sel_bms.loc[0, 'SOC[%]'] - df_sel_bms.loc[len(df_sel_bms)-1, 'SOC[%]'])
  254. return sum_soc
  255. def drive_time_sta(self, df_bms):
  256. '''
  257. 计算周期内累计行车时长/h
  258. ---------输入参数------------
  259. cap : 标称容量
  260. df_bms : 一段周期内的预处理后的bms数据
  261. df_gps : 一段周期内的预处理后的gps数据
  262. ---------输出参数------------
  263. sum_ah : 本周期的累计行车时长
  264. '''
  265. sum_time = 0
  266. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  267. if len(data_number_list) == 0:
  268. return sum_time
  269. for data_number in data_number_list[:]:
  270. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  271. df_sel_bms = df_sel_bms.reset_index(drop=True)
  272. sum_time += (df_sel_bms.loc[len(df_sel_bms)-1, '时间戳'] - df_sel_bms.loc[0, '时间戳']).total_seconds()
  273. return sum_time / 3600.0
  274. def drive_capacity_sta(self, cap, df_bms):
  275. '''
  276. 计算周期内行车净累积ah
  277. ---------输入参数------------
  278. cap : 标称容量
  279. df_bms : 一段周期内的预处理后的bms数据
  280. df_gps : 一段周期内的预处理后的gps数据
  281. ---------输出参数------------
  282. sum_ah : 本周期的净累积ah
  283. '''
  284. sum_ah = 0
  285. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  286. if len(data_number_list) == 0:
  287. return sum_ah
  288. for data_number in data_number_list[:]:
  289. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  290. df_sel_bms = df_sel_bms.reset_index(drop=True)
  291. soc_array = np.array(df_sel_bms['SOC[%]'])
  292. soh_array = np.array(df_sel_bms['SOH[%]'])
  293. sum_ah += self.indexStaByOneCycle.capacity_sta(cap, soc_array, soh_array)
  294. return sum_ah
  295. def drive_energy_sta(self, cap, df_bms):
  296. '''
  297. 计算周期内行车净累积能量
  298. ---------输入参数------------
  299. cap : 标称容量
  300. df_bms : 一段周期内的预处理后的bms数据
  301. df_gps : 一段周期内的预处理后的gps数据
  302. ---------输出参数------------
  303. sum_ah : 本周期的净累积能量
  304. '''
  305. sum_energy = 0
  306. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  307. if len(data_number_list) == 0:
  308. return sum_energy
  309. for data_number in data_number_list[:]:
  310. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  311. df_sel_bms = df_sel_bms.reset_index(drop=True)
  312. soc_array = np.array(df_sel_bms['SOC[%]'])
  313. soh_array = np.array(df_sel_bms['SOH[%]'])
  314. volt_array = np.array(df_sel_bms['总电压[V]'])
  315. sum_energy += self.indexStaByOneCycle.energy_sta(cap, soc_array, soh_array, volt_array)
  316. >>>>>>> master
  317. =======
  318. '''
  319. 基于某个周期(一天,一周...)的指标统计库
  320. '''
  321. __author__ = 'lmstack'
  322. # import CONFIGURE.PathSetting as PathSetting
  323. # import sys
  324. # sys.path.append(PathSetting.backend_path)
  325. # sys.path.append(PathSetting.middle_path)
  326. import datetime
  327. import Tools
  328. import pandas as pd
  329. import numpy as np
  330. from LIB.MIDDLE import IndexStaByOneCycle
  331. class IndexStaByPeriod():
  332. def __init__(self):
  333. self.indexStaByOneCycle = IndexStaByOneCycle.IndexStaByOneCycle()
  334. pass
  335. def drive_odo_sta(self, df_bms, df_gps):
  336. '''
  337. 计算周期内行车累积行驶里程
  338. ---------输入参数------------
  339. df_bms : 一段周期内的预处理后的bms数据
  340. df_gps : 一段周期内的预处理后的gps数据
  341. ---------输出参数------------
  342. sum_odo : 累积里程, 如果该周期内gps均无效,则返回None
  343. invalid_rate : 该周期内gps无效的bms数据行所占比例
  344. '''
  345. invalid_count = 0
  346. total_count = 0
  347. sum_odo = 0
  348. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_after_combine'])))
  349. if len(data_number_list) == 0:
  350. return {'sum_odo':0, 'invalid_rate':0}
  351. for data_number in data_number_list[:]:
  352. df_sel_bms = df_bms[df_bms['data_split_by_status_after_combine'] == data_number]
  353. df_sel_bms = df_sel_bms.reset_index(drop=True)
  354. total_count += len(df_sel_bms)
  355. if df_sel_bms.loc[0, 'gps_rely'] != 1:
  356. invalid_count += len(df_sel_bms)
  357. continue
  358. else:
  359. df_sel_gps = df_gps[(df_gps['时间戳']>df_sel_bms.loc[0,'时间戳']) & (df_gps['时间戳']<df_sel_bms.loc[len(df_sel_bms)-1,'时间戳'])]
  360. df_sel_gps = df_sel_gps.reset_index(drop=True)
  361. odo = self.indexStaByOneCycle.odo_sta(np.array(df_sel_gps['odo']))
  362. if not pd.isnull(odo):
  363. sum_odo += odo
  364. invalid_rate = invalid_count/total_count
  365. return {'sum_odo':sum_odo, 'invalid_rate':invalid_rate}
  366. #该函数未完成, TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  367. def _energy_consump_sta(self, cap, df_bms, df_gps):
  368. '''
  369. 计算周期内百公里能耗
  370. ---------输入参数------------
  371. df_bms : 本周期内的bms数据
  372. df_gps : 本周期内的gps数据
  373. ---------输出参数------------
  374. 本周期内的百公里能耗
  375. '''
  376. if not df_bms.empty and not df_gps.empty:
  377. # 计算能耗
  378. energy_sum = 0
  379. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  380. for data_number in data_number_list[:]:
  381. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  382. df_sel_bms = df_sel_bms.reset_index(drop=True)
  383. soc_array = np.array(df_sel_bms['SOC[%]'])
  384. soh_array = np.array(df_sel_bms['SOH[%]'])
  385. volt_array = np.array(df_sel_bms['总电压[V]'])
  386. energy = self.indexStaByOneCycle.energy_sta(cap, soc_array, soh_array, volt_array)
  387. if not pd.isnull(energy):
  388. energy_sum += energy
  389. # 计算里程
  390. pass # TODO!!!!!!!!!!!!!!!!!!!!!
  391. return 0
  392. else:
  393. return None
  394. def drive_soc_sta(self, df_bms):
  395. '''
  396. 计算周期内行车净累积soc
  397. ---------输入参数------------
  398. cap : 标称容量
  399. df_bms : 一段周期内的预处理后的bms数据
  400. df_gps : 一段周期内的预处理后的gps数据
  401. ---------输出参数------------
  402. sum_ah : 本周期的净累积soc
  403. '''
  404. sum_soc = 0
  405. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  406. if len(data_number_list) == 0:
  407. return sum_soc
  408. for data_number in data_number_list[:]:
  409. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  410. df_sel_bms = df_sel_bms.reset_index(drop=True)
  411. sum_soc += abs(df_sel_bms.loc[0, 'SOC[%]'] - df_sel_bms.loc[len(df_sel_bms)-1, 'SOC[%]'])
  412. return sum_soc
  413. def drive_time_sta(self, df_bms):
  414. '''
  415. 计算周期内累计行车时长/h
  416. ---------输入参数------------
  417. cap : 标称容量
  418. df_bms : 一段周期内的预处理后的bms数据
  419. df_gps : 一段周期内的预处理后的gps数据
  420. ---------输出参数------------
  421. sum_ah : 本周期的累计行车时长
  422. '''
  423. sum_time = 0
  424. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  425. if len(data_number_list) == 0:
  426. return sum_time
  427. for data_number in data_number_list[:]:
  428. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  429. df_sel_bms = df_sel_bms.reset_index(drop=True)
  430. sum_time += (df_sel_bms.loc[len(df_sel_bms)-1, '时间戳'] - df_sel_bms.loc[0, '时间戳']).total_seconds()
  431. return sum_time / 3600.0
  432. def drive_capacity_sta(self, cap, df_bms):
  433. '''
  434. 计算周期内行车净累积ah
  435. ---------输入参数------------
  436. cap : 标称容量
  437. df_bms : 一段周期内的预处理后的bms数据
  438. df_gps : 一段周期内的预处理后的gps数据
  439. ---------输出参数------------
  440. sum_ah : 本周期的净累积ah
  441. '''
  442. sum_ah = 0
  443. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  444. if len(data_number_list) == 0:
  445. return sum_ah
  446. for data_number in data_number_list[:]:
  447. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  448. df_sel_bms = df_sel_bms.reset_index(drop=True)
  449. soc_array = np.array(df_sel_bms['SOC[%]'])
  450. soh_array = np.array(df_sel_bms['SOH[%]'])
  451. sum_ah += self.indexStaByOneCycle.capacity_sta(cap, soc_array, soh_array)
  452. return sum_ah
  453. def drive_energy_sta(self, cap, df_bms):
  454. '''
  455. 计算周期内行车净累积能量
  456. ---------输入参数------------
  457. cap : 标称容量
  458. df_bms : 一段周期内的预处理后的bms数据
  459. df_gps : 一段周期内的预处理后的gps数据
  460. ---------输出参数------------
  461. sum_ah : 本周期的净累积能量
  462. '''
  463. sum_energy = 0
  464. data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status_time'])))
  465. if len(data_number_list) == 0:
  466. return sum_energy
  467. for data_number in data_number_list[:]:
  468. df_sel_bms = df_bms[df_bms['data_split_by_status_time'] == data_number]
  469. df_sel_bms = df_sel_bms.reset_index(drop=True)
  470. soc_array = np.array(df_sel_bms['SOC[%]'])
  471. soh_array = np.array(df_sel_bms['SOH[%]'])
  472. volt_array = np.array(df_sel_bms['总电压[V]'])
  473. sum_energy += self.indexStaByOneCycle.energy_sta(cap, soc_array, soh_array, volt_array)
  474. >>>>>>> 65a87ae16013552e359df047df19f46fc4e6eb08
  475. return sum_energy