24
24
25
25
py_eddy_tracker_classes.py
26
26
27
- Version 2.0.1
27
+ Version 2.0.3
28
28
===========================================================================
29
29
30
30
@@ -376,7 +376,7 @@ def fit_circle(xvec, yvec):
376
376
377
377
# Indices of polygon points outside circle
378
378
# p_inon_? : polygon x or y points inside & on the circle
379
- pout_id = np . nonzero (dist_poly > r )
379
+ pout_id = (dist_poly > r ). nonzero ( )
380
380
381
381
p_inon_x = xvec # init
382
382
p_inon_y = yvec # init
@@ -954,9 +954,10 @@ def track_eddies(Eddy, first_record):
954
954
new_cntr_e , new_cntr_s , new_uavg_prf = [], [], []
955
955
new_shp_err = np .array ([])
956
956
957
- new_inds , backup_ind , backup_dist = np .array ([], dtype = np .int16 ), \
958
- np .array ([], dtype = np .int16 ), \
959
- np .array ([])
957
+ #new_inds, backup_ind, backup_dist = np.array([], dtype=np.int16), \
958
+ #np.array([], dtype=np.int16), \
959
+ #np.array([])
960
+ backup_ind = np .array ([], dtype = np .int16 )
960
961
961
962
'''
962
963
# See http://stackoverflow.com/questions/11528078/determining-duplicate-values-in-an-array
@@ -983,6 +984,7 @@ def track_eddies(Eddy, first_record):
983
984
plt .xlabel ('new' )
984
985
plt .ylabel ('old' )
985
986
plt .title ('original' )
987
+ plt .show ()
986
988
987
989
# Make an ellipse at current old_eddy location
988
990
# (See CSS11 sec. B4, pg. 208)
@@ -997,7 +999,7 @@ def track_eddies(Eddy, first_record):
997
999
for new_ind in new_sparse_inds :
998
1000
999
1001
new_dist = dist_mat [old_ind , new_ind ]
1000
-
1002
+
1001
1003
within_range = False
1002
1004
#print far_away, Eddy.search_ellipse.rw_c_mod, new_dist
1003
1005
if new_dist < Eddy .search_ellipse .rw_c_mod :#far_away:
@@ -1018,54 +1020,38 @@ def track_eddies(Eddy, first_record):
1018
1020
1019
1021
# Pass only the eddies within ellipse or sep_dist
1020
1022
if within_range :
1023
+
1024
+ dist_arr = np .r_ [dist_arr , new_dist ]
1025
+ new_ln .append (Eddy .new_lon_tmp [new_ind ])
1026
+ new_lt .append (Eddy .new_lat_tmp [new_ind ])
1027
+ new_rd_s .append (Eddy .new_radii_tmp_s [new_ind ])
1028
+ new_rd_e .append (Eddy .new_radii_tmp_e [new_ind ])
1029
+ new_am .append (Eddy .new_amp_tmp [new_ind ])
1030
+ new_Ua .append (Eddy .new_uavg_tmp [new_ind ])
1031
+ new_ek .append (Eddy .new_teke_tmp [new_ind ])
1032
+ new_tm .append (Eddy .new_time_tmp [new_ind ])
1021
1033
1022
- old_amplitude [:] = Eddy .old_amp [old_ind ]
1023
- new_amplitude [:] = Eddy .new_amp_tmp [new_ind ]
1024
-
1025
- # Following CSS11, we use effective radius rather than speed based...
1026
- old_area [:] = Eddy .old_radii_s [old_ind ]** 2
1027
- old_area *= np .pi
1028
- new_area [:] = Eddy .new_radii_tmp_s [new_ind ]** 2
1029
- new_area *= np .pi
1030
-
1031
- # Pass only the eddies within min and max times old amplitude
1032
- # and area (KCCMC11 and CSS11 use 0.25 and 2.5, respectively)
1033
- if (new_amplitude >= (Eddy .EVOLVE_AMP_MIN * old_amplitude ) and
1034
- new_amplitude <= (Eddy .EVOLVE_AMP_MAX * old_amplitude )) and \
1035
- (new_area >= (Eddy .EVOLVE_AREA_MIN * old_area ) and
1036
- new_area <= (Eddy .EVOLVE_AREA_MAX * old_area )):
1037
-
1038
- dist_arr = np .r_ [dist_arr , new_dist ]
1039
- new_ln .append (Eddy .new_lon_tmp [new_ind ])
1040
- new_lt .append (Eddy .new_lat_tmp [new_ind ])
1041
- new_rd_s .append (Eddy .new_radii_tmp_s [new_ind ])
1042
- new_rd_e .append (Eddy .new_radii_tmp_e [new_ind ])
1043
- new_am .append (Eddy .new_amp_tmp [new_ind ])
1044
- new_Ua .append (Eddy .new_uavg_tmp [new_ind ])
1045
- new_ek .append (Eddy .new_teke_tmp [new_ind ])
1046
- new_tm .append (Eddy .new_time_tmp [new_ind ])
1047
-
1048
- if 'ROMS' in Eddy .PRODUCT :
1049
- #new_tp = np.r_[new_tp, Eddy.new_temp_tmp[new_ind]]
1050
- #new_st = np.r_[new_st, Eddy.new_salt_tmp[new_ind]]
1051
- pass
1052
-
1053
- if Eddy .TRACK_EXTRA_VARIABLES :
1054
- new_cntr_e .append (Eddy .new_contour_e_tmp [new_ind ])
1055
- new_cntr_s .append (Eddy .new_contour_s_tmp [new_ind ])
1056
- new_uavg_prf .append (Eddy .new_uavg_profile_tmp [new_ind ])
1057
- new_shp_err = np .r_ [new_shp_err ,
1058
- Eddy .new_shape_error_tmp [new_ind ]]
1059
-
1060
- new_inds = np .r_ [new_inds , new_ind ]
1061
- backup_ind = np .r_ [backup_ind , new_ind ]
1062
-
1063
- # An old (active) eddy has been detected, so
1064
- # corresponding new_eddy_inds set to False
1065
- new_eddy_inds [np .nonzero (Eddy .new_lon_tmp ==
1066
- Eddy .new_lon_tmp [new_ind ])] = False
1067
-
1068
- dist_mat [:, new_ind ] = far_away # km
1034
+
1035
+ if 'ROMS' in Eddy .PRODUCT :
1036
+ #new_tp = np.r_[new_tp, Eddy.new_temp_tmp[new_ind]]
1037
+ #new_st = np.r_[new_st, Eddy.new_salt_tmp[new_ind]]
1038
+ pass
1039
+
1040
+ if Eddy .TRACK_EXTRA_VARIABLES :
1041
+ new_cntr_e .append (Eddy .new_contour_e_tmp [new_ind ])
1042
+ new_cntr_s .append (Eddy .new_contour_s_tmp [new_ind ])
1043
+ new_uavg_prf .append (Eddy .new_uavg_profile_tmp [new_ind ])
1044
+ new_shp_err = np .r_ [new_shp_err ,
1045
+ Eddy .new_shape_error_tmp [new_ind ]]
1046
+
1047
+ backup_ind = np .r_ [backup_ind , new_ind ]
1048
+
1049
+ # An old (active) eddy has been detected, so
1050
+ # corresponding new_eddy_inds set to False
1051
+ new_eddy_inds [np .nonzero (Eddy .new_lon_tmp ==
1052
+ Eddy .new_lon_tmp [new_ind ])] = False
1053
+
1054
+ dist_mat [:, new_ind ] = far_away # km
1069
1055
1070
1056
if Eddy .TRACK_EXTRA_VARIABLES :
1071
1057
kwargs = {'contour_e' : new_cntr_e , 'contour_s' : new_cntr_s ,
@@ -1075,7 +1061,6 @@ def track_eddies(Eddy, first_record):
1075
1061
1076
1062
# Only one eddy within range
1077
1063
if dist_arr .size == 1 : # then update the eddy track only
1078
-
1079
1064
# Use index 0 here because type is list and we want the scalar
1080
1065
args = (Eddy , old_ind , new_ln [0 ], new_lt [0 ], new_rd_s [0 ],
1081
1066
new_rd_e [0 ], new_am [0 ], new_Ua [0 ], new_ek [0 ], new_tm [0 ],
@@ -1103,8 +1088,8 @@ def track_eddies(Eddy, first_record):
1103
1088
1104
1089
# Choice of using effective or speed-based...
1105
1090
delta_area_tmp = np .array ([np .pi *
1106
- (Eddy .old_radii_e [old_ind ]** 2 ),
1107
- np .pi * (new_rd_e [i ]** 2 )]).ptp ()
1091
+ (Eddy .old_radii_e [old_ind ] ** 2 ),
1092
+ np .pi * (new_rd_e [i ] ** 2 )]).ptp ()
1108
1093
delta_amp_tmp = np .array ([Eddy .old_amp [old_ind ],
1109
1094
new_am [i ]]).ptp ()
1110
1095
delta_area = np .r_ [delta_area , delta_area_tmp ]
@@ -1120,9 +1105,9 @@ def track_eddies(Eddy, first_record):
1120
1105
#np.abs(np.diff([Eddy.old_salt[old_ind], new_st[i]]))]
1121
1106
1122
1107
# This from Penven etal (2005)
1123
- deltaX = np .sqrt ((delta_area / AREA0 )** 2 +
1124
- (delta_amp / AMP0 )** 2 +
1125
- (dist_arr / DIST0 )** 2 )
1108
+ deltaX = np .sqrt ((delta_area / AREA0 ) ** 2 +
1109
+ (delta_amp / AMP0 ) ** 2 +
1110
+ (dist_arr / DIST0 ) ** 2 )
1126
1111
1127
1112
dx = deltaX .argsort ()
1128
1113
dx0 = dx [0 ] # index to the nearest eddy
0 commit comments