You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

高级峰值“块”分析:车辆路面形变传感器数据处理问询

车辆路面形变数据分析问题

我编程基础薄弱,此前参考相关技巧处理数据,在此致谢。

当前需分析光学传感器采集的车辆路面形变数据:每10分钟生成30万行xlsx格式原始文件,目前采用类zscore算法滤除噪声并检测峰值,但无法捕获全部所需峰值。

我的分析思路:

  • 将检测到的峰值索引作为「块/通行段」,对每个块单独分析;
  • 以初始检测到的峰值为基准,采集其前2秒、后3秒共5秒的数据,覆盖车辆通行的完整时间区间。

采集5秒数据后,需提取以下特征:

  • 车辆峰值/轴数统计;
  • 每个峰值的最大值;
  • 相对于峰值前2秒静止点的形变量增量。

我尝试过Savitzky滤波求导找峰值等方法,目前效果最佳的是通过计算移动平均与标准差、调整阈值、lag和influence参数的类zscore算法,但仍无法捕获全部目标峰值,且后续特征提取环节陷入瓶颈。以下是当前用于初步分析的代码:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt


df = pd.read_excel('2023_09_28_16_59_06.xlsx')


lag = 500
influence = 0.5
threshold = 10


def find_peak_indices(signal, lag, influence, threshold):
    peak_indices = []  
    peaks = []  
    processed_signal = [] 
    processed_signal.append(signal[:lag])
    avg_list = []
    sd_list = []

    for index in range(lag, len(signal)):
        y = signal[index]
        avg_list.append(np.mean(processed_signal[-lag:]))
        sd_list.append(np.std(processed_signal[-lag:]))

        
        if abs(y - avg_list[-1]) > sd_list[-1] * threshold:
            peak_indices.append(index)
            peaks.append(signal[index])  

           
            if index > 0:
                adjusted_value = (influence * y) + ((1 - influence) * processed_signal[-1])
            else:
                adjusted_value = (influence * y)  # No previous value, take y as is
                
            processed_signal = np.append(processed_signal, [adjusted_value])
        
        processed_signal = processed_signal[1:]

    return peak_indices, peaks


signal = df[df.columns[16]]


peak_indices, peak_values = find_peak_indices(signal, lag, influence, threshold)


moving_avg = df[df.columns[16]].rolling(window=lag).mean()
std_dev = df[df.columns[16]].rolling(window=lag).std()


plt.figure(figsize=(12, 12))  


plt.plot(signal, label='Signal')
plt.plot(moving_avg, color='red', label='Moving Average')
plt.title('Signal with Moving Average')
plt.xlabel('Index')
plt.ylabel('Value')
plt.legend()
plt.show()


plt.plot(std_dev, color='green', label='Standard Deviation')
plt.title('Standard Deviation')
plt.xlabel('Index')
plt.ylabel('Value')
plt.legend()
plt.show()


plt.plot(signal, label='Signal')
plt.scatter(peak_indices, peak_values, color='red', label='Peaks')
plt.title('Signal with Peaks Detected') 
plt.xlabel('Index')
plt.ylabel('Value')
plt.legend()
plt.show()


print("Picos encontrados:")
for i in range(len(peak_indices)):
    print("Índice:", peak_indices[i], "- Valor do pico:", peak_values[i])

内容的提问来源于stack exchange,提问作者Francisco Rebelo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 09:15:21