-
Notifications
You must be signed in to change notification settings - Fork 1
/
examples.py
90 lines (73 loc) · 3.09 KB
/
examples.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
# -*- coding: utf-8 -*-
"""
@author: oustry
"""
from FDFDRadiowaveSimulator import FDFDRadiowaveSimulator
from pandas import DataFrame,read_csv
import time
def FirstExample():
"""
First example of use of the FDFDRadiowaveSimulator class. Generate a .png file
Returns
-------
None.
"""
mapname = "MAP4"
sim = FDFDRadiowaveSimulator(mapname)
#Reading map parameters
param = read_csv("sources/"+mapname+".csv")
sim.set_parameters(float(param["dx"]),0.5*float(param["lambda"]),float(param["opt_ind_walls"]),float(param["alpha_walls"]))
#Generates a bitmap in the output folder describing the field
Psi = sim.solve(350,125,True)
def Generate_Gain_Matrix(mapname,nodes_index,wavelength,wlindex):
"""
Generates the gain matrix associated to a map and a set of sources
Parameters
----------
mapname : string
The map name.
nodes_index : int
File index of the nodes positions.
wavelength: float, in meters
Returns
-------
None.
"""
#Simulator
sim = FDFDRadiowaveSimulator(mapname)
#Reading map parameters in the corresponding files (in the "sources" folder)
param = read_csv("sources/"+mapname+".csv")
sim.set_parameters(float(param["dx"]),wavelength,float(param["opt_ind_walls"]),float(param["alpha_walls"]))
#Reading clients and candidates positions in the corresponding files (in the "sources" folder)
dataframe_candidates,dataframe_clients = read_csv("sources/"+mapname+"_CA_"+str(nodes_index)+".csv"),read_csv("sources/"+mapname+"_CL_"+str(nodes_index)+".csv")
list_candidates = [(dataframe_candidates['X'][i],dataframe_candidates['Y'][i]) for i in range(len(dataframe_candidates))]
list_clients = [(dataframe_clients['X'][i],dataframe_clients['Y'][i]) for i in range(len(dataframe_clients))]
floor = [dataframe_clients['Floor'][i] for i in range(len(dataframe_clients))] + [dataframe_candidates['Floor'][i] for i in range(len(dataframe_candidates))]
#Computing 2D gain matrix
t0 = time.time()
gain = sim.gain_matrix(list_clients + list_candidates)
total_sim_time = time.time()-t0
print("\n Total simulation time = {0}s".format(total_sim_time))
sim.export_stats()
#Applying floor attenuation factor (2.5D method)
t0 = time.time()
att_gain = float(param["g"])
for i in range(len(gain)):
for j in range(len(gain)):
d=abs(floor[i]-floor[j])
gain[i,j] = gain[i,j]*(att_gain**d)
total_proj_time = time.time()-t0
print("\n Total projection time = {0}s".format(total_proj_time))
#Storing the gain matrix
G = DataFrame(gain)
G.to_csv("output/"+mapname+"_GainMatrix"+wlindex+"_"+str(nodes_index)+".csv")
if __name__ == "__main__":
#FirstExample()
MAPLIST = ["MAP1","MAP2","MAP3","MAP4","MAP5","MAP6"]
for mapname in MAPLIST:
for i in range(3):
print(mapname,i)
#2.4GHz simulation
Generate_Gain_Matrix(mapname,i,0.125,'A')
#5GHz simulation
Generate_Gain_Matrix(mapname,i,0.06,'B')