【发布时间】:2020-01-25 01:37:37
【问题描述】:
我有一个海平面数据(时间、y、x)的 3D 数据矩阵,我通过取 FFT 的平方找到了功率谱,但低频确实占主导地位。我想通过应用高通滤波器来消除那些低频......我该怎么做呢? 数据集和结构/代码示例如下:
这是数据集和创建数组:
Yearmin = 2018
Yearmax = 2019
year_len = Yearmax - Yearmin + 1.0 # number of years
direcInput = "filepath"
a = s.Dataset(direcInput+"test.nc", mode='r')
#creating arrays
lat = a.variables["latitude"][:]
lon = a.variables["longitude"][:]
time1 = a.variables["time"][:] #DAYS SINCE JAN 1ST 1950
sla = a.variables["sla"][:,:,:] #t, y, x
time = Yearmin + (year_len * (time1 - np.min(time1)) / ( np.max(time1) - np.min(time1)))
#detrending and normalizing data
def standardize(y, detrend = True, normalize = True):
if detrend == True:
y = signal.detrend(y, axis=0)
y = (y - np.mean(y, axis=0))
if normalize == True:
y = y / np.std(y, axis=0)
return y
sla_standard = standardize(sla)
print(sla_standard.shape) = (710, 81, 320)
#fft
fft = np.fft.rfft(sla_standard, axis=0)
spec = np.square(abs(fft))
frequencies = (0, nyquist, df)
#PLOTTING THE FREQUENCIES VS SPECTRUM FOR A FEW DIFFERENT SPATIAL LOCATIONS
plt.plot(frequencies, spec[:, 68,85])
plt.plot(frequencies, spec[:, 23,235])
plt.plot(frequencies, spec[:, 39,178])
plt.plot(frequencies, spec[:, 30,149])
plt.xlim(0,.05)
plt.show()
我的目标是制作原始时间序列 (sla_standard) 的高通滤波器,以去除两个真正的大峰值。我应该使用哪种类型的过滤器?谢谢!
【问题讨论】:
-
高通实际上是低通滤波版本的减法。你知道如何实现低通吗?
-
您可以使用任何您想要的过滤器,您必须根据您的需要决定过滤器的形状。一个简单的(非因果)高通滤波器是对信号执行傅里叶变换,将较低频率设置为零,然后进行傅里叶逆变换。
标签: python multidimensional-array filtering fft