Skip to content

Commit 5c2f202

Browse files
committed
add support to use part of the frequency band for cssm
1 parent df6562c commit 5c2f202

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

doa_py/algorithm/broadband.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ def cssm(
134134
angle_grids,
135135
pre_estimate,
136136
fre_ref=None,
137+
f_min=None,
138+
f_max=None,
137139
unit="deg",
138140
):
139141
"""Coherent Signal Subspace Method (CSSM) for wideband DOA estimation.
@@ -148,6 +150,8 @@ def cssm(
148150
pre_estimate: pre-estimated angles
149151
fre_ref: reference frequency. If it's not provided the frequency point
150152
with the maximum power will be used.
153+
f_min : Minimum frequency of interest. Defaults to None.
154+
f_max : Maximum frequency of interest. Defaults to None.
151155
unit : Unit of angle, 'rad' for radians, 'deg' for degrees. Defaults to
152156
'deg'.
153157
@@ -162,8 +166,18 @@ def cssm(
162166
pre_estimate = pre_estimate.reshape(1, -1)
163167

164168
# Divide the received signal into multiple frequency points
165-
signal_fre_bins = np.fft.fft(received_data, axis=1)
166-
fre_bins = np.fft.fftfreq(num_snapshots, 1 / fs)
169+
delta_f = fs / num_snapshots
170+
# there is a little trick to use as wider frequency range as possible
171+
idx_f_min = max(int(f_min / delta_f) - 1, 0) if f_min is not None else 0
172+
idx_f_max = (
173+
min(int(f_max / delta_f) + 1, num_snapshots // 2)
174+
if f_max is not None
175+
else num_snapshots // 2
176+
)
177+
signal_fre_bins = np.fft.fft(received_data, axis=1)[
178+
:, idx_f_min : idx_f_max + 1
179+
]
180+
fre_bins = np.fft.fftfreq(num_snapshots, 1 / fs)[idx_f_min : idx_f_max + 1]
167181

168182
if fre_ref is None:
169183
# Find the frequency point with the maximum power

0 commit comments

Comments
 (0)