|
59 | 59 | from matplotlib.path import Path as BasePath
|
60 | 60 | from .. import VAR_DESCR, VAR_DESCR_inv
|
61 | 61 | from ..generic import distance_grid, distance, flatten_line_matrix, wrap_longitude
|
62 |
| -from ..poly import bbox_intersection, common_area |
| 62 | +from ..poly import bbox_intersection, common_area, create_vertice |
63 | 63 |
|
64 | 64 | logger = logging.getLogger("pet")
|
65 | 65 |
|
@@ -123,16 +123,6 @@ def shifted_ellipsoid_degrees_mask2(lon0, lat0, lon1, lat1, minor=1.5, major=1.5
|
123 | 123 | return m
|
124 | 124 |
|
125 | 125 |
|
126 |
| -@njit(cache=True, fastmath=True) |
127 |
| -def custom_concat(x, y): |
128 |
| - nb = x.shape[0] |
129 |
| - a = empty((nb, 2)) |
130 |
| - for i in range(nb): |
131 |
| - a[i, 0] = x[i] |
132 |
| - a[i, 1] = y[i] |
133 |
| - return a |
134 |
| - |
135 |
| - |
136 | 126 | class EddiesObservations(object):
|
137 | 127 | """
|
138 | 128 | Class to hold eddy properties *amplitude* and counts of
|
@@ -761,10 +751,10 @@ def cost_function_common_area(cls, xy_in, xy_out, distance, intern=False):
|
761 | 751 | continue
|
762 | 752 |
|
763 | 753 | x_in_, x_out_ = x_in[i], x_out[i]
|
764 |
| - p_in = Polygon(custom_concat(x_in_, y_in[i])) |
| 754 | + p_in = Polygon(create_vertice(x_in_, y_in[i])) |
765 | 755 | if abs(x_in_[0] - x_out_[0]) > 180:
|
766 | 756 | x_out_ = (x_out[i] - (x_in_[0] - 180)) % 360 + x_in_[0] - 180
|
767 |
| - p_out = Polygon(custom_concat(x_out_, y_out[i])) |
| 757 | + p_out = Polygon(create_vertice(x_out_, y_out[i])) |
768 | 758 | costs[i] = 1 - (p_in & p_out).area() / min(p_in.area(), p_out.area())
|
769 | 759 | costs.mask = costs == 1
|
770 | 760 | return costs
|
@@ -1288,7 +1278,7 @@ def grid_count(self, bins, intern=False, center=False):
|
1288 | 1278 | else:
|
1289 | 1279 | x, y = (self[x_name] - x0) % 360 + x0, self[y_name]
|
1290 | 1280 | for x_, y_ in zip(x, y):
|
1291 |
| - i, j = BasePath(custom_concat(x_, y_)).pixels_in(regular_grid) |
| 1281 | + i, j = BasePath(create_vertice(x_, y_)).pixels_in(regular_grid) |
1292 | 1282 | grid_count_(grid, i, j)
|
1293 | 1283 | grid.mask = grid == 0
|
1294 | 1284 | return regular_grid
|
|
0 commit comments