DataPreProcess.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <html><head><title>Python: module DataPreProcess</title>
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  4. </head><body bgcolor="#f0f0f8">
  5. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
  6. <tr bgcolor="#7799ee">
  7. <td valign=bottom>&nbsp;<br>
  8. <font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>DataPreProcess</strong></big></big></font></td
  9. ><td align=right valign=bottom
  10. ><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:d%3A%5Cplatform%5Cplatform%5Cbackend%5Cdatapreprocess.py">d:\platform\platform\backend\datapreprocess.py</a></font></td></tr></table>
  11. <p><tt>数据预处理类</tt></p>
  12. <p>
  13. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  14. <tr bgcolor="#aa55cc">
  15. <td colspan=3 valign=bottom>&nbsp;<br>
  16. <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
  17. <tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  18. <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="PathSetting.html">PathSetting</a><br>
  19. <a href="Tools.html">Tools</a><br>
  20. </td><td width="25%" valign=top><a href="numpy.html">numpy</a><br>
  21. <a href="pandas.html">pandas</a><br>
  22. </td><td width="25%" valign=top><a href="pdb.html">pdb</a><br>
  23. <a href="sys.html">sys</a><br>
  24. </td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
  25. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  26. <tr bgcolor="#ee77aa">
  27. <td colspan=3 valign=bottom>&nbsp;<br>
  28. <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
  29. <tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  30. <td width="100%"><dl>
  31. <dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
  32. </font></dt><dd>
  33. <dl>
  34. <dt><font face="helvetica, arial"><a href="DataPreProcess.html#DataPreProcess">DataPreProcess</a>
  35. </font></dt></dl>
  36. </dd>
  37. </dl>
  38. <p>
  39. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  40. <tr bgcolor="#ffc8d8">
  41. <td colspan=3 valign=bottom>&nbsp;<br>
  42. <font color="#000000" face="helvetica, arial"><a name="DataPreProcess">class <strong>DataPreProcess</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
  43. <tr><td bgcolor="#ffc8d8"><tt>&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  44. <td width="100%">Methods defined here:<br>
  45. <dl><dt><a name="DataPreProcess-__init__"><strong>__init__</strong></a>(self)</dt><dd><tt>Initialize&nbsp;self.&nbsp;&nbsp;See&nbsp;help(type(self))&nbsp;for&nbsp;accurate&nbsp;signature.</tt></dd></dl>
  46. <dl><dt><a name="DataPreProcess-cal_stand_time"><strong>cal_stand_time</strong></a>(self, dfin)</dt><dd><tt>#&nbsp;计算静置时间<br>
  47. #&nbsp;将每次行车或充电的前后静置时间,赋值给stand_time&nbsp;列,&nbsp;单位为分钟<br>
  48. &nbsp;<br>
  49. ----------------输入参数---------<br>
  50. dfin:&nbsp;调用data_split_by_status()后输出的bms数据<br>
  51. &nbsp;<br>
  52. ----------------输出参数----------<br>
  53. 在输入数据后面,增加stand_time列<br>
  54. stand_time&nbsp;:&nbsp;在行车段或充电段的起止两个位置处,表明开始前和结束后的静置时长,单位为分钟</tt></dd></dl>
  55. <dl><dt><a name="DataPreProcess-combine_drive_stand"><strong>combine_drive_stand</strong></a>(self, dfin)</dt><dd><tt>合并放电和静置段:将两次充电之间的所有数据段合并为一段,&nbsp;状态分为&nbsp;charge&nbsp;和not&nbsp;charge<br>
  56. ---------------输入----------<br>
  57. dfin:&nbsp;调用data_split_by_status()后输出的bms数据<br>
  58. &nbsp;<br>
  59. ---------------输出----------<br>
  60. 在输入数据后面,增加data_split_by_status_after_combine,&nbsp;data_status_after_combine&nbsp;两列<br>
  61. data_split_by_status_after_combine:&nbsp;将两次充电间的数据合并后的段序号<br>
  62. data_status_after_combine:&nbsp;每段数据的状态标识</tt></dd></dl>
  63. <dl><dt><a name="DataPreProcess-data_gps_judge_after_combine"><strong>data_gps_judge_after_combine</strong></a>(self, df_bms, df_gps, time_diff_thre=600, odo_sum_thre=200, drive_spd_thre=80, parking_spd_thre=2)</dt><dd><tt>GPS数据可靠性判断函数2&nbsp;(基于combine后的分段)&nbsp;判别方式同data_gps_judge</tt></dd></dl>
  64. <dl><dt><a name="DataPreProcess-data_split_by_status"><strong>data_split_by_status</strong></a>(self, dfin, drive_interval_threshold=120, charge_interval_threshold=300, drive_stand_threshold=120, charge_stand_threshold=300)</dt><dd><tt>#&nbsp;数据预处理分段,&nbsp;将原始数据段分为&nbsp;charge、drive、stand、none段<br>
  65. #&nbsp;状态判断<br>
  66. #&nbsp;1、drive:(状态为2或3&nbsp;且&nbsp;存在电流&gt;0&nbsp;)&nbsp;或&nbsp;(电流持续为0&nbsp;且&nbsp;持续时间&lt;阈值&nbsp;且&nbsp;上一段数据为行车)<br>
  67. #&nbsp;2、charge:(状态为2或3&nbsp;且&nbsp;不存在电流&gt;0&nbsp;)&nbsp;或&nbsp;(电流持续为0&nbsp;且&nbsp;持续时间&lt;阈值&nbsp;且&nbsp;上一段数据为充电)<br>
  68. #&nbsp;3、stand:(电流持续为0&nbsp;且&nbsp;是数据段的第一段)&nbsp;或&nbsp;(电流持续为0&nbsp;且&nbsp;持续时间&gt;阈值)<br>
  69. #&nbsp;4、none:&nbsp;其他<br>
  70. &nbsp;<br>
  71. --------------输入参数-------------:<br>
  72. drive_interval_threshold:&nbsp;行车段拼接阈值,如果两段行车的间隔时间小于该值,则两段行车合并。<br>
  73. charge_interval_threshold:&nbsp;充电段拼接阈值,如果两段充电的间隔时间小于该值,则两段充电合并。<br>
  74. drive_stand_threshold:&nbsp;静置段合并至行车段阈值,如果静置时间小于该值,则合并到上一段的行车中。<br>
  75. charge_stand_threshold:&nbsp;静置段合并至充电段阈值,如果静置时间小于该值,则合并到上一段的充电中。<br>
  76. &nbsp;<br>
  77. --------------输出-----------------:<br>
  78. 在原始数据后面,增加data_split_by_crnt,&nbsp;data_split_by_status,&nbsp;data_status&nbsp;三列<br>
  79. data_split_by_crnt:&nbsp;按电流分段的序号<br>
  80. data_split_by_status:按电流和状态分段的序号<br>
  81. data_status:&nbsp;状态标识</tt></dd></dl>
  82. <dl><dt><a name="DataPreProcess-data_split_by_time"><strong>data_split_by_time</strong></a>(self, dfin, default_time_threshold=300, drive_time_threshold=300, charge_time_threshold=300, stand_time_threshold=1800)</dt><dd><tt>#&nbsp;该函数用来解决数据丢失问题导致的分段序号异常,<br>
  83. #&nbsp;将经过data_split_by_status分段后的数据,每个段内两行数据的时间跳变如果超过阈值,则继续分为两段<br>
  84. &nbsp;<br>
  85. --------------输入参数-------------:<br>
  86. dfin:&nbsp;&nbsp;调用data_split_by_status之后的函数<br>
  87. default_time_threshold:&nbsp;默认时间阈值,如果状态内部时间跳变大于该值,则划分为两段<br>
  88. drive_time_threshold:&nbsp;行车时间阈值,如果行车状态内部时间跳变大于该值,则划分为两段<br>
  89. charge_time_threshold:&nbsp;充电时间阈值,如果充电状态内部时间跳变大于该值,则划分为两段<br>
  90. stand_time_threshold:静置时间阈值,如果静置状态内部时间跳变大于该值,则划分为两段<br>
  91. &nbsp;<br>
  92. --------------输出-----------------:<br>
  93. 在输入数据后面,增加data_split_by_status_time&nbsp;一列<br>
  94. data_split_by_status_time:&nbsp;按照状态和时间分段后的序号</tt></dd></dl>
  95. <dl><dt><a name="DataPreProcess-gps_data_judge"><strong>gps_data_judge</strong></a>(self, df_bms, df_gps, time_diff_thre=300, odo_sum_thre=200, drive_spd_thre=80, parking_spd_thre=2)</dt><dd><tt>GPS数据可靠性判断函数(基于combine前的分段)<br>
  96. &nbsp;<br>
  97. GPS数据出现以下情况时,判定为不可靠:<br>
  98. 1)如果该段对应的地理位置数据&nbsp;少于2&nbsp;个,则认为不可靠<br>
  99. 2)如果截取的GPS数据的起止时间,与BMS数据段的起止时间相差超过阈值,则认为不可靠<br>
  100. 3)如果行车段&nbsp;累积里程超过阈值,车速超过阈值<br>
  101. 4)&nbsp;如果非行车段&nbsp;车速超过阈值<br>
  102. &nbsp;<br>
  103. --------------输入参数--------------:<br>
  104. time_diff_thre:&nbsp;时间差阈值<br>
  105. odo_sum_thre:&nbsp;累积里程阈值<br>
  106. drive_spd_thre:&nbsp;行车车速阈值<br>
  107. parking_spd_thre:&nbsp;非行车状态车速阈值<br>
  108. &nbsp;<br>
  109. --------------输出参数--------------:<br>
  110. df_bms&nbsp;增加一列gps_rely,&nbsp;表明对应的GPS数据是否可靠。<br>
  111. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1:可靠<br>
  112. &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;0:&nbsp;表示不可靠的原因<br>
  113. df_gps&nbsp;增加两列odo,&nbsp;speed,&nbsp;分别表示前后两点间的距离和速度</tt></dd></dl>
  114. <dl><dt><a name="DataPreProcess-time_filter"><strong>time_filter</strong></a>(self, df_bms, df_gps)</dt><dd><tt>#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'''</tt></dd></dl>
  115. <hr>
  116. Data descriptors defined here:<br>
  117. <dl><dt><strong>__dict__</strong></dt>
  118. <dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
  119. </dl>
  120. <dl><dt><strong>__weakref__</strong></dt>
  121. <dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
  122. </dl>
  123. </td></tr></table></td></tr></table><p>
  124. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  125. <tr bgcolor="#55aa55">
  126. <td colspan=3 valign=bottom>&nbsp;<br>
  127. <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
  128. <tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  129. <td width="100%"><strong>CONF_PATH</strong> = r'D:\Platform\platform\CONFIGURE\'<br>
  130. <strong>defpath</strong> = r'.;C:\bin'</td></tr></table><p>
  131. <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
  132. <tr bgcolor="#7799ee">
  133. <td colspan=3 valign=bottom>&nbsp;<br>
  134. <font color="#ffffff" face="helvetica, arial"><big><strong>Author</strong></big></font></td></tr>
  135. <tr><td bgcolor="#7799ee"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
  136. <td width="100%">wlm</td></tr></table>
  137. </body></html>