Example #1
0
    def create_show(self):
        """ create a vizualization
        """

        plt.ion()
        fig_net = 'network'
        fig_table = 'table'

        if str2bool(self.net_opt['show']):
            if str2bool(self.net_opt['ipython_nb_show']):
                notebook = True
            else:
                notebook = False
            self.sh = ShowNet(net=self.net,
                              L=self.L,
                              sim=self,
                              fname=fig_net,
                              notebook=notebook)
            self.activate(self.sh, self.sh.run(), 1.0)

        if str2bool(self.net_opt['show_table']):
            self.sht = ShowTable(net=self.net,
                                 lAg=self.lAg,
                                 sim=self,
                                 fname=fig_table)
            self.activate(self.sht, self.sht.run(), 1.0)
Example #2
0
    def create(self):
        """ Create the simulation, to be ready to run

        """

        # this is just to redump the database at each simulation
        if 'mysql' in self.save_opt['save']:
            if str2bool(self.sql_opt['dumpdb']):
                os.popen('mysql -u ' + self.sql_opt['user'] + ' -p ' + self.sql_opt['dbname'] +\
                '< /private/staff/t/ot/niamiot/svn2/devel/simulator/pyray/SimWHERE2.sql' )

        if 'txt' in self.save_opt['save']:
            pyu.writeDetails(self)
            if os.path.isfile(basename + '/output/Nodes.txt'):
                print 'would you like to erase previous txt files ?'
                A = raw_input()
                if A == 'y':
                    for f in os.listdir(basename + '/output/'):
                        try:
                            fi, ext = f.split('.')
                            if ext == 'txt':
                                os.remove(basename + '/output/' + f)
                        except:
                            pass

        self.create_layout()
        self.create_EMS()
        self.create_network()
        if str2bool(self.sim_opt['showtk']):
            self.create_visual()
        self.create_show()

        if str2bool(self.save_opt['savep']):
            self.save = Save(L=self.L, net=self.net, sim=self)
            self.activate(self.save, self.save.run(), 0.0)
Example #3
0
    def create_network(self):
        """ create the whole network
        """

        self.net = Network(EMS=self.EMS)
        self.gcom=Gcom(net=self.net,sim=self)

        self.create_agent()
        # create network
        if str2bool(self.net_opt['network']):
            self.net.create()

            # create All Personnal networks
            for n in self.net.nodes():
                self.net.node[n]['PN']._get_wstd()
                self.net.node[n]['PN']._get_SubNet()
            self.gcom.create()


           # create Process Network
            self.Pnet = PNetwork(net=self.net,
                                 net_updt_time=float(self.net_opt['network_update_time']),
                                 L=self.L,
                                 sim=self,
                                 show_sg=str2bool(self.net_opt['show_sg']),
                                 disp_inf=str2bool(self.net_opt['dispinfo']),
                                 save=eval(self.save_opt['save']))
            self.activate(self.Pnet, self.Pnet.run(), 0.0)
Example #4
0
    def create_network(self):
        """ create the whole network
        """

        self.net = Network(EMS=self.EMS)
        self.gcom = Gcom(net=self.net, sim=self)

        self.create_agent()
        # create network
        if str2bool(self.net_opt['network']):
            self.net.create()

            # create All Personnal networks
            for n in self.net.nodes():
                self.net.node[n]['PN']._get_wstd()
                self.net.node[n]['PN']._get_SubNet()
            self.gcom.create()

           # create Process Network
            self.Pnet = PNetwork(net=self.net,
                                 net_updt_time=float(
                                     self.net_opt['network_update_time']),
                                 L=self.L,
                                 sim=self,
                                 show_sg=str2bool(self.net_opt['show_sg']),
                                 disp_inf=str2bool(self.net_opt['dispinfo']),
                                 save=eval(self.save_opt['save']))
            self.activate(self.Pnet, self.Pnet.run(), 0.0)
Example #5
0
    def __init__(self):

        #SimulationRT.__init__(self)  # Simpy 2
        simpy.RealtimeEnvironment.__init__(self)  #simpy 3
        #self.initialize()

        self.config = ConfigParser.ConfigParser(inline_comment_prefixes=(';',),comment_prefixes=('#',';'))
        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()
Example #6
0
    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()
Example #7
0
    def create(self):
        """ Create the simulation, to be ready to run

        """

        # this is just to redump the database at each simulation
        if 'mysql' in self.save_opt['save']:
            if str2bool(self.sql_opt['dumpdb']):
                os.popen('mysql -u ' + self.sql_opt['user'] + ' -p ' + self.sql_opt['dbname'] +\
                '< /private/staff/t/ot/niamiot/svn2/devel/simulator/pyray/SimWHERE2.sql' )

        if 'txt' in self.save_opt['save']:
            pyu.writeDetails(self)
            if os.path.isfile(basename+'/output/Nodes.txt'):
                print 'would you like to erase previous txt files ?'
                A=raw_input()
                if A == 'y':
                    for f in os.listdir(basename+'/output/'):
                        try:
                            fi,ext=f.split('.')
                            if ext == 'txt':
                                os.remove(basename+'/output/'+f)
                        except:
                            pass
                        


        self.create_layout()
        self.create_EMS()
        self.create_network()
        if str2bool(self.sim_opt['showtk']):
            self.create_visual()
        self.create_show()
Example #8
0
    def create_show(self):
        plt.ion()
        fig_net = 'network'
        fig_table = 'table'

        if str2bool(self.net_opt['show']):
            self.sh=ShowNet(net=self.net, L=self.L,sim=self,fname=fig_net,)
            self.activate(self.sh,self.sh.run(),1.0)

        if str2bool(self.net_opt['show_table']):
            self.sht=ShowTable(net=self.net,lAg=self.lAg,sim=self,fname=fig_table)
            self.activate(self.sht,self.sht.run(),1.0)
Example #9
0
    def create_agent(self):
        """ create simulation's Agents

        ..todo:: change lAg list to a dictionnary ( modification in show.py too) 

        """

        self.lAg = []
        agents = []
        Cf = ConfigParser.ConfigParser()
        Cf.read(pyu.getlong('agent.ini', 'ini'))
        agents = eval(dict(Cf.items('used_agent'))['list'])
        for i, ag in enumerate(agents):
            ag_opt = dict(Cf.items(ag))
            self.lAg.append(
                Agent(ID=ag_opt['id'],
                      name=ag_opt['name'],
                      typ=ag_opt['typ'],
                      color=eval(ag_opt['color']),
                      pdshow=str2bool(self.meca_opt['pdshow']),
                      pos=np.array(eval(ag_opt['pos'])),
                      roomId=int(ag_opt['roomid']),
                      froom=eval(ag_opt['froom']),
                      meca_updt=float(self.meca_opt['mecanic_update_time']),
                      wait=float(ag_opt['wait']),
                      cdest=eval(self.meca_opt['choose_destination']),
                      loc=str2bool(self.loc_opt['localization']),
                      loc_updt=float(self.loc_opt['localization_update_time']),
                      loc_method=eval(self.loc_opt['method']),
                      L=self.L,
                      network=str2bool(self.net_opt['network']),
                      net=self.net,
                      epwr=dict([(eval(
                          (ag_opt['wstd']))[ep], eval((ag_opt['epwr']))[ep])
                                 for ep in range(len(eval((ag_opt['wstd']))))
                                 ]),
                      sens=dict([(eval(
                          (ag_opt['wstd']))[ep], eval(
                              (ag_opt['sensitivity']))[ep])
                                 for ep in range(len(eval((ag_opt['wstd']))))
                                 ]),
                      world=self.the_world,
                      wstd=eval(ag_opt['wstd']),
                      save=eval(self.save_opt['save']),
                      gcom=self.gcom,
                      comm_mode=eval(self.net_opt['communication_mode']),
                      sim=self,
                      seed=self.seed))
Example #10
0
    def create_show(self):
        plt.ion()
        fig_net = 'network'
        fig_table = 'table'

        if str2bool(self.net_opt['show']):
            if str2bool(self.net_opt['ipython_nb_show']):
                notebook=True
            else:
                notebook =False
            self.sh=ShowNet(net=self.net, L=self.L,sim=self,fname=fig_net,notebook=notebook)
            self.activate(self.sh,self.sh.run(),1.0)

        if str2bool(self.net_opt['show_table']):
            self.sht=ShowTable(net=self.net,lAg=self.lAg,sim=self,fname=fig_table)
            self.activate(self.sht,self.sht.run(),1.0)
Example #11
0
    def __init__(self):
        SimulationRT.__init__(self)
        self.initialize()
        self.config = ConfigParser.ConfigParser()
        self.config.read(pyu.getlong('simulnet.ini','ini'))
        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=[]
Example #12
0
    def create_agent(self):
        """ create simulation's Agents

        ..todo:: change lAg list to a dictionnary ( modification in show.py too) 

        """

        self.lAg = []
        agents = []
        Cf = ConfigParser.ConfigParser()
        Cf.read(pyu.getlong('agent.ini', 'ini'))
        agents = eval(dict(Cf.items('used_agent'))['list'])
        for i, ag in enumerate(agents):
            ag_opt = dict(Cf.items(ag))
            self.lAg.append(
                    Agent(
                    ID=ag_opt['id'],
                    name=ag_opt['name'],
                    typ=ag_opt['typ'],
                    color=eval(ag_opt['color']),
                    pdshow=str2bool(self.meca_opt['pdshow']),
                    pos=np.array(eval(ag_opt['pos'])),
                    roomId=int(ag_opt['roomid']),
                    froom=eval(ag_opt['froom']),
                    meca_updt=float(self.meca_opt['mecanic_update_time']),
                    wait=float(ag_opt['wait']),
                    cdest=eval(self.meca_opt['choose_destination']),
                    loc=str2bool(self.loc_opt['localization']),
                    loc_updt=float(self.loc_opt['localization_update_time']),
                    loc_method=eval(self.loc_opt['method']),
                    L=self.L,
                    network=str2bool(self.net_opt['network']),
                    net=self.net,
                    epwr=dict([(eval((ag_opt['wstd']))[ep], 
                                eval((ag_opt['epwr']))[ep]) 
                                for ep in range(len(eval((ag_opt['wstd']))))]),
                    sens=dict([(eval((ag_opt['wstd']))[ep],
                                eval((ag_opt['sensitivity']))[ep]) 
                                for ep in range(len(eval((ag_opt['wstd']))))]),
                    world=self.the_world,
                    wstd=eval(ag_opt['wstd']),
                    save=eval(self.save_opt['save']),
                    gcom=self.gcom,
                    comm_mode=eval(self.net_opt['communication_mode']),
                    sim=self,
                    seed=self.seed))
Example #13
0
    def __init__(self):
        SimulationRT.__init__(self)
        self.initialize()
        self.config = ConfigParser.ConfigParser()
        self.config.read(pyu.getlong('simulnet.ini', 'ini'))
        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 = []
Example #14
0
    def create(self):
        """ create the simulation
            This method is called at the end of __init__

        """
        # this is to redump the database at each simulation
        if 'mysql' in self.save_opt['save']:
            if str2bool(self.sql_opt['dumpdb']):
                os.popen(
                    'mysql -u ' + self.sql_opt['user'] + ' -p ' +
                    self.sql_opt['dbname'] +
                    '< /private/staff/t/ot/niamiot/svn2/devel/simulator/pyray/SimWHERE2.sql'
                )

        # TODO remove the hard reference
        if 'txt' in self.save_opt['save']:
            pyu.writeDetails(self)
            if os.path.isfile(os.path.join(basename, 'output', 'Nodes.txt')):
                print 'would you like to erase previous txt files ?'
                A = raw_input()
                if A == 'y':
                    for f in os.listdir(os.path.join(basename, 'output')):
                        try:
                            fi, ext = f.split('.')
                            if ext == 'txt':
                                os.remove(os.path.join(basename, 'output' + f))
                        except:
                            pass

        # Layout
        self.create_layout()
        # Electro Magnetic Simulator
        self.create_EMS()
        # Network
        self.create_network()

        if str2bool(self.sim_opt['showtk']):
            self.create_visual()
        self.create_show()

        if str2bool(self.save_opt['savep']):
            self.save = Save(L=self.L, net=self.net, sim=self)
            self.activate(self.save, self.save.run(), 0.0)
Example #15
0
    def create(self):
        """ create the simulation
            This method is called at the end of __init__

        """
        # this is to redump the database at each simulation
        if 'mysql' in self.save_opt['save']:
            if str2bool(self.sql_opt['dumpdb']):
                os.popen('mysql -u ' + self.sql_opt['user'] + ' -p ' + self.sql_opt['dbname'] +\
                '< /private/staff/t/ot/niamiot/svn2/devel/simulator/pyray/SimWHERE2.sql' )

        ## TODO remove the hard reference
        if 'txt' in self.save_opt['save']:
            pyu.writeDetails(self)
            if os.path.isfile(os.path.join(basename,'output','Nodes.txt')):
                print 'would you like to erase previous txt files ?'
                A=raw_input()
                if A == 'y':
                    for f in os.listdir(os.path.join(basename,'output')):
                        try:
                            fi,ext=f.split('.')
                            if ext == 'txt':
                                os.remove(os.path.join(basename,'output'+f))
                        except:
                            pass


        # Layout
        self.create_layout()
        # Electro Magnetic Simulator
        self.create_EMS()
        # Network
        self.create_network()

        if str2bool(self.sim_opt['showtk']):
            self.create_visual()
        self.create_show()

        if str2bool(self.save_opt['savep']):
            self.save=Save(L=self.L,net=self.net,sim=self)
            self.activate(self.save,self.save.run(),0.0)
Example #16
0
    def runsimul(self):
        """ run simulation
        """
        if not self.finish :
            seed(self.seed)
            self.simulate(until=float(self.sim_opt['duration']),
                          real_time=True,
                          rel_speed=float(self.sim_opt['speedratio']))
            self.the_world._boids={}


            if str2bool(self.save_opt['savep']):
                print 'Processing save results, please wait'
                self.save.mat_export()


            if str2bool(self.save_opt['savepd']):
                self.savepandas()
            self.finish = True
        else :
            raise NameError('Reinstantiate a new simul object to run again')
Example #17
0
    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)
Example #18
0
    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=Model(f=eval(self.plm['f']),
                         rssnp=eval(self.plm['rssnp']),
                         d0=eval(self.plm['d0']),
                         sigrss=eval(self.plm['sigrss']))
        self.xstep = eval(self.gridopt['xstep'])
        self.ystep = eval(self.gridopt['ystep'])
        # transitter section
        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()
Example #19
0
    def create_agent(self):
        """    
        create simulation's Agents

        ..todo:: change lAg list to a dictionnary ( modification in show.py too) 

        """


        self.lAg = []
        agents=[]
        Cf = ConfigParser.ConfigParser()
        Cf.read(pyu.getlong('agent.ini','ini'))
        agents=eval(dict(Cf.items('used_agent'))['list'])
        for i, ag in enumerate(agents):
            ag_opt = dict(Cf.items(ag))
            self.lAg.append(Agent(
                            ID=ag_opt['id'],
                            name=ag_opt['name'],
                            type=ag_opt['type'],
                            pos=np.array(eval(ag_opt['pos'])),
                            roomId=int(ag_opt['roomid']),
                            froom=eval(ag_opt['froom']),
                            meca_updt=float(self.meca_opt['mecanic_update_time']),
                            wait=float(ag_opt['wait']),
                            loc=str2bool(self.loc_opt['localization']),
                            loc_updt=float(self.loc_opt['localization_update_time']),
                            loc_method=eval(self.loc_opt['method']),
                            Layout=self.L,
                            net=self.net,
                            epwr=dict([(eval((ag_opt['rat']))[ep],eval((ag_opt['epwr']))[ep]) for ep in range(len(eval((ag_opt['rat']))))]),
                            sens=dict([(eval((ag_opt['rat']))[ep],eval((ag_opt['sensitivity']))[ep]) for ep in range(len(eval((ag_opt['rat']))))]),
                            world=self.the_world,
                            RAT=eval(ag_opt['rat']),
                            save=eval(self.save_opt['save']),
                            gcom=self.gcom,
                            sim=self))
#                            
            if self.lAg[i].type == 'ag':
                self.activate(self.lAg[i].meca,
                              self.lAg[i].meca.move(), 0.0)
Example #20
0
    def runsimul(self):
        """ run simulation
        """

        if not self.finish:
            # random number seed
            seed(self.seed)
            self.simulate(until=float(self.sim_opt['duration']),
                          real_time=True,
                          rel_speed=float(self.sim_opt['speedratio']))

            self.the_world._boids = {}

            # if str2bool(self.save_opt['savep']):
            # print 'Processing save results, please wait'
            # self.save.mat_export()

            if str2bool(self.save_opt['savepd']):
                self.savepandas()
            self.finish = True
        else:
            raise NameError('Reinstantiate a new simul object to run again')
Example #21
0
    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.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

        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'])

        try:
            self.L.Gt.nodes()
        except:
            pass
        try:
            self.L.dumpr()
        except:
            self.L.build()
            self.L.dumpw()
Example #22
0
    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(allow_no_value=True)
        self.config.read(pyu.getlong(_fileini, pstruc['DIRSIMUL']))

        # section layout
        self.layoutopt = dict(self.config.items('layout'))
        # section sector
        self.gridopt = dict(self.config.items('grid'))
        # section ap (access point)
        self.apopt = dict(self.config.items('ap'))
        # section receiver  parameters
        self.rxopt = dict(self.config.items('rx'))
        # section receiver  parameters
        self.showopt = dict(self.config.items('show'))

        # get the Layout
        filename = self.layoutopt['filename']
        if filename.endswith('lay'):
            self.typ = 'indoor'
            self.L = Layout(filename)

            # get the receiving grid
            self.nx = eval(self.gridopt['nx'])
            self.ny = eval(self.gridopt['ny'])
            if 'zgrid' in self.gridopt:
                self.zgrid = eval(self.gridopt['zgrid'])
            else:
                self.zgrid = 1.0
            self.mode = self.gridopt['mode']
            assert self.mode in ['file', 'full',
                                 'zone'], "Error reading grid 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()

        # The frequency is fixed from the AP nature
        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'])

        self.sinr = False
        self.snr = False
        self.best = False
        self.egd = False
        self.Pr = False
        self.capacity = False
        self.pr = False
        self.loss = False
Example #23
0
    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.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

        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"])

        try:
            self.L.Gt.nodes()
        except:
            pass
        try:
            self.L.dumpr()
        except:
            self.L.build()
            self.L.dumpw()
Example #24
0
    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'])

        # list of access points
        lap  = self.dap.keys()
        # list of channels
        lchan = map(lambda x: self.dap[x]['chan'],lap)

        apchan = zip(self.dap.keys(),lchan)
        self.bmhz = np.array(map(lambda x: self.dap[x[0]].s.chan[x[1][0]]['BMHz']*len(x[1]),apchan))
        # Evaluate Noise Power (in dBm)

        Pn = (10**(self.noisefactordb/10.)+1)*kBoltzmann*self.temperaturek*self.bmhz*1e3
        self.pndbm = 10*np.log10(Pn)+60

        # show section
        self.bshow = str2bool(self.showopt['show'])

        try:
            self.L.Gt.nodes()
        except:
            pass
        try:
            self.L.dumpr()
        except:
            self.L.build()
            self.L.dumpw()
Example #25
0
    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'])