Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate sequence pulses as samples of continuous wave
Browse files Browse the repository at this point in the history
Doreban committed Jan 29, 2025

Verified

This commit was signed with the committer’s verified signature.
lann Lann
1 parent 22efc90 commit 865cf5a
Showing 3 changed files with 19 additions and 35 deletions.
12 changes: 8 additions & 4 deletions src/experiment_prototype/interface_classes/sequences.py
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
import inspect
import math
from pathlib import Path
from src.utils.signals import basic_pulse_phase_offset

# third-party
import numpy as np
@@ -595,6 +596,12 @@ def make_sequence(self, beam_iter, sequence_num):
basic_samples = self.basic_slice_pulses[slice_id][beam_num]

num_pulses = len(exp_slice.pulse_sequence)
basic_phases = basic_pulse_phase_offset(exp_slice)
basic_phases = np.exp(1j * basic_phases)
# Build pulse sequence slices with phases adjusted for time between pulses
# to mimic a sampled continuous wave
samples = np.einsum("i,jk->ijk", basic_phases, basic_samples)

encode_fn = exp_slice.pulse_phase_offset
if encode_fn:
# Must return 1D array of length [pulses].
@@ -610,10 +617,7 @@ def make_sequence(self, beam_iter, sequence_num):
# samples: [pulses, antennas, samples]
phase_encoding = np.radians(phase_encoding)
phase_encoding = np.exp(1j * phase_encoding)
samples = np.einsum("i,jk->ijk", phase_encoding, basic_samples)

else: # no encodings, all pulses in the slice are all the same
samples = np.repeat(basic_samples[np.newaxis, :, :], num_pulses, axis=0)
samples = np.einsum("i,ijk->ijk", phase_encoding, samples)

# sum the samples into their position in the sequence buffer. Find where the relative
# timing of each pulse matches the sample number in the buffer. Directly sum the samples
21 changes: 5 additions & 16 deletions src/radar_control.py
Original file line number Diff line number Diff line change
@@ -26,7 +26,6 @@
from utils.options import Options
import utils.message_formats as messages
from utils import socket_operations as so
from utils.signals import calc_pulse_base_offset

sys.path.append(os.environ["BOREALISPATH"])
if __debug__:
@@ -360,23 +359,13 @@ def create_dsp_message(radctrl_params):

# Get the phase offset for this pulse combination
pulse_phase_offsets = radctrl_params.sequence.output_encodings
base_pulse_offset = calc_pulse_base_offset(slice_dict[slice_id])
if len(pulse_phase_offsets[slice_id]) != 0 or base_pulse_offset is not None:
if len(pulse_phase_offsets[slice_id]) != 0:
pulse_phase_offset = pulse_phase_offsets[slice_id][-1]
else:
pulse_phase_offset = np.zeros(len(base_pulse_offset))
if len(pulse_phase_offsets[slice_id]) != 0:
pulse_phase_offset = pulse_phase_offsets[slice_id][-1]
lag0_idx = slice_dict[slice_id].pulse_sequence.index(lag[0])
lag1_idx = slice_dict[slice_id].pulse_sequence.index(lag[1])
if base_pulse_offset is not None:
phase_in_rad = np.radians(
(pulse_phase_offset[lag0_idx] - base_pulse_offset[lag0_idx])
- (pulse_phase_offset[lag1_idx] - base_pulse_offset[lag1_idx])
)
else:
phase_in_rad = np.radians(
pulse_phase_offset[lag0_idx] - pulse_phase_offset[lag1_idx]
)
phase_in_rad = np.radians(
pulse_phase_offset[lag0_idx] - pulse_phase_offset[lag1_idx]
)
phase_offset = np.exp(1j * np.array(phase_in_rad, np.float32))
# Catch case where no pulse phase offsets are specified
else:
21 changes: 6 additions & 15 deletions src/utils/signals.py
Original file line number Diff line number Diff line change
@@ -526,22 +526,16 @@ def get_samples(rate, wave_freq, pulse_len, ramp_time, max_amplitude):
return samples


def calc_pulse_base_offset(exp_slice):
def basic_pulse_phase_offset(exp_slice):
"""
Determine the phase offset of each pulse from the first pulse based on the
transmit frequency and the pulse separation (tau spacing). Required due to
phase shift that occurs when the signal is shifted down to baseband due to
the construction of the pulses and the frequency shift that will be applied
to shift to baseband. When the frequency is not a multiple of 10 kHz (or
when the pulse transmit delay from first pulse is not an integer multiple
of 1 ms), the lag pulses become out of phase introducing an artificial
velocity shift in the rawacf data.
Calculate the phase difference of each pulse with respect to the first
pulse based on the transmit frequency and the pulse separation.
:param exp_slice: The experiment slice information
:type exp_slice: class
:returns: Base pulse phase offsets when shifting to baseband.
:rtype: array (deg) or None (if all phases are the same)
:returns: Pulse phase offsets
:rtype: array (rad)
"""
freq_hz = exp_slice.freq * 1e3
tau_s = exp_slice.tau_spacing / 1e6
@@ -552,9 +546,6 @@ def calc_pulse_base_offset(exp_slice):
pulse_phases = np.zeros(num_pulses)
for p in range(num_pulses):
pulse_time = pulse_sequence[p] * tau_s
pulse_phases[p] = np.rad2deg(np.angle(np.exp(1j * omega * pulse_time)))

if all(np.isclose(pulse_phases, pulse_phases[0], atol=1e-6)):
pulse_phases = None
pulse_phases[p] = np.angle(np.exp(1j * omega * pulse_time))

return pulse_phases

0 comments on commit 865cf5a

Please sign in to comment.