Skip to content

Commit 714d185

Browse files
committed
Update raytracing.py
-Fix for enabling arbitrary user IDs
1 parent 10b85bf commit 714d185

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/DeepMIMO/raytracing.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ def extract_data_from_ray(ray_data, ids, params):
5252
c.OUT_PATH_RX_POW: [],
5353
c.OUT_PATH_ACTIVE: []
5454
}
55-
data = {c.OUT_PATH: [dict(path_dict) for j in range(len(ids))],
56-
c.OUT_LOS : np.zeros(num_channels, dtype=int),
57-
c.OUT_LOC : np.zeros((num_channels, 3)),
58-
c.OUT_DIST : np.zeros(num_channels),
59-
c.OUT_PL : np.zeros(num_channels)
60-
}
55+
data = {c.OUT_PATH: np.array([dict(path_dict) for j in range(len(ids))]),
56+
c.OUT_LOS : np.zeros(num_channels, dtype=int),
57+
c.OUT_LOC : np.zeros((num_channels, 3)),
58+
c.OUT_DIST : np.zeros(num_channels),
59+
c.OUT_PL : np.zeros(num_channels)
60+
}
6161

6262
j = 0
6363
for user in tqdm(range(max(ids)+1), desc='Reading ray-tracing'):
@@ -85,6 +85,13 @@ def extract_data_from_ray(ray_data, ids, params):
8585
pointer += num_paths_available*4
8686

8787
path_verifier.notify()
88+
89+
# The reading operation of the raytracing is linear
90+
# Therefore, it is re-ordered to return in the same order of user IDs
91+
rev_argsort = np.empty(ids.shape, dtype=np.intp)
92+
rev_argsort[np.argsort(ids)] = np.arange(len(ids))
93+
for dict_key in data.keys():
94+
data[dict_key] = data[dict_key][rev_argsort]
8895
return data
8996

9097
# Split variables into a dictionary

0 commit comments

Comments
 (0)