我应该使用哪种平滑滤波器来清除这种噪音?

which smoothing filter should i use to clean this noise?

我得到的图表是

来自代码:

    import matplotlib.pyplot as plt

x = [165.65, 165.78, 165.44, 168.48, 163.79, 162.74, 162.9, 160.57, 154.24, 153.04, 153.45, 153.14, 153.56, 155.94,
     152.22, 149.53, 149.41, 145.8, 136.74, 138.47, 128.42, 127.19, 122.52, 105.48, 66.75, 104.0, 104.01, 99.46, 98.25,
     89.24, 88.12, 87.78, 86.13, 86.08, 84.86, 83.69, 83.68, 83.78, 84.86, 86.71, 86.28, 86.27, 86.72, 86.89, 88.37,
     88.75, 88.75, 91.38, 94.37, 94.44, 98.06, 97.32, 101.99, 105.99, 108.19, 110.88, 110.88, 112.03, 114.18, 62.32,
     116.96, 117.26, 124.88, 129.62, 136.4, 151.54, 153.59, 148.74, 151.95, 156.98, 163.03, 162.51, 163.67, 162.6,
     164.92, 170.24, 169.71, 168.77, 169.65, 169.82, 168.9, 167.41, 168.03, 167.35, 168.38, 165.65, 165.65, 165.29,
     164.32, 164.36, 51.45, 160.58, 156.38, 154.38, 146.3, 137.55, 137.33, 131.48, 125.72, 120.4, 118.36, 118.07, 66.18,
     108.33, 108.7, 105.71, 106.64, 69.58, 101.83, 101.08, 96.07, 94.97, 87.99, 86.89, 84.92, 86.66, 86.66, 87.68,
     86.97, 86.82, 85.84, 85.48, 86.21, 85.59, 87.04, 89.01, 89.16, 90.6, 93.28, 94.65, 97.87, 97.05, 104.07, 106.56,
     110.99, 65.52, 65.52, 114.09, 123.96, 126.31, 129.29, 130.55, 151.23, 155.58, 155.96, 157.92, 158.03, 49.38, 43.29,
     162.74, 41.63, 163.59, 169.33, 174.64, 171.67, 161.99, 168.68, 166.99, 167.32, 163.86, 164.11, 43.82, 154.1,
     151.97, 148.16, 147.34, 141.02, 125.56, 117.88, 114.14, 112.87, 110.47, 108.21, 104.97, 103.15, 103.28, 96.81,
     89.54, 89.51, 89.58, 89.57, 87.96, 85.55, 84.29, 84.78, 84.78, 84.26, 83.09, 84.33, 83.87, 84.3, 83.9, 83.91,
     84.82, 84.74, 84.79, 84.84, 83.9, 82.63, 82.69, 83.07, 83.09, 82.23, 81.83, 82.62, 81.72, 80.55, 79.6, 77.34,
     74.53, 74.55, 76.21, 72.85, 71.9, 72.03, 71.6, 73.3, 73.58, 73.62, 72.97, 72.97, 73.62, 73.27, 73.57, 72.84, 72.83,
     72.96, 72.83, 72.11, 73.18, 73.18, 72.68, 73.56, 73.7, 73.85, 73.85, 73.72, 73.41, 73.41, 73.83, 73.82, 73.63,
     73.62, 73.48, 73.92, 73.93, 74.57, 73.83, 74.12, 74.12, 73.83, 74.12, 74.12, 74.11, 74.12, 74.12, 73.83, 74.13,
     74.15, 73.49, 73.49, 73.91, 73.91, 73.61, 73.0, 73.0, 73.34, 72.94, 72.94, 73.36, 73.36, 73.36, 73.29, 73.7, 73.35,
     73.35, 73.34, 73.34, 73.34, 73.06, 73.05, 73.06, 73.47, 73.46, 73.47, 73.06, 73.06, 73.06, 73.06, 73.06, 73.97,
     73.54, 72.49, 72.49, 72.49, 72.49, 72.68, 72.34, 71.9, 72.53, 74.1, 74.09, 74.09, 74.08, 74.09, 74.73, 73.67,
     73.23, 73.52, 73.51, 73.93, 73.52, 73.52, 73.53, 73.94, 73.94, 73.53, 73.11, 73.11, 73.53, 73.53, 73.54, 73.55,
     72.69, 71.9, 72.64, 73.33, 75.13, 74.27, 79.0, 79.0, 82.16, 84.07, 93.99, 102.24, 101.9, 107.38, 116.28, 113.22,
     146.29, 61.81, 153.26, 151.68, 153.33, 148.18, 149.04, 164.4, 154.35]
plt.plot(x)
plt.show()

任何算法或过滤器来清除噪声并获得主要信号? 我会画红线来准确说明我需要什么

只是删除异常值

中值滤波器适用于去除异常值。

Pandas 有一个方便的中央中值滤波器:

import pandas as pd

df = pd.DataFrame({'x': x})

df.x.plot()
df.x.rolling(10, center=True).median().plot()

结果:

在这种特殊情况下,错误似乎主要是“丢失”,因此您也可以阈值:

df.x.plot()
df.x[df.x > 70].plot()

结果: