CommPy icon indicating copy to clipboard operation
CommPy copied to clipboard

Adding AWGN to a signal

Open adeeb10abbas opened this issue 4 years ago • 5 comments

Adding Gaussian noise to a signal of a specific SNR. The signal may or may not have noise already

adeeb10abbas avatar Nov 23 '20 16:11 adeeb10abbas

Hi @adeeb10abbas,

Could you be more precise on your issue. Is this a question? Do you report a bug? Do you ask for a feature?

BastienTr avatar Nov 24 '20 07:11 BastienTr

Yes sorry about that. I am asking for a feature! Thanks!

adeeb10abbas avatar Nov 29 '20 03:11 adeeb10abbas

Did you have a look to the SISOFlatChannel class? It should do what you ask for. There are several variants possible, like using a complex signal but this snippet should be enough to start.

from commpy.channels import SISOFlatChannel
from commpy.utilities import signal_power
import numpy as np

channel = SISOFlatChannel()
noiseless_signal = np.random.choice((-1, 1), 10)  # Use your own signal here
channel.set_SNR_dB(10, Es=signal_power(noiseless_signal))  # I compute the signal power but if you know it, you can just specified the right argument
noisy_signal = channel.propagate(noiseless_signal)

Is it OK for you? If so, I let you close this issue.

BastienTr avatar Nov 30 '20 11:11 BastienTr

Yes, this works but partially. I am looking for something that can add noise to a signal that already has some amount of noise.

adeeb10abbas avatar Dec 07 '20 03:12 adeeb10abbas

Replace noiseless_signal with your already noisy signal and it's done, isn't it?

BastienTr avatar Dec 07 '20 09:12 BastienTr

So I wanted to figure out a way to add less say x amount of noise to a signal that already has y amount of noise (x and y are the snr). The output would be something with a z snr as it can't be a direct x + y as they are ratios. Does that make sense?

adeeb10abbas avatar Dec 08 '20 00:12 adeeb10abbas