Example #1
0
    def __init__(self, **kwargs):
        """
        Examples
        --------

        ... plot::
            :include-source:
        >>> A=AntArray()
        >>> A.plotG()

        """
        defaults = {
            'tarr': 'UA',
            'N': [8, 1, 1],
            'dm': [0.075, 0, 0],
            'S': [],
            'pattern': True,
            #'typant':'S1R1.vsh3',
            'typant': 'Gauss'
        }

        for k in defaults:
            if k not in kwargs:
                kwargs[k] = defaults[k]

        self.tarr = kwargs.pop('tarr')
        self.N = np.array(kwargs.pop('N'))
        self.Na = np.prod(self.N)  # number of antennas
        self.dm = np.array(kwargs.pop('dm'))
        self.typant = kwargs.pop('typant')

        if type(self.typant) == list:
            self.sameAnt = False
            assert len(self.typant) == self.Na, "Wrong number of antennas"
        else:
            self.sameAnt = True

        if self.tarr == 'UA':
            UA = ULArray(N=self.N, dm=self.dm)

        #
        # Add the antennas of the array, either 1 (same for all points), or Na
        # (array size)
        #
        typ = 'Array'
        # init Antenna parent
        self.la = []
        if self.sameAnt:
            self.la.append(ant.Antenna(typ=self.typant))
        else:
            for t in self.typant:
                self.la.append(ant.Antenna(typ=t))

        super(AntArray, self).__init__(p=UA.p, fGHz=self.la[0].fGHz)
        ant.Antenna.__init__(self, typ=typ, **kwargs)
    def __init__(self,**kwargs):
        """

        Examples
        --------

        >>> import pylayers.signal.standard as std
        >>> AP1 = AP()
        >>> AP1.load()

        """

        self['name'] = kwargs.pop('name','default')
        self['p'] = kwargs.pop('p',np.array([0,0,1.2]))
        self['PtdBm'] = kwargs.pop('PtdBm',0)
        self['chan'] = kwargs.pop('chan',[11])
        self['sensdBm'] = kwargs.pop('sensdBm',-94)
        self['nant'] = kwargs.pop('nant',1)
        self['on'] = kwargs.pop('on',True)
        self['ant'] = kwargs.pop('ant','Omni')
        self['phideg'] = kwargs.pop('phideg',0)
        self['wstd'] = kwargs.pop('wstd','ieee80211b')

        self.s = Wstandard(self['wstd'])
        self.A = ant.Antenna(self['ant'])
Example #3
0
    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
Example #4
0
    def __init__(self, **kwargs):
        """

        Examples
        --------

        >>> import pylayers.signal.standard as std
        >>> AP1 = AP()
        >>> AP1.load()

        """
        defaults = {
            'p': np.array([0, 0, 1.2]),
            'name': 'default',
            'wstd': 'ieee80211b',
            'chan': [11],
            'PtdBm': 0,
            'sensdBm': -94,
            'nant': 1,
            'ant': 'Omni',
            'on': True
        }

        for k in defaults:
            if k not in kwargs:
                kwargs[k] = defaults[k]

        self['name'] = kwargs['name']
        self['p'] = kwargs['p']
        self['PtdBm'] = kwargs['PtdBm']
        self['chan'] = kwargs['chan']
        self['sensdBm'] = kwargs['sensdBm']
        self['nant'] = kwargs['nant']
        self['on'] = kwargs['on']
        self['ant'] = kwargs['ant']
        self['phideg'] = kwargs['phideg']

        standard = Wstandard(kwargs['wstd'])
        self.s = standard
        self.A = ant.Antenna(self['ant'])
Example #5
0
    def __init__(self, **kwargs):
        """

        Parameters
        ----------

        mode : string
            'array' | 'grid'
            'array' is for antenna array
            'grid' for cloud of points (scanner).

        typant : string
            either a selected string among the implemented predefined patterns.
            ['Omni','Hertz','Huygens','3gpp','Array'] or a filename of an antenna
            file in one of the supported file format (.vsh3 or .sh3)

        tarr : string 
            type of array 

        N    : array of int 
            Number of points per axis

        dm : array of float 
            Inter element distance (meters)

        min : array of float 

        max : array of float 

        S : coupling matrix

        array : if the antenna is a subarray

        Examples
        --------

        ... plot::
            :include-source:

        >>> A = AntArray()
        >>> A.plotG()

        """
        defaults = {
            'tarr': 'UA',
            'N': [8, 1, 1],
            'dm': [0.075, 0, 0],
            'min': [0, 0, 0, 0],
            'max': [0, 0, 0, 0],
            'S': [],
            'typant': 'Omni',
            'mode': 'array',
            'array': [],
            'p': [],
            'w': [],
            'fGHz': np.array([60])
        }

        for k in defaults:
            if k not in kwargs:
                kwargs[k] = defaults[k]

        self.tarr = kwargs.pop('tarr')
        self.N = np.array(kwargs.pop('N'))
        self.max = np.array(kwargs.pop('max'))
        self.min = np.array(kwargs.pop('min'))
        self.Na = np.prod(self.N)  # number of antennas
        self.dm = np.array(kwargs.pop('dm'))
        self.array = kwargs.pop('array')
        self.w = kwargs.pop('w')

        if self.array == []:
            self.typant = kwargs.pop('typant')
        else:
            self.typant = self.array.typant

        # There are two modes : 'array' and 'grid'
        # If the grid mode is chosen, the spacing dm is determined
        # from max and min. In that mode max and min are prioritary w.r.t to the
        # specified dm. This is a mode which is used when using the
        # scanner for emulating a received array from a specified range of
        # disance on a given axis. The max and min are for fixing those limits.

        if kwargs['mode'] == 'grid':
            for k in range(len(self.N)):
                if self.N[k] == 1:
                    self.dm[k] = self.max[k]
                else:
                    self.dm[k] = (self.max[k] - self.min[k]) / (self.N[k] -
                                                                1.0)

        if type(self.typant) == list:
            self.sameAnt = False
            assert len(self.typant) == self.Na, "Wrong number of antennas"
        else:
            self.sameAnt = True

        # Uniform Array
        # p is obtained from ULArray
        #
        if self.tarr == 'UA':
            if kwargs['p'] == []:
                UA = ULArray(N=self.N, dm=self.dm, w=self.w)
                p = UA.p
            else:
                p = kwargs['p']

        if self.array != []:
            lsh = tuple(list(self.array.p.shape) + [p.shape[1]])
            a = np.kron(self.array.p, np.ones(p.shape[1]))  # 3 x N
            b = np.kron(np.ones(self.array.p.shape[1]), p)  # 3 x M
            p = a + b  # 3 x NM
            p = p.reshape(lsh)

        #
        # Add the antennas of the array, either 1 (same for all points), or Na
        # (array size)
        #
        # init Antenna parent
        self.la = []
        if self.sameAnt:
            self.la.append(ant.Antenna(typ=self.typant))
        else:
            for t in self.typant:
                self.la.append(ant.Antenna(typ=t))

        super(AntArray, self).__init__(p=p, w=self.w)
        typ = 'Array'
        ant.Antenna.__init__(self, typ=typ, **kwargs)
Example #6
0
    def __init__(self, **kwargs):
        """

        Parameters
        ----------

        mode : string
            'array' | 'grid'
            array is for antenna array and grid for scanner cloud of
            points.
        typant : string
            either a selected string among the implemented predefined patterns.
            ['Omni','Hertz','Huygens','3gpp','Array'] or a filename of an antenna
            file in one of the supported file format (.vsh3 or .sh3)



        Examples
        --------

        ... plot::
            :include-source:

        >>> A = AntArray()
        >>> A.plotG()

        """
        defaults = {
            'tarr': 'UA',
            'N': [8, 1, 1],
            'dm': [0.075, 0, 0],
            'min': [0, 0, 0, 0],
            'max': [0, 0, 0, 0],
            'S': [],
            'pattern': True,
            #'typant':'S1R1.vsh3',
            'typant': 'Gauss',
            'mode': 'array',
            'array': [],
            'p': []
        }

        for k in defaults:
            if k not in kwargs:
                kwargs[k] = defaults[k]

        self.tarr = kwargs.pop('tarr')
        self.N = np.array(kwargs.pop('N'))
        self.max = np.array(kwargs.pop('max'))
        self.min = np.array(kwargs.pop('min'))
        self.Na = np.prod(self.N)  # number of antennas
        self.dm = np.array(kwargs.pop('dm'))
        self.array = kwargs.pop('array')

        if self.array == []:
            self.typant = kwargs.pop('typant')
        else:
            self.typant = self.array.typant

        # There are two modes : 'array' and 'grid'
        # If the grid mode is chosen, the spacing dm is determined
        # from max and min. In that mode max and min are prioritary w.r.t to the
        # specified dm. This is a mode which is useful when using the
        # scanner for emulating a received array from a specified range of
        # disance on a given axis. The max and min are for fixing those limits.

        if kwargs['mode'] == 'grid':
            for k in range(len(self.N)):
                if self.N[k] == 1:
                    self.dm[k] = self.max[k]
                else:
                    self.dm[k] = (self.max[k] - self.min[k]) / (self.N[k] -
                                                                1.0)

        if type(self.typant) == list:
            self.sameAnt = False
            assert len(self.typant) == self.Na, "Wrong number of antennas"
        else:
            self.sameAnt = True

        if self.tarr == 'UA':
            if kwargs['p'] == []:
                UA = ULArray(N=self.N, dm=self.dm)
                p = UA.p
            else:
                p = kwargs['p']

        if self.array != []:
            a = np.kron(self.array.p, np.ones(p.shape[1]))  # 3 x N
            b = np.kron(np.ones(self.array.p.shape[1]), p)  # 3 x M
            p = a + b  # 3 x NM

        #
        # Add the antennas of the array, either 1 (same for all points), or Na
        # (array size)
        #

        typ = 'Array'
        # init Antenna parent
        self.la = []
        if self.sameAnt:
            self.la.append(ant.Antenna(typ=self.typant))
        else:
            for t in self.typant:
                self.la.append(ant.Antenna(typ=t))

        super(AntArray, self).__init__(p=p, fGHz=self.la[0].fGHz)
        ant.Antenna.__init__(self, typ=typ, **kwargs)