phypy package

Submodules

phypy.analog module

Module for performing ‘analog’ related PHY tasks such as the power amplifier

class phypy.analog.PowerAmp(order: int = 5, memory_depth: int = 4, memory_stride: int = 1, noise_variance: float = 0.05, add_lo_leakage: bool = True, add_iq_imbalance: bool = True, seed: int = 1)[source]

Bases: phypy.structures.MemoryPolynomial

Power amplifier class that implements a baseband, memory-polynomial based PA

static calculate_nmse(desired, actual)[source]

Calculate the normalized mean squared error Todo:

  • Check this. I think I need to divide by number of samples
make_new_model(pa_input, pa_output)[source]

Learn new coefficients based on pa_inputs and pa_outputs

transmit(x)[source]

Transmit a signal through the Memory Polynomial object

phypy.cli module

Console script for phypy.

phypy.corrections module

Module for performing corrections on impairments related to the PHY such as DPD

class phypy.corrections.ILA_DPD(order: int = 5, memory_depth: int = 1, memory_stride: int = 5, n_iterations: int = 2)[source]

Bases: phypy.structures.MemoryPolynomial

Implements a DPD object that uses an indirect learning architecture (ILA)

Implements a digital predistorter (DPD) that uses an indirect learning architecture (ILA) and a parallel hammerstein, memory polynomial structure that acts as an inverse of the PA model.

perform_learning(pa, signal)[source]

Learn a new DPD model for a given pa

phypy.dsp module

DSP Module for basic DSP functions

phypy.dsp.frequency_shift(signal, shift_amount, sampling_rate)[source]

Performs a shift in the freqeuency shift by multiplying by a complex sinusoid

Args:
signal: The signal to be shifted as a nparray shift_amount: Amount to shift by in Hz sampling_rate: The original sampling rate of the signal in Hz
Returns:
Returns a nparray with the signal shifted by the shift amount

phypy.modulators module

Modulator Module that implements various wireless modulators

These modulators are meant to turn arbitrary bit patterns to analog waveforms for wireless transmission.

class phypy.modulators.OFDM(n_subcarriers: int = 1200, subcarrier_spacing: int = 15000, cp_length: int = 144, constellation: str = 'QPSK', seed: int = 0)[source]

Bases: object

Class that creates OFDM signals.

This class will set up an OFDM modulator to create random OFDM signals.

Attributes:
n_subcarriers: Number of subcarriers per OFDM symbol subcarrier_spacing: Spacing between subcarriers in Hz cp_length : Number of samples in the cyclic prefix fft_size: Size of the IFFT/FFT used. sampling_rate: The native sampling rate based on the FFT size and subcarrier spacing symbol_alphabet: The constellation points
Todo:
  • Add an arbitrary bit input
  • Add a demodulator
add_cyclic_prefix(td_waveform)[source]

Adds cyclic prefix

Adds by taking the last few samples and appending it to the beginning of the signal

Args:
td_waveform: IFFT output signal.
Returns:
time domain signal with a cyclic prefix
calculate_evm(fd_rx_signal)[source]
demodulate(time_domain_rx_signal)[source]

Demodulate a time domain signal back into the FD symbols

frequency_to_time_domain(fd_symbol)[source]

Convert the frequency domain symbol to time domain via IFFT

Args:
fd_symbol: One frequency domain symbol
Returns:
time domain signal
static qam_alphabet(constellation)[source]

Returns constellation points for QPSK, 16QAM, or 64 QAM

Args:
constellation: String saying the desired constellation
Returns:
symbol alphabet on the complex plane
remove_cyclic_prefix(td_grid)[source]
time_to_frequency_domain(td_symbol)[source]
use(n_symbols: int = 10)[source]

Use the OFDM modulator to generate a random signal.

Args:
n_symbols: Number of OFDM symbols to generate
Returns:
A time-domain OFDM signal
TODO:
  • Allow to pass in an arbitrary bit pattern for modulation.

phypy.structures module

File for mathematical structures like a memory polynomial

class phypy.structures.MemoryPolynomial(order: int = 5, memory_depth: int = 4, memory_stride: int = 1)[source]

Bases: object

static check_for_errors(order, memory_depth, memory_stride)[source]

Check for errors. Must be odd order with positive memory

n_coeffs

“Total number of coefficients including the polynomial order and memory depth

n_rows

Total number of rows in the coeff matrix

perform_least_squares(x, y)[source]

Perform a least squares fit Todo:

  • Add support for regularized LS.
setup_basis_matrix(x)[source]

Setup a matrix of the signal and delayed replicas for multiplication by the coeffs

transmit(x)[source]

Transmit a signal through the Memory Polynomial object

Module contents

Top-level package for PhyPy.