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
dfb2022f
Commit
dfb2022f
authored
11 months ago
by
Eric Kooistra
Browse files
Options
Downloads
Patches
Plain Diff
Add functions to find specific frequency or gain value in transfer function.
parent
ccfdcc45
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
applications/lofar2/model/rtdsp/fourier.py
+39
-0
39 additions, 0 deletions
applications/lofar2/model/rtdsp/fourier.py
with
39 additions
and
0 deletions
applications/lofar2/model/rtdsp/fourier.py
+
39
−
0
View file @
dfb2022f
...
...
@@ -133,6 +133,45 @@ def dtft(coefs, Ndtft=None, zeroCenter=True, fftShift=True):
return
h
,
f
,
HF
def
estimate_gain_at_frequency
(
f
,
HF
,
freq
):
"""
Find gain = abs(HF) at frequency in f that is closest to freq.
Input:
. f, HF: frequency axis and spectrum as from dtft() with fftShift=True
. freq : frequency to look for in f
Return:
. fIndex: index of frequency in f that is closest to freq
. fValue: frequency at fIndex
. fGain : gain = abs(HF) at fIndex
"""
fDiff
=
np
.
abs
(
f
-
freq
)
fIndex
=
fDiff
.
argmin
()
fValue
=
f
[
fIndex
]
fGain
=
np
.
abs
(
HF
[
fIndex
])
return
fIndex
,
fValue
,
fGain
def
estimate_frequency_at_gain
(
f
,
HF
,
gain
):
"""
Find positive frequency in f that has gain = abs(HF) closest to gain.
Input:
. f, HF: frequency axis and spectrum as from dtft() with fftShift=True
. gain : gain to look for in HF
Return:
. fIndex: index of frequency in f that has abs(HF) closest to gain
. fValue: frequency at fIndex
. fGain : gain = abs(HF) at fIndex
"""
pos
=
len
(
f
[
f
<=
0
])
HFpos
=
HF
[
pos
:]
HFgain
=
np
.
abs
(
HFpos
)
HFdiff
=
np
.
abs
(
HFgain
-
gain
)
fIndex
=
pos
+
HFdiff
.
argmin
()
fValue
=
f
[
fIndex
]
fGain
=
np
.
abs
(
HF
[
fIndex
])
return
fIndex
,
fValue
,
fGain
###############################################################################
# Radix FFT
###############################################################################
...
...
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