本文整理汇总了Python中pylayers.gis.layout.Layout类的典型用法代码示例。如果您正苦于以下问题:Python Layout类的具体用法?Python Layout怎么用?Python Layout使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Layout类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: replay
def replay(self, fig=[], ax=[], **kwargs):
""" replay a trajectory
Parameters
----------
fig
ax
speed : float
speed ratio
"""
# plt.ion()
if fig == []:
fig = plt.gcf()
if ax == []:
ax = plt.gca()
limkwargs = copy.copy(kwargs)
if "c" in kwargs:
limkwargs.pop("c")
if "color" in kwargs:
limkwargs.pop("c")
limkwargs["marker"] = "*"
limkwargs["s"] = 20
if ("m" or "marker") not in kwargs:
kwargs["marker"] = "o"
if ("c" or "color") not in kwargs:
kwargs["color"] = "b"
L = Layout(self.Lfilename)
fig, ax = L.showG("s", fig=fig, ax=ax, **kwargs)
time = self[0].time()
line, = ax.plot([], [], "ob", lw=2)
time_template = "time = %.1fs"
time_text = ax.text(0.05, 0.9, "", transform=ax.transAxes)
def init():
line.set_data([], [])
time_text.set_text("")
return line, time_text
def animate(it):
X = []
Y = []
for t in self:
if t.typ == "ag":
X.append(t["x"].values[it])
Y.append(t["y"].values[it])
line.set_data(X, Y)
time_text.set_text(time_template % (time[it]))
return line, time_text
ani = animation.FuncAnimation(fig, animate, np.arange(1, len(time)), interval=25, blit=True, init_func=init)
plt.show()
开发者ID:pylayers,项目名称:pylayers,代码行数:60,代码来源:trajectory.py
示例2: create_layout
def create_layout(self):
"""
Create Layout in Simpy the_world thanks to Tk backend
"""
self.the_world = world(width = float(self.lay_opt['the_world_width']),
height = float(self.lay_opt['the_world_height']),
scale=float(self.lay_opt['the_world_scale']))
# tk = self.the_world.tk
# canvas, x_, y_ = tk.canvas, tk.x_, tk.y_
# canvas.create_rectangle(x_(-1), y_(-1), x_(100), y_(100), fill='white')
_filename = self.lay_opt['filename']
#sl=Slab.SlabDB(self.lay_opt['slab'],self.lay_opt['slabmat'])
#G1 = Graph.Graph(sl=sl,filename=_filename)
self.L = Layout(_filename)
#if _filename.split('.')[1] == 'str':
# self.L.loadstr(_filename)
#elif _filename.split('.')[1] == 'str2':
# self.L.loadstr2(_filename)
#elif _filename.split('.')[1] == 'ini':
# self.L.loadini(_filename)
try:
self.L.dumpr()
print 'Layout graphs are loaded from ',basename,'/struc/ini'
except:
#self.L.sl = sl
#self.L.loadGr(G1)
print 'This is the first time the layout file is used\
Layout graphs are curently being built, it may take few minutes.'
self.L.build()
self.L.dumpw()
x_offset = 0 # float(self.lay_opt['x_offset'])
y_offset = 0 # float(self.lay_opt['y_offset'])
for ks in self.L.Gs.pos.keys():
self.L.Gs.pos[ks] = (self.L.Gs.pos[ks][0] +
x_offset, self.L.Gs.pos[ks][1] + y_offset)
for ks in self.L.Gr.pos.keys():
self.L.Gr.pos[ks] = (self.L.Gr.pos[ks][0] +
x_offset, self.L.Gr.pos[ks][1] + y_offset)
for ks in self.L.Gw.pos.keys():
self.L.Gw.pos[ks] = (self.L.Gw.pos[ks][0] +
x_offset, self.L.Gw.pos[ks][1] + y_offset)
#
# Create Layout
#
walls = self.L.thwall(0, 0)
for wall in walls:
points = []
# for point in wall:
# points.append(x_(point[0]))
# points.append(y_(point[1]))
# canvas.create_polygon(points, fill='maroon', outline='black')
for ii in range(0, len(wall) - 1):
self.the_world.add_wall(wall[ii], wall[ii + 1])
开发者ID:iulia-ia13,项目名称:pylayers,代码行数:60,代码来源:simulnet.py
示例3: create_layout
def create_layout(self):
""" create Layout in Simpy the_world thanks to Tk backend
"""
_filename = self.lay_opt['filename']
self.L = Layout(_filename)
self.the_world = world()
try:
self.L.dumpr()
print 'Layout graphs are loaded from ',basename,'/struc/ini'
except:
#self.L.sl = sl
#self.L.loadGr(G1)
print 'This is the first time the layout file is used\
Layout graphs are curently being built, it may take few minutes.'
self.L.build()
self.L.dumpw()
#
# Create Layout
#
walls = self.L.thwall(0, 0)
for wall in walls:
for ii in range(0, len(wall) - 1):
self.the_world.add_wall(wall[ii], wall[ii + 1])
开发者ID:Zulko,项目名称:pylayers,代码行数:29,代码来源:simulnet.py
示例4: __init__
def __init__(self,_fileini='coverage.ini'):
self.config = ConfigParser.ConfigParser()
self.config.read(pyu.getlong(_fileini,pstruc['DIRSIMUL']))
self.plm = dict(self.config.items('pl_model'))
self.layoutopt = dict(self.config.items('layout'))
self.gridopt = dict(self.config.items('grid'))
self.txopt = dict(self.config.items('tx'))
self.rxopt = dict(self.config.items('rx'))
self.showopt = dict(self.config.items('show'))
self.L = Layout(self.layoutopt['filename'])
self.model = PLSmodel(f=eval(self.plm['fghz']),
rssnp=eval(self.plm['rssnp']),
d0=eval(self.plm['d0']),
sigrss=eval(self.plm['sigrss']))
self.nx = eval(self.gridopt['nx'])
self.ny = eval(self.gridopt['ny'])
self.mode = eval(self.gridopt['full'])
self.boundary = eval(self.gridopt['boundary'])
# transitter section
self.fGHz = eval(self.txopt['fghz'])
self.tx = np.array((eval(self.txopt['x']),eval(self.txopt['y'])))
self.ptdbm = eval(self.txopt['ptdbm'])
self.framelengthbytes = eval(self.txopt['framelengthbytes'])
# receiver section
self.rxsens = eval(self.rxopt['sensitivity'])
kBoltzmann = 1.3806503e-23
self.bandwidthmhz = eval(self.rxopt['bandwidthmhz'])
self.temperaturek = eval(self.rxopt['temperaturek'])
self.noisefactordb = eval(self.rxopt['noisefactordb'])
Pn = (10**(self.noisefactordb/10.)+1)*kBoltzmann*self.temperaturek*self.bandwidthmhz*1e3
self.pndbm = 10*np.log10(Pn)+60
self.show = str2bool(self.showopt['show'])
try:
self.L.Gt.nodes()
except:
pass
try:
self.L.dumpr('t')
except:
self.L.buildGt()
self.L.dumpw('t')
self.creategrid(full=self.mode,boundary=self.boundary)
开发者ID:vostro2013,项目名称:pylayers,代码行数:52,代码来源:coverage.py
示例5: load_simul
def load_simul(self, source):
""" load a simultraj configuration file
Parameters
----------
source : string
name of simulation file to be loaded
"""
self.filetraj = source
if not os.path.isfile(source):
raise AttributeError('Trajectory file'+source+'has not been found.\
Please make sure you have run a simulnet simulation before runining simultraj.')
# get the trajectory
traj = tr.Trajectories()
traj.loadh5(self.filetraj)
# get the layout
self.L = Layout(traj.Lfilename)
# resample trajectory
for ut, t in enumerate(traj):
if t.typ == 'ag':
person = Body(t.name + '.ini')
tt = t.time()
self.dpersons.update({t.name: person})
self._tmin = tt[0]
self._tmax = tt[-1]
self.time = tt
else:
pos = np.array([t.x[0], t.y[0], t.z[0]])
self.dap.update({t.ID: {'pos': pos,
'ant': antenna.Antenna(),
'name': t.name
}
})
self.ctime = np.nan
self.Nag = len(self.dpersons.keys())
self.Nap = len(self.dap.keys())
self.traj = traj
开发者ID:Dialloalha,项目名称:pylayers,代码行数:42,代码来源:simultraj.py
示例6: load_simul
def load_simul(self, source):
""" load a simultraj configuration file
Parameters
----------
source : string
name of simulation file to be loaded
"""
self.filetraj = source
# get the trajectory
traj = tr.Trajectories()
traj.loadh5(self.filetraj)
# get the layout
self.L = Layout(traj.Lfilename)
# resample trajectory
for ut, t in enumerate(traj):
if t.typ == 'ag':
person = Body(t.name + '.ini')
tt = t.time()
self.dpersons.update({t.name: person})
self._tmin = tt[0]
self._tmax = tt[-1]
self.time = tt
else:
pos = np.array([t.x[0], t.y[0], t.z[0]])
self.dap.update({t.ID: {'pos': pos,
'ant': antenna.Antenna(),
'name': t.name
}
})
self.ctime = np.nan
self.Nag = len(self.dpersons.keys())
self.Nap = len(self.dap.keys())
self.traj = traj
开发者ID:mmhedhbi,项目名称:pylayers,代码行数:41,代码来源:simultraj.py
示例7: layout
def layout(self, _filestruc):
""" load a layout in the simulation oject
Parameters
----------
_filestruc : string
short file name of the Layout object
Examples
--------
>>> from pylayers.simul.simulem import *
>>> S = Simul()
>>> S.layout('defstr.ini')
"""
self.filestr = _filestruc
self.L = Layout(_filestruc)
# update config
self.config.set("files", "struc", self.filestr)
self.save()
开发者ID:,项目名称:,代码行数:23,代码来源:
示例8: __init__
def __init__(self,_fileini='coverage.ini'):
""" object constructor
Parameters
----------
_fileini : string
name of the configuration file
Notes
-----
Coverage is described in an ini file.
Default file is coverage.ini and is placed in the ini directory of the current project.
"""
self.config = ConfigParser.ConfigParser()
self.config.read(pyu.getlong(_fileini,pstruc['DIRSIMUL']))
self.layoutopt = dict(self.config.items('layout'))
self.gridopt = dict(self.config.items('grid'))
self.apopt = dict(self.config.items('ap'))
self.rxopt = dict(self.config.items('rx'))
self.showopt = dict(self.config.items('show'))
# get the Layout
self.L = Layout(self.layoutopt['filename'])
# get the receiving grid
self.nx = eval(self.gridopt['nx'])
self.ny = eval(self.gridopt['ny'])
self.ng = self.nx*self.ny
self.mode = eval(self.gridopt['full'])
self.boundary = eval(self.gridopt['boundary'])
# create grid
# we could here construct a grid locally around the access point
# to be done later for code acceleration
#
self.creategrid(full=self.mode,boundary=self.boundary)
self.dap = {}
for k in self.apopt:
kwargs = eval(self.apopt[k])
ap = std.AP(**kwargs)
self.dap[eval(k)] = ap
try:
self.aap = np.vstack((self.aap,ap['p'][0:2]))
self.ptdbm = np.vstack((self.ptdbm,ap['PtdBm']))
except:
self.aap = ap['p'][0:2]
self.ptdbm = ap['PtdBm']
# 1 x na
self.ptdbm = self.ptdbm.T
# number of access points
self.na = len(self.dap)
# creating all links
p = product(range(self.ng),range(self.na))
#
# a : access point
# g : grid
#
for k in p:
pg = self.grid[k[0],:]
pa = self.aap[k[1]]
try:
self.pa = np.vstack((self.pa,pa))
except:
self.pa = pa
try:
self.pg = np.vstack((self.pg,pg))
except:
self.pg = pg
self.pa = self.pa.T
self.pg = self.pg.T
# frequency is chosen as all the center frequencies of the standard
# warning assuming the same standard
self.fGHz = self.dap[0].s.fcghz
self.nf = len(self.fGHz)
# AP section
#self.fGHz = eval(self.txopt['fghz'])
#self.tx = np.array((eval(self.txopt['x']),eval(self.txopt['y'])))
#self.ptdbm = eval(self.txopt['ptdbm'])
#self.framelengthbytes = eval(self.txopt['framelengthbytes'])
# receiver section
self.rxsens = eval(self.rxopt['sensitivity'])
kBoltzmann = 1.3806503e-23
self.temperaturek = eval(self.rxopt['temperaturek'])
self.noisefactordb = eval(self.rxopt['noisefactordb'])
#.........这里部分代码省略.........
开发者ID:niamiot,项目名称:pylayers,代码行数:101,代码来源:coverage.py
示例9: __init__
def __init__(self,_fileini='coverage.ini'):
""" object constructor
Parameters
----------
_fileini : string
name of the configuration file
Notes
-----
Coverage is described in an ini file.
Default file is coverage.ini and is placed in the ini directory of the current project.
"""
self.config = ConfigParser.ConfigParser()
self.config.read(pyu.getlong(_fileini,pstruc['DIRSIMUL']))
self.layoutopt = dict(self.config.items('layout'))
self.gridopt = dict(self.config.items('grid'))
self.apopt = dict(self.config.items('ap'))
self.rxopt = dict(self.config.items('rx'))
self.showopt = dict(self.config.items('show'))
# get the Layout
filename = self.layoutopt['filename']
if filename.endswith('ini'):
self.typ = 'indoor'
self.L = Layout(filename)
# get the receiving grid
self.nx = eval(self.gridopt['nx'])
self.ny = eval(self.gridopt['ny'])
self.mode = self.gridopt['mode']
self.boundary = eval(self.gridopt['boundary'])
self.filespa = self.gridopt['file']
#
# create grid
#
self.creategrid(mode=self.mode,boundary=self.boundary,_fileini=self.filespa)
self.dap = {}
for k in self.apopt:
kwargs = eval(self.apopt[k])
ap = std.AP(**kwargs)
self.dap[eval(k)] = ap
try:
self.L.Gt.nodes()
except:
pass
try:
self.L.dumpr()
except:
self.L.build()
self.L.dumpw()
else:
self.typ='outdoor'
self.E = ez.Ezone(filename)
self.E.loadh5()
self.E.rebase()
self.fGHz = np.array([])
#self.fGHz = eval(self.txopt['fghz'])
#self.tx = np.array((eval(self.txopt['x']),eval(self.txopt['y'])))
#self.ptdbm = eval(self.txopt['ptdbm'])
#self.framelengthbytes = eval(self.txopt['framelengthbytes'])
# receiver section
#self.rxsens = eval(self.rxopt['sensitivity'])
self.temperaturek = eval(self.rxopt['temperaturek'])
self.noisefactordb = eval(self.rxopt['noisefactordb'])
# show section
self.bshow = str2bool(self.showopt['show'])
开发者ID:ahrovat,项目名称:pylayers,代码行数:79,代码来源:coverage.py
示例10: Coverage
class Coverage(PyLayers):
""" Handle Layout Coverage
Methods
-------
creategrid()
create a uniform grid for evaluating losses
cover()
run the coverage calculation
showPower()
display the map of received power
showLoss()
display the map of losses
Attributes
----------
All attributes are read from fileini ino the ini directory of the
current project
_fileini
default coverage.ini
L : a Layout
nx : number of point on x
ny : number of point on y
tx : transmitter position
txpe : transmitter power emmission level
show : boolean for automatic display power map
na : number of access point
"""
def __init__(self,_fileini='coverage.ini'):
""" object constructor
Parameters
----------
_fileini : string
name of the configuration file
Notes
-----
Coverage is described in an ini file.
Default file is coverage.ini and is placed in the ini directory of the current project.
"""
self.config = ConfigParser.ConfigParser()
self.config.read(pyu.getlong(_fileini,pstruc['DIRSIMUL']))
self.layoutopt = dict(self.config.items('layout'))
self.gridopt = dict(self.config.items('grid'))
self.apopt = dict(self.config.items('ap'))
self.rxopt = dict(self.config.items('rx'))
self.showopt = dict(self.config.items('show'))
# get the Layout
self.L = Layout(self.layoutopt['filename'])
# get the receiving grid
self.nx = eval(self.gridopt['nx'])
self.ny = eval(self.gridopt['ny'])
self.ng = self.nx*self.ny
self.mode = eval(self.gridopt['full'])
self.boundary = eval(self.gridopt['boundary'])
# create grid
# we could here construct a grid locally around the access point
# to be done later for code acceleration
#
self.creategrid(full=self.mode,boundary=self.boundary)
self.dap = {}
for k in self.apopt:
kwargs = eval(self.apopt[k])
ap = std.AP(**kwargs)
self.dap[eval(k)] = ap
try:
self.aap = np.vstack((self.aap,ap['p'][0:2]))
self.ptdbm = np.vstack((self.ptdbm,ap['PtdBm']))
except:
self.aap = ap['p'][0:2]
self.ptdbm = ap['PtdBm']
# 1 x na
self.ptdbm = self.ptdbm.T
# number of access points
self.na = len(self.dap)
# creating all links
p = product(range(self.ng),range(self.na))
#
#.........这里部分代码省略.........
开发者ID:niamiot,项目名称:pylayers,代码行数:101,代码来源:coverage.py
示例11: Simul
class Simul(SimulationRT): # Sympy 2
#class Simul(sympy.RealtimeEnvironment):
"""
Attributes
----------
config : config parser instance
sim_opt : dictionary of configuration option for simulation
ag_opt : dictionary of configuration option for agent
lay_opt : dictionary of configuration option for layout
meca_opt : dictionary of configuration option for mecanic
net_opt : dictionary of configuration option for network
loc_opt : dictionary of configuration option for localization
save_opt : dictionary of configuration option for save
sql_opt : dictionary of configuration option for sql
Notes
------
All the prvious dictionnary are obtained from the chosen simulnet.ini file
in the project directory
"""
def __init__(self):
SimulationRT.__init__(self) #Sympy 2
#sympy.RealtimeEnvironment.__init__(self) #simpy 3
self.initialize()
self.config = ConfigParser.ConfigParser()
filename = pyu.getlong('simulnet.ini','ini')
self.config.read(filename)
self.sim_opt = dict(self.config.items('Simulation'))
self.lay_opt = dict(self.config.items('Layout'))
self.meca_opt = dict(self.config.items('Mechanics'))
self.net_opt = dict(self.config.items('Network'))
self.loc_opt = dict(self.config.items('Localization'))
self.save_opt = dict(self.config.items('Save'))
self.sql_opt = dict(self.config.items('Mysql'))
self.verbose = str2bool(self.sim_opt['verbose'])
if str2bool(self.net_opt['ipython_nb_show']):
self.verbose = False
self.roomlist=[]
self.create()
def create_layout(self):
"""
Create Layout in Simpy the_world thanks to Tk backend
"""
self.the_world = world(width = float(self.lay_opt['the_world_width']),
height = float(self.lay_opt['the_world_height']),
scale=float(self.lay_opt['the_world_scale']))
# tk = self.the_world.tk
# canvas, x_, y_ = tk.canvas, tk.x_, tk.y_
# canvas.create_rectangle(x_(-1), y_(-1), x_(100), y_(100), fill='white')
_filename = self.lay_opt['filename']
#sl=Slab.SlabDB(self.lay_opt['slab'],self.lay_opt['slabmat'])
#G1 = Graph.Graph(sl=sl,filename=_filename)
self.L = Layout(_filename)
#if _filename.split('.')[1] == 'str':
# self.L.loadstr(_filename)
#elif _filename.split('.')[1] == 'str2':
# self.L.loadstr2(_filename)
#elif _filename.split('.')[1] == 'ini':
# self.L.loadini(_filename)
try:
self.L.dumpr()
print 'Layout graphs are loaded from ',basename,'/struc/ini'
except:
#self.L.sl = sl
#self.L.loadGr(G1)
print 'This is the first time the layout file is used\
Layout graphs are curently being built, it may take few minutes.'
self.L.build()
self.L.dumpw()
x_offset = 0 # float(self.lay_opt['x_offset'])
y_offset = 0 # float(self.lay_opt['y_offset'])
for ks in self.L.Gs.pos.keys():
self.L.Gs.pos[ks] = (self.L.Gs.pos[ks][0] +
x_offset, self.L.Gs.pos[ks][1] + y_offset)
for ks in self.L.Gr.pos.keys():
self.L.Gr.pos[ks] = (self.L.Gr.pos[ks][0] +
x_offset, self.L.Gr.pos[ks][1] + y_offset)
for ks in self.L.Gw.pos.keys():
self.L.Gw.pos[ks] = (self.L.Gw.pos[ks][0] +
x_offset, self.L.Gw.pos[ks][1] + y_offset)
#
# Create Layout
#
walls = self.L.thwall(0, 0)
for wall in walls:
points = []
# for point in wall:
# points.append(x_(point[0]))
#.........这里部分代码省略.........
开发者ID:iulia-ia13,项目名称:pylayers,代码行数:101,代码来源:simulnet.py
示例12: Coverage
class Coverage(PyLayers):
""" Handle Layout Coverage
Methods
-------
creategrid()
create a uniform grid for evaluating losses
cover()
run the coverage calculation
showPower()
display the map of received power
showLoss()
display the map of losses
Attributes
----------
All attributes are read from fileini ino the ini directory of the
current project
_fileini
default coverage.ini
L : a Layout
nx : number of point on x
ny : number of point on y
tx : transmitter position
txpe : transmitter power emmission level
show : boolean for automatic display power map
na : number of access point
"""
def __init__(self,_fileini='coverage.ini'):
""" object constructor
Parameters
----------
_fileini : string
name of the configuration file
Notes
-----
Coverage is described in an ini file.
Default file is coverage.ini and is placed in the ini directory of the current project.
"""
self.config = ConfigParser.ConfigParser()
self.config.read(pyu.getlong(_fileini,pstruc['DIRSIMUL']))
self.layoutopt = dict(self.config.items('layout'))
self.gridopt = dict(self.config.items('grid'))
self.apopt = dict(self.config.items('ap'))
self.rxopt = dict(self.config.items('rx'))
self.showopt = dict(self.config.items('show'))
# get the Layout
filename = self.layoutopt['filename']
if filename.endswith('ini'):
self.typ = 'indoor'
self.L = Layout(filename)
# get the receiving grid
self.nx = eval(self.gridopt['nx'])
self.ny = eval(self.gridopt['ny'])
self.mode = self.gridopt['mode']
self.boundary = eval(self.gridopt['boundary'])
self.filespa = self.gridopt['file']
#
# create grid
#
self.creategrid(mode=self.mode,boundary=self.boundary,_fileini=self.filespa)
self.dap = {}
for k in self.apopt:
kwargs = eval(self.apopt[k])
ap = std.AP(**kwargs)
self.dap[eval(k)] = ap
try:
self.L.Gt.nodes()
except:
pass
try:
self.L.dumpr()
except:
self.L.build()
self.L.dumpw()
else:
self.typ='outdoor'
self.E = ez.Ezone(filename)
self.E.loadh5()
self.E.rebase()
#.........这里部分代码省略.........
开发者ID:ahrovat,项目名称:pylayers,代码行数:101,代码来源:coverage.py
示例13: Layout
from pylayers.gis.layout import Layout
import matplotlib.pyplot as plt
import doctest
#doctest.testmod(layout)
L = Layout()
L.load('TA-Office.str')
#L.editor()
fig = plt.gcf()
#ax1 = fig.add_subplot(221)
ax1 = fig.add_subplot(111)
L.display['thin']=True
fig,ax1 = L.showGs(fig=fig,ax=ax1)
L.display['thin']=False
L.display['edlabel']=True
L.display['edlblsize']=50
fig,ax1 = L.showGs(fig=fig,ax=ax1,edlist=[10,7,54],width=4)
plt.show()
#plt.savefig('graphGs.png')
# build topological graph
#L.buildGt()
#ax2 = fig.add_subplot(222)
#L.showG(fig=fig,ax=ax2,graph='t')
#plt.title('Topological graph')
#plt.savefig('graphGt.png')
# build graph of rooms
#L.buildGr()
#ax3 = fig.add_subplot(223)
#L.showG(fig=fig,ax=ax3,graph='r')
开发者ID:fgrandhomme,项目名称:pylayers,代码行数:31,代码来源:test_layout.py
示例14: Simul
class Simul(PyLayers):
"""
Link oriented simulation
A simulation requires :
A Layout
A Person
A Trajectory
"""
def __init__(self, _filetraj='simulnet_TA-Office.h5',verbose=False):
""" object constructor
Parameters
----------
_filetraj : string
h5 trajectory
verbose : boolean
"""
self.filetraj = _filetraj
# self.progress = -1 # simulation not loaded
self.verbose = verbose
self.cfield = []
self.dpersons = {}
self.dap = {}
self.Nag = 0
self.Nap = 0
self.load_config(_filetraj)
self.gen_net()
self.SL = SLink()
self.DL = DLink(L=self.L,verbose=self.verbose)
self.filename = 'simultraj_' + self.filetraj
self.data = pd.DataFrame(columns=['id_a', 'id_b',
'x_a', 'y_a', 'z_a',
'x_b', 'y_b', 'z_b',
'd', 'eng', 'typ',
'wstd', 'fcghz',
'fbminghz', 'fbmaxghz', 'fstep', 'aktk_id',
'sig_id', 'ray_id', 'Ct_id', 'H_id'
])
self.data.index.name='t'
self._filecsv = self.filename.split('.')[0] + '.csv'
self.todo = {'OB': True,
'B2B': True,
'B2I': True,
'I2I': False}
filenameh5 = pyu.getlong(self.filename,pstruc['DIRLNK'])
if os.path.exists(filenameh5) :
self.loadpd()
# self._saveh5_init()
def __repr__(self):
s = 'Simul trajectories class\n'
s = s + '------------------------\n'
s = s +'\n'
s = s + 'Used layout: ' + self.L.filename + '\n'
s = s + 'Number of Agents: ' + str(self.Nag) + '\n'
s = s + 'Number of Access Points: ' + str(self.Nap) + '\n'
s = s + 'Link to be evaluated: ' + str(self.todo) + '\n'
s = s + 'tmin: ' + str(self._tmin) + '\n'
s = s + 'tmax: ' + str(self._tmax) + '\n'
s = s +'\n'
# network info
s = s + 'self.N :\n'
s = s + self.N.__repr__() + '\n'
s = s + 'CURRENT TIME: ' + str(self.ctime) + '\n'
return s
def load_config(self, _filetraj):
""" load a simultraj configuration file
Parameters
----------
_filetraj : string
name of simulation file to be loaded
"""
self.filetraj = _filetraj
# get the trajectory
traj = tr.Trajectories()
traj.loadh5(self.filetraj)
# get the layout
self.L = Layout(traj.Lfilename)
#.........这里部分代码省略.........
开发者ID:niamiot,项目名称:pylayers,代码行数:101,代码来源:simultraj.py
示例15: Layout
from pylayers.gis.layout import Layout
from pylayers.util.project import *
import pylayers.util.pyutil as pyu
import networkx as nx
import matplotlib.pyplot as plt
import warnings
import shutil
warnings.filterwarnings("error")
#doctest.testmod(layout)
#L = Layout('TA-Office.ini')
L = Layout()
lL = L.ls()
for tL in lL:
print 'Layout : ',tL
print '--------------------------'
if 'Munich' not in tL:
L = Layout(tL,bbuild=0,bgraphs=0)
f,a = L.showG('s')
plt.title(tL,fontsize=32)
plt.show()
plt.close('all')
#if L.check():
# L.save()
#filein = pyu.getlong(L._filename, pstruc['DIRLAY'])
#fileout = '/home/uguen/Documents/rch/devel/pylayers/data/struc/lay/'+L._filename
#print fileout
#shutil.copy2(filein,fileout)
#figure(figsize=(20,10))
#plt.axis('off')
开发者ID:dialounke,项目名称:pylayers,代码行数:31,代码来源:test_layout.py
示例16: Simul
class Simul(SimulationRT): # Sympy 2
#class Simul(sympy.RealtimeEnvironment):
"""
Attributes
----------
config : config parser instance
sim_opt : dictionary of configuration option for simulation
ag_opt : dictionary of configuration option for agent
lay_opt : dictionary of configuration option for layout
meca_opt : dictionary of configuration option for mecanic
net_opt : dictionary of configuration option for network
loc_opt : dictionary of configuration option for localization
save_opt : dictionary of configuration option for save
sql_opt : dictionary of configuration option for sql
Parameters
----------
self.lAg : list of Agent(Object)
list of agents involved in simulation
self.L : Layout
Layout used in simulation
Notes
-----
All the previous dictionnary are obtained from the chosen simulnet.ini file
in the project directory
"""
def __init__(self):
SimulationRT.__init__(self) #Sympy 2
#sympy.RealtimeEnvironment.__init__(self) #simpy 3
self.initialize()
self.config = ConfigParser.ConfigParser()
filename = pyu.getlong('simulnet.ini',pstruc['DIRSIMUL'])
self.config.read(filename)
self.sim_opt = dict(self.config.items('Simulation'))
self.lay_opt = dict(self.config.items('Layout'))
self.meca_opt = dict(self.config.items('Mechanics'))
self.net_opt = dict(self.config.items('Network'))
self.loc_opt = dict(self.config.items('Localization'))
self.save_opt = dict(self.config.items('Save'))
self.sql_opt = dict(self.config.items('Mysql'))
self.seed = eval(self.sim_opt['seed'])
self.traj=Trajectories()
self.verbose = str2bool(self.sim_opt['verbose'])
if str2bool(self.net_opt['ipython_nb_show']):
self.verbose = False
self.roomlist=[]
self.finish = False
self.create()
def __repr__(self):
s = 'Simulation information' + '\n----------------------'
s = s + '\nLayout: ' + self.lay_opt['filename']
s = s + '\nSimulation duration: ' + self.sim_opt['duration']
s = s + '\nRandom seed: ' + self.sim_opt['seed']
s = s + '\nSave simulation: ' + self.save_opt['savep']
s = s + '\n\nUpdate times' + '\n-------------'
s = s + '\nMechanical update: ' + self.meca_opt['mecanic_update_time']
s = s + '\nNetwork update: ' + self.net_opt['network_update_time']
s = s + '\nLocalization update: ' + self.net_opt['communication_mode']
s = s + '\n\nAgents => self.lAg[i]' + '\n------'
s = s + '\nNumber of agents :' + str(len(self.lAg))
s = s + '\nAgents IDs: ' + str([self.lAg[i].ID for i in range(len(self.lAg))])
s = s + '\nAgents names: ' + str([self.lAg[i].name for i in range(len(self.lAg))])
s = s + '\nDestination of chosen agents: ' + self.meca_opt['choose_destination']
s = s + '\n\nNetwork' + '\n-------'
s = s + '\nNodes per wstd: ' + str(self.net.wstd)
s = s + '\n\nLocalization' + '------------'
s = s + '\nLocalization enable: ' + self.loc_opt['localization']
s = s + '\nPostion estimation methods: ' + self.loc_opt['method']
return s
def create_layout(self):
""" create Layout in Simpy the_world thanks to Tk backend
"""
_filename = self.lay_opt['filename']
self.L = Layout(_filename)
self.the_world = world()
try:
self.L.dumpr()
#.........这里部分代码省略.........
开发者ID:Zulko,项目名称:pylayers,代码行数:101,代码来源:simulnet.py
示例17: Layout
from pylayers.gis.layout import Layout
import matplotlib.pyplot as plt
import doctest
#doctest.testmod(layout)
#L = Layout('TA-Office.ini')
L = Layout('DLR.ini')
try:
L.dumpr()
except:
L.build()
L.dumpw()
#L.editor()
fig = plt.gcf()
#ax1 = fig.add_subplot(221)
ax1 = fig.add_subplot(321)
L.display['thin']=True
fig,ax1 = L.showGs(fig=fig,ax=ax1)
#L.display['edlabel']=True
#L.display['edlblsize']=50
# display selected segments
L.display['thin']=True
L.showG(fig=fig,ax=ax1,graph='t')
fig = plt.gcf()
ax1 = plt.gca()
fig,ax1 = L.showGs(fig=fig,ax=ax1,edlist=[125],width=4)
ax11 = fig.add_subplot(322)
L.showG(fig=fig,ax=ax11,graph='')
#plt.savefig('graphGs.png')
开发者ID:mlaaraie,项目名称:pylayers,代码行数:31,代码来源:test_layout.py
示例18: Layout
import time
from pylayers.util.project import *
import pylayers.util.pyutil as pyu
from pylayers.util.utilnet import str2bool
from pylayers.gis.layout import Layout
from pylayers.antprop.multiwall import *
from pylayers.antprop.coverage import *
from pylayers.network.model import *
L = Layout('TA-Office.ini')
L.dumpr()
A=np.array((4,1)) # defining transmitter position
B=np.array((30,12)) # defining receiver position
fGHz = 2.4
r = np.array((B,B))
开发者ID:iulia-ia13,项目名称:pylayers,代码行数:16,代码来源:test_coverage.py
示例19: load
def load(self, _filesimul):
""" load a simulation configuration file
each transmiter simulation results in the creation of an .ini file
with the following sections
related to the results obtained for different receivers
Parameters
----------
_filesimul : file in the simul directory of the Project
"""
self.filesimul = _filesimul
filesimul = pyu.getlong(self.filesimul, "ini")
self.config.read(filesimul)
sections = self.config.sections()
try:
_filetx = self.config.get("files", "tx")
except:
raise NameError('Error in section tx from '+ _filesimul)
try:
_filerx = self.config.get("files", "rx")
except:
raise NameError('Error in section rx from '+ _filesimul)
try:
_fileanttx = self.config.get("files", "txant")
except:
raise NameError('Error in section txant from '+ _filesimul)
try:
_fileantrx = self.config.get("files", "rxant")
except:
raise NameError('Error in section rxant from '+ _filesimul)
try:
self.tx = RadioNode(name = '',
typ = 'tx',
_fileini = _filetx,
_fileant = _fileanttx,
_filestr = self.filestr)
self.rx = RadioNode(name = '',
typ = 'rx',
_fileini = _filerx,
_fileant = _fileantrx,
_filestr = self.filestr)
except:
raise NameError('Error during Radionode load')
#
# Load Layout
#
try:
self.L = Layout(self.filestr)
except:
raise NameError('Layout load error')
#
# Frequency base
#
if "frequency" in sections:
try:
self.fGHz = np.linspace(float(self.config.getfloat("frequency", "fghzmin")),
float(self.config.getfloat("frequency", "fghzmax")),
int(self.config.getint("frequency", "nf")),
endpoint=True)
except:
raise NameError('Error in section frequency from '+ _filesimul)
# update .freq file in tud directory
filefreq = pyu.getlong(self.filefreq, pstruc['DIRTUD'])
fd = open(filefreq, "w")
chaine = self.config.get("frequency", "fghzmin") + ' ' + \
self.config.get("frequency", "fghzmax") + ' ' + \
self.config.get("frequency", "nf")
fd.write(chaine)
fd.close
#
# Simulation Progress
#
self.o
|
请发表评论