Filtering
Implements filter methods
fir_filter
Naive class to demonstrate direct-form FIR filtering. If wanting to efficiently compute the direct-form convolution, see SciPy Signal's lfilter
Source code in rfproto/filter.py
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
RaisedCosine(sample_rate, symbol_rate, alpha, num_taps)
Generates Raised Cosine filter impulse response as:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sample_rate
|
float
|
Sample rate of signal (Hz) |
required |
symbol_rate
|
float
|
Symbol rate of signal (Hz) |
required |
alpha
|
float
|
Roll-off (\(\alpha\)) of impulse response |
required |
num_taps
|
int
|
Number of filter taps |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Array of filter coefficients |
Source code in rfproto/filter.py
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 |
|
RootRaisedCosine(sample_rate, symbol_rate, alpha, num_taps)
Returns unity-gain, floating-point Root-Raised Cosine (RRC) filter coefficients.
Unity passband gain is achieved by ensuring returned coefficients sum to 1.0
:
For more information, see Root Raised Cosine (RRC) Filters and Pulse Shaping in Communication Systems - NASA.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sample_rate
|
float
|
Sample rate of signal (Hz) |
required |
symbol_rate
|
float
|
Symbol rate of signal (Hz) |
required |
alpha
|
float
|
Roll-off (\(\alpha\)) of impulse response |
required |
num_taps
|
int
|
Number of filter taps |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Array of filter coefficients |
Source code in rfproto/filter.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
UnityResponse(num_taps)
Returns unity-gain, passthrough filter coefficients
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_taps
|
int
|
Number of filter taps |
required |
Returns:
Type | Description |
---|---|
ndarray
|
Array of filter coefficients |
Source code in rfproto/filter.py
96 97 98 99 100 101 102 103 104 105 106 107 |
|
firordest(passband_ripple, stopband_atten, transition_bw)
Estimate the number of FIR filter taps to meet the desired specifications. Similar to MATLAB's firpmord method, uses Bellanger's estimate based on:
Parameters:
Name | Type | Description | Default |
---|---|---|---|
passband_ripple
|
float
|
Total passband ripple/deviation (dB) |
required |
stopband_atten
|
float
|
Minimum stopband attenuation from passband (dB) |
required |
transition_bw
|
float
|
Normalized (0.0->1.0 * fs) bandwidth of transition region |
required |
Source code in rfproto/filter.py
193 194 195 196 197 198 199 200 201 202 203 |
|
measure_filter_response(filter_coef, passband_start, passband_stop, stopband_start, stopband_stop=1.0)
Measure the passband ripple and stopband attenuation of a given set of filter coefficients.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filter_coef
|
ndarray
|
filter weights/taps |
required |
passband_start
|
float
|
Normalized (0.0->1.0*fs) frequency the passband starts |
required |
passband_stop
|
float
|
Normalized (0.0->1.0*fs) frequency the passband stops |
required |
stopband_start
|
float
|
Normalized (0.0->1.0*fs) frequency the stopband starts |
required |
stopband_stop
|
float
|
Normalized (0.0->1.0*fs) frequency the stopband stops |
1.0
|
Returns:
Type | Description |
---|---|
Passband ripple (dB), Stopband attenuation (dB) |
Source code in rfproto/filter.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
pulse_shape(symbols, OSR, h, trim_output=True)
Performs integer upsampling and pulse-shape filtering on a given set of input symbols. Commonly this is performed as part of the transmit process in a communications system to eliminate inter-symbol interference (ISI).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
symbols
|
ndarray
|
Input symbol samples to interpolate then pulse-shape |
required |
OSR
|
int
|
Integer Oversampling Rate |
required |
h
|
ndarray
|
Array of filter coefficients to use during pulse-shape filtering (e.x. RRC) |
required |
trim_output
|
bool
|
Append 0's to input and trim output to align directly with input symbols |
True
|
Returns:
Type | Description |
---|---|
Array of pulse-shape filtered symbols |
Source code in rfproto/filter.py
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|