Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
H
HDL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
RTSD
HDL
Commits
e97931a8
Commit
e97931a8
authored
1 year ago
by
Eric Kooistra
Browse files
Options
Downloads
Patches
Plain Diff
Rename beta.
parent
220e931f
Branches
Branches containing commit
No related tags found
1 merge request
!408
Resolve RTSD-271
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
applications/lofar2/model/pfb_os/dsp.py
+26
-26
26 additions, 26 deletions
applications/lofar2/model/pfb_os/dsp.py
with
26 additions
and
26 deletions
applications/lofar2/model/pfb_os/dsp.py
+
26
−
26
View file @
e97931a8
...
@@ -121,15 +121,15 @@ def impulse_at_zero_crossing(x):
...
@@ -121,15 +121,15 @@ def impulse_at_zero_crossing(x):
# Windowed sinc filter design
# Windowed sinc filter design
###############################################################################
###############################################################################
def
raised_cosine_response
(
Ntaps
,
Nsps
,
b
eta
):
def
raised_cosine_response
(
Ntaps
,
Nsps
,
roB
eta
):
"""
Generate a raised cosine (RC) FIR filter impulse response.
"""
Generate a raised cosine (RC) FIR filter impulse response.
Input:
Input:
. Ntaps : FIR filter length
. Ntaps : FIR filter length
. Nsps: symbol period Tsymbol in number of samples per symbol
. Nsps: symbol period Tsymbol in number of samples per symbol
.
b
eta : Roll off factor in [0, 1.0], BW = (1 +
b
eta) / Tsymbol, so:
.
roB
eta : Roll off factor in [0, 1.0], BW = (1 +
roB
eta) / Tsymbol, so:
-
b
eta = 0.0: rectangular spectrum with BW = 1 / Tsymbol
-
roB
eta = 0.0: rectangular spectrum with BW = 1 / Tsymbol
-
b
eta = 1.0: cosine spectrum with BW = 2 / Tsymbol
-
roB
eta = 1.0: cosine spectrum with BW = 2 / Tsymbol
Return:
Return:
. hRc : impulse response of the raised cosine filter.
. hRc : impulse response of the raised cosine filter.
"""
"""
...
@@ -145,12 +145,12 @@ def raised_cosine_response(Ntaps, Nsps, beta):
...
@@ -145,12 +145,12 @@ def raised_cosine_response(Ntaps, Nsps, beta):
# apply cos term, use for loop instead of array assignment, to detect divide by 0
# apply cos term, use for loop instead of array assignment, to detect divide by 0
for
tI
in
tIndices
:
for
tI
in
tIndices
:
t
=
tI
-
tCenter
t
=
tI
-
tCenter
if
np
.
abs
(
t
)
!=
Tsymbol
/
(
2
*
b
eta
):
if
np
.
abs
(
t
)
!=
Tsymbol
/
(
2
*
roB
eta
):
hRc
[
tI
]
*=
np
.
cos
(
np
.
pi
*
b
eta
*
t
/
Tsymbol
)
/
(
1
-
(
2
*
b
eta
*
t
/
Tsymbol
)
**
2
)
hRc
[
tI
]
*=
np
.
cos
(
np
.
pi
*
roB
eta
*
t
/
Tsymbol
)
/
(
1
-
(
2
*
roB
eta
*
t
/
Tsymbol
)
**
2
)
return
hRc
return
hRc
def
square_root_raised_cosine_response
(
Ntaps
,
Nsps
,
b
eta
):
def
square_root_raised_cosine_response
(
Ntaps
,
Nsps
,
roB
eta
):
"""
Generate a square root raised cosine (SRRC) FIR filter impulse response.
"""
Generate a square root raised cosine (SRRC) FIR filter impulse response.
Reference:
Reference:
...
@@ -160,7 +160,7 @@ def square_root_raised_cosine_response(Ntaps, Nsps, beta):
...
@@ -160,7 +160,7 @@ def square_root_raised_cosine_response(Ntaps, Nsps, beta):
Input:
Input:
. Ntaps : FIR filter length
. Ntaps : FIR filter length
. Nsps: symbol period Tsymbol in number of samples per symbol
. Nsps: symbol period Tsymbol in number of samples per symbol
.
b
eta : Roll off factor in [0, 1.0]
.
roB
eta : Roll off factor in [0, 1.0]
Return:
Return:
. hSrRc : impulse response of the square root raised cosine filter.
. hSrRc : impulse response of the square root raised cosine filter.
"""
"""
...
@@ -171,20 +171,20 @@ def square_root_raised_cosine_response(Ntaps, Nsps, beta):
...
@@ -171,20 +171,20 @@ def square_root_raised_cosine_response(Ntaps, Nsps, beta):
t
=
tIndices
-
tCenter
t
=
tIndices
-
tCenter
# numerator term, using array assignment
# numerator term, using array assignment
hSrRc
=
1
/
Tsymbol
*
(
np
.
cos
(
np
.
pi
*
(
1
+
b
eta
)
*
t
/
Tsymbol
)
*
4
*
b
eta
*
t
/
Tsymbol
+
hSrRc
=
1
/
Tsymbol
*
(
np
.
cos
(
np
.
pi
*
(
1
+
roB
eta
)
*
t
/
Tsymbol
)
*
4
*
roB
eta
*
t
/
Tsymbol
+
np
.
sin
(
np
.
pi
*
(
1
-
b
eta
)
*
t
/
Tsymbol
))
np
.
sin
(
np
.
pi
*
(
1
-
roB
eta
)
*
t
/
Tsymbol
))
# apply denumerator term, use for loop instead of array assignment, to detect divide by 0
# apply denumerator term, use for loop instead of array assignment, to detect divide by 0
for
tI
in
tIndices
:
for
tI
in
tIndices
:
t
=
tI
-
tCenter
t
=
tI
-
tCenter
if
t
==
0.0
:
if
t
==
0.0
:
hSrRc
[
tI
]
=
1
/
Tsymbol
*
(
1
+
b
eta
*
(
4
/
np
.
pi
-
1
))
hSrRc
[
tI
]
=
1
/
Tsymbol
*
(
1
+
roB
eta
*
(
4
/
np
.
pi
-
1
))
elif
np
.
abs
(
t
)
==
Tsymbol
/
(
4
*
b
eta
):
elif
np
.
abs
(
t
)
==
Tsymbol
/
(
4
*
roB
eta
):
hSrRc
[
tI
]
=
1
/
Tsymbol
*
b
eta
/
np
.
sqrt
(
2
)
*
\
hSrRc
[
tI
]
=
1
/
Tsymbol
*
roB
eta
/
np
.
sqrt
(
2
)
*
\
((
1
+
2
/
np
.
pi
)
*
np
.
sin
(
np
.
pi
/
(
4
*
b
eta
))
+
((
1
+
2
/
np
.
pi
)
*
np
.
sin
(
np
.
pi
/
(
4
*
roB
eta
))
+
(
1
-
2
/
np
.
pi
)
*
np
.
cos
(
np
.
pi
/
(
4
*
b
eta
)))
(
1
-
2
/
np
.
pi
)
*
np
.
cos
(
np
.
pi
/
(
4
*
roB
eta
)))
else
:
else
:
hSrRc
[
tI
]
/=
(
1
-
(
4
*
b
eta
*
t
/
Tsymbol
)
**
2
)
*
(
np
.
pi
*
t
/
Tsymbol
)
hSrRc
[
tI
]
/=
(
1
-
(
4
*
roB
eta
*
t
/
Tsymbol
)
**
2
)
*
(
np
.
pi
*
t
/
Tsymbol
)
return
hSrRc
return
hSrRc
...
@@ -195,7 +195,7 @@ def square_root_raised_cosine_response(Ntaps, Nsps, beta):
...
@@ -195,7 +195,7 @@ def square_root_raised_cosine_response(Ntaps, Nsps, beta):
def
nof_taps_kaiser_window
(
fs
,
fpass
,
fstop
,
atten_db
):
def
nof_taps_kaiser_window
(
fs
,
fpass
,
fstop
,
atten_db
):
"""
Number of FIR LPF taps using Kaiser window based design
"""
Number of FIR LPF taps using Kaiser window based design
Reference: [HARRIS 3.2, Fig. 3.8 for
b
eta]
Reference: [HARRIS 3.2, Fig. 3.8 for
kaiserB
eta]
"""
"""
df
=
fstop
-
fpass
df
=
fstop
-
fpass
return
int
((
fs
/
df
)
*
(
atten_db
-
8
)
/
14
)
return
int
((
fs
/
df
)
*
(
atten_db
-
8
)
/
14
)
...
@@ -242,7 +242,7 @@ def ideal_low_pass_filter(Npoints, Npass, bandEdgeGain=1.0):
...
@@ -242,7 +242,7 @@ def ideal_low_pass_filter(Npoints, Npass, bandEdgeGain=1.0):
def
prototype_fir_low_pass_filter
(
method
=
'
firls
'
,
def
prototype_fir_low_pass_filter
(
method
=
'
firls
'
,
Npoints
=
1024
,
Ntaps
=
16
,
Ncoefs
=
1024
*
16
,
Npoints
=
1024
,
Ntaps
=
16
,
Ncoefs
=
1024
*
16
,
hpFactor
=
0.9
,
transitionFactor
=
0.4
,
stopRippleFactor
=
1000000
,
b
eta
=
1
,
fs
=
1.0
):
hpFactor
=
0.9
,
transitionFactor
=
0.4
,
stopRippleFactor
=
1000000
,
kaiserB
eta
=
1
,
fs
=
1.0
):
"""
Derive FIR coefficients for prototype low pass filter
"""
Derive FIR coefficients for prototype low pass filter
Use method
'
firls
'
or
'
remez
'
.
Use method
'
firls
'
or
'
remez
'
.
...
@@ -274,7 +274,7 @@ def prototype_fir_low_pass_filter(method='firls',
...
@@ -274,7 +274,7 @@ def prototype_fir_low_pass_filter(method='firls',
- hpFactor : Half power bandwidth of the filter relative to BWbin
- hpFactor : Half power bandwidth of the filter relative to BWbin
- transitionFactor: transition bandwidth factor relative to fpass
- transitionFactor: transition bandwidth factor relative to fpass
- stopRippleFactor: stopband ripple factor relative to pass band ripple
- stopRippleFactor: stopband ripple factor relative to pass band ripple
-
b
eta: When
b
eta > 0 then additionally apply a Kaiser window on FIR
-
kaiserB
eta: When
kaiserB
eta > 0 then additionally apply a Kaiser window on FIR
coefficients
coefficients
- fs: sample frequency, for logging
- fs: sample frequency, for logging
Return:
Return:
...
@@ -292,12 +292,12 @@ def prototype_fir_low_pass_filter(method='firls',
...
@@ -292,12 +292,12 @@ def prototype_fir_low_pass_filter(method='firls',
rippleWeights
=
[
1
,
stopRippleFactor
]
rippleWeights
=
[
1
,
stopRippleFactor
]
# Design subband filter
# Design subband filter
h
=
design_fir_low_pass_filter
(
method
,
Ncoefs
,
fpass
,
fstop
,
fcutoff
,
cutoffGain
,
rippleWeights
,
b
eta
,
fs
)
h
=
design_fir_low_pass_filter
(
method
,
Ncoefs
,
fpass
,
fstop
,
fcutoff
,
cutoffGain
,
rippleWeights
,
kaiserB
eta
,
fs
)
return
h
return
h
def
design_fir_low_pass_filter
(
method
,
def
design_fir_low_pass_filter
(
method
,
Ncoefs
,
fpass
,
fstop
,
fcutoff
=
0
,
cutoffGain
=
0.5
,
rippleWeights
=
[
1
,
1
],
b
eta
=
0
,
fs
=
1.0
):
Ncoefs
,
fpass
,
fstop
,
fcutoff
=
0
,
cutoffGain
=
0.5
,
rippleWeights
=
[
1
,
1
],
kaiserB
eta
=
0
,
fs
=
1.0
):
"""
Derive FIR coefficients for prototype low pass filter
"""
Derive FIR coefficients for prototype low pass filter
Use method
'
firls
'
or
'
remez
'
, fs = 1.0
Use method
'
firls
'
or
'
remez
'
, fs = 1.0
...
@@ -318,7 +318,7 @@ def design_fir_low_pass_filter(method,
...
@@ -318,7 +318,7 @@ def design_fir_low_pass_filter(method,
- fcutoff: when fcutoff > 0, then define cutoff frequency point in transition band, fpass < fcutoff < fstop
- fcutoff: when fcutoff > 0, then define cutoff frequency point in transition band, fpass < fcutoff < fstop
- cutoffGain: normalized LPF gain at fcutoff
- cutoffGain: normalized LPF gain at fcutoff
- rippleWeights: relative ripple factors for pass band, optional fcutoff, and stop band
- rippleWeights: relative ripple factors for pass band, optional fcutoff, and stop band
-
b
eta: When
b
eta > 0, then additionally apply a Kaiser window on FIR
-
kaiserB
eta: When
kaiserB
eta > 0, then additionally apply a Kaiser window on FIR
coefficients
coefficients
Return:
Return:
- h: FIR coefficients for requested Ncoefs
- h: FIR coefficients for requested Ncoefs
...
@@ -368,11 +368,11 @@ def design_fir_low_pass_filter(method,
...
@@ -368,11 +368,11 @@ def design_fir_low_pass_filter(method,
hFir
=
signal
.
remez
(
N
,
[
0
,
f_pb
,
f_co
,
f_co
,
f_sb
,
fNyquist
],
hFir
=
signal
.
remez
(
N
,
[
0
,
f_pb
,
f_co
,
f_co
,
f_sb
,
fNyquist
],
[
1
,
cutoffGain
,
0
],
rippleWeights
,
fs
=
fs
)
[
1
,
cutoffGain
,
0
],
rippleWeights
,
fs
=
fs
)
# Additionally apply a Kaiser window, with
b
eta = 1 like in pfs_coeff_final.m, this improves
# Additionally apply a Kaiser window, with
kaiserB
eta = 1 like in pfs_coeff_final.m, this improves
# the stopband attenuation near the transition band somewhat
# the stopband attenuation near the transition band somewhat
# .
b
eta: 0 rect, 5 hamming, 6 hanning
# .
kaiserB
eta: 0 rect, 5 hamming, 6 hanning
if
b
eta
:
if
kaiserB
eta
:
win
=
signal
.
windows
.
kaiser
(
N
,
b
eta
)
win
=
signal
.
windows
.
kaiser
(
N
,
kaiserB
eta
)
hFir
*=
win
hFir
*=
win
# Normalize DC gain
# Normalize DC gain
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment