我有一组 2s 长度的 RF 信号样本,每个样本都以 2MHz 采样率记录,例如这个 IQ 文件:https ://www.dropbox.com/s/dd6fr4va4alpazj/move_x_movedist_1_speed_25k_sample_6.wav?dl=0
kymatio
我可以使用以下代码有效地收集零阶、一阶和二阶系数并绘制它们:
import scipy.io.wavfile
import numpy as np
import matplotlib.pyplot as plt
from kymatio.numpy import Scattering1D
path = r"move_x_movedist_1_speed_25k_sample_6.wav"
# Read in the sample WAV file
fs, x = scipy.io.wavfile.read(path)
x = x.T
print(fs)
# Once the recording is in memory, we normalise it to +1/-1
x = x / np.max(np.abs(x))
print(x)
# Set up parameters for the scattering transform
## number of samples, T
N = x.shape[-1]
print(N)
## Averaging scale as power of 2, 2**J, for averaging
## scattering scale of 2**6 = 64 samples
J = 6
## No. of wavelets per octave (resolve frequencies at
## a resolution of 1/16 octaves)
Q = 16
# Create object to compute scattering transform
scattering = Scattering1D(J, N, Q)
# Compute scattering transform of our signal sample
Sx = scattering(x)
# Extract meta information to identify scattering coefficients
meta = scattering.meta()
# Zeroth-order
order0 = np.where(meta['order'] == 0)
# First-order
order1 = np.where(meta['order'] == 1)
# Second-order
order2 = np.where(meta['order'] == 2)
#%%
# Plot original signal
plt.figure(figsize=(8, 2))
plt.plot(x)
plt.title('Original Signal')
plt.show()
# Plot zeroth-order scattering coefficient (average of
# original signal at scale 2**J)
plt.figure(figsize=(8,8))
plt.subplot(3, 1, 1)
plt.plot(Sx[order0][0])
plt.title('Zeroth-Order Scattering')
# Plot first-order scattering coefficient (arrange
# along time and log-frequency)
plt.subplot(3, 2, 1)
plt.imshow(Sx[0][order1], aspect='auto')
plt.title('First-order scattering [1]')
plt.subplot(3, 2, 2)
plt.imshow(Sx[1][order1], aspect='auto')
plt.title('First-order scattering [2]')
# Plot second-order scattering coefficient (arranged
# along time but has two log-frequency indicies -- one
# first- and one second-order frequency. Both are mixed
# along the vertical axis)
plt.subplot(3, 3, 1)
plt.imshow(Sx[0][order2], aspect='auto')
plt.title('Second-order scattering [0]')
plt.subplot(3, 3, 2)
plt.imshow(Sx[1][order2], aspect='auto')
plt.title('Second-order scattering [1]')
plt.show()
但是,我的任务是使用神经网络架构对每个样本进行分类。我遇到的问题是这些系数的形状和大小非常大,简单地将它们存储在内存中是不可行的(总共大约有 2k 个样本)。
因此,我想知道是否有一种提取特征的好方法可以用来表示这一点(即,如果我采用 MFCC,我可以创建 1-13 个 MFCC 系数的特征列,例如 via mfcc = librosa.feature.mfcc(y=x, sr=fs, n_mfcc=14, hop_length=hop_length, n_fft=M)[1:]
)。或者也许还有其他缩短这些数据的方法,因此它实际上可用于神经网络进行训练(即,取每个系数的空间平均值:¯Sm,J = ∑x ˜Sm,J ((λ1,··· ,λm), x)
但是这个空间信息同时减少了维度)。
任何帮助都会很棒!
编辑:这是来自 matlab 信号分析仪的功率谱和时频图。如何使用它来识别频谱占用以进行下采样以最小化数据。