impairments#

Transceiver and transmission impairment simulation.

QAMpy impairments 中文接口说明#

模块路径与定位#

  • 文件路径: main/qampy/impairments.py

  • 核心职责: 面向 signals.SignalObject 系列描述链路传输与硬件非理想, 覆盖相位噪声、色散、PMD、SNR 调整、模式延迟等常见损伤。

  • 典型调用场景: 在系统级仿真中串接于信号源之后, 快速叠加单项或组合链路/器件扰动。

关键依赖#

  • 下层模块: qampy.core.impairments 提供向量化数值实现; numpy 负责数组运算; warnings 用于运行时提示。

  • 协同对象: qampy.signals.SignalObject 族类, 需暴露 fsfb 等属性以便重建新信号实例。

主要接口速览#

  • simulate_transmission: 打包常见损伤流程, 便于快速构建链路基线。

  • apply_PMD: 根据偏振角与 DGD 在光场上施加一阶偏振模色散。

  • apply_phase_noise: 以维纳过程注入激光线宽导致的相位噪声。

  • change_snr / add_awgn: 控制信噪比或直接叠加高斯噪声。

  • add_carrier_offset / rotate_field: 在电/光域引入频偏或偏振旋转。

  • add_dispersion / add_modal_delay: 模拟色散与各模群延迟, 支持多模场景。

  • sim_tx_response: 模拟有限 ENOB、量化与 DAC 滤波等发射端硬件限制。

使用建议#

  • 批量仿真时优先调用组合接口 simulate_transmission, 统一控制参数。

  • 若需自定义流程, 可串联底层函数后配合 SignalObject.recreate_from_np_array 还原信号。

  • 在多模或多帧信号上调用延迟/滚动相关函数时, 注意采样率与轴向定义一致。

Functions for the simulation of transmission and transceiver impairments.

qampy.impairments.add_carrier_offset(sig, fo)#

Add frequency offset to signal

Parameters:
  • sig (array_like) – signal input array

  • df (float) – frequency offset

Returns:

signal – signal with added offset

Return type:

array_like

qampy.impairments.add_dispersion(sig, D, L, wl0=1.55e-06)#

Add dispersion to a signal

Parameters:
  • sig (signal_object) – signal to operate on

  • D (float) – Dispersion parameter in s/m/m

  • L (float) – Length of the dispersion in m

  • wl0 (float, optional) – Centre wavelength in m

Returns:

sig_out – output signal with added dispersion

Return type:

signal_object

qampy.impairments.apply_PMD(field, theta, t_dgd)#

Apply PMD to a given input field

Parameters:
  • field (SignalObject) – input dual polarisation optical field (first axis is polarisation)

  • theta (float) – angle of the principle axis to the observed axis

  • t_dgd (float) – differential group delay between the polarisation axes

Returns:

out – new dual polarisation field with PMD

Return type:

SignalObject

qampy.impairments.apply_phase_noise(signal, df)#

Add phase noise from local oscillators, based on a Wiener noise process.

Parameters:
  • signal (array_like) – single polarisation signal

  • df (float) – combined linewidth of local oscillators in the system

Returns:

out – output signal with phase noise

Return type:

array_like

qampy.impairments.change_snr(sig, snr)#

Change the SNR of a signal assuming that the input signal is noiseless

Parameters:
  • sig (array_like) – the signal to change

  • snr (float) – the desired signal to noise ratio in dB

Returns:

sig – output signal with given SNR

Return type:

array_like

qampy.impairments.sim_DAC_response(sig, enob=5, clip_rat=1, quant_bits=0, **dac_params)#

Function to simulate DAC response, including quantization noise (ENOB) and frequency response.

Parameters:
  • sig (array_like) – Input signal

  • enob (float, optional) – Effective number of bits of the DAC (i.e. 6 bits.) modelled as AWGN. If enob=0 only quantize. If both enob and quant_bits are given, quantize first and then add enob noise.

  • clip_rat (float, optional) – Ratio of signal left after clipping. (i.e. clip_rat=0.8 means 20% of the signal is clipped) (default 1: no clipping)

  • quant_bits (float, optional) – Number of bits in the quantizer, only applied if not =0. (Default: don’t qpply quantization)

  • dac_params (dict, optional) – Parameters for the DAC response check apply_DAC_filter for the keyword parameters. If this is empty than do not apply the DAC response

Returns:

filter_sig – Quantized, clipped and filtered output signal

Return type:

array_like

qampy.impairments.sim_mod_response(sig, dcbias=1, gfactr=1, cfactr=0, dcbias_out=0.5, gfactr_out=1)#

Simulate IQ modulator response.

Parameters:
  • rfsig (array_like) – complex version of the I (real part) and Q (imaginary part) of the signal

  • dcsig (complex or float, optional) – DC bias for I (real) and Q (imaginary) channel. If dcsig is real use the same DC bias for I and Q

  • vpi (complex or float, optional) – Vpi of the MZM (zero-power point) in I (real) and Q (imaginary) channel. If vpi is real use the same Vpi for both.

  • gfactr (complex or float, optional) – Split imbalance and path dependent loss of I (real) and Q (imaginary) MZM. An ideal MZM with infinite extinction ratio has gfactor=1. If gfactr is real use the same value for both I and Q.

  • cfactr (complex or float, optional) – Chirp factors of I (real) and (Q) channel MZMs, caused by the asymmetry in the electrode design of the MZM. cfactr = 0 for ideal MZM.

  • prms_outer (array_like, optional) – DCBias, Vpi and gain factor of the outer MZM.

Returns:

e_out – Output signal of IQ modulator. (i.e. Here assume that input laser power is 0 dBm)

Return type:

array_like

qampy.impairments.sim_tx_response(sig, enob=6, tgt_v=1, clip_rat=1, quant_bits=0, dac_params={'ch': None, 'cutoff': 18000000000.0, 'fn': None}, **mod_prms)#

Simulate a realistic transmitter possibly including quantization, noise due to limited ENOB, and DAC frequency response

Parameters:
  • sig (array_like) – Input signal used for transmission

  • enob (float, optional) – efficient number of bits for DAC. If enob=0 only use quantizer. Unit: bits

  • tgt_v (float, optional) – target Voltage as fraction of Vpi

  • clip_rat (float, optional) – Ratio of signal left after clipping. (i.e. clip_rat=0.8 means 20% of the signal is clipped) (default 1: no clipping)

  • quant_bits (float, optional) – Number of bits in the quantizer, only applied if not =0. (Default: don’t qpply quantization)

  • dac_params (dict, optional) – parameters to pass to the DAC filter

  • mod_prms (dict, optional) – parameters to pass to the modulator

Returns:

e_out – Signal with TX impairments

Return type:

array_like

qampy.impairments.simulate_transmission(sig, snr=None, freq_off=None, lwdth=None, dgd=None, theta=0.8420242973974251, modal_delay=None, dispersion=None, roll_frame_sync=False)#

Convenience function to simulate impairments on signal at once

Parameters:
  • sig (array_like) – input signal

  • snr (flaat, optional) – desired signal-to-noise ratio of the signal. (default: None, don’t change SNR)

  • freq_off (float, optional) – apply a carrier offset to signal (default: None, don’t apply offset)

  • lwdth (float) – linewidth of the transmitter and LO lasers (default: None, infinite linewidth)

  • dgd (float) – first-order PMD (differential group delay) (default: None, do not apply PMD)

  • theta (float) – rotation angle to principle states of polarization

  • modal_delay (array_like, optional) – add a delay given in N samples to the signal (default: None, do not add delay)

  • dispersion (float, optional) – dispersion in s/m

Returns:

signal – signal with transmission impairments applied

Return type:

array_like