mathFunctions (skrf.mathFunctions)

Provides commonly used mathematical functions.

Mathematical Constants

Some convenient constants are defined in the skrf.constants module.

Complex Component Conversion

complex_2_reim(z)

Return real and imaginary parts of a complex number.

complex_2_magnitude(z)

Return the magnitude of the complex argument.

complex_2_db(z)

Return the magnitude in dB of a complex number (as \(20\log_{10}(|z|)\))..

complex_2_db10(z)

Return the magnitude in dB of a complex number (as \(10\log_{10}(|z|)\)).

complex_2_radian(z)

Return the angle complex argument in radian.

complex_2_degree(z)

Returns the angle complex argument in degree.

complex_2_magnitude(z)

Return the magnitude of the complex argument.

complex_2_quadrature(z)

Take a complex number and returns quadrature, which is (length, arc-length from real axis)

complex_components(z)

Break up a complex array into all possible scalar components.

Magnitude and decibel

magnitude_2_db(z[, zero_nan])

Convert linear magnitude to dB.

mag_2_db(z[, zero_nan])

Convert linear magnitude to dB.

mag_2_db10(z[, zero_nan])

Convert linear magnitude to dB.

db_2_magnitude(z)

Convert dB to linear magnitude.

db_2_mag(z)

Convert dB to linear magnitude.

db10_2_mag(z)

Convert dB to linear magnitude.

Phase Unwrapping

unwrap_rad(phi)

Unwraps a phase given in radians.

sqrt_phase_unwrap(z)

Take the square root of a complex number with unwrapped phase.

Unit Conversion

radian_2_degree(rad)

Convert angles from radians to degrees.

degree_2_radian(deg)

Convert angles from degrees to radians.

np_2_db(x)

Converts a value in Nepers (Np) to decibel (dB).

db_2_np(db)

Converts a value in decibel (dB) to neper (Np).

feet_2_meter([feet])

Convert length in feet to meter.

meter_2_feet([meter])

Convert length in meter to feet.

db_per_100feet_2_db_per_100meter([...])

Convert attenuation values given in dB/100ft to dB/100m.

Scalar-Complex Conversion

These conversions are useful for wrapping other functions that don’t support complex numbers.

complex2Scalar(z)

Serialize a list/array of complex numbers

scalar2Complex(s)

Unserialize a list/array of real and imag numbers into a complex array.

Special Functions

dirac_delta(x)

Calculate Dirac function.

neuman(x)

Calculate Neumans number.

null(A[, eps])

Calculate the null space of matrix A.

cross_ratio(a, b, c, d)

Calculate the cross ratio of a quadruple of distinct points on the real line.

Random Number Generation

set_rand_rng(rng)

Set the global numpy random number generator instance for generating random numbers in scikit-rf.

rand_rng()

Obtain the global numpy random number generator instance.

rand_c(*size[, rng])

Creates a complex random array of shape s.

Various Utility Functions

psd2TimeDomain(f, y[, windowType])

Convert a one sided complex spectrum into a real time-signal.

rational_interp(x, y[, d, epsilon, axis, ...])

Interpolates function using rational polynomials of degree d.

ifft(x)

Transforms S-parameters to time-domain bandpass.

irfft(x[, n])

Transforms S-parameters to time-domain, assuming complex conjugates for values corresponding to negative frequencies.

is_square(mat)

Tests whether mat is a square matrix.

is_symmetric(mat[, tol])

Tests mat for symmetry.

is_Hermitian(mat[, tol])

Tests whether mat is Hermitian.

is_positive_definite(mat[, tol])

Tests mat for positive definiteness.

is_positive_semidefinite(mat[, tol])

Tests mat for positive semidefiniteness.

get_Hermitian_transpose(mat)

Returns the conjugate transpose of mat.

sqrt_known_sign(z_squared, z_approx)

Return the square root of a complex number, with sign chosen to match z_approx.

find_correct_sign(z1, z2, z_approx)

Create new vector from z1, z2 choosing elements with sign matching z_approx.

find_closest(z1, z2, z_approx)

Return z1 or z2 depending on which is closer to z_approx.

inf_to_num(x)

Convert inf and -inf's to large numbers.

rsolve(A, B)

Solves x @ A = B.

nudge_eig(mat[, cond, min_eig])

Nudge eigenvalues with absolute value smaller than max(cond * max(eigenvalue), min_eig) to that value.