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 Radar

For 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.

carrierfloatrequired

Carrier frequency, Hz. It is also the reference frequency Channel evaluates paths at.

waveformFmcw | Ofdm | Pulsedrequired

The waveform record. See Waveforms.

txsequence of (x, y, z)required

Transmit element positions in the radar's local frame, in antenna_unit.

rxsequence of (x, y, z)required

Receive element positions in the radar's local frame, in antenna_unit.

powerfloatrequired

Transmit power, dBm.

antenna_unitstrdefault 'm'

"m" for metres or "half_wavelength" for multiples of half the carrier wavelength.

patternPatterndefault Pattern.isotropic()

Element power-gain pattern applied to every round trip. See Antenna pattern.

noiseNoise | Nonedefault None

Thermal and oscillator noise stage.

lna_gainfloat | Nonedefault None

Low-noise amplifier gain, dB.

agcAgc | Nonedefault None

Automatic gain control stage.

adcAdc | Nonedefault None

Quantizer stage.

iqIq | Nonedefault None

Quadrature 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.

leakageLeakage | Nonedefault None

Transmit-to-receive coupling, added to the synthesized cube. FMCW only.

impedancefloatdefault 50.0

Receiver impedance, ohms, used to convert power to volts in the receiver chain.

seedintdefault 0

Seed for receiver noise. The same seed gives the same noise on every call.

position(x, y, z)default (0.0, 0.0, 0.0)

Array origin in world coordinates, m.

look_at(x, y, z)default (0.0, 0.0, -1.0)

A world point on the boresight. The boresight is the local -z axis.

up(x, y, z)default (0.0, 1.0, 0.0)

World vector that fixes the roll. It becomes the local +y axis after orthogonalization.

polarizationstr | (x, y, z)default 'up'

"up" (local +y), "right" (local +x), or a world vector not parallel to the boresight.

devicestr | torch.devicedefault 'cuda'

Device the simulation runs on. Radar's propagation has no CPU path.

Raises

  • ValueError: antenna_unit is unknown; seed is not a non-negative int; look_at equals position; up is zero or parallel to the view direction; polarization is an unknown string, zero, or parallel to the boresight.
  • TypeError: pattern, noise, agc or adc has 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#

PropertyReturns
num_txNumber of transmit elements, len(tx).
num_rxNumber of receive elements, len(rx).
wavelengthc0 / carrier, m.
transmit_power_wattspower converted from dBm to W.

Radar.from_dict#

Radar.from_dict(config, **overrides) -> Radar

Build 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.

configMapping[str, Any]required

The flat configuration mapping.

**overridesAny

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) -> Radar

Read a JSON file and pass its object to from_dict.

pathstr | os.PathLikerequired

Path of a UTF-8 JSON file holding the flat configuration mapping.

**overridesAny

As for from_dict.

Returns Radar.

Radar.replace#

Radar.replace(**fields) -> Radar

Return 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) -> Radar

Return a copy of the radar on another device.

Radar.waveform_spec#

Radar.waveform_spec(*, offset=0.0) -> FmcwSpec | OfdmSpec | PulsedSpec

The 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.

offsetfloatdefault 0.0

Frequency 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.

scenewitwin.core.Scene | witwin.core.dynamics.DynamicScenerequired

The world. Meshes reflect; they add no scatterers of their own.

targetsPointTargets | StructureTargetsrequired

Where the scatterers are and how strongly they scatter. See Targets.

timessequence of floatrequired

Frame start times, s. Keyword only.

losbooldefault True

Request the line-of-sight leg component.

reflectionsintdefault 1

Maximum number of specular reflections per leg. 0 gives line of sight only.

motionMotion | Nonedefault None

How often the world is resampled inside a frame. None means Motion.auto(). See Motion.

gradstrdefault 'none'

"none", "vjp" (reverse mode) or "jvp" (forward mode). See Take gradients.

endpointsSensorEndpointIds | Nonedefault None

Bind 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) -> Result

Simulate every frame and return them stacked.

Returns Result with cube of shape [frame, tx, rx, slow, fast]. See Results.

Raises

  • ValueError: times is empty, not finite or not strictly increasing; Motion.static() for a world that moves.
  • NotImplementedError: an unsupported combination, for example Motion.adaptive() with a non-FMCW waveform, leakage with a non-FMCW waveform, or StructureTargets on 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) -> Paths

Run 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) -> Result

Run 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.

pathsPathsrequired

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.

isolation_dbfloatrequired

Transmit-to-receive isolation, dB. Must be positive.

delay_sfloatrequired

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) -> float

Coupled amplitude in sqrt(W) for a transmit power in dBm.