-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathexample.py
111 lines (84 loc) · 3.13 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# -*- coding: utf-8 -*-
"""
% --- DeepMIMO Python: A Generic Dataset for mmWave and massive MIMO ----%
% Authors: Umut Demirhan
% DeepMIMO test script
% Date: 3/19/2022
"""
# # Import DeepMIMOv3 and other needed libraries for this example
import DeepMIMOv3
import numpy as np
from pprint import pprint
import matplotlib.pyplot as plt
#%% Load and print the default parameters
parameters = DeepMIMOv3.default_params()
pprint(parameters, sort_dicts=False)
#%% Change parameters for the setup
# Scenario O1_60 extracted at the dataset_folder
parameters['scenario'] = 'city_4_phoenix'
parameters['dataset_folder'] = r'C:\Users\Umt\Desktop\deepverse_scenarios'
parameters['num_paths'] = 10
# Activate only the first basestation
parameters['active_BS'] = np.array([1])
parameters['OFDM']['bandwidth'] = 0.1 # 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]) # Single antenna
parameters['bs_antenna']['shape'] = np.array([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'
#%% Generate and inspect the dataset
dataset = DeepMIMOv3.generate_data(parameters)
# Number of basestations
len(dataset)
# Keys of a basestation dictionary
dataset[0].keys()
# Keys of a channel
dataset[0]['user'].keys()
# Number of UEs
len(dataset[0]['user']['channel'])
# Shape of the channel matrix
dataset[0]['user']['channel'].shape
# Shape of BS 0 - UE 0 channel
dataset[0]['user']['channel'][0].shape
# Path properties of BS 0 - UE 0
pprint(dataset[0]['user']['paths'][0])
#%% 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')
#%% 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')
#%%
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 (dBm)')