def tangent_point_coordinates(self, lon_lin, lat_lin, flight_alt=14, cut_height=12): """ Computes coordinates of tangent points given coordinates of flight path. Args: lon_lin: longitudes of flight path lat_lin: latitudes of flight path flight_alt: altitude of aircraft (scalar or numpy array) cut_height: altitude of tangent points Returns: List of tuples of longitude/latitude coordinates """ lins = list(zip(lon_lin[0:-1], lon_lin[1:], lat_lin[0:-1], lat_lin[1:])) lins = [(x0 * np.cos(np.deg2rad(np.mean([y0, y1]))), x1 * np.cos(np.deg2rad(np.mean([y0, y1]))), y0, y1) for x0, x1, y0, y1 in lins] direction = [(x1 - x0, y1 - y0) for x0, x1, y0, y1 in lins] direction = [(_x / np.hypot(_x, _y), _y / np.hypot(_x, _y)) for _x, _y in direction] los = [ rotate_point(point, -self.dsbObsAngleAzimuth.value()) for point in direction ] los.append(los[-1]) if isinstance(flight_alt, (collections.abc.Sequence, np.ndarray)): dist = [(np.sqrt( max((EARTH_RADIUS + a)**2 - (EARTH_RADIUS + cut_height)**2, 0)) / 110.) for a in flight_alt[:-1]] dist.append(dist[-1]) else: dist = (np.sqrt((EARTH_RADIUS + flight_alt)**2 - (EARTH_RADIUS + cut_height)**2) / 110.) tp_dir = (np.array(los).T * dist).T tps = [(x0 + tp_x, y0 + tp_y, y0) for ((x0, x1, y0, y1), (tp_x, tp_y)) in zip(lins, tp_dir)] tps = [(x0 / np.cos(np.deg2rad(yp)), y0) for (x0, y0, yp) in tps] return tps
def create_hexagon(center_lat, center_lon, radius, angle=0.): coords_0 = (radius, 0.) coords_cart_0 = [rotate_point(coords_0, angle=0. + angle), rotate_point(coords_0, angle=60. + angle), rotate_point(coords_0, angle=120. + angle), rotate_point(coords_0, angle=180. + angle), rotate_point(coords_0, angle=240. + angle), rotate_point(coords_0, angle=300. + angle), rotate_point(coords_0, angle=360. + angle)] coords_sphere_rot = [ (center_lat + (vec[0] / 110.), center_lon + (vec[1] / (110. * np.cos(np.deg2rad((vec[0] / 110.) + center_lat))))) for vec in coords_cart_0] return coords_sphere_rot
def direction_coordinates(self, lon_lin, lat_lin): """ Computes coordinates of tangent points given coordinates of flight path. Args: lon_lin: longitudes of flight path lat_lin: latitudes of flight path flight_alt: altitude of aircraft (scalar or numpy array) cut_height: altitude of tangent points Returns: List of tuples of longitude/latitude coordinates """ lins = list(zip(lon_lin[0:-1], lon_lin[1:], lat_lin[0:-1], lat_lin[1:])) lins = [(x0 * np.cos(np.deg2rad(np.mean([y0, y1]))), x1 * np.cos(np.deg2rad(np.mean([y0, y1]))), y0, y1) for x0, x1, y0, y1 in lins] lens = [np.hypot(x1 - x0, y1 - y0) * 110. for x0, x1, y0, y1 in lins] lins = [_x for _x, _l in zip(lins, lens) if _l > 10] direction = [(0.5 * (x0 + x1), 0.5 * (y0 + y1), x1 - x0, y1 - y0) for x0, x1, y0, y1 in lins] direction = [(_u, _v, _x / np.hypot(_x, _y), _y / np.hypot(_x, _y)) for _u, _v, _x, _y in direction] los = [ rotate_point(point[2:], -self.dsbObsAngleAzimuth.value()) for point in direction ] dist = 1. tp_dir = (np.array(los).T * dist).T tps = [(x0, y0, x0 + tp_x, y0 + tp_y) for ((x0, y0, _, _), (tp_x, tp_y)) in zip(direction, tp_dir)] tps = [[(x0 / np.cos(np.deg2rad(y0)), y0), (x1 / np.cos(np.deg2rad(y0)), y1)] for (x0, y0, x1, y1) in tps] return tps
def test_rotate_point(self): assert utils.rotate_point([0, 0], 0) == (0.0, 0.0) assert utils.rotate_point([0, 0], 180) == (0.0, 0.0) assert utils.rotate_point([1, 0], 0) == (1.0, 0.0) assert utils.rotate_point([100, 90], 90) == (-90, 100)