1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
|
# Copyright Cartopy Contributors
#
# This file is part of Cartopy and is released under the LGPL license.
# See COPYING and COPYING.LESSER in the root of the repository for full
# licensing details.
import numpy as np
from cartopy.geodesic import Geodesic
class DirectSuite:
params = [
('scalar', 'array'),
('scalar', 'array'),
('zero', 'scalar', 'array'),
]
param_names = ['points', 'azimuths', 'distances']
def setup(self, points, azimuths, distances):
self.geod = Geodesic()
self.points = {
'scalar': (0, 0),
'array': np.arange(200).reshape(-1, 2),
}[points]
self.azimuths = {
'scalar': 0,
'array': np.arange(100) * 2,
}[azimuths]
self.distances = {
'zero': 0,
'scalar': 100,
'array': np.logspace(2, 5, 100),
}[distances]
def time_direct(self, points, azimuths, distances):
self.geod.direct(self.points, self.azimuths, self.distances)
class InverseSuite:
params = [
('scalar', 'array'),
('scalar', 'array'),
]
param_names = ['points', 'endpoints']
def setup(self, points, endpoints):
self.geod = Geodesic()
possible_points = {
'scalar': (0, 0),
'array': np.arange(200).reshape(-1, 2),
}
self.points = possible_points[points]
self.endpoints = possible_points[endpoints]
def time_inverse(self, points, endpoints):
self.geod.inverse(self.points, self.endpoints)
class CircleSuite:
params = [100, 1000, 10000, 100e3, 1000e3, 10000e3] # in metres
param_names = ['radius']
def time_circle(self, radius):
geod = Geodesic()
geod.circle(0, 0, radius)
|