Radar
The Radar record and its four verbs, trace, echo, simulate and stream, plus from_dict, from_json, replace and the derived properties.
Radar describes one instrument: carrier, waveform, antenna array, receiver chain and pose. It is a frozen dataclass. Import it from the top-level package:
from witwin.radar import RadarFor the ideas behind the fields, read Radar and waveforms. For how the verbs fit together, read Simulation pipeline.
Radar#
class Radar(carrier, waveform, tx, rx, power, antenna_unit='m', pattern=Pattern.isotropic(),
noise=None, lna_gain=None, agc=None, adc=None, iq=None, leakage=None,
impedance=50.0, seed=0, position=(0.0, 0.0, 0.0), look_at=(0.0, 0.0, -1.0),
up=(0.0, 1.0, 0.0), polarization='up', device='cuda')Immutable radar record. Construction validates the fields, builds the antenna positions from the pose, and builds the receiver chain.
Carrier frequency, Hz. It is also the reference frequency Channel evaluates paths at.
The waveform record. See Waveforms.
Transmit element positions in the radar's local frame, in antenna_unit.
Receive element positions in the radar's local frame, in antenna_unit.
Transmit power, dBm.
'm'"m" for metres or "half_wavelength" for multiples of half the carrier wavelength.
Pattern.isotropic()Element power-gain pattern applied to every round trip. See Antenna pattern.
NoneThermal and oscillator noise stage.
NoneLow-noise amplifier gain, dB.
NoneAutomatic gain control stage.
NoneQuantizer stage.
NoneQuadrature gain and phase imbalance. Applied only when a receiver chain exists, that is, when at least one of noise, lna_gain, agc or adc is set.
NoneTransmit-to-receive coupling, added to the synthesized cube. FMCW only.
50.0Receiver impedance, ohms, used to convert power to volts in the receiver chain.
0Seed for receiver noise. The same seed gives the same noise on every call.
(0.0, 0.0, 0.0)Array origin in world coordinates, m.
(0.0, 0.0, -1.0)A world point on the boresight. The boresight is the local -z axis.
(0.0, 1.0, 0.0)World vector that fixes the roll. It becomes the local +y axis after orthogonalization.
'up'"up" (local +y), "right" (local +x), or a world vector not parallel to the boresight.
'cuda'Device the simulation runs on. Radar's propagation has no CPU path.
Raises
ValueError:antenna_unitis unknown;seedis not a non-negativeint;look_atequalsposition;upis zero or parallel to the view direction;polarizationis an unknown string, zero, or parallel to the boresight.TypeError:pattern,noise,agcoradchas the wrong type.- A pose value given as a tensor that carries a gradient is refused, not detached.
from witwin.radar import Fmcw, Noise, Radar
radar = Radar(
carrier=77e9,
waveform=Fmcw(slope=60.012e12, sample_rate=4.4e6, samples_per_chirp=256, chirps_per_frame=128,
adc_start=6e-6, idle=7e-6, ramp_end=65e-6),
tx=[(0, 0, 0), (4, 0, 0), (2, 1, 0)],
rx=[(-6, 0, 0), (-5, 0, 0), (-4, 0, 0), (-3, 0, 0)],
antenna_unit="half_wavelength",
power=15.0,
noise=Noise(figure=10.0),
)Properties#
| Property | Returns |
|---|---|
num_tx | Number of transmit elements, len(tx). |
num_rx | Number of receive elements, len(rx). |
wavelength | c0 / carrier, m. |
transmit_power_watts | power converted from dBm to W. |
Radar.from_dict#
Radar.from_dict(config, **overrides) -> RadarBuild a radar from the flat FMCW configuration format. The mapping uses vendor units: slope in MHz/µs, sample_rate in ksps, adc_start_time, idle_time and ramp_end_time in µs, power in dBm, and tx_loc / rx_loc in half wavelengths. The keys are listed in Load a radar configuration file.
The flat configuration mapping.
Other Radar fields in SI units, applied after the mapping is read, for example noise=, seed=, position= or look_at=. A non-FMCW waveform is also passed here, as waveform=.
Returns Radar.
Raises ValueError for a missing required key, an unsupported key (also inside antenna_pattern), or a tx_loc / rx_loc length that differs from num_tx / num_rx.
radar = Radar.from_dict(CONFIG, noise=Noise(figure=10.0), seed=1, look_at=(0.0, 0.0, -1.0))Radar.from_json#
Radar.from_json(path, **overrides) -> RadarRead a JSON file and pass its object to from_dict.
Path of a UTF-8 JSON file holding the flat configuration mapping.
As for from_dict.
Returns Radar.
Radar.replace#
Radar.replace(**fields) -> RadarReturn a new radar with some fields changed. The original is not modified.
noisy = radar.replace(noise=Noise(figure=12.0), seed=7)Radar.to#
Radar.to(device) -> RadarReturn a copy of the radar on another device.
Radar.waveform_spec#
Radar.waveform_spec(*, offset=0.0) -> FmcwSpec | OfdmSpec | PulsedSpecThe SI synthesis spec this radar's waveform and array describe. See Synthesis. You need it only to call low-level processing such as matched_filter or pulse_samples yourself.
0.0Frequency offset, Hz, added to the carrier in the spec.
The four verbs#
simulate, trace and stream take the same arguments. echo(trace(...)) gives the same numbers as simulate(...), bit for bit.
The world. Meshes reflect; they add no scatterers of their own.
Where the scatterers are and how strongly they scatter. See Targets.
Frame start times, s. Keyword only.
TrueRequest the line-of-sight leg component.
1Maximum number of specular reflections per leg. 0 gives line of sight only.
NoneHow often the world is resampled inside a frame. None means Motion.auto(). See Motion.
'none'"none", "vjp" (reverse mode) or "jvp" (forward mode). See Take gradients.
NoneBind the array to existing Core endpoints by ID, so endpoint trajectories move the elements. None lets Radar place its own endpoints from the pose.
Radar.simulate#
Radar.simulate(scene, targets, *, times, los=True, reflections=1, motion=None, grad='none', endpoints=None) -> ResultSimulate every frame and return them stacked.
Returns Result with cube of shape [frame, tx, rx, slow, fast]. See Results.
Raises
ValueError:timesis empty, not finite or not strictly increasing;Motion.static()for a world that moves.NotImplementedError: an unsupported combination, for exampleMotion.adaptive()with a non-FMCW waveform,leakagewith a non-FMCW waveform, orStructureTargetson a structure without rigid motion.RuntimeError: the adaptive evaluation budget is exhausted.
result = radar.simulate(scene, targets, times=(0.0, 0.1), los=True, reflections=1)
print(result.cube.shape, result.axis_names)Radar.trace#
Radar.trace(scene, targets, *, times, los=True, reflections=1, motion=None, grad='none', endpoints=None) -> PathsRun only the world half: sample the world, discover and compose the round trips, and apply the antenna pattern. Stop before the waveform and the receiver chain.
Returns Paths, which keeps the rows of every evaluated observation. A long ADC-resampled trace can use a lot of device memory; see Reuse a trace with echo.
paths = radar.trace(scene, targets, times=(0.0, 0.05), reflections=1)
print(paths.frame_count, paths.observation_count, paths.row_count)Radar.echo#
Radar.echo(paths) -> ResultRun the instrument half over composed rows: synthesize the waveform, apply the receiver chain and assemble the Result. The echoing radar may differ from the tracing radar in its receiver chain, seed and FMCW output domain.
The output of trace, or one frame of it from paths.frame(index).
Returns Result.
Raises ValueError when the echoing radar differs in anything the observation schedule was built from: carrier, num_tx, num_rx, or the waveform (unless the trace is static). Oscillator phase noise also needs an ADC-time or adaptive trace with FMCW.
from dataclasses import replace
noisy = radar.replace(noise=Noise(figure=8.0), seed=3)
spectrum = noisy.echo(paths)
beat = radar.replace(waveform=replace(radar.waveform, output="beat")).echo(paths)Radar.stream#
Radar.stream(scene, targets, *, times, los=True, reflections=1, motion=None, grad='none', endpoints=None) -> Iterator[Result]Simulate the same session as simulate, but yield one single-frame Result per entry in times. Arguments are checked when iteration starts.
Returns an iterator of Result, each with frame_count == 1. Each yielded result's frame(0).index is 0; use enumerate for the sequence index. See Stream long sequences.
for k, frame_result in enumerate(radar.stream(scene, targets, times=times)):
cloud = frame_result.frame(0).points(max_points=64)Leakage#
class Leakage(isolation_db, delay_s)Transmit-to-receive antenna coupling. It adds one row per sensor pair with amplitude sqrt(P_tx) · 10^(-isolation_db / 20) and delay delay_s. After de-chirping it is a strong near-range tone. See Model the receiver chain.
Transmit-to-receive isolation, dB. Must be positive.
Round-trip delay of the coupling path, s. Must not be negative.
Raises ValueError for a non-positive isolation or a negative delay. NotImplementedError at synthesis for OFDM and pulsed waveforms.
Leakage.amplitude#
Leakage.amplitude(power_dbm) -> floatCoupled amplitude in sqrt(W) for a transmit power in dBm.