Other Utilitiy Functions

The module utils.py contains utility classes and functions used by other modules in NeoRadium.

neoradium.utils.toRadian(angle)

Converts an angle (or array of angles) from degrees to radians. Returns None unchanged so that optional-angle parameters can be passed through transparently.

Parameters:

angle (float, NumPy array, or None) – The angle(s) in degrees.

Returns:

The same input converted to radians, or None if angle is None.

Return type:

float, NumPy array, or None

neoradium.utils.toDegrees(angle)

Converts an angle (or array of angles) from radians to degrees. Returns None unchanged so that optional-angle parameters can be passed through transparently.

Parameters:

angle (float, NumPy array, or None) – The angle(s) in radians.

Returns:

The same input converted to degrees, or None if angle is None.

Return type:

float, NumPy array, or None

neoradium.utils.toLinear(x)

Converts a value (or array of values) from decibels (dB) to linear scale using \(10^{x/10}\).

Parameters:

x (float or NumPy array) – Value(s) in dB.

Returns:

The corresponding linear value(s).

Return type:

float or NumPy array

neoradium.utils.toDb(x)

Converts a value (or array of values) from linear scale to decibels (dB) using \(10\log_{10}(x)\).

Parameters:

x (float or NumPy array) – Linear value(s). Must be positive; toDb(0) returns -inf.

Returns:

The corresponding value(s) in dB.

Return type:

float or NumPy array

neoradium.utils.herm(x)

Returns the Hermitian (conjugate) transpose of x along its last two axes — i.e., \(x^H\) for batched matrix operations where leading dimensions broadcast and only the trailing two axes are transposed.

Parameters:

x (NumPy array) – Input array of shape (..., M, N).

Returns:

Array of shape (..., N, M) containing the conjugate transpose of x along the last two axes.

Return type:

NumPy array

neoradium.utils.getMse(h, hEst)

Returns the Mean Squared Error between an estimate and a reference:

\[\text{MSE} = \frac{1}{N} \sum |\hat{h} - h|^2\]

where the sum runs over all elements of the input arrays.

Parameters:
  • h (NumPy array) – The reference (true) values.

  • hEst (NumPy array) – The estimated values. Must have the same shape as h.

Returns:

The mean squared error.

Return type:

float

neoradium.utils.getNmse(u, uEst)

Returns the Normalized Mean Squared Error between an estimate uEst and a reference u, following the definition used by MATLAB’s goodnessoffit:

\[\text{NMSE} = \frac{\sum |\hat{u} - u|^2}{\sum |\bar{u} - u|^2}\]

where \(\bar{u}\) is the mean of the reference. NMSE is dimensionless and equals 1.0 for a trivial estimator that just returns the reference mean.

Parameters:
  • u (NumPy array) – The reference values.

  • uEst (NumPy array) – The estimated values. Must have the same shape as u.

Returns:

The normalized mean squared error.

Return type:

float