In [15]:
# Import DeepMIMO and other needed libraries for this example
import DeepMIMO
import numpy as np
from pprint import pprint
import matplotlib.pyplot as plt

plt.rcParams['figure.figsize'] = [12, 8] # Set default plot size
In [2]:
## Load and print the default parameters
parameters = DeepMIMO.default_params()
pprint(parameters)
{'OFDM': {'RX_filter': 0,
          'bandwidth': 0.05,
          'subcarriers': 512,
          'subcarriers_limit': 64,
          'subcarriers_sampling': 1},
 'OFDM_channels': 1,
 'active_BS': array([1]),
 'bs_antenna': {'radiation_pattern': 'isotropic',
                'shape': array([1, 8, 4]),
                'spacing': 0.5},
 'dataset_folder': './Raytracing_scenarios',
 'dynamic_settings': {'first_scene': 1, 'last_scene': 1},
 'enable_BS2BS': 1,
 'num_paths': 5,
 'row_subsampling': 1,
 'scenario': 'O1_60',
 'ue_antenna': {'radiation_pattern': 'isotropic',
                'shape': array([1, 4, 2]),
                'spacing': 0.5},
 'user_row_first': 1,
 'user_row_last': 1,
 'user_subsampling': 1}
In [3]:
## Change parameters for the setup
# Scenario O1_60 extracted at the dataset_folder
parameters['scenario'] = 'O1_60'
parameters['dataset_folder'] = r'C:\Users\Umt\Desktop\DeepMIMO_scenarios'

parameters['num_paths'] = 10

# User rows 1-100
parameters['user_row_first'] = 1
parameters['user_row_last'] = 100

# Activate only the first basestation
parameters['active_BS'] = np.array([1]) 

parameters['OFDM']['bandwidth'] = 0.05 # 50 MHz
parameters['OFDM']['subcarriers'] = 512 # OFDM with 512 subcarriers
parameters['OFDM']['subcarriers_limit'] = 64 # Keep only first 64 subcarriers

parameters['ue_antenna']['shape'] = np.array([1, 1, 1]) # Single antenna
parameters['bs_antenna']['shape'] = np.array([1, 32, 1]) # ULA of 32 elements
#parameters['bs_antenna']['rotation'] = np.array([0, 30, 90]) # ULA of 32 elements
#parameters['ue_antenna']['rotation'] = np.array([[0, 30], [30, 60], [60, 90]]) # ULA of 32 elements
#parameters['ue_antenna']['radiation_pattern'] = 'isotropic' 
#parameters['bs_antenna']['radiation_pattern'] = 'halfwave-dipole' 
In [4]:
## Generate and inspect the dataset
dataset = DeepMIMO.generate_data(parameters)
Basestation 1

UE-BS Channels
Reading ray-tracing: 100%|████████████████████████████████████████████████████| 18100/18100 [00:00<00:00, 20268.73it/s]
Generating channels: 100%|█████████████████████████████████████████████████████| 18100/18100 [00:04<00:00, 3942.49it/s]
BS-BS Channels
Reading ray-tracing: 100%|██████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 988.52it/s]
Generating channels: 100%|██████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 142.95it/s]
In [5]:
# Number of basestations
len(dataset)
Out[5]:
1
In [6]:
# Keys of a basestation dictionary
dataset[0].keys()
Out[6]:
dict_keys(['user', 'basestation', 'location'])
In [7]:
# Keys of a channel
dataset[0]['user'].keys()
Out[7]:
dict_keys(['paths', 'LoS', 'location', 'distance', 'pathloss', 'channel'])
In [8]:
# Number of UEs
len(dataset[0]['user']['channel'])
Out[8]:
18100
In [9]:
# Shape of the channel matrix
dataset[0]['user']['channel'].shape
Out[9]:
(18100, 1, 32, 64)
In [10]:
# Shape of BS 0 - UE 0 channel
dataset[0]['user']['channel'][0].shape
Out[10]:
(1, 32, 64)
In [11]:
# Path properties of BS 0 - UE 0
pprint(dataset[0]['user']['paths'][0])
{'DoA_phi': array([ 94.2855, 100.091 ,  94.2855, 100.091 ,  40.3649,  40.3649,
        38.0195,  38.0195,  21.0355], dtype=float32),
 'DoA_theta': array([87.5263, 87.5587, 94.4464, 94.8737, 88.3929, 92.8912, 88.4721,
       92.7487, 89.1191], dtype=float32),
 'DoD_phi': array([ -85.7145, -100.538 ,  -85.7145, -100.538 ,  -40.3649,  -40.3649,
       -142.427 , -142.427 , -159.858 ], dtype=float32),
 'DoD_theta': array([92.4737, 92.4413, 94.4464, 94.8737, 91.6071, 92.8912, 91.5279,
       92.7487, 90.8809], dtype=float32),
 'ToA': array([3.09241e-07, 3.13340e-07, 3.09885e-07, 3.14191e-07, 4.75887e-07,
       4.76306e-07, 5.00580e-07, 5.00978e-07, 8.68157e-07], dtype=float32),
 'num_paths': 9,
 'phase': array([-157.337 ,   54.5518,  141.645 , -160.27  ,   88.501 , -144.626 ,
         77.2966,  -78.412 ,   80.9291], dtype=float32),
 'power': array([1.3595650e-11, 9.8197344e-12, 6.9758851e-12, 1.5166997e-12,
       3.8229565e-13, 3.2003716e-13, 2.1350155e-14, 2.0710962e-14,
       2.5527045e-15], dtype=float32)}
In [16]:
## Visualization of a channel matrix

plt.figure()
# Visualize channel magnitude response
# First, select indices of a user and bs
ue_idx = 0
bs_idx = 0
# Import channel
channel = dataset[bs_idx]['user']['channel'][ue_idx]
# Take only the first antenna pair
plt.imshow(np.abs(np.squeeze(channel).T))
plt.title('Channel Magnitude Response')
plt.xlabel('TX Antennas')
plt.ylabel('Subcarriers')
Out[16]:
Text(0, 0.5, 'Subcarriers')
In [17]:
## Visualization of the UE positions and path-losses
loc_x = dataset[bs_idx]['user']['location'][:, 0]
loc_y = dataset[bs_idx]['user']['location'][:, 1]
loc_z = dataset[bs_idx]['user']['location'][:, 2]
pathloss = dataset[bs_idx]['user']['pathloss']
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
im = ax.scatter(loc_x, loc_y, loc_z, c=pathloss)
ax.set_xlabel('x (m)')
ax.set_ylabel('y (m)')
ax.set_zlabel('z (m)')

bs_loc_x = dataset[bs_idx]['basestation']['location'][:, 0]
bs_loc_y = dataset[bs_idx]['basestation']['location'][:, 1]
bs_loc_z = dataset[bs_idx]['basestation']['location'][:, 2]
ax.scatter(bs_loc_x, bs_loc_y, bs_loc_z, c='r')
ttl = plt.title('UE and BS Positions')
In [18]:
fig = plt.figure()
ax = fig.add_subplot()
im = ax.scatter(loc_x, loc_y, c=pathloss)
ax.set_xlabel('x (m)')
ax.set_ylabel('y (m)')
fig.colorbar(im, ax=ax)
ttl = plt.title('UE Grid Path-loss (dB)')