-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathheatmap.py
More file actions
48 lines (40 loc) · 1.46 KB
/
heatmap.py
File metadata and controls
48 lines (40 loc) · 1.46 KB
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
import numpy as np
from tqdm import tqdm
import matplotlib.pyplot as plt
from ofdm.simulation.monte_carlo import run_monte_carlo
from ofdm.config import loadLayout
def main():
layout_config_pth = "./configs/layout.json"
rx_coords, tx_true = loadLayout(layout_config_pth)
rx_x = rx_coords[:, 0].reshape(-1, 1, 1)
rx_y = rx_coords[:, 1].reshape(-1, 1, 1)
x_range = np.linspace(0, 2, num=50)
y_range = np.linspace(0, 2, num=50)
X, Y = np.meshgrid(x_range, y_range)
bounds = ([0, 2], [0, 2])
error_heatmap = np.zeros(X.shape)
for i in tqdm(range(len(x_range)), desc="Running Monte Carlo Simulations"):
for j in range(len(y_range)):
tx_coords = np.array([X[i][j], Y[i][j]])
results = run_monte_carlo(
rx_coords=rx_coords,
tx_pos=tx_coords,
sigma_ns=0.5,
n_trials=30,
seed=42,
bounds=bounds
)
error_heatmap[i][j] = results['rmse']
plt.figure(figsize=(10, 8))
v_max = 1.5
v_min = 0
cp = plt.pcolormesh(X, Y, error_heatmap,vmin=v_min, vmax=v_max, shading='auto', cmap='viridis')
plt.colorbar(cp, label='RMSE (meters)')
plt.scatter(rx_x, rx_y, marker='^', color='red', label='Receivers', s=150)
plt.title('OFDM Localization Error Heatmap')
plt.xlabel('X Position (m)')
plt.ylabel('Y Position (m)')
plt.legend()
plt.show()
if __name__ == "__main__":
main()