mmWrt package
Submodules
mmWrt.Plots module
- mmWrt.Plots.plot_range_doppler(cube, radar, _d0=None, _v0=None, no_speed_shift=True)
Plots Range Doppler with axis labeled in SI
- Parameters:
cube (numpy array) – contains a 2D array with slow time and fast time samples
radar (Radar instance) – contains configuration values for displaying the range doppler
_d0 (optional) – if is not None, will be used in title for target pos
_v0 (optional) – if is not None, will be used in title as target speed
no_speed_shift (bool) – if True does not do fftshift on the speeds
- Returns:
plot_details – (fig, ranges, speeds)
- Return type:
tuple
mmWrt.PointCloud module
mmWrt.RadarSignalProcessing module
- mmWrt.RadarSignalProcessing.cfar_1d(FT, num_training_cells=10, num_guard_cells=2, mode='same', cfar_type='CA', debug=False)
CFAR for 1D FFT values
- Parameters:
FT (ndarray) – signal whose peaks have to be detected and reported
num_training_cells (int) – sum of left and right train cells count
num_guard_cells (int) – sum of left and right guard cells count
mode (str) – same as np.convolve
cfar_type (str) – valid value CA, OS, GO
debug (bool) – if True outputs debug info
- Returns:
cfar_th – CFAR threshold values
- Return type:
numpy array
- Raises:
ValueError – if CFAR type is not supported
- mmWrt.RadarSignalProcessing.cfar_ca_1d(X, num_training_cells=10, num_guard_cells=2, Pfa=0.01, mode='same', debug=False)
Retuns indexs of peaks found via CA-CFAR i.e Cell Averaging Constant False Alarm Rate algorithm
- Parameters:
X (numpy ndarray) – signal whose peaks have to be detected and reported
num_training_cells (int) – number of cells used to train CA-CFAR
num_guard_cells (int) – number of cells guarding CUT against noise power calculation
Pfa (float) – Probability of false alert, used to compute the variable threshold
mode (str) – same meaning as np.convolve
debug (bool) – if True will output debug info
- Returns:
cfar_th – CFAR threshold values
- Return type:
numpy array
- mmWrt.RadarSignalProcessing.error(targets_synthetics, targets_f)
Computes the error in the targets position estimation
- Parameters:
targets_synthetics (list[Targets]) – list of synthetic targets (as defined intially)
targets_f (list[Targets]) – list of targets as computed by rt and rsp
- Returns:
total_error – sum of distances between each closest targets
- Return type:
float
- mmWrt.RadarSignalProcessing.frequency_estimator(FFT, idxs, estimator_name='fft')
Wrapper around the different frequency estimator possible
- Parameters:
FFT (numpy array) – Fourier Transform with complex values
idxs (List[int]) – list of indexes where peaks in FFT are found and where the frequency estimator estimator_name needs to be applied
estimator_name (str) – fft phase quinn_second
- Returns:
i_peaks – array of estimated float index from the int idxs
- Return type:
numpy array
- Raises:
ValueError # noqa – DAR402: when invalid estimator_name value is passed as parameter
- mmWrt.RadarSignalProcessing.if2d(radar)
ratio from IF frequency to distance !!! important
the ratio is 1/2 of the d2f as the IF frequency results from the wave traveling to the target and back. Whereas if2d gives the distance between the radar and the scatterer which is 1/2 the distance travelled by the radar EM wave.
- Parameters:
radar (object) – a radar object
- Returns:
f2d (float) – ratio between frequency and distance for given radar settings
Usage
—–
f2d = if2d(radar)
# assuming f_if is an IF frequency
# then d will be the distsance to the target
d = f2d * f_if
- mmWrt.RadarSignalProcessing.pcl(cube)
returns array of 3D pcl
- Parameters:
cube (numpy array) – cube is [chirp][elevation][azimuth][adc]
- Returns:
pcl – pcl is a 1D array of point each point is defined by (x,y,z,vr,mag)
- Return type:
numpy array
- mmWrt.RadarSignalProcessing.peak_grouping_1d(cfar_idx, mag_r)
groups adjacent idx from cfar by first putting adjacent one in clusters then finding the index with the highest magnitude in FFT and returning this one as peak
- Parameters:
cfar_idx (numpy array) – vector of index where fft magnitude is higher than CFAR threshold
mag_r (numpy array) – abs(FFT)
- Returns:
idx_peaks – grouped peaks
- Return type:
numpy array
- mmWrt.RadarSignalProcessing.range_fft(baseband, chirp_index=0, fft_window=None, fft_padding=0, full_FFT=False, debug=False)
scipy FFT wrapper with windowing and padding options
- Parameters:
baseband (numpy array) – the IF ADC signals data matrix
chirp_index (int) – index of the chirp in the data matrix
fft_window (str) – FFT windowing names supported by scipy get_window
fft_padding (int) – if 0 - no padding if -1: padding to next level of power of 2 other values: padding to those values
full_FFT (bool) – if True returns the full FFT, else only 0..d_max_unambiguous
debug (bool) – if True logs debug information on console
- Returns:
Range_FFT – Distances: np array abs_FT: np array
- Return type:
tuple
- Raises:
ValueError – when fft_padding has a value < -1
- mmWrt.RadarSignalProcessing.range_resolution(v, B)
Range resolution is c/2B
- Parameters:
v (float) – celerity of light in medium
B (float) – Bandwidth of signal sampled (often simplified as chirped)
- Returns:
delta_R – Range Resolution
- Return type:
float
mmWrt.Raytracing module
mmWrt.Scene module
- class mmWrt.Scene.Antenna(x=0.0, y=0, z=0, angle_gains_db10=array([[0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], ..., [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.], [0., 0., 0., ..., 0., 0., 0.]], shape=(360, 360)), f_min_GHz=60, f_max_GHz=64, freq_gains_db10=array([0., 0., 0., 0.]))
Bases:
object- freq_gain_db10(freq)
antenna gain at given frequency
- Parameters:
freq (float) – frequency in Hertz
- Returns:
gain_dB – gain in dB
- Return type:
float
- Raises:
ValueError – if freq is too low
- gain(azimuth, elevation, freq)
computes total antenna gain over elevation, aziumth and frequency
- Parameters:
azimuth (float) – between -pi and pi value
elevation (float) – between -pi and pi value
freq (float) – frequency at which antenna gain needs to be calculated
- Returns:
overall_gain – antenna gain at freq and given direction
- Return type:
float
- class mmWrt.Scene.Medium(v=300000000.0, L=0, name='void')
Bases:
object
- class mmWrt.Scene.Radar(transmitter=<mmWrt.Scene.Transmitter object>, receiver=<mmWrt.Scene.Receiver object>, medium=<mmWrt.Scene.Medium object>, adc_po2=False, debug=False)
Bases:
object
- class mmWrt.Scene.Receiver(fs=400.0, antennas=(<mmWrt.Scene.Antenna object>, ), max_adc_buffer_size=1024, max_fs=25000000.0, n_adc=0, config=None, debug=False)
Bases:
object
- class mmWrt.Scene.Target(x=0.0, y=0.0, z=0.0, xt=None, yt=None, zt=None, rcs_f=<function Target.<lambda>>, target_type='point')
Bases:
object- distance(target=None, t=0)
- pos_t(t=0)
- rcs(f)
- class mmWrt.Scene.Transmitter(f0_min=60000000000.0, slope=None, slope_MHz_us=None, bw=4000000000.0, antennas=[<mmWrt.Scene.Antenna object>], t_inter_chirp=0.0, chirps_count=1, t_inter_frame=0.0, frames_count=1, conf=None)
Bases:
object
mmWrt.fmcw module
- mmWrt.fmcw.BB_IF(f0_min, slope, T, antenna_tx, antenna_rx, target, v=300000000.0)
This function implements the mathematical IF defined in latex as y_{IF} = cos(2 pi [f_0delta + s * delta * t - s* delta^2]) into following python code y_IF = cos (2*pi*(f_0 * delta + slope * delta * T + slope * delta**2))
- Parameters:
f0_min (float) – the frequency at the begining of the chirp
slope (float) – the slope with which the chirp frequency inceases over time
T (ndarray) – the 1D vector containing time values
antenna_tx (tuple of floats) – x, y, z coordinates
antenna_rx (tuple of floats) – x, y, z coordinates
target (tuple of floats) – x, y, z coordinates
v (float) – speed of light in considered medium
- Returns:
YIF – vector containing the IF values
- Return type:
ndarray