Digital Signal Processing (DSP)

Core digital signal processing utilities (optic.dsp.core)

sigPow(x)

Calculate the average power of x per mode.

signal_power(x)

Calculate the total power of x.

firFilter(h, x)

Perform FIR filtering and compensate for filter delay.

rrcFilterTaps(t, alpha, Ts)

Generate Root-Raised Cosine (RRC) filter coefficients.

rcFilterTaps(t, alpha, Ts)

Generate Raised Cosine (RC) filter coefficients.

pulseShape(pulseType[, SpS, N, alpha, Ts])

Generate a pulse shaping filter.

clockSamplingInterp(x[, Fs_in, Fs_out, ...])

Interpolate signal to a given sampling rate.

quantizer(x[, nBits, maxV, minV])

Quantize the input signal using a uniform quantizer with the specified precision.

lowPassFIR(fc, fa, N[, typeF])

Calculate FIR coefficients of a lowpass filter.

decimate(Ei, param)

Decimate signal.

resample(Ei, param)

Resample signal to a given sampling rate.

upsample(x, factor)

Upsample a signal by inserting zeros between samples.

symbolSync(rx, tx, SpS[, mode])

Symbol synchronizer.

finddelay(x, y)

Find delay between x and y.

pnorm(x)

Normalize the average power of each componennt of x.

gaussianComplexNoise(shapeOut, σ2=None)

Generate complex circular Gaussian noise.

gaussianNoise(shapeOut, σ2=None)

Generate Gaussian noise.

phaseNoise(lw, Nsamples, Ts)

Generate realization of a random-walk phase-noise process.

movingAverage(x, N)

Calculate the sliding window moving average of a 2D NumPy array along each column.

clockSamplingInterp(x, Fs_in=1, Fs_out=1, jitter_rms=1e-09)

Interpolate signal to a given sampling rate.

Parameters:
  • x (np.array) – Input signal.

  • param (core.parameter) –

    Resampling parameters:
    • param.Fs_in : sampling frequency of the input signal.

    • param.Fs_out : sampling frequency of the output signal.

    • param.jitter_rms: standard deviation of the time jitter.

Returns:

y – Resampled signal.

Return type:

np.array

decimate(Ei, param)

Decimate signal.

Parameters:
  • Ei (np.array) – Input signal.

  • param (core.parameter) –

    Decimation parameters:

    • param.SpS_in : samples per symbol of the input signal.

    • param.SpS_out : samples per symbol of the output signal.

Returns:

Eo – Decimated signal.

Return type:

np.array

References

[1] P. S. R. Diniz, E. A. B. da Silva, e S. L. Netto, Digital Signal Processing: System Analysis and Design. Cambridge University Press, 2010.

delaySignal(sig, delay, fs)

Apply a time delay to a signal sampled at fs samples per second using FFT/IFFT algorithms.

Parameters:
  • sig (array_like) – The input signal.

  • delay (float) – The time delay to apply to the signal (in seconds).

  • fs (float) – Sampling frequency of the signal (in samples per second).

Returns:

The delayed signal.

Return type:

array_like

finddelay(x, y)

Find delay between x and y.

Parameters:
  • x (np.array) – Signal 1.

  • y (np.array) – Signal 2.

Returns:

d – Delay between x and y, in samples.

Return type:

int

firFilter(h, x)

Perform FIR filtering and compensate for filter delay.

Parameters:
  • h (np.array) – Coefficients of the FIR filter (impulse response, symmetric).

  • x (np.array) – Input signal.

  • prec (cp.dtype) – Size of the complex representation.

Returns:

y – Output (filtered) signal.

Return type:

np.array

References

[1] P. S. R. Diniz, E. A. B. da Silva, e S. L. Netto, Digital Signal Processing: System Analysis and Design. Cambridge University Press, 2010.

gaussianComplexNoise(shapeOut, σ2=1.0)

Generate complex circular Gaussian noise.

Parameters:
  • shapeOut (tuple of int) – Shape of np.array to be generated.

  • σ2 (float, optional) – Variance of the noise (default is 1).

Returns:

noise – Generated complex circular Gaussian noise.

Return type:

np.array

gaussianNoise(shapeOut, σ2=1.0)

Generate Gaussian noise.

Parameters:
  • shapeOut (tuple of int) – Shape of np.array to be generated.

  • σ2 (float, optional) – Variance of the noise (default is 1).

Returns:

noise – Generated Gaussian noise.

Return type:

np.array

lowPassFIR(fc, fa, N, typeF='rect')

Calculate FIR coefficients of a lowpass filter.

Parameters:
  • fc (float) – Cutoff frequency.

  • fa (float) – Sampling frequency.

  • N (int) – Number of filter coefficients.

  • typeF (string, optional) – Type of response (‘rect’, ‘gauss’). The default is “rect”.

Returns:

h – Filter coefficients.

Return type:

np.array

References

[1] P. S. R. Diniz, E. A. B. da Silva, e S. L. Netto, Digital Signal Processing: System Analysis and Design. Cambridge University Press, 2010.

movingAverage(x, N)

Calculate the sliding window moving average of a 2D NumPy array along each column.

Parameters:
  • x (numpy.np.array) – Input 2D array with shape (M, N), where M is the number of samples and N is the number of columns.

  • N (int) – Size of the sliding window.

Returns:

2D array containing the sliding window moving averages along each column.

Return type:

numpy.np.array

Notes

The function pads the signal with zeros at both ends to compensate for the lag between the output of the moving average and the original signal.

phaseNoise(lw, Nsamples, Ts)

Generate realization of a random-walk phase-noise process.

Parameters:
  • lw (scalar) – laser linewidth.

  • Nsamples (scalar) – number of samples to be draw.

  • Ts (scalar) – sampling period.

Returns:

phi – realization of the phase noise process.

Return type:

np.array

References

[1] M. Seimetz, High-Order Modulation for Optical Fiber Transmission. em Springer Series in Optical Sciences. Springer Berlin Heidelberg, 2009.

pnorm(x)

Normalize the average power of each componennt of x.

Parameters:

x (np.array) – Signal.

Returns:

Signal x with each component normalized in power.

Return type:

np.array

pulseShape(pulseType, SpS=2, N=1024, alpha=0.1, Ts=1)

Generate a pulse shaping filter.

Parameters:
  • pulseType (string ('rect','nrz','rrc')) – type of pulse shaping filter.

  • SpS (int, optional) – Number of samples per symbol of input signal. The default is 2.

  • N (int, optional) – Number of filter coefficients. The default is 1024.

  • alpha (float, optional) – Rolloff of RRC filter. The default is 0.1.

  • Ts (float, optional) – Symbol period in seconds. The default is 1.

Returns:

filterCoeffs – Array of filter coefficients (normalized).

Return type:

np.array

quantizer(x, nBits=16, maxV=1, minV=-1)

Quantize the input signal using a uniform quantizer with the specified precision.

Parameters:
  • x (np.array) – The input signal to be quantized.

  • nBits (int) – Number of bits used for quantization. The quantizer will have 2^nBits levels.

  • maxV (float, optional) – Maximum value for the quantizer’s full-scale range (default is 1).

  • minV (float, optional) – Minimum value for the quantizer’s full-scale range (default is -1).

Returns:

The quantized output signal with the same shape as ‘x’, quantized using ‘nBits’ levels.

Return type:

np.array

rcFilterTaps(t, alpha, Ts)

Generate Raised Cosine (RC) filter coefficients.

Parameters:
  • t (np.array) – Time values.

  • alpha (float) – RC roll-off factor.

  • Ts (float) – Symbol period.

Returns:

coeffs – RC filter coefficients.

Return type:

np.array

References

[1] Proakis, J. G., & Salehi, M. (2008). Digital Communications (5th Edition). McGraw-Hill Education.

resample(Ei, param)

Resample signal to a given sampling rate.

Parameters:
  • Ei (np.array) – Input signal.

  • param (core.parameter) –

    Resampling parameters:
    • param.Rs : symbol rate of the signal.

    • param.SpS_in : samples per symbol of the input signal.

    • param.SpS_out : samples per symbol of the output signal.

Returns:

Eo – Resampled signal.

Return type:

np.array

References

[1] P. S. R. Diniz, E. A. B. da Silva, e S. L. Netto, Digital Signal Processing: System Analysis and Design. Cambridge University Press, 2010.

rrcFilterTaps(t, alpha, Ts)

Generate Root-Raised Cosine (RRC) filter coefficients.

Parameters:
  • t (np.array) – Time values.

  • alpha (float) – RRC roll-off factor.

  • Ts (float) – Symbol period.

Returns:

coeffs – RRC filter coefficients.

Return type:

np.array

References

[1] Proakis, J. G., & Salehi, M. (2008). Digital Communications (5th Edition). McGraw-Hill Education.

sigPow(x)

Calculate the average power of x per mode.

Parameters:

x (np.array) – Signal.

Returns:

Average power of x: P = mean(abs(x)**2).

Return type:

scalar

signal_power(x)

Calculate the total power of x.

Parameters:

x (np.array) – Signal.

Returns:

Total power of x: P = sum(abs(x)**2).

Return type:

scalar

symbolSync(rx, tx, SpS, mode='amp')

Symbol synchronizer.

Parameters:
  • rx (np.array) – Received symbol sequence.

  • tx (np.array) – Transmitted symbol sequence.

  • SpS (int) – Samples per symbol of input signals.

Returns:

tx – Transmitted sequence synchronized to rx.

Return type:

np.array

upsample(x, factor)

Upsample a signal by inserting zeros between samples.

Parameters:
  • x (np.array) – Input signal to upsample.

  • factor (int) – Upsampling factor. The signal will be upsampled by inserting factor - 1 zeros between each original sample.

Returns:

xUp – The upsampled signal with zeros inserted between samples.

Return type:

np.array

Notes

This function inserts zeros between the samples of the input signal to increase its sampling rate. The upsampling factor determines how many zeros are inserted between each original sample.

If the input signal is a 2D array, the upsampling is performed column-wise.

References

[1] P. S. R. Diniz, E. A. B. da Silva, e S. L. Netto, Digital Signal Processing: System Analysis and Design. Cambridge University Press, 2010.

DSP algorithms for equalization (optic.dsp.equalization)

edc(Ei, param)

Electronic chromatic dispersion compensation (EDC).

mimoAdaptEqualizer(x[, param, dx])

N-by-N MIMO adaptive equalizer.

dbp(Ei, Fs, Ltotal, Lspan, hz=0.5, alpha=0.2, gamma=1.3, D=16, Fc=193100000000000.0)

Digital backpropagation (symmetric, single-pol.)

Parameters:
  • Ei – input signal

  • Ltotal – total fiber length [km]

  • Lspan – span length [km]

  • hz – step-size for the split-step Fourier method [km][default: 0.5 km]

  • alpha – fiber attenuation parameter [dB/km][default: 0.2 dB/km]

  • D – chromatic dispersion parameter [ps/nm/km][default: 16 ps/nm/km]

  • gamma – fiber nonlinear parameter [1/W/km][default: 1.3 1/W/km]

  • Fc – carrier frequency [Hz][default: 193.1e12 Hz]

  • Fs – sampling frequency [Hz]

Return Ech:

backpropagated signal

edc(Ei, param)

Electronic chromatic dispersion compensation (EDC).

Parameters:
  • Ei (np.array) – Input optical field.

  • param (parameter object (struct)) –

    Object with physical/simulation parameters of the optical channel.

    • param.L: total fiber length [km][default: 50 km]

    • param.D: chromatic dispersion parameter [ps/nm/km][default: 16 ps/nm/km]

    • param.Fc: carrier frequency [Hz] [default: 193.1e12 Hz]

    • param.Fs: sampling frequency [Hz] [default: []]

Returns:

CD compensated signal.

Return type:

np.array

References

[1] S. J. Savory, “Digital coherent optical receivers: Algorithms and subsystems”, IEEE Journal on Selected Topics in Quantum Electronics, vol. 16, nº 5, p. 1164–1179, set. 2010, doi: 10.1109/JSTQE.2010.2044751.

[2] K. Kikuchi, “Fundamentals of Coherent Optical Fiber Communications”, J. Lightwave Technol., JLT, vol. 34, nº 1, p. 157–179, jan. 2016.

mimoAdaptEqualizer(x, param=None, dx=None)

N-by-N MIMO adaptive equalizer.

Parameters:
  • x (np.array) – Input array.

  • dx (np.array, optional) – Syncronized exact symbol sequence corresponding to the received input array x.

  • param (object, optional) –

    Parameter object containing the following attributes:

    • numIter : int, number of pre-convergence iterations (default: 1)

    • nTaps : int, number of filter taps (default: 15)

    • mu : float or list of floats, step size parameter(s) (default: [1e-3])

    • lambdaRLS : float, RLS forgetting factor (default: 0.99)

    • SpS : int, samples per symbol (default: 2)

    • H : np.array, coefficient matrix (default: [])

    • L : int or list of ints, length of the output of the training section (default: [])

    • Hiter : list, history of coefficient matrices (default: [])

    • storeCoeff : bool, flag indicating whether to store coefficient matrices (default: False)

    • runWL: bool, flag indicating whether to run the equalizer in the widely-linear mode. (default: False)

    • alg : str or list of strs, specifying the equalizer algorithm(s) (default: [‘nlms’])

    • constType : str, constellation type (default: ‘qam’)

    • M : int, modulation order (default: 4)

    • prgsBar : bool, flag indicating whether to display progress bar (default: True)

Returns:

  • yEq (np.array) – Equalized output array.

  • H (np.array) – Coefficient matrix.

  • errSq (np.array) – Squared absolute error array.

  • Hiter (list) – History of coefficient matrices.

Notes

Algorithms available: ‘cma’, ‘rde’, ‘nlms’, ‘dd-lms’, ‘da-rde’, ‘rls’, ‘dd-rls’, ‘static’.

References

[1] P. S. R. Diniz, Adaptive Filtering: Algorithms and Practical Implementation. Springer US, 2012.

[2] S. J. Savory, “Digital coherent optical receivers: Algorithms and subsystems”, IEEE Journal on Selected Topics in Quantum Electronics, vol. 16, nº 5, p. 1164–1179, set. 2010, doi: 10.1109/JSTQE.2010.2044751.

[3] K. Kikuchi, “Fundamentals of Coherent Optical Fiber Communications”, J. Lightwave Technol., JLT, vol. 34, nº 1, p. 157–179, jan. 2016.

[4] E. P. Da Silva e D. Zibar, “Widely Linear Equalization for IQ Imbalance and Skew Compensation in Optical Coherent Receivers”, Journal of Lightwave Technology, vol. 34, nº 15, p. 3577–3586, ago. 2016, doi: 10.1109/JLT.2016.2577716.

DSP algorithms for carrier phase and frequency recovery (optic.dsp.carrierRecovery)

bps

Blind phase search (BPS) algorithm

ddpll

Decision-directed Phase-locked Loop (DDPLL) algorithm

viterbi

Viterbi & Viterbi carrier phase recovery algorithm.

fourthPowerFOE

Estimate the frequency offset (FO) with the 4th-power method.

cpr

Carrier phase recovery function (CPR)

bps(Ei, N, constSymb, B)

Blind phase search (BPS) algorithm

Parameters:
  • Ei (complex-valued np.array) – Received constellation symbols.

  • N (int) – Half of the 2*N+1 average window.

  • constSymb (complex-valued np.array) – Complex-valued constellation.

  • B (int) – number of test phases.

Returns:

θ – Time-varying estimated phase-shifts.

Return type:

real-valued np.array

References

[1] T. Pfau, S. Hoffmann, e R. Noé, “Hardware-efficient coherent digital receiver concept with feedforward carrier recovery for M-QAM constellations”, Journal of Lightwave Technology, vol. 27, nº 8, p. 989–999, 2009, doi: 10.1109/JLT.2008.2010511.

cpr(Ei, param=None, symbTx=None)

Carrier phase recovery function (CPR)

Parameters:
  • Ei (complex-valued np.array) – received constellation symbols.

  • param (core.param object, optional) –

    configuration parameters. The default is [].

    • param.alg: CPR algorithm to be used [‘bps’, ‘ddpll’, or ‘viterbi’]

    BPS params:

    • param.M: constellation order. The default is 4.

    • param.N: length of BPS the moving average window. The default is 35.

    • param.B: number of BPS test phases. The default is 64.

    DDPLL params:

    • param.tau1: DDPLL loop filter param. 1. The default is 1/2*pi*10e6.

    • param.tau2: DDPLL loop filter param. 2. The default is 1/2*pi*10e6.

    • param.Kv: DDPLL loop filter gain. The default is 0.1.

    • param.Ts: symbol period. The default is 1/32e9.

    • param.pilotInd: indexes of pilot-symbol locations.

    Viterbi params:

    • param.N: length of the moving average window. The default is 35.

  • symbTx (complex-valued np.array, optional) – Transmitted symbol sequence. The default is [].

Raises:

ValueError – Error is generated if the CPR algorithm is not correctly passed.

Returns:

  • Eo (complex-valued np.array) – Phase-compensated signal.

  • θ (real-valued np.array) – Time-varying estimated phase-shifts.

References

[1] T. Pfau, S. Hoffmann, e R. Noé, “Hardware-efficient coherent digital receiver concept with feedforward carrier recovery for M-QAM constellations”, Journal of Lightwave Technology, vol. 27, nº 8, p. 989–999, 2009, doi: 10.1109/JLT.2008.2010511.

[2] S. J. Savory, “Digital coherent optical receivers: Algorithms and subsystems”, IEEE Journal on Selected Topics in Quantum Electronics, vol. 16, nº 5, p. 1164–1179, set. 2010, doi: 10.1109/JSTQE.2010.2044751.

[3] H. Meyer, Digital Communication Receivers: Synchronization, Channel estimation, and Signal Processing, Wiley 1998. Section 5.8 and 5.9.

ddpll(Ei, Ts, Kv, tau1, tau2, constSymb, symbTx, pilotInd)

Decision-directed Phase-locked Loop (DDPLL) algorithm

Parameters:
  • Ei (complex-valued np.array) – Received constellation symbols.

  • Ts (float scalar) – Symbol period.

  • Kv (float scalar) – Loop filter gain.

  • tau1 (float scalar) – Loop filter parameter 1.

  • tau2 (float scalar) – Loop filter parameter 2.

  • constSymb (complex-valued np.array) – Complex-valued ideal constellation symbols.

  • symbTx (complex-valued np.array) – Transmitted symbol sequence.

  • pilotInd (int np.array) – Indexes of pilot-symbol locations.

Returns:

θ – Time-varying estimated phase-shifts.

Return type:

real-valued np.array

References

[1] H. Meyer, Digital Communication Receivers: Synchronization, Channel estimation, and Signal Processing, Wiley 1998. Section 5.8 and 5.9.

fourthPowerFOE(Ei, Fs, plotSpec=False)

Estimate the frequency offset (FO) with the 4th-power method.

Parameters:
  • Ei (np.array) – Input signal.

  • Fs (float) – Sampling frequency.

  • plotSpec (bool, optional) – Whether to plot the spectrum. Default is False.

Returns:

  • The output signal after applying frequency offset correction.

  • The estimated frequency offset.

Return type:

np.array, float

References

[1] S. J. Savory, “Digital coherent optical receivers: Algorithms and subsystems”, IEEE Journal on Selected Topics in Quantum Electronics, vol. 16, nº 5, p. 1164–1179, set. 2010, doi: 10.1109/JSTQE.2010.2044751.

viterbi(Ei, N=35, M=4)

Viterbi & Viterbi carrier phase recovery algorithm.

Parameters:
  • Ei (np.array) – Input signal.

  • N (int, optional) – Size of the moving average window.

  • M (int, optional) – M-th power order.

Returns:

Estimated phase error.

Return type:

np.array, float

References

[1] S. J. Savory, “Digital coherent optical receivers: Algorithms and subsystems”, IEEE Journal on Selected Topics in Quantum Electronics, vol. 16, nº 5, p. 1164–1179, set. 2010, doi: 10.1109/JSTQE.2010.2044751.

DSP algorithms for clock and timming recovery (optic.dsp.clockRecovery)

gardnerTED

Calculate the timing error using the Gardner timing error detector.

gardnerTEDnyquist

Modified Gardner timing error detector for Nyquist pulses.

interpolator

Perform cubic interpolation using the Farrow structure.

gardnerClockRecovery

Perform clock recovery using Gardner's algorithm with a loop PI filter.

calcClockDrift

Calculate the clock drift in parts per million (ppm) from t_nco values.

calcClockDrift(t_nco_values)

Calculate the clock drift in parts per million (ppm) from t_nco values.

Parameters:

t_nco_values (np.array) – An array containing the relative time delay values provided to the NCO.

Returns:

The clock deviation in parts per million (ppm).

Return type:

float

gardnerClockRecovery(Ei, param=None)

Perform clock recovery using Gardner’s algorithm with a loop PI filter.

Parameters:
  • Ei (numpy.np.array) – Input array representing the received signal.

  • param (core.parameter) –

    Clock recovery parameters:
    • kp : Proportional gain for the loop filter. Default is 1e-3.

    • ki : Integral gain for the loop filter. Default is 1e-6.

    • isNyquist: is the pulse shape a Nyquist pulse? Default is True.

    • returnTiming: return estimated timing values. Default is False.

    • lpad: length of zero padding at the end of the input vector. Default is 1.

    • maxPPM: maximum clock rate expected deviation in PPM. Default is 500.

Returns:

Tuple containing the recovered signal (Eo) and the timing values.

Return type:

tuple

gardnerTED(x)

Calculate the timing error using the Gardner timing error detector.

Parameters:

x (numpy.np.array) – Input array of size 3 representing a segment of the received signal.

Returns:

Gardner timing error detector (TED) value.

Return type:

float

gardnerTEDnyquist(x)

Modified Gardner timing error detector for Nyquist pulses.

Parameters:

x (numpy.np.array) – Input array of size 3 representing a segment of the received signal.

Returns:

Gardner timing error detector (TED) value.

Return type:

float

interpolator(x, t)

Perform cubic interpolation using the Farrow structure.

Parameters:
  • x (numpy.np.array) – Input array of size 4 representing the values for cubic interpolation.

  • t (float) – Interpolation parameter.

Returns:

y – Interpolated signal value.

Return type:

float