RAN Utils#
General utility functions for RAN algorithms.
Overview#
The RAN Utils module provides:
HDF5 I/O - Load and save data in HDF5 format
Data Transformation - Key mapping and data manipulation
Measurements - dB conversions and calculations
Timing Utilities - Performance measurement tools
API Reference#
Utils package.
- ran.utils.db(x: numpy.typing.ArrayLike) FloatArrayNP[source]#
Compute 10*log10(x) elementwise.
- Parameters:
x (array-like) – Linear-scale input. Must be positive to avoid -inf results.
- Returns:
Decibel-scale output as float64.
- Return type:
np.ndarray
- ran.utils.hdf5_load(filename: Path | str) dict[str, Any][source]#
Load data from an HDF5 file.
- Parameters:
filename (Path) – Path object pointing to the HDF5 file
- Returns:
dict
- Return type:
Dictionary containing datasets
- ran.utils.hdf5_save( ) None[source]#
Save a flat dict of numpy arrays/scalars to an HDF5 file.
- Parameters:
Notes
Behavior matches the inverse of hdf5_load:
Real arrays are saved transposed
Complex arrays are saved as structured dataset with re and im fields, each already transposed
Python scalars are saved as 0-d datasets
Only top-level datasets are supported (no groups), matching the loader
- ran.utils.load_config(cfg_path: Path) dict[source]#
Load configuration from YAML file.
- Parameters:
cfg_path – Path to config file.
- Returns:
Configuration dictionary
- ran.utils.max_abs_diff( ) tuple[float, float, float, float][source]#
Compare two arrays and optionally print the differences.
- Parameters:
x – First array to compare.
y – Second array to compare.
eps – Small value to avoid division by zero.
- Returns:
max_abs (Maximum absolute difference.)
mean_abs (Mean absolute difference.)
max_rel_pct (Maximum relative percentage difference.)
mean_rel_pct (Mean relative percentage difference.)