Utilities¶
DeepMIMO provides utility modules organized by function:
deepmimo/utils/
├── scenarios.py (Scenario management)
├── io.py (File I/O operations)
├── geometry.py (Geometric calculations)
├── data_structures.py (Custom data structures)
└── dict_utils.py (Dictionary utilities)
deepmimo/datasets/sampling.py
├── Unit Conversion (dbw2watt)
└── Position Sampling (get_uniform_idxs, get_linear_idxs, get_grid_idxs)
deepmimo/generator/geometry.py
└── Beamforming (steering_vec)
Scenario Management¶
import deepmimo as dm
# Get available scenarios
scenarios = dm.get_available_scenarios()
# Get scenario paths
folder = dm.get_scenario_folder('scenario_name')
params = dm.get_params_path('scenario_name')
Get the absolute path to a specific scenario folder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_name
|
str
|
Name of the scenario |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Absolute path to the scenario folder |
Get the absolute path to a scenario's params file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scenario_name
|
str
|
Name of the scenario |
required |
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Absolute path to the scenario's params file |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the scenario folder or params file is not found |
Get list of available scenarios in the scenarios directory.
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
List of scenario folder names |
User Sampling¶
# Get uniform sampling indices
idxs = dm.get_uniform_idxs(
n_ue=1000, # Number of users
grid_size=[10, 10], # Grid dimensions
steps=[2, 2] # Sampling steps
)
# Get indices for specific rows in a grid dataset (if it's a grid)
idxs = dataset.get_row_idxs(np.arange(40, 60)) # Get rows 40-59
# Get indices for specific columns in a grid dataset (if it's a grid)
idxs = dataset.get_col_idxs(np.arange(40, 60)) # Get columns 40-59
# Get positions within limits
idxs = dm.get_idxs_with_limits(
data_pos,
x_min=0, x_max=100,
y_min=0, y_max=100,
z_min=0, z_max=50
)
# Create linear sampling along a path
idxs = dm.get_linear_idxs(
rx_pos, # Receiver positions [N, 3]
start_pos=[0, 0, 0], # Start position
end_pos=[100, 0, 0], # End position
n_steps=100 # Number of samples
)
User sampling examples
See the User Sampling section of the DeepMIMO Manual for examples.
Return indices of users at uniform intervals.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_ue
|
int
|
Number of users |
required |
grid_size
|
ndarray
|
Grid size [x_size, y_size] |
required |
steps
|
list[int]
|
List of sampling steps for each dimension [x_step, y_step] |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of indices for uniformly sampled users |
Raises:
| Type | Description |
|---|---|
ValueError
|
If dataset does not have a valid grid structure |
Return indices of users within specified coordinate limits.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_pos
|
ndarray
|
User positions array [n_users, 3] |
required |
**limits
|
float
|
Coordinate limits as keyword arguments: x_min, x_max: X coordinate limits y_min, y_max: Y coordinate limits z_min, z_max: Z coordinate limits |
{}
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of indices for users within limits |
Return indices of users in the specified rows or columns, assuming a grid structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
grid_size
|
ndarray
|
Grid size as [x_size, y_size] where x_size is number of columns and y_size is number of rows |
required |
axis
|
str
|
Either 'row' or 'col' to specify which indices to get |
required |
idxs
|
int | list[int] | ndarray
|
Array of row or column indices to include |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of indices of receivers in the specified rows or columns |
Raises:
| Type | Description |
|---|---|
ValueError
|
If axis is not 'row' or 'col' |
Return indices of users along a linear path between two points.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rx_pos
|
ndarray
|
Positions of dataset points |
required |
start_pos
|
ndarray
|
Starting position coordinates (2D or 3D) |
required |
end_pos
|
ndarray
|
Ending position coordinates (2D or 3D) |
required |
n_steps
|
int
|
Number of steps along the path (default: 100) |
required |
filter_repeated
|
bool
|
Whether to filter repeated positions (default: True) |
True
|
Returns:
| Type | Description |
|---|---|
ndarray
|
Array of indices of users along the linear path |
User sampling examples
See the User Sampling section of the DeepMIMO Manual for examples.
Beamforming¶
Beamforming examples
See the Beamforming section of the DeepMIMO Manual for examples.
Calculate the steering vector for an antenna array.
This function computes the normalized array response vector for a given array geometry and steering direction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array
|
NDArray
|
Array of antenna positions |
required |
phi
|
float
|
Azimuth angle in degrees. (0°=+x, 90°=+y) Defaults to 0. |
0
|
theta
|
float
|
Elevation angle in degrees. (0°=xy-plane, 90°=+z) Defaults to 0. |
0
|
spacing
|
float
|
Antenna spacing in wavelengths. Defaults to 0.5. |
0.5
|
Returns:
| Name | Type | Description |
|---|---|---|
NDArray |
NDArray
|
Complex normalized steering (array response) vector |
Unit Conversions¶
# Convert dBW to Watts
power_w = dm.dbw2watt(power_dbw)
Convert power from dBW to Watts.
This function performs the standard conversion from decibel-watts (dBW) to linear power in Watts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
val
|
float | ndarray
|
Power value(s) in dBW |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
Power value(s) in Watts |
Zip & Unzip¶
# File compression
dm.zip('path/to/folder')
dm.unzip('path/to/file.zip')
Create zip archive of folder contents.
This function creates a zip archive containing all files and subdirectories in the specified folder. The archive is created in the same directory as the folder with '.zip' appended to the folder name. The directory structure is preserved in the zip.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
folder_path
|
str
|
Path to folder to be zipped |
required |
Returns:
| Type | Description |
|---|---|
str
|
Path to the created zip file |
Extract a zip file to its parent directory.
This function extracts the contents of a zip file to the directory containing the zip file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_to_zip
|
str
|
Path to the zip file to extract. |
required |
Raises:
| Type | Description |
|---|---|
BadZipFile
|
If zip file is corrupted. |
OSError
|
If extraction fails due to file system issues. |
Returns:
| Type | Description |
|---|---|
str
|
Path to the extracted folder |