-
Notifications
You must be signed in to change notification settings - Fork 185
/
Copy pathimpairments.py
42 lines (30 loc) · 908 Bytes
/
impairments.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Authors: CommPy contributors
# License: BSD 3-Clause
"""
============================================
Impairments (:mod:`commpy.impairments`)
============================================
.. autosummary::
:toctree: generated/
add_frequency_offset -- Add frequency offset impairment.
"""
from numpy import exp, pi, arange
__all__ = ['add_frequency_offset']
def add_frequency_offset(waveform, Fs, delta_f):
"""
Add frequency offset impairment to input signal.
Parameters
----------
waveform : 1D ndarray of floats
Input signal.
Fs : float
Sampling frequency (in Hz).
delta_f : float
Frequency offset (in Hz).
Returns
-------
output_waveform : 1D ndarray of floats
Output signal with frequency offset.
"""
output_waveform = waveform*exp(1j*2*pi*(delta_f/Fs)*arange(len(waveform)))
return output_waveform