Files
lingniu-vehicle-ingest/reports/hydrogen-diagnostics/粤AGP3080-2026-08-11-用氢差异诊断.ipynb
T

109 lines
4.5 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# 粤AGP3080 2026-08-11 用氢量差异诊断\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## tl;dr\n",
"\n",
"- 生产数据库当前值为 **5.992 kg**,分段关键帧合并值为 **12.051 kg**,差 **6.059 kg+101.12%**。\n",
"- 根因已确认:同一车辆当天使用了3个 `source_endpoint`。现有算法按 `VIN + source_endpoint` 分组后只选择样本最多的一组,导致后续两个连续时间段被舍弃。\n",
"- 三个来源片段按现有算法分别得到5.992、0.697、5.349 kg,合计12.038 kg;与分段关键帧结果仅差0.013 kg。\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Context & Methods\n",
"\n",
"诊断对象:粤AGP3080VIN `LB9A32A25R0LS1452`2026-08-11Asia/Shanghai)。\n",
"\n",
"对比口径:生产表日结果、现有算法按连接来源分组的结果、合并全部来源后按工作段首尾5帧中位数做差的结果。加氢、异常跳变和超过5分钟的数据断点用于切段。\n",
"\n",
"### Key Assumptions\n",
"\n",
"三个端口属于同一VIN当天的连接重连,不是三个独立车辆数据源;百公里氢耗采用生产日里程502.4km。\n",
"\n",
"> 执行状态:生产查询已于2026-08-19完成并复核。本地缺少 `nbformat`、`jupyter` 和可用内核,因此本笔记本保存可复算代码但未在本机执行。复跑命令:`python -m jupyter nbconvert --execute --to notebook --inplace <notebook>`。\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Data\n",
"\n",
"| 来源连接 | 时间范围 | 原始帧 | 工作帧 | 现有算法用氢量 |\n",
"|---|---|---:|---:|---:|\n",
"| 8.134.95.166:54760 | 06:28:1212:34:43 | 1542 | 1539 | 5.992kg |\n",
"| 8.134.95.166:41692 | 12:35:1314:38:29 | 328 | 328 | 0.697kg |\n",
"| 8.134.95.166:37898 | 14:54:0019:59:02 | 1357 | 1357 | 5.349kg |\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"mileage_km = 502.4\n",
"stored_kg = 5.992\n",
"source_consumption_kg = [5.992, 0.697, 5.349]\n",
"segment_consumption_kg = [0.462, 2.537, 3.685, 0.000, 2.629, 2.738]\n",
"source_sum_kg = round(sum(source_consumption_kg), 3)\n",
"proposed_kg = round(sum(segment_consumption_kg), 3)\n",
"gap_kg = round(proposed_kg - stored_kg, 3)\n",
"gap_pct = round((proposed_kg / stored_kg - 1) * 100, 2)\n",
"omitted_sources_kg = round(source_sum_kg - stored_kg, 3)\n",
"method_residual_kg = round(proposed_kg - source_sum_kg, 3)\n",
"current_rate = round(stored_kg / mileage_km * 100, 3)\n",
"proposed_rate = round(proposed_kg / mileage_km * 100, 3)\n",
"assert (source_sum_kg, proposed_kg, gap_kg) == (12.038, 12.051, 6.059)\n",
"{\n",
" '数据库用氢量_kg': stored_kg,\n",
" '新算法用氢量_kg': proposed_kg,\n",
" '差值_kg': gap_kg,\n",
" '差值比例_pct': gap_pct,\n",
" '被舍弃来源片段_kg': omitted_sources_kg,\n",
" '方法残差_kg': method_residual_kg,\n",
" '数据库百公里氢耗': current_rate,\n",
" '新算法百公里氢耗': proposed_rate,\n",
"}\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Takeaways\n",
"\n",
"1. 差值不是压力换算公式造成的;被舍弃的两个连接片段贡献6.046kg,解释总差值的99.79%。\n",
"2. 问题在聚合粒度:`source_endpoint` 包含临时TCP端口,重连会改变端口,不能作为车辆日统计的互斥来源键。\n",
"3. 当前生产结果只保留06:2812:34的数据,12:35–19:59的连续有效工作数据没有进入日用氢量。\n",
"4. 建议先按VIN和事件时间合并去重,再识别工作段;来源字段只用于追踪。\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"name": "python",
"version": "3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}