rftool package

Submodules

rftool.EMC module

rftool.EMC.LisnImpedance()

Returns a vector containing the target impedance for MIL-STD-461G The impedance shall be measured into the LISN DUT port with a 50 Ohm load at the instrument port. Additional tolerance is +-20%.

Returns:f [Hz], R [Ohm]
Return type:ndarray, vector
import matplotlib.pyplot as plt
from rftool import LisnImpedance


f, R = LisnImpedance()

plt.semilogx(f, R)
plt.grid()
plt.show()

rftool.LFM module

class rftool.LFM.chirp(Fs=1000.0, T=1, fStart=1, fStop=10, nChirps=16, **kwargs)

Bases: object

Object for generating a set of linear chirps

T = None
getPrimaryChirp()

Generate the primary LFM chirp with no delay.

getSymbolIF(symbol)

Return the IF of the symbols

getSymbolSig(symbol)

Generate chirps for specified symbols.

Parameters:symbol (integer) – Symbol
Returns:The chirp of the specified symbol
Return type:ndarray, time series
modulate(symbolStream=array([1, 0, 1, 0]))

Modulate bit stream to a chirp. One chirp per symbol.

Parameters:symbolStream – The bitstream to be modulated (numpy array).
plotAutocorr()

Plot the autocorrelation of the chirps.

plotDotProd()

Plot the dot-product of the chirps.

Returns:“Correlation” matrix
Return type:ndarray, matrix
plotSymbols()

Plot the various symbols.

plotXcorr()

Plot the cross correlation of the chirps

t = None

rftool.communications module

rftool.communications.EbN0toSNRdB(EbN0, M, Fs, Fsymb)

Calculte the necessary SNR in order to obtain a target Eb/N0.

Parameters:
  • EbN0 (ndarray, scalar or vector) – The intended ratio
  • M (int, scalar) – The order of the modultion
  • Fs – The sample rate of the signal.
  • Fsymb – The symbol rate of the signal (pulse rate).
Returns:

Necessary SNR for obtaining a Eb/N0 in Deci-Bell form.

rftool.communications.Q(x)

The Q-function. (just a translation for readability).

rftool.communications.errorProbabilityBpsk(EbN0)

Probability of error in AWGN as a function of Eb/N0 for Binary Phase Shift Keying (BPSK).

Parameters:EbN0 (ndarray, scalar or vector) – The intended ratio
Returns:Error probability
      1. Rappaport, Wireless Communications Principles and Practice, 2nd ed, Prentice Hall, 1995
rftool.communications.errorProbabilityCoherentFsk(EbN0)

Probability of error in AWGN as a function of Eb/N0 for coherent Frequency Shift Keying (FSK).

Parameters:EbN0 (ndarray, scalar or vector) – The intended ratio
Returns:Error probability.
      1. Rappaport, Wireless Communications Principles and Practice, 2nd ed, Prentice Hall, 1995
rftool.communications.errorProbabilityCoherentMFsk(EbN0, M)

Probability of error in AWGN as a function of Eb/N0 for coherent M-ary Frequency Shift Keying (M-FSK).

Parameters:
  • EbN0 (ndarray, scalar or vector) – The intended ratio
  • M (int, scalar) – The order of the modultion
Returns:

Error probability.

      1. Rappaport, Wireless Communications Principles and Practice, 2nd ed, Prentice Hall, 1995
rftool.communications.errorProbabilityFsk(EbN0)

Probability of error in AWGN as a function of Eb/N0 for non-coherent Frequency Shift Keying (FSK).

Parameters:EbN0 (ndarray, scalar or vector) – The intended ratio
Returns:Error probability.
      1. Rappaport, Wireless Communications Principles and Practice, 2nd ed, Prentice Hall, 1995
rftool.communications.errorProbabilityGMSK(EbN0)

Probability of error in AWGN as a function of Eb/N0 and the 3-dB bandwidth bit-dutation product, BT = 0.25 for Gaussian Minimum Shift Keying (GMSK).

Parameters:EbN0 (ndarray, scalar or vector) – The intended ratio
Returns:Error probability.
      1. Rappaport, Wireless Communications Principles and Practice, 2nd ed, Prentice Hall, 1995
rftool.communications.errorProbabilityMPsk(EbN0, M)

Probability of error in AWGN as a function of Eb/N0 for M-Ary Phase Shift Keying (M-PSK).

Parameters:EbN0 (ndarray, scalar or vector) – The intended ratio
Returns:Error probability.
      1. Rappaport, Wireless Communications Principles and Practice, 2nd ed, Prentice Hall, 1995
rftool.communications.errorProbabilityQam(EbN0, M)

Probability of error in AWGN as a function of Eb/N0 with the minimum Eb and order M for Quadrature Amplitude Modulaion (QAM).

Parameters:
  • EbN0 (ndarray, scalar or vector) – The intended ratio
  • M (int, scalar) – The order of the modultion
Returns:

Error probability.

      1. Rappaport, Wireless Communications Principles and Practice, 2nd ed, Prentice Hall, 1995
rftool.communications.errorProbabilityQpsk(EbN0)

Probability of error in AWGN as a function of Eb/N0 for Quadrature Phase Shift Keying (QPSK).

Parameters:EbN0 (ndarray, scalar or vector) – The intended ratio
Returns:Error probability.
      1. Rappaport, Wireless Communications Principles and Practice, 2nd ed, Prentice Hall, 1995

rftool.estimation module

rftool.estimation.FAM(x, *args, **kwargs)

Estimate the discrete time Spectral Correlation Density (SCD) using the Time-Smoothing FFT Accumulation Method.

Parameters:
  • x (ndarray, time series) – The time series being analyzed
  • **kwargs – See below
Returns:

SCD, f_j, alpha_i. A matrix of the specral correlation for frequencies f_j and cyclefrequencies alpha_i

Return type:

ndarray

Keyword Arguments:
 
  • plot (bool) – Defines whether to plot the SCD, defaults to False
  • scale (str) – Defines the scaling, ‘absolute’, ‘log’, ‘dB’
  • Fs (scalar) – Sample frequency [Hz]
  • method (str) – Defines the method, ‘conj’, ‘non-conj’
class rftool.estimation.HilberHuang(sig, Fs=1)

Bases: object

discreteMatrix(frequencyBins=256, *args, **kwargs)

Hilbert-Huang transform with Hilbert spectral plot. The result is a matric of discrete time-frequency bins with the cumulated intensity of the IMFs. The plot neglects negative frequencies.

Parameters:
  • frequencyBins (int, optional) – The number of discrete bins from 0 Hz to Fs/2, defaults to 256
  • **kwargs – See below
Returns:

A matrix containing the energy sum in each time-frequnecy bin

Return type:

ndarray, matrix

Keyword Arguments:
 
  • includeRes (bool) – Defines whether the residual is included in the spectrum, defaults to False
  • Huang et. al, The empirical mode decomposition and the Hilbert spectrum for nonlinear and non-stationary time series analysis, Proceedings of the Royal Society of London, 1998
  • S.E. Hamdi et al., Hilbert-Huang Transform versus Fourier based analysis for diffused ultrasonic waves structural health monitoring in polymer based composite materials, Proceedings of the Acoustics 2012 Nantes Conference.
discreteSpectrum(frequencyBins=256, *args, **kwargs)

Hilbert-Huang transform with Hilbert spectral plot. The result is a matric of discrete time-frequency bins with the cumulated intensity of the IMFs. The plot neglects negative frequencies.

Parameters:
  • frequencyBins (int, scalar, optional) – Tthe number of discrete bins from 0 Hz to Fs/2, defaults to 256
  • **kwargs – See below
Returns:

a figure with the sum energy in each time-frequnecy bin.

Return type:

fig, ax

Keyword Arguments:
 
  • decimateTime (int) – Decimates along the time axis to reduce the image size. Input Decimation factor, optional
  • includeRes (bool) – Defines whether the residu is included in the spectrum, defaults to False
  • Huang et. al, The empirical mode decomposition and the Hilbert spectrum for nonlinear and non-stationary time series analysis, Proceedings of the Royal Society of London, 1998
  • S.E. Hamdi et al., Hilbert-Huang Transform versus Fourier based analysis for diffused ultrasonic waves structural health monitoring in polymer based composite materials, Proceedings of the Acoustics 2012 Nantes Conference.
spectrum(*args, **kwargs)

Hilbert-Huang transform with Hilbert spectral plot. The plot neglects negative frequencies.

Returns:[description]
Return type:[type]
Keyword Arguments:
 
  • includeRes (bool) – Defines whether the residu is included in the spectrum, defaults to False
  • Huang et. al, The empirical mode decomposition and the Hilbert spectrum for nonlinear and non-stationary time series analysis, Proceedings of the Royal Society of London, 1998
  • S.E. Hamdi et al., Hilbert-Huang Transform versus Fourier based analysis for diffused ultrasonic waves structural health monitoring in polymer based composite materials, Proceedings of the Acoustics 2012 Nantes Conference.
rftool.estimation.bandwidthEstimator(psd, f, threshold)

Estimate the bandwidth of an incomming signal in the frequency domain.

Parameters:
  • psd (ndarray, vector) – The frequency domain signal to be analyzed (dB scale)
  • f (ndarray, vector) – The corresponding frequency vector
  • threshold (scalar) – The power rollof at which the bandwidth is defined in dB
Returns:

fCenter, bw, fUpper, fLower, fCenterIndex, fUpperIndex, fLowerIndex

Return type:

set of scalars

rftool.estimation.carierFrequencyEstimator(sig_t, Fs, *args, **kwargs)

Estimate the carrier frequency of a signal using an autocorrelation method, or a frequency domain maximum likelihood method. Autocorrelation method is applicable for sigle carrier signals as ASK, PSK, QAM. MLE method is applicable for the signal above in addition to continious carrier signals such as chirp. The MLE method utilizes either periodogram or Welch’s method of spectral estimation.

Parameters:
  • sig_t (ndarray, time series) – The signal being analyzed.
  • Fs (scalar) – Sample frequency
  • **kwargs – See below
Returns:

Estimated center frequency

Return type:

scalar

Keyword Arguments:
 
  • method (str) – Decides which method is used, ‘xcor’ for autocorrelation method (default), ‘mle’ for maximum likelihood method.
  • nfft (int, scalar) – Configures the length of the FFT used in the MLE method.

Correlation method:

    1. Yu et al., A blind carrier frequency estimation algorithm for digitally modulated signals, IEEE 2004
  • Wang et al., Improved Carrier Frequency Estimation Based on Autocorrelation, Advances in Computer, Communication, Control and Automation, Springer 2011

Maximum likelihood method:

  • Stotica et al., Maximum Likelihood Estimation of the Parameters of Multiple Sinusoids from Noisy Measurements, IEEE 1989
rftool.estimation.cyclicEstimator(SCD, f, alpha, bandLimited=True, **kwargs)

Estimates center frequency and symbol rate from a Spectral Correlation Density.

Parameters:
  • SCD (ndarray, matrix) – An m,n matrix of the Spectral Correlation Density (complex).
  • f (ndarray, vector) – A frequency vector of length m
  • alpha (ndarray, vector) – A cyclic frequency vector of length n
  • bandLimited (bool, optional) – When set to True, the symbol tate estimator only utilizes the 1 dB bw for estimation. Estimator relies on a >1 dB inband SNR., defaults to True
Returns:

Estimated center frequency and symbol rate.

Return type:

scalar

rftool.estimation.f0MLE(psd, f, peaks, blankDistance=2, resolution=4)

Maximum likelihood estimation of the fundamental frequency of a signal with repeating harmonics in the frequiency domain. A frequency domain intrepetation of [1].

Parameters:
  • psd (ndarray, vector) – the two-sided frequency domain representation of the signal under observation
  • f (ndarray, vector) – The frequency vector of PSD
  • peaks (integer, scalar) – The number of harmonic peaks to include in the estimation
  • blankDistance (int, optional) – The distance which the estimats are neglected, defaults to 2
  • resolution (int, optional) – The fractional resolution of the estimate. When resolution=1, then the PSD resolution is the bound., defaults to 4
Returns:

Estimated funcamental frequency

Return type:

scalar

[1] Wise et. al, Maximum likelihood pitch estimation, IEEE Transactions on Acoustics, Speech, and Signal Processing, 1976

rftool.estimation.f0MleTime(Rxx, f, peaks, blankDistance=20, resolution=1)

Maximum likelihood estimation of the fundamental frequency of a signal with repeating autocorrelation peaks.

Parameters:
  • Rxx (ndarray, vector) – The two-sided (‘full’) autocorrelation
  • f (scalar) – The sampling frequency [Hz]
  • peaks (int, scalar) – The number of harmonic peaks to include in the estimation
  • blankDistance (int, optional) – The distance from full overlap wchich is to be ignored in the estimation, defaults to 20
  • resolution (int, optional) – [description], defaults to 1
Returns:

The fundamental/cyclic frequency f0

Return type:

scalar

[1] Wise et. al, Maximum likelihood pitch estimation, IEEE Transactions on Acoustics, Speech, and Signal Processing, 1976

rftool.estimation.fftQuadraticInterpolation(X_f, f, **kwargs)

Estimate the carrier frequency of a signal using quadratic interpolation. This function is called from carierFrequencyEstimator.

Parameters:
  • X_f (ndarray, vector) – The complex frequency domain vector of the signal.
  • f (ndarray, vector) – The corresponding frequency vector.
Returns:

The center frequency and its index

Return type:

scalar

rftool.estimation.inspectPackage(sig_t, Fs, T, **kwargs)

Estimate the number of unique symbols (pulses) in a packet

Parameters:
  • sig_t (time series) – The extracted packet in time domain
  • Fs (scalar) – The sampling frequency [Hz]
  • T (scalar) – The symbol periond [s]
Returns:

The packet as a vector of symbols. Symbols are numbered as they appear in the signal.

symbolAlpahebt, a vector of the time domain symbols. :rtype: set of two vectors

Keyword Arguments:
 
  • threshold (scalar) – The threshhold for which two sybls are deemed identical
rftool.estimation.instFreq(sig_t, Fs, method='derivative', *args, **kwargs)

Estimate the instantaneous frequency of a time series.

Parameters:
  • sig_t (ndarray, time series) – Time series being analyzed
  • Fs (scalar) – The sample frequency [Hz]
  • method (str, optional) –

    Parameter deciding the estimator, defaults to ‘derivative’

    • ’derivative’ is a numerical approximation of the direct derivative approach
    • ’BarnesTwo’ is Barnes “two-point filter approximation”.
    • ’BarnesThree’ is the Barnes “three-point filter approximation”.
    • ’Claerbouts’ is the Claerbouts approximation.
    • ’maxDHHT’ is a numerical maximum likelihood method on the Discretized Hilbert spectrum.
    • ’polyLeastSquares’ uses a method of phase polynomial with a least squares coefficient estimation.
    • ’polyMle’ uses a method of phase polynomial with a maxumum likelihood coefficient estimation.
Returns:

The instantaneous frequency as a function of time

Return type:

ndarray, time series

      1. Barnes, The calculation of instantaneous frequency and instantaneous bandwidth, GEOPHYSICS, VOL. 57, NO. 11, 1992
  • Boashash et. al, Algorithms for instantaneous frequency estimation: a comparative study, Proceedings of SPIE, 1990
rftool.estimation.pulseCarrierCRLB(p_n, Fs, K, l_k, N)

Calculates the Cramer-Rao Lower Bound for estimation of carrier frequency of a pulse train of unknown coherent pulses. Returns CRLB in angular frequency.

p_n is a single pulse (time series) of appropriate power.
K is the number of pulses in the pulse train. l_k is the discrete pulse times [sample].

N is a scalar or vector representing the variance of the noise. (Noise power).

  • POURHOMAYOUN, et al., Cramer-Rao Lower Bound for Frequency Estimation for Coherent Pulse Train With Unknown Pulse, IEEE 2013

rftool.pcb module

rftool.pcb.Z01HJ(h, w, e_r)

Calculate Z01 from Hammerstad-Jensen (simplified formula). Impedance in strip with air dielectric.

Parameters:
  • h (scalar) – Strip height over dielectric [M]
  • w (scalar) – Strip width
  • e_r (scalar) – The relative permittivity of the dielectric
Returns:

Strip impeadnce

Return type:

scalar

_images/aafig-82199a88cb9f25969f9a29334d85020089391bfe.svg
      1. Edwards and M. B. Steer, Foundations for microstrip circuit design, fourth edition, Wiley, 2016
rftool.pcb.effectivePermittivityHJ(h, w, e_r)

Calculate effective permittivity from Hammerstad-Jensen (simplified formula).

Parameters:
  • h (scalar) – Strip height over dielectric [M]
  • w (scalar) – Strip width
  • e_r (scalar) – The relative permittivity of the dielectric
Returns:

Strip impeadnce

Return type:

scalar

_images/aafig-82199a88cb9f25969f9a29334d85020089391bfe.svg
      1. Edwards and M. B. Steer, Foundations for microstrip circuit design, fourth edition, Wiley, 2016
rftool.pcb.effectivePermittivityYa(h, w, e_r, f)

Calculate frequency dependendt effective permittivity form Yamashita (dispersion).

Parameters:
  • h (scalar) – Strip height over dielectric [M]
  • w (scalar) – Strip width
  • e_r (scalar) – The relative permittivity of the dielectric
  • f (scalar) – The signal frequency [Hz]
Returns:

Strip impedance

Return type:

scalar

_images/aafig-6ac35240e49ad89111094457864962cb01c7ac8f.svg
      1. Edwards and M. B. Steer, Foundations for microstrip circuit design, fourth edition, Wiley, 2016
rftool.pcb.effectiveStripWidthHJ(h, w, t, e_r)

Calculate effective width w_eff for a microstrip of finite thickness. Hammerstad and Jenson’s method. This effective width can be used in microstripImpedanceHJ to take strip thickness into account.

Parameters:
  • h (scalar) – Strip height over dielectric [M]
  • w (scalar) – Strip width
  • t (scalare) – The strip thickness
  • e_r (scalar) – The relative permittivity of the dielectric
Returns:

Effective strip width

Return type:

scalar

_images/aafig-d6c20ec1cc96db6cecebfb22d339e94387483eaa.svg
      1. Edwards and M. B. Steer, Foundations for microstrip circuit design, fourth edition, Wiley, 2016
rftool.pcb.microstripImpedanceHJ(h, w, e_r)

Calculate Characteristic Impedance from Hammerstad-Jensen (simplified formula).

Parameters:
  • h (scalar) – Strip height over dielectric [M]
  • w (scalar) – Strip width
  • e_r (scalar) – The relative permittivity of the dielectric
Returns:

Strip impeadnce

Return type:

scalar

_images/aafig-82199a88cb9f25969f9a29334d85020089391bfe.svg
      1. Edwards and M. B. Steer, Foundations for microstrip circuit design, fourth edition, Wiley, 2016
rftool.pcb.microstripImpedanceKJ(h, w, e_r, f)

Calculate frequency dependendt Characteristic Impedance form Kirschning and Jansen.

Parameters:
  • h (scalar) – Strip height over dielectric [M]
  • w (scalar) – Strip width
  • e_r (scalar) – The relative permittivity of the dielectric
  • f (scalar) – The signal frequency [Hz]
Returns:

Strip impedance

Return type:

scalar

_images/aafig-9888d3e2ed04cb2381aa8a2afe12143a962a69e3.svg

Accurate within 0.6% for: f < 60 [GHz] 1 <= e_r <= 20 0.1 <= w/h <= 100 0 <= h/lambda_0 <= 0.13

      1. Edwards and M. B. Steer, Foundations for microstrip circuit design, fourth edition, Wiley, 2016
rftool.pcb.microstripImpedanceYa(h, w, e_r, f)

Calculate frequency dependendt Characteristic Impedance form Yamashita.

Parameters:
  • h (scalar) – Strip height over dielectric [M]
  • w (scalar) – Strip width
  • e_r (scalar) – The relative permittivity of the dielectric
  • f (scalar) – The signal frequency [Hz]
Returns:

Strip impedance

Return type:

scalar

_images/aafig-9888d3e2ed04cb2381aa8a2afe12143a962a69e3.svg

Accurate within 1% for 0.1 < f < 100 [GHz]

      1. Edwards and M. B. Steer, Foundations for microstrip circuit design, fourth edition, Wiley, 2016
rftool.pcb.shieldedMicrostripImpedanceHJ(h, w, t, a, b, e_r)

Calculate Characteristic Impedance of microstrip in a metallic enclosure. Hammerstad-Jensen (simplified formula) quasi-static impedance. Using Hammerstad-Jensen effective width calculation.

Parameters:
  • h (scalar) – Strip height over dielectric [M]
  • w (scalar) – Strip width
  • t (scalare) – The strip thickness
  • a (scalar) – The enclosure height
  • b (scalar) – The enclosure width
  • e_r (scalar) – The relative permittivity of the dielectric
Returns:

Strip impedance

Return type:

scalar

_images/aafig-e6f26155fbd86ebdc5c07cf8c254be0a26b373a4.svg
      1. Edwards and M. B. Steer, Foundations for microstrip circuit design, fourth edition, Wiley, 2016

rftool.radar module

rftool.radar.ACF(x, Fs, plot=True, **kwargs)

Normalized autocorrelation Function of input x.

Parameters:
  • x (Vector or matrix, ndarray) – The signal being analyzed. If x is a matrix, the correlation is performed columnwise
  • Fs (integer, scalar) – The sample frequency.
  • plot (bool, optional) – Decides whether to plot the result, defaults to True
  • **kwargs – See below
Returns:

The output is 2*len(x)-1 long.

Return type:

Vector or matrix. If the input is a matrix, the output is a matrix (ndarray)

Keyword Arguments:
 
  • label (list) – The plot label for each vector as such: [‘label0’, ‘label1’]
rftool.radar.Albersheim(Pfa, Pd, N)

Calculate required SNR for non-coherent integration over N pulses, by use of Albersheims equation.

Parameters:
  • Pfa (scalar) – The probability of false alarm (linear)
  • Pd (scalar) – The probability of detection (linear)
  • N (Integer) – The number of non-coherently integrated pulses
Returns:

Required SNR in dB

Return type:

scalar

Accurate within 0.2 dB for: 10^-7 < Pfa < 10^-3 0.1 < Pd < 0.9 1 <= N < 8096

      1. Richards and J. A. Scheer and W. A. Holm, Principles of Modern Radar, SciTech Publishing, 2010
rftool.radar.Shnidman(Pfa, Pd, N, SW)

Calculate required SNR for non-coherent integration over N pulses for swerling cases, by use of Shnidman equation.

Parameters:
  • Pfa (scalar) – The probability of false alarm (linear)
  • Pd (scalar) – The probability of detection (linear)
  • N (Integer) – The number of non-coherently integrated pulses
  • SW (Integer) – The Swerling model 0-4 (zero is non-swerling)
Returns:

Required SNR in dB.

Return type:

scalar

Accurate within 1 dB for: 10^-7 < Pfa < 10^-3 0.1 <= Pd =< 0.99*10^-9 1 <= N < 100

      1. Richards and J. A. Scheer and W. A. Holm, Principles of Modern Radar, SciTech Publishing, 2010
class rftool.radar.chirp(Fs=1)

Bases: object

Object for generating linear and non-linear chirp generation.

PSD(sig_t, plot=False)

Calculates Power Spectral Density in dBW/Hz.

Parameters:
  • sig_t (ndarray) – Signal time series.
  • plot (bool, optional) – Decides whether to plot the PSD, defaults to False
Returns:

PSD as a vector (dBW/Hz)

Return type:

ndarray, vector

T = None
W(omega)

Lookup table for the W function. Takes instantaneous frequency as input.

Parameters:omega (ndarray) – Insatnaneous frequency vector/time series
Returns:Chirp bandwidth
Return type:scalar
checkSampleRate()

Check that the sample rate is within the nyquist criterion. I.e. that no phase difference between two consecutive samples exceeds pi.

gamma_t_objective(scale)

Objective function for finding gamma_t that meets the constraints. scale scales the gamma function.

Returns:Cost
Return type:scalar
genFromPoly(direction=None)

Generate Non-Linear Frequency Modualted (NLFM) chirps based on a polynomial of arbitrary order. :param direction: Controls the chirp direction. 'inverted' inverts the chirp direction, defaults to None :type direction: str :return: Chirp :rtype: ndarray, time series

genNumerical(direction=None)

Generate Non.Linear Frequency Modualted (NLFM) chirps.

Parameters:direction (str) – Controls the chirp direction. 'inverted' inverts the chirp direction, defaults to None
Returns:Chirp
Return type:ndarray, time series
getChirpRate(poly=True, plot=True)

Calculate the chirp rate as a function of time.

Parameters:
  • poly (bool, optional) – Decides if the chirprate is calculated based on polynoimial coefficients, defaults to True
  • plot (bool, optional) – Decides whether to plot the chirp rate, defaults to True
Returns:

Chirp rate function

Return type:

ndarray, time series

getCoefficients(window, T=0.001, targetBw=10000.0, centerFreq=20000.0, order=48)

Calculate the necessary coefficients in order to generate a NLFM chirp with a specific magnitude envelope (in frequency domain). Chirp generated using rftool.radar.generate(). Coefficients are found through non-linear optimization.

Parameters:
  • window (ndarray) – The window function for the target PSD. It is used as a LUT based function from -Omega/2 to Omega/2, where Omega=targetBw.
  • T (scalar, optional) – The pulse duration [s]., defaults to 1e-3
  • targetBw (scalar, optional) – The taget bandwidth of the chirp [Hz], defaults to 10e3
  • centerFreq (scalar, optional) – The center frequency of the chirp [Hz], defaults to 20e3
  • order (int, scalar, optional) – he order of the phase polynomial used to generate the chirp frequency characteristics [integer], defaults to 48
Returns:

Polynomial coefficients

Return type:

ndarray, vector

getInstFreq(poly=True, plot=True)

Calculate the instantaneous frequency as a function of time

Parameters:
  • poly (bool, optional) – Decides whther to use polynomial coefficients, defaults to True
  • plot (bool, optional) – Decides whether to plot the IF, defaults to True
Returns:

Instantaneous frequency

Return type:

ndarray, time series

modulate(bitstream=array([1, 0, 1, 0]))

Modulate bit stream to a chirp. One chirp per bit. A 1 is represented as a forward time chirp. A zero is represented as a time-reversed chirp.

bitStream is the bitstream to be modulated (numpy array).

Parameters:bitstream (vector, optional) – [description], defaults to np.array([1,0,1,0])
Returns:Modulated waveform
Return type:ndarray, time series
t = None
rftool.radar.upconvert(sig, f_c, Fs=1)

Upconvert baseband waveform to IF. :param f_c: The IF center frequency. :type f_c: scalar :param Fs: The sample frequency. :type Fs: integer, scalar :return: The upconverted signal. :rtype: ndarray

rftool.temcell module

rftool.temcell.chamberDimensions(minHeight=0.1, minWidth=0.3, minLength=0.3)

Optimization routine for solving the physical dimensions for the chamber which satisifies a 50 ohm impedance. minHeight is the height of the intended test object. minWidth is the x and y dimention of the intended test area.

rftool.temcell.chamberImpedance(x)

Dimension calculations for an open TEM cell. S. M. Satav et al., Do-it-Yourself Fabrication of an Open TEM Cell for EMC Pre-compliance, Indian Institute of Technology-Bombay, 2008 Taking in a parameter vector for the different dimensions.

Chamber below, with ceptum in the center. .. aafig:

:aspect: 60
:scale: 150
:proportional:
:textual:
 _______
/_______        \_______/

rftool.utility module

rftool.utility.Gamma2VSWR(Gamma)

Convert between reflection coefficient Gamma and Voltage Standing Wave Ratio (VSWR)

Parameters:Gamma (complex scalar) – The reflection coefficient
Returns:VSVR
Return type:real scalar
rftool.utility.db2mag(dB)

Conversion between logaithmic decibel and linear scale

Parameters:dB (scalar, vector or matrix) – dB value
Returns:The converted magnitude (linear scale)
Return type:scalar, vector or matrix
rftool.utility.db2pow(dB)

Conversion between logaithmic decibel and linear scale

Parameters:dB (scalar, vector or matrix) – dB value
Returns:Conerted power value (linear scale)
Return type:scalar, vector or matrix
rftool.utility.energy(x)

Signal energy operator

Parameters:x (ndarray, time series) – Time series
Returns:Signal energy
Return type:scalar
rftool.utility.indefIntegration(x_t, dt)

Indefinite-like numerical integration. Takes in a vector (function), returns the integrated vector(function).

Parameters:
  • x_t (ndarray, vector) – Input vector
  • dt (scalar) – Time delta between samples
Returns:

Numerical integral

Return type:

ndarray, vector

rftool.utility.mag2db(mag)

Conversion between linear magnitude (voltage etc.) and logaithmic decibel scale

Parameters:mag (scalar, vector or matrix) – The magnitude
Returns:The converted dB value
Return type:scalar, vector or matrix
rftool.utility.magnitudeSpectrum(sig, Fs, nfft=2048, plot=False)

Normalized magnitude spectrumPower spectral density sig is the signal to be analyzed Fs is the sampling frequency [Hz] nfft is the length of the FFT. Is set to the singal length if the nfft<len(sig)

Parameters:
  • sig (ndarray, time series) – Inpu time series
  • Fs (scalar) – Sample frequency [Hz]
  • nfft (int, optional) – Length of DFT, defaults to 2048
  • plot (bool, optional) – Decides wheter to plot the spectrum, defaults to False
Returns:

f, sig_f

Return type:

set of two vectors

rftool.utility.periodogram(sig, Fs, nfft=2048)

Calculate power spectral density using a Periodogram

Parameters:
  • sig (ndarray, time series) – Time series
  • Fs (scalar) – Sample frequency [Hz]
  • nfft (int, optional) – DFT length, defaults to 2048
rftool.utility.pow2db(power)

Conversion between linear power (Watt etc.) and logaithmic decibel scale

Parameters:power (scalar, vector or matrix) – The input power value
Returns:The converted power value
Return type:scalar, vector or matrix
rftool.utility.pow2normdb(pow)

Conversion between linear power normalized logaithmic decibel scale

Parameters:mag (scalar, vector or matrix) – The magnitude
Returns:The converted dB value
Return type:scalar, vector or matrix
rftool.utility.powerdB(x)

Calculate the average signal power in dBW.

Parameters:x (ndarray, time series) – A time series
Returns:The avereage power
Return type:scalar
rftool.utility.welch(x, Fs, nfft=2048)

Wrapper for welch spectral power estimate.

Parameters:
  • x (ndarray, time series) – Input Time series
  • Fs (scalar) – Sample frequency [Hz]
  • nfft (int, optional) – Length of DFT, defaults to 2048
Returns:

f, Pxx_den

Return type:

Set of two vectors

rftool.utility.wgnSnr(x, SNRdB)

Add noise to obtain an intendet SNR.

Parameters:
  • x (ndarray, time series) – Clean time series
  • SNRdB (scalar) – Target SNR in dB
Returns:

Noisy time series

Return type:

ndarray, time series

rftool.utility.wgndB(x, dB)

Apply white Gaussian noise of specified power in dBW to signal.

Parameters:
  • x (ndarray, time series) – Clean time series
  • dB (scalar) – Target noise power level [dBW]
Returns:

Noisy signal

Return type:

ndarray, time series

Module contents