36
36
from .tracking_objects import uniform_resample , nearest
37
37
from .observations import EddiesObservations
38
38
from .property_objects import Amplitude
39
- from .tools import distance , winding_number_poly , fit_circle_c
39
+ from .tools import distance , winding_number_poly , fit_circle_c , poly_contain_poly
40
40
from matplotlib .path import Path as BasePath
41
41
from scipy .interpolate import griddata
42
42
@@ -166,7 +166,6 @@ def get_uavg(eddy, contours, centlon_e, centlat_e, poly_eff, grd,
166
166
167
167
if 'RectBivariate' in eddy .interp_method :
168
168
uavg = eddy .uspd_coeffs .ev (theseglat [1 :], theseglon [1 :]).mean ()
169
-
170
169
elif 'griddata' in eddy .interp_method :
171
170
uspd1d = eddy .uspd [eddy .slice_j , eddy .slice_i ].ravel ()
172
171
uavg = griddata (points , uspd1d ,
@@ -201,7 +200,6 @@ def get_uavg(eddy, contours, centlon_e, centlat_e, poly_eff, grd,
201
200
# Leave loop if no contours at level citer.index
202
201
theindex = eddy .swirl .get_index_nearest_path (
203
202
corrected_coll_index , centlon_e , centlat_e )
204
-
205
203
if theindex is None :
206
204
continue
207
205
@@ -212,15 +210,14 @@ def get_uavg(eddy, contours, centlon_e, centlat_e, poly_eff, grd,
212
210
continue
213
211
214
212
# 2. Ensure polygon_i is within polygon_e
215
- if not poly_eff .contains_path ( poly_i ):
213
+ if not poly_contain_poly ( poly_eff .vertices , poly_i . vertices ):
216
214
continue
217
215
218
216
# 3. Respect size range
219
217
mask_i_sum = poly_i .contains_points (points ).sum ()
220
218
if not (mask_i_sum >= pixel_min and
221
219
mask_i_sum <= eddy .pixel_threshold [1 ]):
222
220
continue
223
-
224
221
any_inner_contours = True
225
222
226
223
seglon , seglat = (poly_i .vertices [:, 0 ], poly_i .vertices [:, 1 ])
@@ -249,27 +246,14 @@ def get_uavg(eddy, contours, centlon_e, centlat_e, poly_eff, grd,
249
246
250
247
if not any_inner_contours :
251
248
# set speed based contour parameters
252
- # proj = Proj('+proj=aeqd +lat_0=%s +lon_0=%s'
253
- # % (theseglat.mean(), theseglon.mean()))
254
- # cx, cy = proj(theseglon, theseglat)
255
- # # cx, cy = eddy.m_val(theseglon, theseglat)
256
- # centx_s, centy_s, eddy_radius_s, junk = fit_circle(cx, cy)
257
- # centlon_s, centlat_s = proj(centx_s, centy_s, inverse=True)
258
- # # centlon_s, centlat_s = eddy.m_val(centx_s, centy_s, inverse=True)
259
-
260
- # else: # use the effective contour
261
- # centlon_s, centlat_s = centlon_e, centlat_e
262
- # eddy_radius_s = eddy_radius_e
263
249
inner_seglon , inner_seglat = theseglon , theseglat
264
250
265
251
if not save_all_uavg :
266
- # return (uavg, centlon_s, centlat_s, eddy_radius_s,
267
- # theseglon, theseglat, inner_seglon, inner_seglat)
268
- return (uavg , theseglon , theseglat , inner_seglon , inner_seglat )
269
-
252
+ return (uavg , theseglon , theseglat ,
253
+ inner_seglon , inner_seglat , any_inner_contours )
270
254
else :
271
- return (uavg , theseglon , theseglat , inner_seglon , inner_seglat ,
272
- all_uavg )
255
+ return (uavg , theseglon , theseglat ,
256
+ inner_seglon , inner_seglat , any_inner_contours , all_uavg )
273
257
274
258
275
259
def isvalid (self ):
@@ -438,8 +422,6 @@ def collection_loop(contours, grd, rtime, a_list_obj, c_list_obj,
438
422
if 'Q' in eddy .diagnostic_type :
439
423
# KCCMC11
440
424
# Note, eddy amplitude == max(abs(vort/f)) within eddy,
441
- # amplitude = np.abs(x_i[jmin:jmax,imin:imax
442
- # ].flat[mask_eff]).max()
443
425
amplitude = np .abs (x_i [eddy .slice_j , eddy .slice_i
444
426
][eddy .mask_eff ]).max ()
445
427
@@ -475,19 +457,15 @@ def collection_loop(contours, grd, rtime, a_list_obj, c_list_obj,
475
457
#~ if eddy.track_array_variables > 0:
476
458
477
459
if not eddy .track_extra_variables :
478
- # (uavg, centlon_s, centlat_s,
479
- # eddy_radius_s, contlon_s, contlat_s,
480
- # inner_contlon, inner_contlat) = get_uavg(*args)
481
460
(uavg , contlon_s , contlat_s ,
482
- inner_contlon , inner_contlat ) = get_uavg (* args )
461
+ inner_contlon , inner_contlat ,
462
+ any_inner_contours
463
+ ) = get_uavg (* args )
483
464
else :
484
- # (uavg, centlon_s, centlat_s,
485
- # eddy_radius_s, contlon_s, contlat_s,
486
- # inner_contlon, inner_contlat,
487
- # uavg_profile) = get_uavg(*args, save_all_uavg=True)
488
465
(uavg , contlon_s , contlat_s ,
489
466
inner_contlon , inner_contlat ,
490
- uavg_profile ) = get_uavg (
467
+ any_inner_contours , uavg_profile
468
+ ) = get_uavg (
491
469
* args , save_all_uavg = True )
492
470
493
471
# Use azimuth equal projection for radius
0 commit comments