Skip to content

Commit

Permalink
Upsample the comb filter when downsampling is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
tryuan99 committed Jun 24, 2024
1 parent d439c4a commit a6fe085
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 2 additions & 3 deletions simulation/cic_filter/cic_filter_comb_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ def compare_crc_filter_combs(length: int, R: int) -> None:

for coefficients in FILTERS:
# Apply a comb filter to the signal.
comb_filter = _create_comb_filter_before_decimation(coefficients, R)
cic_filter_decimator = CicFilterDecimator(R=1,
cic_filter_decimator = CicFilterDecimator(R=R,
N=1,
comb_filter=comb_filter)
comb_filter=coefficients)
response = cic_filter_decimator.filter(delta, downsampling=False)

# Plot the spectrum.
Expand Down
6 changes: 4 additions & 2 deletions simulation/cic_filter/cic_filter_decimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ def __init__(self, R: int, N: int, comb_filter: np.ndarray = None) -> None:

if comb_filter is None:
comb_filter = np.ones(1)
self.comb_filter = comb_filter
self.comb_filter = comb_filter.astype(np.float64)
self.num_comb_filter_taps = len(comb_filter)
self.comb_filter_diff = self._create_comb_filter_diff(comb_filter)
# Scale the filter to its length.
self.comb_filter /= np.mean(self.comb_filter)
self.comb_filter_diff = self._create_comb_filter_diff(self.comb_filter)

def filter(self,
signal: np.ndarray,
Expand Down

0 comments on commit a6fe085

Please sign in to comment.