import radarsimpy
radarsimpy.__version__
'11.1.0'
This is an example of simulating interference with RadarSimPy
.
The interference radar has up chirps -- from 60.4 GHz to 60.6 GHz. The chirp repetition time is 11e-6 s. The interfernce radar is located at (30, 0, 0) m and facing towards negative x direction.
import numpy as np
from radarsimpy import Radar, Transmitter, Receiver
f_offset_int = np.arange(0, 8)*70e6
int_tx = Transmitter(f=[60.4e9, 60.6e9],
t=[0, 8e-6],
tx_power=15,
prp=11e-6,
pulses=8,
f_offset=f_offset_int,
channels=[dict(location=(0, 0.1, 0),
pulse_phs=np.array([0,0,180,0,0,0,0,0]))])
int_rx = Receiver(fs=20e6,
noise_figure=8,
rf_gain=20,
load_resistor=500,
baseband_gain=30,
channels=[dict(location=(0, 0.1, 0))])
int_radar = Radar(transmitter=int_tx, receiver=int_rx,
location=(30, 0, 0), rotation=(180, 0, 0))
The victim radar has down chirps -- from 60.6 GHz to 60.4 GHz. The chirp repetition time is 40e-6 s. The victim radar is located at (0, 0, 0) m and facing towards positive x direction.
Add the interference radar into the victim radar by setting interf
.
f_offset_vit = np.arange(0, 4)*90e6
tx = Transmitter(f=[60.6e9, 60.4e9],
t=[0, 16e-6],
tx_power=25,
prp=20e-6,
pulses=4,
f_offset=f_offset_vit,
channels=[dict(location=(0, 0, 0),
pulse_phs=np.array([180,0,0,0]))])
rx = Receiver(fs=40e6,
noise_figure=2,
rf_gain=20,
load_resistor=500,
baseband_gain=60,
channels=[dict(location=(0, 0, 0))])
radar = Radar(transmitter=tx, receiver=rx, interf=int_radar)
target_1 = dict(location=(30, 0, 0), speed=(0, 0, 0), rcs=10, phase=0)
target_2 = dict(location=(20, 1, 0), speed=(-10, 0, 0), rcs=10, phase=0)
targets = [target_1, target_2]
Use C++ engine to simulate the baseband.
For convenience, the baseband data and the interference data are separated. To obtain the interferenced baseband data, simply add them together.
from radarsimpy.simulator import simc
bb_data = simc(radar, targets, noise=False)
time_matrix = bb_data['timestamp']
baseband = bb_data['baseband'] # baseband data without interference
interf = bb_data['interference'] # interference data
interf_bb = baseband + interf # baseband data with interference
import plotly.graph_objs as go
from plotly.subplots import make_subplots
from IPython.display import Image
import plotly.express as px
fig = go.Figure()
fig = make_subplots(rows=2, cols=1)
for idx in range(0, radar.transmitter.pulses):
fig.add_trace(go.Scatter(
x=time_matrix[0, idx, :],
y=np.linspace(
radar.f[0],
radar.f[1],
radar.samples_per_pulse,
endpoint=False,
) / 1e9+f_offset_vit[idx]/ 1e9,
line=dict(color=px.colors.qualitative.Plotly[0]),
name='Victim',
showlegend=(idx == 0),
), row=1, col=1)
for idx in range(0, int_radar.transmitter.pulses):
fig.add_trace(go.Scatter(
x=int_radar.timestamp[0, idx, :],
y=np.linspace(
int_radar.f[0],
int_radar.f[1],
int_radar.samples_per_pulse,
endpoint=False,
) / 1e9+f_offset_int[idx]/ 1e9,
line=dict(color=px.colors.qualitative.Plotly[1]),
name='Interference',
showlegend=(idx == 0),
), row=1, col=1)
for idx in range(0, radar.transmitter.pulses):
fig.add_trace(go.Scatter(x=time_matrix[0, idx, :],
y=np.real(interf_bb[0, idx, :]),
line=dict(color=px.colors.qualitative.Plotly[2]),
name='Real',
showlegend=(idx == 0),),
row=2, col=1
)
fig.add_trace(go.Scatter(x=time_matrix[0, idx, :],
y=np.imag(interf_bb[0, idx, :]),
line=dict(color=px.colors.qualitative.Plotly[3]),
name='Imag',
showlegend=(idx == 0),),
row=2, col=1
)
fig.update_xaxes(title_text='Time (s)', range=[
0, time_matrix[0, 3, -1]], row=1, col=1)
fig.update_yaxes(title_text='Frequency (GHz)', row=1, col=1)
fig.update_xaxes(title_text='Time (s)', range=[
0, time_matrix[0, 3, -1]], row=2, col=1)
fig.update_yaxes(title_text='Amplitude (V)', row=2, col=1)
fig.update_layout(
height=800,
margin=dict(l=10, r=10, b=10, t=40),
)
# fig.show()
Image(fig.to_image(format="jpg", scale=2))