Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
AP-S 2020 - PyRaTk
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
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
DELTA
DELTA Low-Cost 5.8GHz FMCW Radar PCB
AP-S 2020 Software
AP-S 2020 - PyRaTk
Commits
10c9cfe1
Commit
10c9cfe1
authored
4 years ago
by
Merlo, Jason
Browse files
Options
Downloads
Patches
Plain Diff
Updated to add fourier interpolation
parent
60dbce69
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
pyratk/radars/radar.py
+9
-4
9 additions, 4 deletions
pyratk/radars/radar.py
pyratk/widgets/fft_widget.py
+5
-6
5 additions, 6 deletions
pyratk/widgets/fft_widget.py
with
14 additions
and
10 deletions
pyratk/radars/radar.py
+
9
−
4
View file @
10c9cfe1
...
...
@@ -13,6 +13,7 @@ Maintainer: Jason Merlo (merlojas@msu.edu)
import
numpy
as
np
# Storing data
from
pyratk.datatypes.ts_data
import
TimeSeries
# storing data
import
scipy.constants
as
spc
# speed of light
from
scipy
import
signal
# Upsampling
from
pyratk.datatypes.geometry
import
Point
# radar location
# from pyratk.datatypes.motion import StateMatrix # track location
from
pyqtgraph
import
QtCore
...
...
@@ -39,6 +40,7 @@ class Radar(object):
# === INITIALIZATION METHODS ==============================================
def
__init__
(
self
,
data_mgr
,
index
,
loc
=
Point
(),
f0
=
24.150e9
,
fft_size
=
2
**
16
,
fft_win_size
=
2
**
12
,
interp_size
=
25e3
,
cluda_thread
=
None
):
super
(
Radar
,
self
).
__init__
()
"""
...
...
@@ -65,11 +67,12 @@ class Radar(object):
# Processing parameters
self
.
fft_size
=
fft_size
self
.
window_size
=
fft_win_size
self
.
interp_size
=
int
(
interp_size
)
# Derived processing parameters
self
.
update_rate
=
self
.
data_mgr
.
sample_rate
/
self
.
data_mgr
.
sample_chunk_size
self
.
center_bin
=
np
.
ceil
(
self
.
fft
_size
/
2
)
self
.
bin_size
=
self
.
data_mgr
.
sample_rate
/
self
.
fft
_size
self
.
center_bin
=
np
.
ceil
(
self
.
interp
_size
/
2
)
self
.
bin_size
=
self
.
data_mgr
.
sample_rate
/
self
.
interp
_size
# === State variables ===
# initial array size 4096 samples
...
...
@@ -106,7 +109,7 @@ class Radar(object):
"""
Compute frequency based on bin location.
"""
return
(
bin
-
self
.
center_bin
)
*
float
(
self
.
bin_size
)
def
compute_cfft
(
self
,
complex_data
,
fft_size
):
def
compute_cfft
(
self
,
complex_data
,
fft_size
,
interp_size
=
1000
):
"""
Compute fft and fft magnitude for plotting.
"""
# Create hanning window
# hanning = np.hanning(complex_data.shape[0])
...
...
@@ -124,6 +127,8 @@ class Radar(object):
# Display only magnitude
fft_mag
=
np
.
linalg
.
norm
([
fft_complex
.
real
,
fft_complex
.
imag
],
axis
=
0
)
fft_mag
=
signal
.
resample
(
fft_mag
,
interp_size
)
return
fft_mag
# === CONTROL METHODS =====================================================
...
...
@@ -143,7 +148,7 @@ class Radar(object):
# Calculate complex FFT
# may be zero-padded if fft-size > sample_chunk_size
self
.
cfft_data
=
self
.
compute_cfft
(
window_slice
,
self
.
fft_size
)
self
.
cfft_data
=
self
.
compute_cfft
(
window_slice
,
self
.
fft_size
,
self
.
interp_size
)
# Find maximum frequency
fmax_bin
=
np
.
argmax
(
self
.
cfft_data
)
...
...
This diff is collapsed.
Click to expand it.
pyratk/widgets/fft_widget.py
+
5
−
6
View file @
10c9cfe1
...
...
@@ -9,12 +9,13 @@ Maintainer: Jason Merlo (merlojas@msu.edu)
"""
import
pyqtgraph
as
pg
# Used for RadarWidget superclass
import
numpy
as
np
# Used for numerical operations
from
scipy
import
signal
# Used for upsampling
import
time
# Used for FPS calculations
class
FftWidget
(
pg
.
GraphicsLayoutWidget
):
def
__init__
(
self
,
radar
,
vmax_len
=
100
,
show_max_plot
=
False
,
fft_yrange
=
[
-
100
,
100
],
fft_xrange
=
[
-
50000
,
50000
]):
fft_yrange
=
[
-
100
,
100
],
fft_xrange
=
[
-
25e3
,
25e3
]):
super
(
FftWidget
,
self
).
__init__
()
# Copy arguments to member variables
...
...
@@ -54,9 +55,6 @@ class FftWidget(pg.GraphicsLayoutWidget):
# fft_xrange = [-50 / self.radar.bin_size, 50 / self.radar.bin_size]
# fft_yrange = [-100, 0]
for
r
in
fft_xrange
:
r
/=
self
.
radar
.
bin_size
# Add FFT plot
self
.
fft_plot
=
self
.
addPlot
()
...
...
@@ -65,7 +63,8 @@ class FftWidget(pg.GraphicsLayoutWidget):
self
.
fft_plot
.
setClipToView
(
True
)
# self.fft_plot.setLogMode(x=False, y=True) # Log Y-axis of FFT views
self
.
fft_plot
.
setRange
(
disableAutoRange
=
True
,
xRange
=
fft_xrange
,
yRange
=
fft_yrange
)
xRange
=
np
.
array
(
fft_xrange
)
/
self
.
radar
.
bin_size
,
yRange
=
fft_yrange
)
self
.
fft_plot
.
setLimits
(
xMin
=
fft_xrange
[
0
],
xMax
=
fft_xrange
[
1
],
yMin
=
fft_yrange
[
0
],
yMax
=
fft_yrange
[
1
])
...
...
@@ -106,11 +105,11 @@ class FftWidget(pg.GraphicsLayoutWidget):
def
update_fft
(
self
):
if
self
.
radar
.
cfft_data
is
not
None
:
log_fft
=
10
*
np
.
log
(
self
.
radar
.
cfft_data
)
max_log_fft
=
np
.
max
(
log_fft
)
self
.
fft_pw
.
setData
(
log_fft
)
self
.
fft_pw
.
setPos
(
-
self
.
radar
.
center_bin
,
0
)
# draw max FFT lines
max_log_fft
=
np
.
nanmax
(
log_fft
)
self
.
fft_max_freq_line
.
setValue
(
self
.
radar
.
fmax
/
self
.
radar
.
bin_size
)
self
.
fft_max_pwr_line
.
setValue
(
max_log_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