2424
2525py_eddy_tracker_classes.py
2626
27- Version 2.0.1
27+ Version 2.0.3
2828===========================================================================
2929
3030
@@ -376,7 +376,7 @@ def fit_circle(xvec, yvec):
376376
377377 # Indices of polygon points outside circle
378378 # 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 ( )
380380
381381 p_inon_x = xvec # init
382382 p_inon_y = yvec # init
@@ -954,9 +954,10 @@ def track_eddies(Eddy, first_record):
954954 new_cntr_e , new_cntr_s , new_uavg_prf = [], [], []
955955 new_shp_err = np .array ([])
956956
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 )
960961
961962 '''
962963 # See http://stackoverflow.com/questions/11528078/determining-duplicate-values-in-an-array
@@ -983,6 +984,7 @@ def track_eddies(Eddy, first_record):
983984 plt .xlabel ('new' )
984985 plt .ylabel ('old' )
985986 plt .title ('original' )
987+ plt .show ()
986988
987989 # Make an ellipse at current old_eddy location
988990 # (See CSS11 sec. B4, pg. 208)
@@ -997,7 +999,7 @@ def track_eddies(Eddy, first_record):
997999 for new_ind in new_sparse_inds :
9981000
9991001 new_dist = dist_mat [old_ind , new_ind ]
1000-
1002+
10011003 within_range = False
10021004 #print far_away, Eddy.search_ellipse.rw_c_mod, new_dist
10031005 if new_dist < Eddy .search_ellipse .rw_c_mod :#far_away:
@@ -1018,54 +1020,38 @@ def track_eddies(Eddy, first_record):
10181020
10191021 # Pass only the eddies within ellipse or sep_dist
10201022 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 ])
10211033
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
10691055
10701056 if Eddy .TRACK_EXTRA_VARIABLES :
10711057 kwargs = {'contour_e' : new_cntr_e , 'contour_s' : new_cntr_s ,
@@ -1075,7 +1061,6 @@ def track_eddies(Eddy, first_record):
10751061
10761062 # Only one eddy within range
10771063 if dist_arr .size == 1 : # then update the eddy track only
1078-
10791064 # Use index 0 here because type is list and we want the scalar
10801065 args = (Eddy , old_ind , new_ln [0 ], new_lt [0 ], new_rd_s [0 ],
10811066 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):
11031088
11041089 # Choice of using effective or speed-based...
11051090 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 ()
11081093 delta_amp_tmp = np .array ([Eddy .old_amp [old_ind ],
11091094 new_am [i ]]).ptp ()
11101095 delta_area = np .r_ [delta_area , delta_area_tmp ]
@@ -1120,9 +1105,9 @@ def track_eddies(Eddy, first_record):
11201105 #np.abs(np.diff([Eddy.old_salt[old_ind], new_st[i]]))]
11211106
11221107 # 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 )
11261111
11271112 dx = deltaX .argsort ()
11281113 dx0 = dx [0 ] # index to the nearest eddy
0 commit comments