{ "cells": [ { "cell_type": "code", "execution_count": 2, "source": [ "# 获取数据\r\n", "import sys\r\n", "from LIB.BACKEND import DBManager\r\n", "\r\n", "sn = \"PK10001A326000123\"\r\n", "st = '2021-07-06 00:00:00'\r\n", "et = '2021-07-07 20:00:00'\r\n", "\r\n", "dbManager = DBManager.DBManager()\r\n", "df_data = dbManager.get_data(sn=sn, start_time=st, end_time=et, data_groups=['bms', 'gps', 'accum', 'system'])\r\n", "# \r\n", "df_bms = df_data['bms']\r\n", "df_gps = df_data['gps']\r\n", "df_accum = df_data['accum']\r\n", "df_system = df_data['system']" ], "outputs": [ { "output_type": "stream", "name": "stdout", "text": [ "### start to get data PK10001A326000123 from 2021-07-06 00:00:00 to 2021-07-07 20:00:00\n", "# get data from 2021-07-06 00:00:00 to 2021-07-07 00:00:00......... \n", "Server Error, retry 1...... \n", "# get data from 2021-07-07 00:00:00 to 2021-07-07 20:00:00......... \n", "all data-getting done, bms_count is 0, gps_count is 0, system_count is 0, accum_count is 0 \n", "\n" ] } ], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# 下载数据 \r\n", "import sys\r\n", "from LIB.BACKEND import Tools\r\n", "\r\n", "tools = Tools.Tools()\r\n", "write_path = r''\r\n", "sn = \"PK50001A100000680\"\r\n", "\r\n", "st = '2021-07-06 00:00:00'\r\n", "et = '2021-07-07 20:00:00'\r\n", "tools.data_download(write_path=write_path, sn=sn, start_time=st, end_time=et, data_groups=['bms'])" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# 数据预处理\r\n", "import sys\r\n", "from LIB.BACKEND import DataPreProcess\r\n", "\r\n", "dataPrePro = DataPreProcess.DataPreProcess()\r\n", "# 时间完全相同的数据仅保留一行\r\n", "df_bms_pro, df_gps_pro = dataPrePro.time_filter(df_bms, df_gps)\r\n", "\r\n", "# bms数据按照电流和状态分段, 然后在状态分段内部,根据时间跳变继续分段(解决段内数据丢失)\r\n", "df_bms_pro = dataPrePro.data_split_by_status(df_bms_pro)\r\n", "df_bms_pro = dataPrePro.data_split_by_time(df_bms_pro)\r\n", "\r\n", "# bms数据将两次充电间的状态合并\r\n", "df_bms_pro = dataPrePro.combine_drive_stand(df_bms_pro)\r\n", "# bms 数据计算行车和充电开始前后的静置时间\r\n", "df_bms_pro = dataPrePro.cal_stand_time(df_bms_pro)\r\n", "# gps 数据可靠性判断, 并增加里程和速度至gps数据(根据未合并的数据段判断)\r\n", "df_bms_pro, df_gps_pro, res_record= dataPrePro.gps_data_judge(df_bms_pro, df_gps_pro)\r\n", "# gps 数据可靠性判断, 并增加里程和速度至gps数据(根据已合并的数据段判断)\r\n", "df_bms_pro, df_gps_pro, res_record= dataPrePro.data_gps_judge_after_combine(df_bms_pro, df_gps_pro)" ], "outputs": [], "metadata": {} }, { "cell_type": "code", "execution_count": null, "source": [ "# 单cycle指标统计\r\n", "import sys\r\n", "from LIB.BACKEND import IndexStaByOneCycle\r\n", "\r\n", "indexSta = IndexStaByOneCycle.IndexStaByOneCycle()\r\n", "\r\n", "data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status'])))\r\n", "for data_number in data_number_list[:]:\r\n", " df_sel_bms = df_bms[df_bms['data_split_by_status'] == data_number]\r\n", " df_sel_bms = df_sel_bms.reset_index(drop=True)\r\n", " df_sel_gps = df_gps[(df_gps['时间戳']>df_sel_bms.loc[0,'时间戳']) & (df_gps['时间戳']