-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Change README logo if in dark mode (#95) * Start transform tests & minor `RandomTimeShift` optimization (#94) * Start transform tests & slight optimization in RandomTimeShift * Add new length check for TimeCrop tests * Code style * Fixed name mangling. * QAM/PSK Pulse shaping filter transition bandwidth corrected (#98) * excess bandwidth is defined in porportion to signal bandwidth, not sampling rate, thus needs to be scaled by the samples per symbol * filling in a comment to describe modification to code * QAM/PSK Pulse shaping filter transition bandwidth corrected (#98) * excess bandwidth is defined in porportion to signal bandwidth, not sampling rate, thus needs to be scaled by the samples per symbol * filling in a comment to describe modification to code * OFDM Modulator filter lengths estimated and bandwidth randomized (#99) * * cutoff frequency for LPF now randomized when using 'rand_lpf' * derives a transition bandwidth from the cutoff frequency * uses filter length approximating function for the randomized LPF * using filter estimation function for pre-computed LPF taps * Tests for visual inspection. (#103) * 91 create generation performance benchmarks for each modulation type (#104) * Initial benchmarking code. * Some benchmarks * Adding initial benchmarks. * Fix action. --------- * 75 examine ofdm generation for potential speedups for sig53 (#105) * Tests for visual inspection of modulation generation. (#102) * Optimizations show significant improvement in generation speed. * Nominal behavior after using scipy. * Adding initial Dockerfile (#108) * Incrementing version
- Loading branch information
Showing
11 changed files
with
286 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,3 +10,4 @@ checkpoints/ | |
lightning_logs/ | ||
*.pt | ||
*.jpg | ||
*.benchmarks/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM pytorch/pytorch:1.13.1-cuda11.6-cudnn8-runtime | ||
|
||
ENV DEBIAN_FRONTEND=noninteractive | ||
|
||
ADD torchsig/ /build/torchsig | ||
|
||
ADD pyproject.toml /build/pyproject.toml | ||
|
||
RUN pip3 install /build | ||
|
||
RUN pip3 install notebook | ||
|
||
WORKDIR /workspace/code | ||
|
||
ADD examples/ /workspace/code/examples |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from torchsig.datasets.synthetic import ( | ||
ConstellationDataset, | ||
FSKDataset, | ||
OFDMDataset, | ||
default_const_map, | ||
freq_map, | ||
) | ||
from matplotlib import pyplot as plt | ||
import numpy as np | ||
import pytest | ||
|
||
|
||
def iterate_one_epoch(dataset): | ||
for _ in dataset: | ||
pass | ||
|
||
|
||
@pytest.mark.benchmark(group="constellation") | ||
@pytest.mark.parametrize("modulation_name", default_const_map.keys()) | ||
def test_generate_constellation_benchmark(benchmark, modulation_name): | ||
dataset = ConstellationDataset( | ||
[modulation_name], | ||
num_iq_samples=4096, | ||
num_samples_per_class=100, | ||
iq_samples_per_symbol=2, | ||
pulse_shape_filter=None, | ||
random_pulse_shaping=False, | ||
random_data=False, | ||
use_gpu=False, | ||
) | ||
benchmark(iterate_one_epoch, dataset) | ||
|
||
|
||
@pytest.mark.benchmark(group="fsk") | ||
@pytest.mark.parametrize("modulation_name", freq_map.keys()) | ||
def test_generate_fsk_benchmark(benchmark, modulation_name): | ||
dataset = FSKDataset( | ||
[modulation_name], | ||
num_iq_samples=4096, | ||
num_samples_per_class=100, | ||
iq_samples_per_symbol=2, | ||
random_pulse_shaping=False, | ||
random_data=False, | ||
use_gpu=False, | ||
) | ||
benchmark(iterate_one_epoch, dataset) | ||
|
||
|
||
num_subcarriers = (64, 72, 128, 180, 256, 300, 512, 600, 900, 1024, 1200, 2048) | ||
|
||
|
||
@pytest.mark.benchmark(group="ofdm") | ||
@pytest.mark.parametrize("num_subcarriers", num_subcarriers) | ||
def test_generate_ofdm_benchmark(benchmark, num_subcarriers): | ||
constellations = ("bpsk", "qpsk", "16qam", "64qam", "256qam", "1024qam") | ||
sidelobe_suppression_methods = ("lpf", "win_start") | ||
dataset = OFDMDataset( | ||
constellations, | ||
num_subcarriers=(num_subcarriers,), | ||
num_iq_samples=4096, | ||
num_samples_per_class=100, | ||
sidelobe_suppression_methods=sidelobe_suppression_methods, | ||
use_gpu=False, | ||
) | ||
benchmark(iterate_one_epoch, dataset) | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
from unittest import TestCase | ||
from torchsig.transforms.system_impairment.si import RandomTimeShift, TimeCrop | ||
import numpy as np | ||
|
||
|
||
class RandomTimeShiftTestCase(TestCase): | ||
def test_random_time_shift_right(self): | ||
rng = np.random.RandomState(0) | ||
data = ( | ||
rng.rand( | ||
16, | ||
) | ||
- 0.5 | ||
) + 1j * ( | ||
rng.rand( | ||
16, | ||
) | ||
- 0.5 | ||
) | ||
shift = 5 | ||
t = RandomTimeShift( | ||
shift=shift, | ||
) | ||
new_data = t(data) | ||
self.assertTrue(np.allclose(data[:-shift], new_data[shift:])) | ||
self.assertTrue(np.allclose(new_data[:shift], np.zeros(shift))) | ||
|
||
def test_random_time_shift_left(self): | ||
rng = np.random.RandomState(0) | ||
data = ( | ||
rng.rand( | ||
16, | ||
) | ||
- 0.5 | ||
) + 1j * ( | ||
rng.rand( | ||
16, | ||
) | ||
- 0.5 | ||
) | ||
shift = -5 | ||
t = RandomTimeShift( | ||
shift=shift, | ||
) | ||
new_data = t(data) | ||
self.assertTrue(np.allclose(data[-shift:], new_data[:shift])) | ||
self.assertTrue(np.allclose(new_data[shift:], np.zeros(np.abs(shift)))) | ||
|
||
|
||
class TimeCropTestCase(TestCase): | ||
def test_time_crop_start(self): | ||
rng = np.random.RandomState(0) | ||
num_iq_samples = 16 | ||
data = ( | ||
rng.rand( | ||
num_iq_samples, | ||
) | ||
- 0.5 | ||
) + 1j * ( | ||
rng.rand( | ||
num_iq_samples, | ||
) | ||
- 0.5 | ||
) | ||
length = 4 | ||
t = TimeCrop( | ||
crop_type="start", | ||
length=length, | ||
) | ||
new_data: np.ndarray = t(data) | ||
self.assertTrue(np.allclose(data[:length], new_data)) | ||
self.assertTrue(new_data.shape[0] == length) | ||
|
||
def test_time_crop_center(self): | ||
rng = np.random.RandomState(0) | ||
num_iq_samples = 16 | ||
data = ( | ||
rng.rand( | ||
num_iq_samples, | ||
) | ||
- 0.5 | ||
) + 1j * ( | ||
rng.rand( | ||
num_iq_samples, | ||
) | ||
- 0.5 | ||
) | ||
length = 4 | ||
t = TimeCrop( | ||
crop_type="center", | ||
length=length, | ||
) | ||
new_data: np.ndarray = t(data) | ||
extra_samples = num_iq_samples - length | ||
self.assertTrue( | ||
np.allclose(data[extra_samples // 2 : -extra_samples // 2], new_data) | ||
) | ||
self.assertTrue(new_data.shape[0] == length) | ||
|
||
def test_time_crop_end(self): | ||
rng = np.random.RandomState(0) | ||
num_iq_samples = 16 | ||
data = ( | ||
rng.rand( | ||
num_iq_samples, | ||
) | ||
- 0.5 | ||
) + 1j * ( | ||
rng.rand( | ||
num_iq_samples, | ||
) | ||
- 0.5 | ||
) | ||
length = 4 | ||
t = TimeCrop( | ||
crop_type="end", | ||
length=length, | ||
) | ||
new_data: np.ndarray = t(data) | ||
self.assertTrue(np.allclose(data[-length:], new_data)) | ||
self.assertTrue(new_data.shape[0] == length) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
__version__ = "0.3.0" | ||
__version__ = "0.3.1" |
Oops, something went wrong.