Python reference¶
The parts of the library a script is most likely to call, with their own
docstrings. Command line and Python shows them in use.
Quantities are in SI units and angles in radians unless a name says otherwise
(_deg, _db, _km). Anything whose name starts with an underscore is not
meant to be called from outside and may change without notice.
Scenarios¶
scenario_loader ¶
Scenario files (YAML or JSON) into a configured SimulationEngine.
engine = ScenarioLoader(resolve_scenario("escort_jamming")).create_simulation_engine()
Every key a scenario may contain is listed in radarsim.io.scenario_schema.
A key outside the schema is reported in ScenarioLoader.warnings, with a
suggestion when it looks like a typo, and a value a model cannot use raises
ValueError with the name of the key.
Coordinates are ENU (x East, y North, z Up) in metres; azimuths run clockwise from North.
ScenarioLoader ¶
Loads a scenario file and builds the simulation engine.
Attributes:
| Name | Type | Description |
|---|---|---|
data |
Dict[str, Any]
|
Raw parsed file contents |
warnings |
List[str]
|
Messages about keys the loader does not understand |
load ¶
load(filepath)
Load and validate a scenario file.
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file does not exist |
ValueError
|
If the file is empty, malformed, or has invalid values |
YAMLError
|
If the file is not valid YAML/JSON |
create_simulation_engine ¶
create_simulation_engine()
Build a SimulationEngine with every configured feature applied.
Raises:
| Type | Description |
|---|---|
ValueError
|
If no scenario is loaded |
resolve_scenario ¶
resolve_scenario(name_or_path)
A path as given, or the built-in scenario with that name (escort_jamming).
The engine¶
SimulationEngine ¶
One radar, the objects it looks at, and simulated time.
step advances the scene by dt: the objects move, the beam turns, and
every object the beam swept in the step gets one dwell (evaluate_look),
whose detections go to the tracker. run repeats that for a duration.
The looks are kept in log, the tracks in tracks, and what happened
in event_log. With a seed a run can be repeated exactly.
Other radars watching the same scene are added with add_peer.
seed
property
writable
¶
seed
Seed of the random generator; assigning it restarts the random stream.
effective_pulses
property
¶
effective_pulses
Pulses integrated in one dwell.
pulses_integrated is what the processor is set to; a scanning beam
cannot deliver more than theta_az PRF / omega_scan hits on a point.
step ¶
step(dt=None)
Advance simulation by one time step.
Kinematics first; then one dwell on every target the beam sweeps during
the step (see evaluate_look), on the jammers' false targets and on
empty cells that cross the threshold by noise; then the tracker.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dt
|
float
|
Time step [s] (uses default if None) |
None
|
Returns:
| Type | Description |
|---|---|
List[DetectionResult]
|
List of DetectionResult for this time step (one per active target) |
run ¶
run(duration_s)
Run simulation for a specified duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
duration_s
|
float
|
Simulation duration [s] |
required |
Returns:
| Type | Description |
|---|---|
SimulationLog
|
SimulationLog with all results |
evaluate_look ¶
evaluate_look(position, velocity, rcs, swerling_model, target_id, jammers=None, illuminated=True, draw=True)
Run the detection chain for one dwell on an echo at position.
Geometry and line of sight; absorption, antenna pattern, multipath and
eclipsing on the thermal SNR; the MTI response; surface and rain clutter;
noise jamming through main lobe and sidelobes; the receiver limiter; then
the Swerling Pd for the pulses of the dwell. With draw the detection
decision and the measurement noise are sampled from the engine's
generator; without it the result carries Pd only (analysis).
remove_target ¶
remove_target(target_id)
Take a target out of the scene, with what the radars remember of it.
add_peer ¶
add_peer(peer, link_delay_ms=100.0)
Add another radar that watches this engine's scene.
peer is a complete engine with its own radar, receiver, random
stream and tracker. From now on it takes its targets, clock and jammer
switch from this engine and is stepped by it. After every step the
radars send their established tracks and their bearings on noise
jammers over a link with link_delay_ms of delay; the fused picture
is in fused_tracks and jammer_fixes.
set_ecm_mode ¶
set_ecm_mode(active, ecm_type=ECM_PER_TARGET)
Switch electronic attack on or off.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
active
|
bool
|
Master switch for all jammer-equipped targets |
required |
ecm_type
|
str
|
ECM_PER_TARGET ("per_target", default; legacy alias "noise") to let every jammer use its own technique, or one technique ('noise_barrage', 'noise_spot', 'drfm') for all |
ECM_PER_TARGET
|
set_pulse_doppler_mode ¶
set_pulse_doppler_mode(enabled, n_pulses=64, prf_hz=None, mti_order=0)
Switch the coherent pulse-Doppler processor on or off.
When on, every step also makes a range-Doppler map from the pulses of one coherent interval. The detection decision does not depend on it.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enabled
|
bool
|
Whether the map is computed |
required |
n_pulses
|
int
|
Pulses in the coherent interval |
64
|
prf_hz
|
Optional[float]
|
Pulse repetition frequency in Hz; the radar's own if not given |
None
|
mti_order
|
int
|
Delays of the canceller ahead of the Doppler transform (0: none) |
0
|
configuration_problems ¶
configuration_problems()
Reasons the current settings fall outside a model's validity range.
Empty when everything is usable. The GUI calls this after each change and
undoes a change that produces a problem; step never raises for these.
DetectionResult
dataclass
¶
One dwell on one object: where the object was, what the radar measured if
it detected it, and every term that went into the signal-to-interference
ratio. to_dict gives the row written by radarsim --out.
Objects¶
Radar ¶
A radar: transmitter, antenna, receiver and scan, at a position that may move.
The constructor takes SI units, with angles of the antenna in degrees as their names say. Quantities that follow from the parameters (wavelength, unambiguous range, revisit period) are properties, so changing a parameter changes them.
Target ¶
An object the radar can see: an aircraft, a missile, a ship, a chaff cloud or a decoy.
It has a position and a velocity in ENU, a motion model (constant velocity, constant acceleration, a constant turn or a route of waypoints), a radar cross-section with a Swerling fluctuation model, and optionally a jammer.
Analysis¶
analysis ¶
Analysis helpers built on the engine's own physics.
coverage_curve evaluates the SNR and Pd of one dwell against range for a probe
target by running the same per-look chain the simulation uses (propagation,
clutter, pulse compression, CFAR loss, receiver limiting, Swerling Pd), so the
curve and the live picture can never disagree.
probe_engine ¶
probe_engine(engine)
Copy of engine's radar, environment and processing without targets.
coverage_curve ¶
coverage_curve(probe, rcs_m2=1.0, swerling=1, altitude_m=3000.0, azimuth_deg=0.0, max_range_m=200000.0, points=160, radial_speed_mps=200.0)
SNR and Pd of one dwell against range for a probe target (no jamming).
The probe flies towards the radar at radial_speed_mps, which matters
only with MTI on (the canceller response depends on it).
monte_carlo_pd ¶
monte_carlo_pd(probe, ranges_m, looks_per_point=200, rcs_m2=1.0, swerling=1, altitude_m=3000.0, seed=1, progress=None)
Empirical detection probability from repeated independent looks.
wilson_interval ¶
wilson_interval(successes, trials, z=1.96)
Wilson score interval for a binomial proportion (Wilson 1927).
ospa_distance ¶
ospa_distance(truth, estimates, cutoff_m=2000.0, order=2.0)
Optimal sub-pattern assignment distance between two sets of positions [m].
The points of the smaller set are paired with points of the larger one so
that the distances, each cut off at cutoff_m, are smallest; every point
left without a partner counts as one cutoff. One number therefore charges
both the position error of the tracks and the targets missed or invented:
d = ((sum_i min(d_i, c)^p + c^p |n - m|) / max(m, n))^(1/p)
Reference
Schuhmacher, D., Vo, B.-T. & Vo, B.-N., "A Consistent Metric for Performance Evaluation of Multi-Object Filters", IEEE Trans. Signal Processing, Vol. 56, No. 8, 2008
tracking_accuracy ¶
tracking_accuracy(engine, duration_s, cutoff_m=2000.0, sample_period_s=None, progress=None)
Run engine for duration_s and compare its established tracks with
the targets in plan position, once every sample_period_s (by default
once per antenna revolution). The engine is advanced: pass a fresh one.
A target the radar cannot yet see is still a target, so the distance starts at the cutoff and falls as tracks are confirmed.
tracking_accuracy_runs ¶
tracking_accuracy_runs(engine, runs=20, duration_s=120.0, cutoff_m=2000.0, seed=1, progress=None)
Repeat engine's scenario from t = 0 with the seeds seed, seed + 1, ...
and collect the OSPA distance between targets and established tracks at
every antenna revolution. engine itself is copied, not advanced.
Detection¶
radar_equation ¶
The monostatic radar equation: received power, noise power from the system noise temperature, signal-to-noise ratio, the range for a given SNR, and the Doppler shift.
The scalar kernels are compiled with numba; the functions that take a
RadarParameters call them.
References
Skolnik, M. I. (ed.), "Radar Handbook", 3rd Ed., McGraw-Hill, 2008 Blake, L. V., "Radar Range-Performance Analysis", Lexington Books, 1980
system_noise_temperature ¶
system_noise_temperature(antenna_temperature_k, noise_figure_db)
Ts = Ta + T0 (F - 1) [K] (Blake 1980).
noise_power_watts ¶
noise_power_watts(antenna_temperature_k, bandwidth_hz, noise_figure_db)
Receiver noise power k Ts B [W].
calculate_received_power ¶
calculate_received_power(radar, rcs, range_m, atmospheric_loss_db=0.0)
Calculate received power using radar equation.
Pr = (Pt * Gt * Gr * λ² * σ) / ((4π)³ * R⁴ * Lt * Lr * La)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radar
|
RadarParameters
|
Radar system parameters |
required |
rcs
|
float
|
Target radar cross section [m²] |
required |
range_m
|
float
|
Target range [m] |
required |
atmospheric_loss_db
|
float
|
Atmospheric loss [dB] |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
Received power [W] |
Reference: Skolnik, "Radar Handbook", 3rd Ed.
calculate_snr ¶
calculate_snr(radar, rcs, range_m, atmospheric_loss_db=0.0)
Calculate Signal-to-Noise Ratio.
SNR = Pr / (k * Ts * B), Ts = Ta + T0 (F - 1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radar
|
RadarParameters
|
Radar system parameters |
required |
rcs
|
float
|
Target radar cross section [m²] |
required |
range_m
|
float
|
Target range [m] |
required |
atmospheric_loss_db
|
float
|
Atmospheric loss [dB] |
0.0
|
Returns:
| Type | Description |
|---|---|
float
|
SNR [dB] |
Reference: Skolnik, "Radar Handbook", 3rd Ed.
calculate_detection_range ¶
calculate_detection_range(radar, rcs, min_snr_db=13.0)
Calculate maximum detection range.
Rmax = [(Pt * Gt * Gr * λ² * σ) / ((4π)³ * Lt * Lr * Pr_min)]^(1/4)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radar
|
RadarParameters
|
Radar system parameters |
required |
rcs
|
float
|
Target radar cross section [m²] |
required |
min_snr_db
|
float
|
Minimum required SNR [dB] (default 13 dB ≈ Pd=0.9, Pfa=1e-6) |
13.0
|
Returns:
| Type | Description |
|---|---|
float
|
Maximum detection range [m] |
Reference: Skolnik, "Radar Handbook", 3rd Ed.
calculate_doppler_shift ¶
calculate_doppler_shift(radar, target_pos, target_vel, radar_pos=None, radar_vel=None)
Doppler shift of a target's echo, fd = -2 vr / lambda.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
radar
|
RadarParameters
|
Radar system parameters |
required |
target_pos
|
ndarray
|
Target position (x, y, z) in metres |
required |
target_vel
|
ndarray
|
Target velocity (vx, vy, vz) in m/s |
required |
radar_pos
|
ndarray
|
Radar position (x, y, z) in metres; the origin if not given |
None
|
radar_vel
|
ndarray
|
Radar velocity (vx, vy, vz) in m/s; at rest if not given |
None
|
Returns:
| Type | Description |
|---|---|
float
|
Doppler shift [Hz] (negative = target receding, positive = approaching) |
Reference: Skolnik, "Radar Handbook", 3rd Ed.
metrics ¶
Detection probability and CFAR loss.
calculate_pd_swerling gives the probability that a square-law detector
integrating N pulses declares a Swerling 0 to 4 target at a given mean
signal-to-noise ratio and false-alarm probability. The CFAR functions give the
extra signal a threshold estimated from reference cells costs.
References
Marcum, J. I., "A Statistical Theory of Target Detection by Pulsed Radar", IRE Trans. Information Theory, Vol. IT-6, 1960 Swerling, P., "Probability of Detection for Fluctuating Targets", IRE Trans. Information Theory, Vol. IT-6, 1960 DiFranco, J. V. & Rubin, W. L., "Radar Detection", Prentice-Hall, 1968 Albersheim, W. J., "A Closed-Form Approximation to Robertson's Detection Characteristics", Proc. IEEE, Vol. 69, No. 7, 1981 Gandhi, P. P. & Kassam, S. A., "Analysis of CFAR Processors in Nonhomogeneous Background", IEEE Trans. Aerospace and Electronic Systems, Vol. 24, No. 4, 1988 Rohling, H., "Radar CFAR Thresholding in Clutter and Multiple Target Situations", IEEE Trans. Aerospace and Electronic Systems, Vol. 19, No. 4, 1983
calculate_pd_swerling ¶
calculate_pd_swerling(snr_db, pfa=1e-06, swerling_case=1, n_pulses=1)
Return square-law detection probability for Swerling cases 0 through 4.
snr_db is the mean single-pulse signal-to-noise ratio. Integrated
noise power is gamma distributed. Conditional target power is evaluated
with the non-central chi-square survival function; gamma-distributed RCS
is averaged exactly (Swerling 1, 2) or by adaptive quadrature (3, 4).
albersheim_snr ¶
albersheim_snr(pd, pfa, n_pulses=1)
Albersheim's equation: SNR required for given Pd and Pfa.
This closed-form approximation is valid for
- 0.1 < Pd < 0.9999
- 1e-10 < Pfa < 1e-3
- 1 ≤ n_pulses ≤ 8096
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pd
|
float
|
Probability of detection (0-1) |
required |
pfa
|
float
|
Probability of false alarm (0-1) |
required |
n_pulses
|
int
|
Number of pulses integrated |
1
|
Returns:
| Type | Description |
|---|---|
float
|
Required SNR in dB |
Reference: Albersheim, IEEE Trans. AES, 1981
cfar_loss_db ¶
cfar_loss_db(cfar_type, reference_cells, pfa=1e-06, os_rank=None)
CFAR loss: extra SNR an adaptive detector needs over a known-noise detector.
Evaluated at Pd = 0.5 for a single-pulse Swerling-1 target, where exact closed forms exist; the loss depends only weakly on Pd and target model, so it is applied as an SNR penalty to every detection.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cfar_type
|
str
|
"CA", "GO", "SO" or "OS" |
required |
reference_cells
|
int
|
Total reference cells N (both sides together) |
required |
pfa
|
float
|
Design probability of false alarm |
1e-06
|
os_rank
|
int
|
OS-CFAR rank k (default 3N/4, Rohling 1983) |
None
|
Returns:
| Type | Description |
|---|---|
float
|
CFAR loss [dB] (positive) |
Reference: Richards (2005); Gandhi & Kassam (1988)
dwell ¶
What happens to an echo during one dwell of a pulsed radar.
Hits per scan and beam-shape loss, range ambiguity and eclipsing, the response of an MTI canceller, the integration improvement factor and binary (M-of-N) integration.
References
- Skolnik, M.I. "Introduction to Radar Systems", 3rd Ed., 2001 (integration of pulses, binary integration, beam-shape loss, delay-line cancellers, blind speeds, staggered PRF)
- Blake, L.V. "The effective number of pulses per beamwidth for a scanning radar", Proc. IRE 41(6), 1953 (1.6 dB beam-shape loss)
- Barton, D.K. "Radar System Analysis and Modeling", 2005 (eclipsing)
hits_per_scan ¶
hits_per_scan(beamwidth_rad, prf_hz, scan_rate_rad_s)
Pulses returned while the 3 dB beam sweeps a point: n = theta_B f_p / omega_s.
beam_shape_loss_db ¶
beam_shape_loss_db(dwell_fraction=1.0)
Loss from the two-way Gaussian pattern when the integrated pulses span
dwell_fraction of the 3 dB beamwidth, centred on the beam axis.
The mean two-way gain over u in [-x/2, x/2] (u in beamwidths) of exp(-8 ln2 u^2) is sqrt(pi / (8 ln2)) erf(x sqrt(2 ln2)) / x; for x = 1 this is -1.67 dB, Blake's 1.6 dB. A single pulse on the axis (x -> 0) loses nothing.
apparent_range_m ¶
apparent_range_m(range_m, prf_hz)
Range the radar reports without ambiguity resolution, and the trip number (0 = first).
eclipsing_factor ¶
eclipsing_factor(range_m, prf_hz, pulse_width_s)
Fraction of the echo pulse that arrives while the receiver is on (0 to 1).
The receiver is blanked for the transmitted pulse at the start of every repetition interval. With matched filtering the output voltage is proportional to the received fraction, so the SNR scales with its square (Barton 2005). The same expression covers the minimum range R < c tau / 2.
mti_response ¶
mti_response(radial_velocity_mps, wavelength_m, prf_hz, order=1, stagger_ratios=())
Signal power gain of an order-delay canceller relative to its noise gain.
|H(f)|^2 = (2 sin(pi f / f_p))^(2n), divided by the average gain C(2n, n)
(2 for a single canceller, 6 for a double) so that white noise passes with
unit gain (Skolnik 2001). The response vanishes at the
blind speeds v = k lambda f_p / 2. stagger_ratios lists the repetition
intervals of a staggered PRF relative to the mean; the response is then the
mean over the intervals, which fills the nulls.
binary_integration_pd ¶
binary_integration_pd(snr_db, pfa, swerling_case, n_pulses, m_required)
Detection probability of an M-of-N (double-threshold) detector.
Each pulse is compared with a first threshold set for the per-pulse
false-alarm probability p_fa that yields pfa after M-of-N; a detection
is declared when at least M pulses cross it (Skolnik 2001). The
per-pulse crossing probabilities are independent for steady and
pulse-to-pulse fluctuating targets (Swerling 0, 2, 4); for scan-to-scan
fluctuation (1, 3) the binomial is averaged over the RCS of the dwell.
Propagation¶
propagation ¶
Propagation over a spherical Earth: horizon, multipath and slant-path absorption.
Geometry uses the effective Earth radius k R_E with k = 4/3 (standard refraction).
References
- Blake, L.V. "Radar Range-Performance Analysis", Artech House, 1986 (pattern-propagation factor, reflection point on a spherical Earth)
- Kerr, D.E. (ed.) "Propagation of Short Radio Waves", MIT Rad. Lab. Vol. 13, 1951 (divergence factor)
- Ament, W.S. "Toward a theory of reflection by a rough surface", Proc. IRE 41(1), 1953 (roughness factor)
- ITU-R P.676-13 Annex 1 (line-by-line slant paths), ITU-R P.835-6 (mean annual global reference atmosphere)
horizon_range_m ¶
horizon_range_m(height_m, earth_radius_m=EARTH_RADIUS_EFFECTIVE)
Ground distance to the horizon from height_m over a smooth Earth [m].
beyond_horizon ¶
beyond_horizon(radar_height_m, target_height_m, ground_range_m, earth_radius_m=EARTH_RADIUS_EFFECTIVE)
True when the smooth Earth blocks the line of sight (Skolnik 2008).
grazing_angle_rad ¶
grazing_angle_rad(height_m, slant_range_m, earth_radius_m=EARTH_RADIUS_EFFECTIVE)
Grazing angle at the surface point slant_range_m away from an antenna at
height_m [rad]; negative beyond the horizon.
sin(psi) = h/R + h^2/(2 a R) - R/(2 a) (law of cosines in the Earth-centre triangle)
propagation_factor ¶
propagation_factor(radar_height_m, target_height_m, ground_range_m, wavelength_m, relative_permittivity, rms_height_m=0.0, polarization='H', direct_pattern=1.0, reflected_pattern=1.0, earth_radius_m=EARTH_RADIUS_EFFECTIVE)
One-way pattern-propagation factor F = |E / E_free space| (Blake 1986).
F = | f_d + f_r rho D exp(-j (2 pi delta / lambda)) |, with rho the complex reflection coefficient times the roughness factor, D the divergence factor and f_d, f_r the antenna's field pattern toward the target and toward the reflection point. The echo power scales with F^4.
Outside the interference region (geometry unsolvable) F = f_d.
lobe_elevations_rad ¶
lobe_elevations_rad(radar_height_m, wavelength_m, count=5)
Elevation of the first interference maxima over a flat, perfectly reflecting surface with a 180 deg phase reversal: sin(theta_n) = (2n - 1) lambda / (4 h).
slant_path_gas_attenuation_db ¶
slant_path_gas_attenuation_db(frequency_ghz, start_height_m, elevation_rad, slant_range_m, surface_temperature_c=15.0, surface_pressure_hpa=1013.25, surface_vapour_density=7.5, two_way=True, earth_radius_m=EARTH_RADIUS_EFFECTIVE)
Gaseous attenuation along a ray leaving start_height_m at elevation_rad.
The specific attenuation of ITU-R P.676-13 Annex 1 is evaluated in the P.835 reference atmosphere and integrated along the ray, whose height over the 4/3 Earth is h(s) = sqrt((a + h0)^2 + s^2 + 2 s (a + h0) sin(el)) - a. Valid from 1 GHz upward.
Tracking¶
measurement ¶
Radar plots as the tracker sees them.
A radar measures range and angle; the tracker works in Cartesian coordinates.
converted_measurement makes the change without bias and with the covariance
that goes with it, so that a plot at long range is known to be accurate along
the line of sight and much less so across it.
Reference
Mo, L., Song, X., Zhou, Y., Sun, Z.K. & Bar-Shalom, Y., "Unbiased Converted Measurements for Tracking", IEEE Trans. Aerospace and Electronic Systems, Vol. 34, No. 3, 1998 Bar-Shalom, Y., Li, X.R. & Kirubarajan, T., "Estimation with Applications to Tracking and Navigation", 2001
Plot
dataclass
¶
One detection handed to the tracker.
x, y and covariance are the Cartesian measurement every filter
can use. The polar originals, when present, let the extended Kalman filter
work on the measurement the radar actually made. altitude_m is present
when the radar measures elevation.
from_position
classmethod
¶
from_position(position, sigma_m, source_id=None)
A plot known equally well in every direction.
converted_measurement ¶
converted_measurement(ground_range_m, azimuth_rad, range_sigma_m, azimuth_sigma_rad, sensor_xy=(0.0, 0.0))
Unbiased conversion of (ground range, azimuth) to East/North.
Azimuth is clockwise from North: East = rho sin(az), North = rho cos(az). With Gaussian errors, E[sin(az_m)] = lambda sin(az) and likewise for the cosine, lambda = exp(-sigma_az^2 / 2): the plain conversion falls short of the target, so the position is divided by lambda. The filter needs the covariance of the error given what was measured, not given the truth it does not know (Mo et al.), with lambda' = exp(-2 sigma_az^2):
R_EE = (lambda^-2 - 2) rho^2 sin^2 + (rho^2 + sigma_r^2)(1 - lambda' cos 2az) / 2
R_NN = (lambda^-2 - 2) rho^2 cos^2 + (rho^2 + sigma_r^2)(1 + lambda' cos 2az) / 2
R_EN = (lambda^-2 - 2) rho^2 sin cos + (rho^2 + sigma_r^2) lambda' sin 2az / 2
in the measured range and azimuth. For small angle errors this is the familiar ellipse of sigma_r along the line of sight and rho sigma_az across it. With 3 deg of angle error at 80 km the errors, normalised by this covariance, average 2.00 as they should; the covariance of the error about the true position, put at the measured one, gives 3.7 and the linearised ellipse 22.
Returns:
| Type | Description |
|---|---|
Tuple[float, float, ndarray]
|
East [m], North [m] and the 2 x 2 covariance [m^2]. |
TrackManager ¶
Multi-target track manager.
Example
manager = TrackManager(gate_distance=1000, max_misses=5) tracks = manager.update([(1000, 2000), (3000, 4000)], dt=0.1) for track in tracks: ... print(f"Track {track.id}: {track.position}")
update ¶
update(detections, dt, detection_data=None, in_coverage=None, revisit_guard_s=0.0, max_coast_time_s=None)
Process new detections and update tracks.
Track-while-scan: with in_coverage given, an unassociated track is
charged a miss only if its predicted position was inside this update's
coverage and it has not been updated within revisit_guard_s (it was
already seen during the current scan). Other tracks are only predicted.
Without in_coverage every unassociated track is charged a miss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
detections
|
Sequence[Detection]
|
(x, y) positions or |
required |
dt
|
float
|
Time since last update (seconds) |
required |
detection_data
|
Optional[List[Dict]]
|
Optional metadata for each detection |
None
|
in_coverage
|
Optional[CoveragePredicate]
|
Optional coverage predicate (see above) |
None
|
revisit_guard_s
|
float
|
Minimum time between two looks at the same track [s] |
0.0
|
max_coast_time_s
|
Optional[float]
|
Drop any track not updated for this long [s] (covers tracks that leave the radar's coverage for good) |
None
|
Returns:
| Type | Description |
|---|---|
List[Track]
|
List of active tracks |
get_confirmed_tracks ¶
get_confirmed_tracks()
Get established tracks, including tracks currently coasting.
Radar networks¶
NetworkManager ¶
The fusion centre of a radar network.
Radars are registered with their positions and submit their tracks and
bearings; these arrive after the link delay. fuse brings the tracks to a
common time, groups those of the same aircraft and combines each group by
covariance intersection. triangulate_jammers crosses the bearings.
>>> network = NetworkManager(link_delay_ms=100)
>>> network.register_node("north", position_xy=np.array([0.0, 30e3]))
>>> network.register_node("south", position_xy=np.array([0.0, -30e3]))
>>> network.submit_tracks("north", tracks_north, current_time=1.0)
>>> network.submit_tracks("south", tracks_south, current_time=1.0)
>>> picture = network.fuse(current_time=1.2)
register_node ¶
register_node(node_id, position_xy, lat_lon=None)
Register a radar node in the network.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
str
|
Unique node identifier |
required |
position_xy
|
ndarray
|
Position [x, y] in meters |
required |
lat_lon
|
Optional[Tuple[float, float]]
|
Geographic coordinates (optional) |
None
|
Returns:
| Type | Description |
|---|---|
RadarNode
|
Registered RadarNode |
submit_tracks ¶
submit_tracks(node_id, tracks, current_time=0.0)
Submit track data from a radar node (enters latency queue).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
str
|
Source node ID |
required |
tracks
|
List[NetworkTrack]
|
Track list from this node |
required |
current_time
|
float
|
Current simulation time [s] |
0.0
|
submit_strobes ¶
submit_strobes(node_id, strobes, current_time=0.0)
Submit jammer strobe reports from a radar node.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
node_id
|
str
|
Source node ID |
required |
strobes
|
List[StrobeReport]
|
Strobe reports |
required |
current_time
|
float
|
Current simulation time [s] |
0.0
|
fuse ¶
fuse(current_time)
Take in what the link has delivered by current_time and return the
fused tracks at that time.
triangulate_jammers ¶
triangulate_jammers(current_time=0.0, max_range_m=500000.0)
Locate the jammers the radars currently report bearings to.
The bearings are sorted into jammers by StrobeTriangulator.locate.
A fix keeps its number while it stays within three of its own sigmas
(at least 2 km) of where it was.
Recordings and reports¶
recording ¶
Recordings, format 2: what the displays were shown, frame by frame.
A recording holds the scenario it was made from (the canonical mapping, so the run can be repeated), the seed, and for every frame the targets, the plots the radar made, its tracks, the jammers' false targets, the events, and in a network the other radars, fused tracks and jammer fixes. Replaying it puts the same frames back on the same displays. The range-Doppler map is not recorded.
The file is HDF5. Each kind of record is one table (a compound dataset that grows); a frame says where its rows are:
/ attributes: format_version, radarsim_version, created,
scenario_name, seed, dt
/scenario the scenario mapping, JSON
/frames one row per frame: time, radar position, antenna azimuth,
running counts, and for each table below the first row
and the number of rows that belong to the frame
/targets truth and last look of every target
/tracks the radar's tracks
/false_targets echoes made by deception jammers
/plots detections, each with its time (not tied to a frame)
/events events with their time; the text is in /event_text and
its values, as JSON, in /event_params
/radar_states radar parameters and settings, JSON, written when they change
/target_info name, type, affiliation of a target, JSON, when they change
/network/... others, other_tracks, strobes, fused, fixes
Rows are buffered and written every flush_every frames, so a long run
does not pile up in memory and a crash loses at most that many frames.
Format 1 files (4.x: ground truth and one SNR per target) are read by
radarsim.io.replay_loader; recording_version tells the two apart.
RecordingWriter ¶
Writes frames to a recording as they are made.
writer = RecordingWriter(path, scenario_dict(engine), seed=engine.seed, dt=engine.dt)
writer.write(build_frame(engine, engine.dt)) # after every step, or every display frame
writer.close()
Recording ¶
A format-2 recording, read into memory.
frame_at(time) gives the frame shown at that time. The tables are also
there for analysis as numpy structured arrays: frames, targets,
tracks, plots, events, false_targets.
frame ¶
frame(index, plots_since=None, events_since=None)
The frame index. Its plots and events are those of the frame
itself, or, with plots_since / events_since (recording times),
all made after that time up to this frame: what a display needs after a
jump.
frame_at ¶
frame_at(time_s, plots_window_s=None, all_events=False)
The frame on display time_s after the start of the recording. With
plots_window_s it carries every plot of that many seconds before
it, and with all_events every event up to it.
RecordingUnavailable ¶
Bases: RuntimeError
h5py is not installed.
recording_version ¶
recording_version(path)
Format of the recording at path: 2, or 1 for a file written by RadarSim 4.
report ¶
Run reports.
build_report summarises a run (per-object looks, detections, first
detection, median SNR, the final track picture and the event log);
write_report saves it as JSON, or as CSV (one summary table followed by the
event table) when the file name ends in .csv.
build_report ¶
build_report(engine, scenario_name='')
Summary of what engine has simulated so far, as a mapping ready for JSON:
looks, detections and first detection per object, the tracks as they are
now, the event log and, with several radars, the fused picture.
write_report ¶
write_report(report, path)
Write a report as JSON, or as two CSV tables when path ends in .csv.