|
@@ -2,164 +2,183 @@
|
|
|
"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']"
|
|
|
- ],
|
|
|
+ "execution_count": 6,
|
|
|
+ "metadata": {},
|
|
|
"outputs": [
|
|
|
{
|
|
|
- "output_type": "stream",
|
|
|
"name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
"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",
|
|
|
+ "### 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"
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
- "metadata": {}
|
|
|
+ "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,
|
|
|
- "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'])"
|
|
|
+ "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": [],
|
|
|
- "metadata": {}
|
|
|
+ "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": [
|
|
|
- "# 数据预处理\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",
|
|
|
+ "# 数据预处理\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)"
|
|
|
- ],
|
|
|
- "outputs": [],
|
|
|
- "metadata": {}
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
"execution_count": null,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
"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['时间戳']<df_sel_bms.loc[len(df_sel_bms)-1,'时间戳'])]\r\n",
|
|
|
- " df_sel_gps = df_sel_gps.reset_index(drop=True)\r\n",
|
|
|
- "\r\n",
|
|
|
- " print(indexSta.odo_sta(np.array(df_sel_gps['odo'])))\r\n",
|
|
|
- " print(indexSta.capacity_sta(40, np.array(df_sel_bms['SOC[%]']), np.array(df_sel_bms['SOH[%]'])))\r\n",
|
|
|
- " print(indexSta.energy_sta(40, np.array(df_sel_bms['SOC[%]']), np.array(df_sel_bms['SOH[%]']),np.array(df_sel_bms['总电压[V]'])))\r\n",
|
|
|
- " print(indexSta.acc_time_sta(np.array(df_sel_bms['时间戳'])))\r\n",
|
|
|
- " print(indexSta.mean_temp_sta(np.array(df_sel_bms['单体温度1'])))\r\n",
|
|
|
- " print(indexSta.temp_change_rate_sta(np.array(df_sel_bms['时间戳']), np.array(df_sel_bms['单体温度1'])))\r\n",
|
|
|
- " print(indexSta.dischrg_max_pwr_sta(np.array(df_sel_bms['总电压[V]']), np.array(df_sel_bms['总电流[A]'])))\r\n",
|
|
|
- " print(indexSta.chrg_max_pwr_sta(np.array(df_sel_bms['总电压[V]']), np.array(df_sel_bms['总电流[A]'])))\r\n",
|
|
|
- " 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'])))\r\n",
|
|
|
+ "# 单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['时间戳']<df_sel_bms.loc[len(df_sel_bms)-1,'时间戳'])]\n",
|
|
|
+ " df_sel_gps = df_sel_gps.reset_index(drop=True)\n",
|
|
|
+ "\n",
|
|
|
+ " print(indexSta.odo_sta(np.array(df_sel_gps['odo'])))\n",
|
|
|
+ " print(indexSta.capacity_sta(40, np.array(df_sel_bms['SOC[%]']), np.array(df_sel_bms['SOH[%]'])))\n",
|
|
|
+ " print(indexSta.energy_sta(40, np.array(df_sel_bms['SOC[%]']), np.array(df_sel_bms['SOH[%]']),np.array(df_sel_bms['总电压[V]'])))\n",
|
|
|
+ " print(indexSta.acc_time_sta(np.array(df_sel_bms['时间戳'])))\n",
|
|
|
+ " print(indexSta.mean_temp_sta(np.array(df_sel_bms['单体温度1'])))\n",
|
|
|
+ " print(indexSta.temp_change_rate_sta(np.array(df_sel_bms['时间戳']), np.array(df_sel_bms['单体温度1'])))\n",
|
|
|
+ " print(indexSta.dischrg_max_pwr_sta(np.array(df_sel_bms['总电压[V]']), np.array(df_sel_bms['总电流[A]'])))\n",
|
|
|
+ " print(indexSta.chrg_max_pwr_sta(np.array(df_sel_bms['总电压[V]']), np.array(df_sel_bms['总电流[A]'])))\n",
|
|
|
+ " 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'])))\n",
|
|
|
" break"
|
|
|
- ],
|
|
|
- "outputs": [],
|
|
|
- "metadata": {}
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
"execution_count": 2,
|
|
|
- "source": [
|
|
|
- "# 生成pydoc 说明文档\r\n",
|
|
|
- "!python -m pydoc -w LIB\\BACKEND\\DataPreProcess.py"
|
|
|
- ],
|
|
|
+ "metadata": {},
|
|
|
"outputs": [
|
|
|
{
|
|
|
- "output_type": "stream",
|
|
|
"name": "stdout",
|
|
|
+ "output_type": "stream",
|
|
|
"text": [
|
|
|
"problem in LIB\\BACKEND\\DataPreProcess.py - ModuleNotFoundError: No module named 'DBManager'\n"
|
|
|
]
|
|
|
}
|
|
|
],
|
|
|
- "metadata": {}
|
|
|
+ "source": [
|
|
|
+ "# 生成pydoc 说明文档\n",
|
|
|
+ "!python -m pydoc -w LIB\\BACKEND\\DataPreProcess.py"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
"execution_count": 1,
|
|
|
- "source": [
|
|
|
- "from LIB.BACKEND import DBManager, Log\r\n",
|
|
|
- "log = Log.Mylog(log_name='signal_monitor', log_level = 'info')\r\n",
|
|
|
- "log.set_file_hl(file_name='info.log', log_level='info')\r\n",
|
|
|
- "log.set_file_hl(file_name='error.log', log_level='error')\r\n",
|
|
|
- "logger = log.get_logger()\r\n"
|
|
|
- ],
|
|
|
+ "metadata": {},
|
|
|
"outputs": [],
|
|
|
- "metadata": {}
|
|
|
+ "source": [
|
|
|
+ "from LIB.BACKEND import DBManager, Log\n",
|
|
|
+ "log = Log.Mylog(log_name='signal_monitor', log_level = 'info')\n",
|
|
|
+ "log.set_file_hl(file_name='info.log', log_level='info')\n",
|
|
|
+ "log.set_file_hl(file_name='error.log', log_level='error')\n",
|
|
|
+ "logger = log.get_logger()\n"
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
"execution_count": 6,
|
|
|
+ "metadata": {},
|
|
|
+ "outputs": [],
|
|
|
"source": [
|
|
|
"logger.error(\"ttt5\")"
|
|
|
- ],
|
|
|
- "outputs": [],
|
|
|
- "metadata": {}
|
|
|
+ ]
|
|
|
},
|
|
|
{
|
|
|
"cell_type": "code",
|
|
|
"execution_count": null,
|
|
|
- "source": [],
|
|
|
+ "metadata": {},
|
|
|
"outputs": [],
|
|
|
- "metadata": {}
|
|
|
+ "source": []
|
|
|
}
|
|
|
],
|
|
|
"metadata": {
|
|
@@ -167,23 +186,23 @@
|
|
|
"hash": "b3ba2566441a7c06988d0923437866b63cedc61552a5af99d1f4fb67d367b25f"
|
|
|
},
|
|
|
"kernelspec": {
|
|
|
- "name": "python3",
|
|
|
- "display_name": "Python 3.8.8 64-bit ('base': conda)"
|
|
|
+ "display_name": "Python 3.8.8 64-bit ('base': conda)",
|
|
|
+ "name": "python3"
|
|
|
},
|
|
|
"language_info": {
|
|
|
- "name": "python",
|
|
|
- "version": "3.8.8",
|
|
|
- "mimetype": "text/x-python",
|
|
|
"codemirror_mode": {
|
|
|
"name": "ipython",
|
|
|
"version": 3
|
|
|
},
|
|
|
- "pygments_lexer": "ipython3",
|
|
|
+ "file_extension": ".py",
|
|
|
+ "mimetype": "text/x-python",
|
|
|
+ "name": "python",
|
|
|
"nbconvert_exporter": "python",
|
|
|
- "file_extension": ".py"
|
|
|
+ "pygments_lexer": "ipython3",
|
|
|
+ "version": "3.8.12"
|
|
|
},
|
|
|
"orig_nbformat": 4
|
|
|
},
|
|
|
"nbformat": 4,
|
|
|
"nbformat_minor": 2
|
|
|
-}
|
|
|
+}
|