Datasets:
Tasks:
Other
Formats:
parquet
Size:
100K - 1M
Tags:
wireless
physical-layer-security
covert-communication
low-probability-of-detection
virtual-mimo
anomaly-detection
License:
| """Single-carrier QPSK/QAM with root-raised-cosine pulse shaping. | |
| Frame: 16 pilot symbols (orthogonal per-user preamble) + 144 data symbols | |
| = 160 symbols, oversampled by 2 -> 320 samples. Roll-off beta = 0.5 with | |
| symbol rate 0.5 Fs gives occupied bandwidth (1+beta)/2 = 0.75 Fs, matching | |
| the multicarrier formats' 48/64 subcarrier occupancy. | |
| """ | |
| from __future__ import annotations | |
| import numpy as np | |
| from ..pilots import pilot_matrix | |
| from .base import Waveform | |
| def rrc_taps(oversample: int, beta: float, span: int) -> np.ndarray: | |
| """Unit-energy root-raised-cosine filter, `span` symbols long.""" | |
| n = np.arange(-span * oversample // 2, span * oversample // 2 + 1) | |
| t = n / oversample # in symbol durations | |
| h = np.empty(t.shape, dtype=float) | |
| for i, ti in enumerate(t): | |
| if abs(ti) < 1e-12: | |
| h[i] = 1.0 - beta + 4.0 * beta / np.pi | |
| elif abs(abs(ti) - 1.0 / (4.0 * beta)) < 1e-9: | |
| h[i] = (beta / np.sqrt(2.0)) * ( | |
| (1.0 + 2.0 / np.pi) * np.sin(np.pi / (4.0 * beta)) | |
| + (1.0 - 2.0 / np.pi) * np.cos(np.pi / (4.0 * beta)) | |
| ) | |
| else: | |
| num = np.sin(np.pi * ti * (1.0 - beta)) + 4.0 * beta * ti * np.cos(np.pi * ti * (1.0 + beta)) | |
| den = np.pi * ti * (1.0 - (4.0 * beta * ti) ** 2) | |
| h[i] = num / den | |
| return h / np.linalg.norm(h) | |
| def conv_same(x: np.ndarray, h: np.ndarray) -> np.ndarray: | |
| """FFT-based 'same' convolution along the last axis (batched).""" | |
| t, l = x.shape[-1], len(h) | |
| nfft = int(2 ** np.ceil(np.log2(t + l - 1))) | |
| y = np.fft.ifft(np.fft.fft(x, nfft, axis=-1) * np.fft.fft(h, nfft), axis=-1) | |
| lo = (l - 1) // 2 | |
| return y[..., lo : lo + t] | |
| class SingleCarrier(Waveform): | |
| name = "sc" | |
| oversample = 2 | |
| beta = 0.5 | |
| span = 8 | |
| n_pilot_syms = 16 | |
| def __init__(self, cfg): | |
| assert cfg.n_samples == self.oversample * (self.n_pilot_syms + cfg.n_data) | |
| self.taps = rrc_taps(self.oversample, self.beta, self.span) | |
| self.pilots = pilot_matrix(cfg.pilot_scheme, cfg.n_tx, self.n_pilot_syms) | |
| super().__init__(cfg) | |
| def n_pilot_re(self) -> int: | |
| return self.n_pilot_syms | |
| def _modulate_raw(self, s): | |
| pil = np.broadcast_to(self.pilots, s.shape[:-1] + (self.n_pilot_syms,)) | |
| syms = np.concatenate([pil, s], axis=-1) # (..., M, 160) | |
| up = np.zeros(syms.shape[:-1] + (self.cfg.n_samples,), dtype=np.complex128) | |
| up[..., :: self.oversample] = syms | |
| return conv_same(up, self.taps) | |
| def demodulate(self, u): | |
| # Matched filter (overall raised-cosine => ~ISI-free at symbol instants) | |
| v = conv_same(np.asarray(u, dtype=np.complex128), self.taps) | |
| return v[..., :: self.oversample][..., self.n_pilot_syms :] | |