Signals

signals

This file contains the digital signal processing functionality of Borealis. This includes generation of pulses, determination of antenna phases for beamforming, filtering and downsampling of received signals, beamforming of filtered signals, and extraction of lag profiles from beamformed samples.

copyright

2024 SuperDARN Canada

author

Remington Rohel

class src.utils.signals.DSP(rx_rate, filter_taps, mixing_freqs, dm_rates, use_shared_mem=True)[source]

Bases: object

This class performs the digital signal processing functions of Borealis. Filtering and downsampling are specified by lists of filter taps and downsampling factors, which must have the same length. The first filter stage is always a bandpass filter, specified by a list of mixing frequencies which can be selected simultaneously. All subsequent filter stages are lowpass.

Beamforming can also be conducted on the filtered and downsampled data, requiring a list of complex antenna phases for the beamforming operation. Multiple beams can be formed simultaneously.

This class also supports extraction of lag profiles from multi-pulse sequences.

static apply_bandpass_decimate(input_samples, bp_filters, mixing_freqs, dm_rate, rx_rate)[source]

Apply a Frerking bandpass filter to the input samples. Several different frequencies can be centered on simultaneously. Downsampling is done in parallel via a strided window view of the input samples.

Parameters
  • input_samples (ndarray [num_antennas, num_samples]) – The input raw rf samples for each antenna.

  • bp_filters (ndarray [num_slices, num_taps]) – The bandpass filter(s).

  • mixing_freqs (list) – The frequencies used to mix the first stage filter for bandpass.

  • dm_rate (int) – The decimation rate of this stage

  • rx_rate (float) – The rf rx rate.

Returns

Samples after bandpass filter and downsampling operations. Shape [num_slices, num_antennas, samples]

Return type

ndarray

apply_filters(input_samples)[source]

Applies the multi-stage filter to input_samples. Filter results are kept on the same device as input_samples.

Parameters

input_samples (ndarray) – The wideband samples to operate on.

static apply_lowpass_decimate(input_samples, lp_filter, dm_rate)[source]

Apply a lowpass filter to the baseband input samples. Downsampling is done in parallel via a strided window view of the input samples.

Parameters
  • input_samples (ndarray [num_slices, num_antennas, num_samples]) – Baseband input samples

  • lp_filter (ndarray [1, num_taps]) – Lowpass filter taps

  • dm_rate (int) – The decimation rate of this stage.

Returns

Samples after lowpass filter and downsampling operations. Shape [num_slices, num_antennas, samples]

Return type

ndarray

beamform(beam_phases)[source]

Applies the beamforming operation to the antennas_iq samples. Different beam directions are formed in parallel, and the results are stored in SharedMemory if so specified for this instance.

Parameters

beam_phases (list) – The phases used to beamform the filtered samples.

static beamform_samples(filtered_samples, beam_phases)[source]

Beamform the filtered samples for multiple beams simultaneously.

Parameters
  • filtered_samples (ndarray [num_slices, num_antennas, num_samples]) – The filtered input samples.

  • beam_phases (ndarray [num_slices, num_beams, num_antennas]) – The beam phases used to phase each antenna’s samples before combining.

Returns

Beamformed samples of shape [num_slices, num_beams, num_samples]

Return type

np.ndarray

static correlations_from_samples(beamformed_samples_1, beamformed_samples_2, output_sample_rate, slice_index_details)[source]

Correlate two sets of beamformed samples together. Correlation matrices are used and indices corresponding to lag pulse pairs are extracted.

Parameters
  • beamformed_samples_1 (ndarray [num_slices, num_beams, num_samples]) – The first beamformed samples.

  • beamformed_samples_2 (ndarray [num_slices, num_beams, num_samples]) – The second beamformed samples.

  • output_sample_rate (float) – Sampling rate of data.

  • slice_index_details (list) – Details used to extract indices for each slice.

Returns

Correlations for slices. List of length num_slices, with each entry having shape [num_beams, num_range_gates, num_lags].

Return type

list[ndarray]

static create_filters(filter_taps, mixing_freqs, rx_rate)[source]

Creates and shapes the filters arrays using the original sets of filter taps. The first stage filters are mixed to bandpass and the low pass filters are reshaped. The filters coefficients are typically symmetric, except for the first-stage bandpass filters. Mixing frequencies should be given as an offset from the center frequency. For example, with 12 MHz center frequency and a 10.5 MHz transmit frequency, the mixing frequency should be -1.5 MHz.

Parameters
  • filter_taps (list) – The filter taps from the experiment decimation scheme.

  • mixing_freqs (list) – The frequencies used to mix the first stage filter for bandpass.

  • rx_rate (float) – The rf rx rate.

Returns

List of stages of filter taps. First stage is bandpass, subsequent stages are lowpass.

Return type

list[ndarray]

move_filter_results()[source]

Move the final results of filtering (antennas_iq data) to the CPU, optionally in SharedMemory if specified for this instance.

static windowed_view(ndarray, window_len, step)[source]

Creates a strided and windowed view of the ndarray. This allows us to skip samples that will otherwise be dropped without missing samples needed for the convolutions windows. The strides will also not extend out of bounds meaning we do not need to pad extra samples and then drop bad samples after the fact.

Parameters
  • ndarray (ndarray) – The input ndarray

  • window_len (int) – The window length(filter length)

  • step (int) – The step(dm rate)

Returns

The array with a new view.

Return type

ndarray

src.utils.signals.get_phase_shift(beam_angle, freq, num_antennas, antenna_spacing, centre_offset=0.0)[source]

Find the phase shift for a given antenna and beam direction.

Form the beam given the beam direction (degrees off boresite), the tx frequency, the antenna number, a specified extra phase shift if there is any, the number of antennas in the array, and the spacing between antennas.

Parameters
  • beam_angle (list) – list of azimuthal direction of the beam off boresight, in degrees, positive beamdir being to the right of the boresight (looking along boresight from ground). This is for this antenna.

  • freq (float) – transmit frequency in kHz

  • num_antennas (int) – number of antennas in this array

  • antenna_spacing (float) – distance between antennas in this array, in meters

  • centre_offset (float) – the phase reference for the midpoint of the array. Default = 0.0, in metres. Important if there is a shift in centre point between arrays in the direction along the array. Positive is shifted to the right when looking along boresight (from the ground).

Returns

phase_shift a 2D array of beam_phases x antennas in radians.

Return type

phase_shift ndarray

src.utils.signals.get_samples(rate, wave_freq, pulse_len, ramp_time, max_amplitude)[source]

Get basic (not phase-shifted) samples for a given pulse.

Find the normalized sample array given the rate (Hz), frequency (Hz), pulse length (s). Will shift for beam later.

Parameters
  • rate (float) – tx sampling rate, in Hz.

  • wave_freq (float) – frequency offset from the centre frequency on the USRP, given in Hz. To be mixed with the centre frequency before transmitting. (ex. centre = 12 MHz, wave_freq = + 1.2 MHz, output = 13.2 MHz.

  • pulse_len (float) – length of the pulse (in seconds)

  • ramp_time (float) – ramp up and ramp down time for the pulse, in seconds. Typical 0.00001 s from config.

  • max_amplitude (float) – USRP’s max DAC amplitude. N200 = 0.707 max

Returns samples

a numpy array of complex samples, representing all samples needed for a pulse of length pulse_len sampled at a rate of rate.

Return type

ndarray