1+ import numpy as np
2+ import matplotlib .pyplot as plt
3+ from ofdm .simulation .monte_carlo import run_monte_carlo
4+ from ofdm .config import loadLayout
5+
6+
7+ def main ():
8+ layout_config_pth = "./configs/layout.json"
9+ rx_coords , tx_true = loadLayout (layout_config_pth )
10+
11+ rx_x = rx_coords [:, 0 ].reshape (- 1 , 1 , 1 )
12+ rx_y = rx_coords [:, 1 ].reshape (- 1 , 1 , 1 )
13+
14+ x_range = np .linspace (0 , 1 , num = 40 )
15+ y_range = np .linspace (0 , 1 , num = 40 )
16+ X , Y = np .meshgrid (x_range , y_range )
17+
18+ error_heatmap = np .zeros (X .shape )
19+
20+ for i in range (len (x_range )):
21+ for j in range (len (y_range )):
22+ tx_coords = np .array ([X [i ][j ], Y [i ][j ]])
23+ results = run_monte_carlo (
24+ rx_coords = rx_coords ,
25+ tx_pos = tx_coords ,
26+ sigma_ns = 0.1 ,
27+ n_trials = 10 ,
28+ seed = 42 ,
29+ )
30+ error_heatmap [i ][j ] = results ['rmse' ]
31+
32+ plt .figure (figsize = (10 , 8 ))
33+ v_max = 1
34+ v_min = 0
35+ cp = plt .pcolormesh (X , Y , error_heatmap ,vmin = v_min , vmax = v_max , shading = 'auto' , cmap = 'viridis' )
36+ plt .colorbar (cp , label = 'RMSE (meters)' )
37+ plt .scatter (rx_x , rx_y , marker = '^' , color = 'red' , label = 'Receivers' )
38+ plt .title ('OFDM Localization Error Heatmap' )
39+ plt .xlabel ('X Position (m)' )
40+ plt .ylabel ('Y Position (m)' )
41+ plt .legend ()
42+ plt .show ()
43+
44+
45+ if __name__ == "__main__" :
46+ main ()
0 commit comments