{ "cells": [ { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "### start to get data PK50001A100000100 from 2021-02-10 22:54:36 to 2021-02-20 22:54:36\n", "# get data from 2021-02-19 22:54:36 to 2021-02-20 22:54:36......... \n", "all data-getting done, bms_count is 19444, gps_count is 5960, system_count is 566, accum_count is 2391 \n", "\n" ] } ], "source": [ "# 获取数据\n", "import sys\n", "from LIB.BACKEND import DBManager\n", "\n", "sn = \"PK50001A100000100\"\n", "st = '2021-02-10 22:54:36'\n", "et = '2021-02-20 22:54:36'\n", "\n", "dbManager = DBManager.DBManager()\n", "df_data = dbManager.get_data(sn=sn, start_time=st, end_time=et, data_groups=['bms', 'gps', 'accum', 'system'])\n", "# \n", "df_bms = df_data['bms']\n", "df_gps = df_data['gps']\n", "df_accum = df_data['accum']\n", "df_system = df_data['system']" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "ename": "", "evalue": "", "output_type": "error", "traceback": [ "\u001b[1;31mPython 3.8.12 64-bit ('algo_dev_env': conda) 需要安装 ipykernel。\n", "Run the following command to install 'ipykernel' into the Python environment. \n", "Command: 'conda install -n algo_dev_env ipykernel --update-deps --force-reinstall'" ] } ], "source": [ "import plotly.io as pio\n", "pio.renderers.default = 'iframe_connected'" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 下载数据 \n", "import sys\n", "from LIB.BACKEND import Tools\n", "\n", "tools = Tools.Tools()\n", "write_path = r''\n", "sn = \"PK50001A100000680\"\n", "\n", "st = '2021-07-06 00:00:00'\n", "et = '2021-07-07 20:00:00'\n", "tools.data_download(write_path=write_path, sn=sn, start_time=st, end_time=et, data_groups=['bms'])" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 数据预处理\n", "import sys\n", "from LIB.BACKEND import DataPreProcess\n", "\n", "dataPrePro = DataPreProcess.DataPreProcess()\n", "# 时间完全相同的数据仅保留一行\n", "df_bms_pro, df_gps_pro = dataPrePro.time_filter(df_bms, df_gps)\n", "\n", "# bms数据按照电流和状态分段, 然后在状态分段内部,根据时间跳变继续分段(解决段内数据丢失)\n", "df_bms_pro = dataPrePro.data_split_by_status(df_bms_pro)\n", "df_bms_pro = dataPrePro.data_split_by_time(df_bms_pro)\n", "\n", "# bms数据将两次充电间的状态合并\n", "df_bms_pro = dataPrePro.combine_drive_stand(df_bms_pro)\n", "# bms 数据计算行车和充电开始前后的静置时间\n", "df_bms_pro = dataPrePro.cal_stand_time(df_bms_pro)\n", "# gps 数据可靠性判断, 并增加里程和速度至gps数据(根据未合并的数据段判断)\n", "df_bms_pro, df_gps_pro, res_record= dataPrePro.gps_data_judge(df_bms_pro, df_gps_pro)\n", "# gps 数据可靠性判断, 并增加里程和速度至gps数据(根据已合并的数据段判断)\n", "df_bms_pro, df_gps_pro, res_record= dataPrePro.data_gps_judge_after_combine(df_bms_pro, df_gps_pro)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# 单cycle指标统计\n", "import sys\n", "from LIB.BACKEND import IndexStaByOneCycle\n", "\n", "indexSta = IndexStaByOneCycle.IndexStaByOneCycle()\n", "\n", "data_number_list = sorted(list(set(df_bms[(df_bms['data_status'].isin(['drive']))]['data_split_by_status'])))\n", "for data_number in data_number_list[:]:\n", " df_sel_bms = df_bms[df_bms['data_split_by_status'] == data_number]\n", " df_sel_bms = df_sel_bms.reset_index(drop=True)\n", " df_sel_gps = df_gps[(df_gps['时间戳']>df_sel_bms.loc[0,'时间戳']) & (df_gps['时间戳']