将 1D 余弦锥度应用于 3D 阵列

Applying 1D cosine taper to 3D array

我有一个时间序列数据集,我已将其窗口化为 n 个片段。我的数据现在具有维度(n、t、x、y)。我希望对每个段应用维度为 (t,) 的余弦锥度,但我显然不能将维度 (t,) 的数组乘以维度 (t, x, y) 的数组。

有人能给我提供一个方法吗?

您可以使用 NumPy 将它们相乘 broadcasting

在这种情况下,只需重塑余弦 window 并乘以

# data set with shape (n, t, x, y), window has shape (t,)
tapered_data = data * window.reshape(1, t, 1, 1)