Skip to content

Commit

Permalink
Tweaked based on comments (and some code refactor)
Browse files Browse the repository at this point in the history
  • Loading branch information
Doreban committed Jun 13, 2024
1 parent 1e5f6ef commit 30cf2fd
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 40 deletions.
28 changes: 15 additions & 13 deletions src/experiment_prototype/experiment_utils/decimation_scheme.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,19 +126,21 @@ def __init__(self, rxrate, output_sample_rate, stages=None):
)
raise ValueError(errmsg)

if (
self.input_rates[stage_num]
> self.dm_rates[stage_num] * self.output_rates[stage_num]
) and not math.isclose(
self.input_rates[stage_num],
self.dm_rates[stage_num] * self.output_rates[stage_num],
):
errmsg = (
f"Experiment decimation stage {stage_num} is aliasing. Ensure that "
f"input_rate/output_rate ({self.input_rates[stage_num]}/{self.output_rates[stage_num]}) is "
f"greater than the decimation rate ({self.dm_rates[stage_num]})."
)
raise ValueError(errmsg)
# TODO: Enable checking of if decimation scheme will alias.
# Code below needs the passband width, not output rate
# if (
# self.input_rates[stage_num]
# > self.dm_rates[stage_num] * self.output_rates[stage_num]
# ) and not math.isclose(
# self.input_rates[stage_num],
# self.dm_rates[stage_num] * self.output_rates[stage_num],
# ):
# errmsg = (
# f"Experiment decimation stage {stage_num} is aliasing. Ensure that "
# f"input_rate/output_rate ({self.input_rates[stage_num]}/{self.output_rates[stage_num]}) is "
# f"greater than the decimation rate ({self.dm_rates[stage_num]})."
# )
# raise ValueError(errmsg)

if not math.isclose(
self.output_rates[-1], self.output_sample_rate, abs_tol=0.001
Expand Down
8 changes: 4 additions & 4 deletions src/usrp_drivers/usrp_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ void transmit(zmq::context_t &driver_c, USRP &usrp_d,
md.set_end_of_burst(true);
tx_stream->send("", 0, md.get_md());
}() // pulse lambda
); // pulse timeit macro
); // pulse timeit macro
}

// Read AGC and Low Power signals, bitwise OR to catch any time
Expand Down Expand Up @@ -451,9 +451,9 @@ void transmit(zmq::context_t &driver_c, USRP &usrp_d,
<< i);
}
}() // all pulses lambda
); // all pulses timeit macro
}() // full usrp function lambda
); // full usrp function timeit macro
); // all pulses timeit macro
}() // full usrp function lambda
); // full usrp function timeit macro

rxsamplesmetadata::RxSamplesMetadata samples_metadata;

Expand Down
5 changes: 1 addition & 4 deletions src/utils/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,8 @@ def cfs_freq_analysis(self, metadata):
data_chunks = np.reshape(data, data.shape[:-1] + (num_intervals, n))

fft_data = fft.fftshift(fft.fft(data_chunks, axis=-1), axes=-1)
freqs = fft.fftshift(fft.fftfreq(n, d=1 / fs))
df = freqs[1] - freqs[0]

cfs_data = np.sum(np.abs(np.average(fft_data, axis=2)), axis=1)
cfs_freqs = freqs - df / 2
cfs_freqs = fft.fftshift(fft.fftfreq(n, d=1 / fs))

return cfs_data, cfs_freqs

Expand Down
20 changes: 8 additions & 12 deletions tests/simulators/n200_test_packet/n200testpacket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,13 @@
#include "utils/shared_memory/shared_memory.hpp"
#include "utils/zmq_borealis_helpers/zmq_borealis_helpers.hpp"

#define PULSE7 \
{ 0, 9, 12, 20, 22, 26, 27 }
#define PULSE27 \
{ \
0, 3, 15, 41, 66, 95, 97, 106, 142, 152, 220, 221, 225, 242, 295, 330, \
338, 354, 382, 388, 402, 415, 486, 504, 523, 546, 553 \
}
#define PULSE7 {0, 9, 12, 20, 22, 26, 27}
#define PULSE27 \
{0, 3, 15, 41, 66, 95, 97, 106, 142, 152, 220, 221, 225, 242, \
295, 330, 338, 354, 382, 388, 402, 415, 486, 504, 523, 546, 553}
#define PULSE16 \
{ 0, 1, 4, 11, 26, 32, 56, 68, 76, 115, 117, 134, 150, 163, 168, 177 }
#define longdelay \
{ 0, 9, 12, 20, 22, 26, 10000 }
{0, 1, 4, 11, 26, 32, 56, 68, 76, 115, 117, 134, 150, 163, 168, 177}
#define longdelay {0, 9, 12, 20, 22, 26, 10000}

std::vector<std::complex<float>> make_pulse(DriverOptions &driver_options) {
auto amp = 1.0 / sqrt(2.0);
Expand Down Expand Up @@ -60,13 +56,13 @@ std::vector<std::complex<float>> make_pulse(DriverOptions &driver_options) {
auto ramp_size = int(10e-6 * tx_rate);

for (auto j = tr_start_pad, k = 0; j < tr_start_pad + ramp_size; j++, k++) {
auto a = ((k)*1.0) / ramp_size;
auto a = ((k) * 1.0) / ramp_size;
samples[j] *= std::complex<float>(a, 0);
}

for (auto j = num_samps_per_antenna - tr_end_pad - 1, k = 0;
j > num_samps_per_antenna - tr_end_pad - 1 - ramp_size; j--, k++) {
auto a = ((k)*1.0) / ramp_size;
auto a = ((k) * 1.0) / ramp_size;
samples[j] *= std::complex<float>(a, 0);
}

Expand Down
12 changes: 5 additions & 7 deletions tests/test_rx_tx/test_rx_tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@
#define RXSUBDEV std::string("A:A A:B")
#define TXSUBDEV std::string("A:A")

#define TXCHAN \
{ 0 }
#define RXCHAN \
{ 0, 1 }
#define TXCHAN {0}
#define RXCHAN {0, 1}

#define TXRATE (250.0e3)
#define RXRATE (250.0e3)
Expand All @@ -31,7 +29,7 @@
#define DELAY 10e-3

#define PULSETIMES \
{ 0.0, 13500e-6, 18000e-6, 30000e-6, 33000e-6, 39000e-6, 40500e-6 }
{0.0, 13500e-6, 18000e-6, 30000e-6, 33000e-6, 39000e-6, 40500e-6}
#define SAMPSPERCHAN(x) int(RXRATE * (x.back() + 23.5e-3))

bool start_tx = false;
Expand Down Expand Up @@ -70,13 +68,13 @@ std::vector<std::complex<float>> make_ramped_pulse(double tx_rate) {
auto ramp_size = int(10e-6 * tx_rate);

for (auto j = tr_start_pad, k = 0; j < tr_start_pad + ramp_size; j++, k++) {
auto a = ((k)*1.0) / ramp_size;
auto a = ((k) * 1.0) / ramp_size;
samples[j] *= std::complex<float>(a, 0);
}

for (auto j = num_samps_per_antenna - tr_end_pad - 1, k = 0;
j > num_samps_per_antenna - tr_end_pad - 1 - ramp_size; j--, k++) {
auto a = ((k)*1.0) / ramp_size;
auto a = ((k) * 1.0) / ramp_size;
samples[j] *= std::complex<float>(a, 0);
}

Expand Down

0 comments on commit 30cf2fd

Please sign in to comment.