Added necessary methods, suppressed unnecessary warnings

This commit is contained in:
M madrigal 2025-12-12 14:43:26 -05:00
parent 5f0ab7ac71
commit 6ba108c908
4 changed files with 19 additions and 11 deletions

View File

@ -58,3 +58,6 @@ class Downsampling(Block):
:rtype: DataType
"""
return DataType.BASEBAND_SIGNAL
def get_samples(self, num_samples):
raise NotImplementedError

View File

@ -51,6 +51,9 @@ class Upsampling(Block):
"""
return DataType.UPSAMPLED_SYMBOLS
def get_samples(self, num_samples):
raise NotImplementedError
def __call__(self, signal: np.ndarray) -> np.ndarray:
"""Upsample the input signal by inserting zeros between samples.

View File

@ -85,13 +85,14 @@ class RaisedCosineFilter(PulseShapingFilter):
"""
t_symbol = self.upsampling_factor
beta = self.beta
f_val = (
1
/ t_symbol
* np.sinc(t / t_symbol)
* np.cos(np.pi * beta * t / t_symbol)
/ (1 - (2 * beta * t / t_symbol) ** 2)
)
with np.errstate(divide='ignore', invalid='ignore'):
f_val = (
1
/ t_symbol
* np.sinc(t / t_symbol)
* np.cos(np.pi * beta * t / t_symbol)
/ (1 - (2 * beta * t / t_symbol) ** 2)
)
idx_limit_case = np.where(np.abs(np.abs(t) - (t_symbol / (2 * beta))) < 1e-6)[0]
if idx_limit_case.size > 0:
f_val[idx_limit_case] = np.pi / (4 * t_symbol) * np.sinc(1 / (2 * beta))

View File

@ -86,10 +86,11 @@ class RootRaisedCosineFilter(PulseShapingFilter):
alpha = 4 * beta * t / t_symbol
t[t == 0] = 1e9
f_val = (np.sin(np.pi * t / t_symbol * (1 - beta)) + alpha * np.cos(np.pi * t / t_symbol * (1 + beta))) / (
np.pi * t * (1 - alpha**2)
)
f_val[t == 1e9] = (1 + beta * (4 / np.pi - 1)) / t_symbol
with np.errstate(divide='ignore', invalid='ignore'):
f_val = (np.sin(np.pi * t / t_symbol * (1 - beta)) + alpha * np.cos(np.pi * t / t_symbol * (1 + beta))) / (
np.pi * t * (1 - alpha**2)
)
f_val[t == 1e9] = (1 + beta * (4 / np.pi - 1)) / t_symbol
idx_limit_case = np.where(np.abs(np.abs(t) - (t_symbol / (4 * beta))) < 1e-6)[0]
if idx_limit_case.size > 0: