幅度和相位分析

Amplitude and Phase analysis

我在数据分析方面遇到了一些问题。我有大量数据写成如下:

-0,30273438;-0,06835938;
-0,29785156;-0,05371094;
-0,28320313;-0,04882813;
-0,28808594;-0,06347656;
-0,27343750;-0,03417969;
-0,24414063;-0,03906250;
-0,24414063;-0,01464844;

我写了一个为 2 个向量构建图形的小程序:

 import csv
 import matplotlib.pyplot as plt
 import matplotlib.dates as mdates
 import numpy as np

 x = []
 y = []

 with open('20283.dat', newline='') as csvfile:
     trash = csv.reader(csvfile, delimiter=';')
     for row in trash:
         x.append(float(row[0].replace(",", ".")))
         y.append(float(row[1].replace(",", ".")))
 #print(x)
 z = len(x)
 #print(t)
 t = np.arange(z)
 plt.figure(1)
 plt.plot(t,x, label='signal')
 plt.xlabel('timing')
 plt.ylabel('x')
 plt.title('First channel')
 plt.legend()
 plt.figure(2)
 plt.plot(t,y, label='signal')
 plt.xlabel('timing')
 plt.ylabel('y')
 plt.title('Second channel')
 plt.legend()

 plt.show()

如何获得振幅和相位谱?我如何实现可定制的简单移动平均滤波器(window 大小、时间步长、开始和停止点)?

对于 python numpyscipy 通常是您要查找线性代数的地方。

对于移动 window 功能,请查看 pandas 它与 numpy 具有相当的互操作性,并以有用的方式扩展了 numpy 功能。

https://scipy.org/

https://docs.scipy.org/doc/numpy-dev/user/quickstart.html

https://docs.scipy.org/doc/scipy/reference/

http://pandas.pydata.org/