|
28 | 28 | isnan, |
29 | 29 | percentile, |
30 | 30 | zeros, |
31 | | - arctan2, |
32 | | - arcsin, |
33 | 31 | round_, |
34 | 32 | nanmean, |
35 | 33 | exp, |
|
50 | 48 | from ..observations.observation import EddiesObservations |
51 | 49 | from ..eddy_feature import Amplitude, Contours |
52 | 50 | from .. import VAR_DESCR |
53 | | -from ..generic import distance, interp2d_geo, fit_circle, uniform_resample |
54 | | -from ..poly import poly_contain_poly, winding_number_grid_in_poly, winding_number_poly |
| 51 | +from ..generic import distance, interp2d_geo, fit_circle, uniform_resample, coordinates_to_local, local_to_coordinates |
| 52 | +from ..poly import poly_contain_poly, winding_number_grid_in_poly, winding_number_poly, create_vertice |
55 | 53 |
|
56 | 54 | logger = logging.getLogger("pet") |
57 | 55 |
|
@@ -86,14 +84,6 @@ def lat(self): |
86 | 84 | BasePath.lat = lat |
87 | 85 |
|
88 | 86 |
|
89 | | -@njit(cache=True) |
90 | | -def prepare_for_kdtree(x_val, y_val): |
91 | | - data = empty((x_val.shape[0], 2)) |
92 | | - data[:, 0] = x_val |
93 | | - data[:, 1] = y_val |
94 | | - return data |
95 | | - |
96 | | - |
97 | 87 | @njit(cache=True) |
98 | 88 | def uniform_resample_stack(vertices, num_fac=2, fixed_size=None): |
99 | 89 | x_val, y_val = vertices[:, 0], vertices[:, 1] |
@@ -195,45 +185,6 @@ def _get_pixel_in_unregular(vertices, x_c, y_c, x_start, x_stop, y_start, y_stop |
195 | 185 | return i_x, i_y |
196 | 186 |
|
197 | 187 |
|
198 | | -@njit(cache=True, fastmath=True) |
199 | | -def coordinates_to_local(lon, lat, lon0, lat0): |
200 | | - D2R = pi / 180.0 |
201 | | - R = 6370997 |
202 | | - dlon = (lon - lon0) * D2R |
203 | | - sin_dlat = sin((lat - lat0) * 0.5 * D2R) |
204 | | - sin_dlon = sin(dlon * 0.5) |
205 | | - cos_lat0 = cos(lat0 * D2R) |
206 | | - cos_lat = cos(lat * D2R) |
207 | | - a_val = sin_dlon ** 2 * cos_lat0 * cos_lat + sin_dlat ** 2 |
208 | | - module = R * 2 * arctan2(a_val ** 0.5, (1 - a_val) ** 0.5) |
209 | | - |
210 | | - azimuth = pi / 2 - arctan2( |
211 | | - cos_lat * sin(dlon), |
212 | | - cos_lat0 * sin(lat * D2R) - sin(lat0 * D2R) * cos_lat * cos(dlon), |
213 | | - ) |
214 | | - return module * cos(azimuth), module * sin(azimuth) |
215 | | - |
216 | | - |
217 | | -@njit(cache=True, fastmath=True) |
218 | | -def local_to_coordinates(x, y, lon0, lat0): |
219 | | - D2R = pi / 180.0 |
220 | | - R = 6370997 |
221 | | - d = (x ** 2 + y ** 2) ** 0.5 / R |
222 | | - a = -(arctan2(y, x) - pi / 2) |
223 | | - lat = arcsin(sin(lat0 * D2R) * cos(d) + cos(lat0 * D2R) * sin(d) * cos(a)) |
224 | | - lon = ( |
225 | | - lon0 |
226 | | - + arctan2( |
227 | | - sin(a) * sin(d) * cos(lat0 * D2R), cos(d) - sin(lat0 * D2R) * sin(lat) |
228 | | - ) |
229 | | - / D2R |
230 | | - ) |
231 | | - return lon, lat / D2R |
232 | | - |
233 | | - |
234 | | -BasePath.fit_circle = fit_circle_path |
235 | | - |
236 | | - |
237 | 188 | def pixels_in(self, grid): |
238 | 189 | if not hasattr(self, "_slice"): |
239 | 190 | self._slice = grid.bbox_indice(self.vertices) |
@@ -1081,7 +1032,7 @@ def compute_pixel_path(self, x0, y0, x1, y1): |
1081 | 1032 | def init_pos_interpolator(self): |
1082 | 1033 | logger.debug("Create a KdTree could be long ...") |
1083 | 1034 | self.index_interp = cKDTree( |
1084 | | - prepare_for_kdtree(self.x_c.reshape(-1), self.y_c.reshape(-1)) |
| 1035 | + create_vertice(self.x_c.reshape(-1), self.y_c.reshape(-1)) |
1085 | 1036 | ) |
1086 | 1037 |
|
1087 | 1038 | logger.debug("... OK") |
|
0 commit comments