Пример #1
0
    def route(self, pa, pb, **kwargs):
        """ coverage on a route

        Parameters
        ----------

        pa : np.array (1x2)
            lon,lat
        pb : np.array (Nx2)
            lon,lat
        Nr  :
        Ha  : float
            antenna a height
        Hb  : float
            antenna b height
        fGHz : float
            frequency
        K   : float 
            K facteur (default 4/3)
        method :
        source :
        binterb : boolean
            interpolation (default True)

        Returns
        -------

        L : Loss
        lon
        lat

        """

        self.pa = pa
        self.pb = pb
        Nr = kwargs.pop('Nr',200)
        Ha = kwargs.pop('Ha',30)
        Hb = kwargs.pop('Hb',200)
        fGHz = kwargs.pop('fGHz',0.868)
        K = kwargs.pop('K',1.333)
        method = kwargs.pop('method','deygout')
        source = kwargs.pop('source','srtm')
        binterp = kwargs.pop('binterp',True)
        divider = kwargs.pop('divider',[])

        x_a, y_a = self.m(pa[0], pa[1])
        x_b, y_b = self.m(pb[:, 0], pb[:, 1])
        u = np.linspace(0, 1, Nr)
        x = x_a + (x_b[:,None] - x_a)*u[None,:]
        y = y_a + (y_b[:,None] - y_a)*u[None,:]

        lon, lat = self.m(x, y, inverse=True)
        # distance along path
        Dx = x - x[:, 0][:, None]
        Dy = y - y[:, 0][:, None]
        d = np.sqrt(Dx*Dx+Dy*Dy)
        # equivalent earth curvature
        dh = d*(d[:,::-1])/(2*K*6375e3)

        Dlon = (lon - self.extent[0]) / self.lonstep
        Dlat= (self.extent[3]-lat) / self.latstep
        #
        # Interpolation
        #

        if binterp:
            rlon = np.floor(Dlon).astype(int)
            rlat = np.floor(Dlat).astype(int)
            dlon = Dlon - rlon
            dlat = Dlat - rlat

            if source == 'srtm':
                hll = self.hgts[rlat, rlon]
                hlr = self.hgts[rlat, rlon+1]
                hul = self.hgts[rlat+1, rlon]
                hur = self.hgts[rlat+1, rlon+1]

            if source == 'aster':
                hll = self.hgta[rlat, rlon]
                hlr = self.hgta[rlat, rlon+1]
                hul = self.hgta[rlat+1, rlon]
                hur = self.hgta[rlat+1, rlon+1]
            #    height = self.hgta[ry, rx]

            wll = dlon**2 + (1-dlat)**2
            wlr = (1-dlon)**2 + (1-dlat)**2
            wul = dlon**2 + dlat**2
            wur = (1-dlon)**2 + dlat**2
            height = (wll*hll+wlr*hlr+wul*hul+wur*hur)/(wll+wlr+wul+wur) + dh
        else:
            rlon = np.round(Dlon).astype(int)
            rlat = np.round(Dlat).astype(int)
            if source == 'srtm':
                height = self.hgts[rlat, rlon] + dh
            if source == 'srtm':
                height = self.hgta[rlat, rlon] + dh

        self.L = loss.route(x, y, height, Ha, Hb, fGHz, K, method=method)

        return(self.L,lon,lat)
Пример #2
0
    def route(self, pa, pb, **kwargs):
        """ coverage on a route

        Parameters
        ----------

        pa : np.array (1x2)
            lon,lat
        pb : np.array (Nx2)
            lon,lat
        Nr  :
        Ha  : float
            antenna a height
        Hb  : float
            antenna b height
        fGHz : float
            frequency
        K   : float
            K facteur (default 4/3)
        method :
        source :
        binterb : boolean
            interpolation (default True)

        Returns
        -------

        L : Loss
        lon
        lat

        """

        self.pa = pa
        self.pb = pb
        Nr = kwargs.pop('Nr', 200)
        Ha = kwargs.pop('Ha', 30)
        Hb = kwargs.pop('Hb', 200)
        fGHz = kwargs.pop('fGHz', 0.868)
        K = kwargs.pop('K', 1.333)
        method = kwargs.pop('method', 'deygout')
        source = kwargs.pop('source', 'srtm')
        binterp = kwargs.pop('binterp', True)
        divider = kwargs.pop('divider', [])

        x_a, y_a = self.m(pa[0], pa[1])
        x_b, y_b = self.m(pb[:, 0], pb[:, 1])
        u = np.linspace(0, 1, Nr)
        x = x_a + (x_b[:, None] - x_a) * u[None, :]
        y = y_a + (y_b[:, None] - y_a) * u[None, :]

        lon, lat = self.m(x, y, inverse=True)
        # distance along path
        Dx = x - x[:, 0][:, None]
        Dy = y - y[:, 0][:, None]
        d = np.sqrt(Dx * Dx + Dy * Dy)
        # equivalent earth curvature
        dh = d * (d[:, ::-1]) / (2 * K * 6375e3)

        Dlon = (lon - self.extent[0]) / self.lonstep
        Dlat = (self.extent[3] - lat) / self.latstep
        #
        # Interpolation
        #

        if binterp:
            rlon = np.floor(Dlon).astype(int)
            rlat = np.floor(Dlat).astype(int)
            dlon = Dlon - rlon
            dlat = Dlat - rlat

            if source == 'srtm':
                hll = self.hgts[rlat, rlon]
                hlr = self.hgts[rlat, rlon + 1]
                hul = self.hgts[rlat + 1, rlon]
                hur = self.hgts[rlat + 1, rlon + 1]

            if source == 'aster':
                hll = self.hgta[rlat, rlon]
                hlr = self.hgta[rlat, rlon + 1]
                hul = self.hgta[rlat + 1, rlon]
                hur = self.hgta[rlat + 1, rlon + 1]
            #    height = self.hgta[ry, rx]

            wll = dlon**2 + (1 - dlat)**2
            wlr = (1 - dlon)**2 + (1 - dlat)**2
            wul = dlon**2 + dlat**2
            wur = (1 - dlon)**2 + dlat**2
            height = (wll * hll + wlr * hlr + wul * hul +
                      wur * hur) / (wll + wlr + wul + wur) + dh
        else:
            rlon = np.round(Dlon).astype(int)
            rlat = np.round(Dlat).astype(int)
            if source == 'srtm':
                height = self.hgts[rlat, rlon] + dh
            if source == 'srtm':
                height = self.hgta[rlat, rlon] + dh

        self.L = loss.route(x, y, height, Ha, Hb, fGHz, K, method=method)

        return (self.L, lon, lat)