def cover(self, **kwargs): """ coverage around a point Parameters ---------- pc : np.array center point in lonlat coordinates Nphi : int Number of angular direction Nr : int Number of points along radius Rmax : float Radius maximum (meters) Hr : float Receiver height Ht : float Transmitter height K : float K factor Returns ------- triang, L """ defaults = {'pc': (-1.627449, 48.124648), 'Nphi': 360, 'Nr': 200, 'Rmax': 4000, 'Ht': 30, 'Hr': 1.5, 'K': 1.3333, 'fGHz': .3, 'source': 'srtm', 'divider': [] } for key in defaults: if key not in kwargs: kwargs[key] = defaults[key] if 'fig' not in kwargs: f, a = plt.subplots(1, 1) else: f = kwargs['fig'] a = kwargs['ax'] Ht = kwargs['Ht'] Hr = kwargs['Hr'] fGHz = kwargs['fGHz'] K = kwargs['K'] Rmax = kwargs['Rmax'] Nr = kwargs['Nr'] Nphi = kwargs['Nphi'] x_c, y_c = self.m(kwargs['pc'][0], kwargs['pc'][1]) pc = np.array([x_c, y_c]) #lmbda = 0.3/fGHz # phi: Nphi x 1 phi = np.linspace(0, 2*np.pi, Nphi)[:, None] # r : 1 x Nr r = np.linspace(0.02, Rmax, Nr)[None, :] x = pc[0] + r*np.cos(phi) y = pc[1] + r*np.sin(phi) # extent_c = np.array([x.min(),x.max(),y.min(),y.max()]) #dh = d*(d[::-1])/(2*K*6375e3) # Triangulation of the coverage zone triang = tri.Triangulation(x.flatten(), y.flatten()) lon, lat = self.m(triang.x, triang.y, inverse=True) # back in lon,lat coordinates triang.x = lon triang.y = lat lon, lat = self.m(x, y, inverse=True) rx = np.floor((lon - self.extent[0]) / self.lonstep).astype(int) ry = np.floor((self.extent[3]-lat) / self.latstep).astype(int) # height #cov = self.hgts[ry, rx] if kwargs['source'] == 'srtm': height = self.hgts[ry, rx] if kwargs['source'] == 'aster': height = self.hgta[ry, rx] L = loss.cover(x, y, height, Ht, Hr, fGHz, K, method='deygout') self.triang = triang self.coverage = L return triang, L
def cover(self, **kwargs): """ coverage around a point Parameters ---------- pc : np.array center point in lonlat coordinates Nphi : int Number of angular direction Nr : int Number of points along radius Rmax : float Radius maximum (meters) Hr : float Receiver height Ht : float Transmitter height K : float K factor Returns ------- triang, L """ defaults = { 'pc': (-1.627449, 48.124648), 'Nphi': 360, 'Nr': 200, 'Rmax': 4000, 'Ht': 30, 'Hr': 1.5, 'K': 1.3333, 'fGHz': .3, 'source': 'srtm', 'divider': [] } for key in defaults: if key not in kwargs: kwargs[key] = defaults[key] if 'fig' not in kwargs: f, a = plt.subplots(1, 1) else: f = kwargs['fig'] a = kwargs['ax'] Ht = kwargs['Ht'] Hr = kwargs['Hr'] fGHz = kwargs['fGHz'] K = kwargs['K'] Rmax = kwargs['Rmax'] Nr = kwargs['Nr'] Nphi = kwargs['Nphi'] x_c, y_c = self.m(kwargs['pc'][0], kwargs['pc'][1]) pc = np.array([x_c, y_c]) #lmbda = 0.3/fGHz # phi: Nphi x 1 phi = np.linspace(0, 2 * np.pi, Nphi)[:, None] # r : 1 x Nr r = np.linspace(0.02, Rmax, Nr)[None, :] x = pc[0] + r * np.cos(phi) y = pc[1] + r * np.sin(phi) # extent_c = np.array([x.min(),x.max(),y.min(),y.max()]) #dh = d*(d[::-1])/(2*K*6375e3) # Triangulation of the coverage zone triang = tri.Triangulation(x.flatten(), y.flatten()) lon, lat = self.m(triang.x, triang.y, inverse=True) # back in lon,lat coordinates triang.x = lon triang.y = lat lon, lat = self.m(x, y, inverse=True) rx = np.floor((lon - self.extent[0]) / self.lonstep).astype(int) if rx.max() > self.hgts.shape[1]: rx = np.floor((self.extent[1] - lon) / self.lonstep).astype(int) ry = np.floor((self.extent[3] - lat) / self.latstep).astype(int) if ry.max() > self.hgts.shape[0]: ry = np.floor((lat - self.extent[2]) / self.latstep).astype(int) # height #cov = self.hgts[ry, rx] if kwargs['source'] == 'srtm': height = self.hgts[ry, rx] if kwargs['source'] == 'aster': height = self.hgta[ry, rx] L = loss.cover(x, y, height, Ht, Hr, fGHz, K, method='deygout') self.triang = triang self.coverage = L return triang, L