2525
2626make_eddy_tracker_list_obj.py
2727
28- Version 1.2.1
28+ Version 1.3.0
2929
3030
3131===========================================================================
@@ -123,7 +123,7 @@ class track (object):
123123 saved2nc - Becomes True once saved to netcdf file
124124 dayzero - True at first appearance of eddy
125125 '''
126- def __init__ (self , eddy_index , datatype , lon , lat , time , Uavg ,
126+ def __init__ (self , eddy_index , datatype , lon , lat , time , Uavg , teke ,
127127 radius_s , radius_e , amplitude , bounds ,
128128 temp = None ,
129129 salt = None ):
@@ -134,6 +134,7 @@ def __init__(self, eddy_index, datatype, lon, lat, time, Uavg,
134134 self .lat = np .atleast_1d (lat )
135135 self .ocean_time = np .atleast_1d (time )
136136 self .Uavg = np .atleast_1d (Uavg )
137+ self .teke = np .atleast_1d (teke )
137138 self .radius_s = np .atleast_1d (radius_s ) # speed-based eddy radius
138139 self .radius_e = np .atleast_1d (radius_e ) # effective eddy radius
139140 self .amplitude = np .atleast_1d (amplitude )
@@ -146,7 +147,7 @@ def __init__(self, eddy_index, datatype, lon, lat, time, Uavg,
146147 self .saved2nc = False
147148
148149
149- def append_pos (self , lon , lat , time , Uavg ,
150+ def append_pos (self , lon , lat , time , Uavg , teke ,
150151 radius_s , radius_e , amplitude , bounds , temp , salt ):
151152 '''
152153 Append track updates
@@ -155,6 +156,7 @@ def append_pos(self, lon, lat, time, Uavg,
155156 self .lat = np .r_ [self .lat , lat ]
156157 self .ocean_time = np .r_ [self .ocean_time , time ]
157158 self .Uavg = np .r_ [self .Uavg , Uavg ]
159+ self .teke = np .r_ [self .teke , teke ]
158160 self .radius_s = np .r_ [self .radius_s , radius_s ]
159161 self .radius_e = np .r_ [self .radius_e , radius_e ]
160162 self .amplitude = np .r_ [self .amplitude , amplitude ]
@@ -210,6 +212,7 @@ def __init__(self, datatype, track_duration_min):
210212 self .new_radii_e = np .array ([])
211213 self .new_amp = np .array ([])
212214 self .new_Uavg = np .array ([])
215+ self .new_teke = np .array ([])
213216 if 'ROMS' in self .datatype :
214217 self .new_temp = np .array ([])
215218 self .new_salt = np .array ([])
@@ -221,6 +224,7 @@ def __init__(self, datatype, track_duration_min):
221224 self .old_radii_e = np .array ([])
222225 self .old_amp = np .array ([])
223226 self .old_Uavg = np .array ([])
227+ self .old_teke = np .array ([])
224228 if 'ROMS' in self .datatype :
225229 self .old_temp = np .array ([])
226230 self .old_salt = np .array ([])
@@ -235,24 +239,24 @@ def __init__(self, datatype, track_duration_min):
235239 assert datatype in ('ROMS' , 'AVISO' ), "Unknown string in 'datatype' parameter"
236240
237241
238- def append_list (self , lon , lat , time , Uavg ,
242+ def append_list (self , lon , lat , time , Uavg , teke ,
239243 radius_s , radius_e , amplitude , bounds , temp = None , salt = None ):
240244 '''
241245 Append a new 'track' object to the list
242246 '''
243247 self .tracklist .append (track (self .index , self .datatype ,
244- lon , lat , time , Uavg ,
248+ lon , lat , time , Uavg , teke ,
245249 radius_s , radius_e ,
246250 amplitude , bounds ,
247251 temp , salt ))
248252
249253
250- def update_track (self , index , lon , lat , time , Uavg ,
254+ def update_track (self , index , lon , lat , time , Uavg , teke ,
251255 radius_s , radius_e , amplitude , bounds , temp = None , salt = None ):
252256 '''
253257 Update a track at index
254258 '''
255- self .tracklist [index ].append_pos (lon , lat , time , Uavg ,
259+ self .tracklist [index ].append_pos (lon , lat , time , Uavg , teke ,
256260 radius_s , radius_e ,
257261 amplitude , bounds ,
258262 temp , salt )
@@ -268,6 +272,7 @@ def reset_holding_variables(self):
268272 self .new_radii_tmp_e = np .array ([])
269273 self .new_amp_tmp = np .array ([])
270274 self .new_Uavg_tmp = np .array ([])
275+ self .new_teke_tmp = np .array ([])
271276 self .new_time_tmp = np .array ([])
272277 self .new_temp_tmp = np .array ([])
273278 self .new_salt_tmp = np .array ([])
@@ -285,6 +290,7 @@ def set_old_variables(self):
285290 self .old_radii_e = np .copy (self .new_radii_tmp_e )
286291 self .old_amp = np .copy (self .new_amp_tmp )
287292 self .old_Uavg = np .copy (self .new_Uavg_tmp )
293+ self .old_teke = np .copy (self .new_teke_tmp )
288294 self .old_temp = np .copy (self .new_temp_tmp )
289295 self .old_salt = np .copy (self .new_salt_tmp )
290296
@@ -391,6 +397,7 @@ def create_netcdf(self, directory, savedir, title,
391397 nc .createVariable ('A' , 'f8' , ('Nobs' ), fill_value = self .fillval )
392398 nc .createVariable ('L' , 'f8' , ('Nobs' ), fill_value = self .fillval )
393399 nc .createVariable ('U' , 'f8' , ('Nobs' ), fill_value = self .fillval )
400+ nc .createVariable ('Teke' , 'f8' , ('Nobs' ), fill_value = self .fillval )
394401 nc .createVariable ('radius_e' , 'f8' , ('Nobs' ), fill_value = self .fillval )
395402 if 'Q' in self .diag_type :
396403 nc .createVariable ('qparameter' , 'f8' , ('Nobs' ), fill_value = self .fillval )
@@ -446,10 +453,11 @@ def create_netcdf(self, directory, savedir, title,
446453 'between the extremum of SSH within ' + \
447454 'the eddy and the SSH around the contour ' + \
448455 'defining the eddy perimeter'
456+
449457 nc .variables ['L' ].units = 'km'
450458 nc .variables ['L' ].min_val = self .radmin / 1000.
451459 nc .variables ['L' ].max_val = self .radmax / 1000.
452- nc .variables ['L' ].long_name = 'radius scale'
460+ nc .variables ['L' ].long_name = 'speed radius scale'
453461 nc .variables ['L' ].description = 'radius of a circle whose area is equal ' + \
454462 'to that enclosed by the contour of ' + \
455463 'maximum circum-average speed'
@@ -460,6 +468,13 @@ def create_netcdf(self, directory, savedir, title,
460468 nc .variables ['U' ].long_name = 'maximum circum-averaged speed'
461469 nc .variables ['U' ].description = 'average speed of the contour defining ' + \
462470 'the radius scale L'
471+ nc .variables ['Teke' ].units = 'm^2/sec^2'
472+ #nc.variables['Teke'].min = 0.
473+ #nc.variables['Teke'].max = 376.6
474+ nc .variables ['Teke' ].long_name = 'sum EKE within contour Ceff'
475+ nc .variables ['Teke' ].description = 'sum of eddy kinetic energy within contour defining ' + \
476+ 'the effective radius'
477+
463478 nc .variables ['radius_e' ].units = 'km'
464479 nc .variables ['radius_e' ].min_val = self .radmin / 1000.
465480 nc .variables ['radius_e' ].max_val = self .radmax / 1000.
@@ -495,6 +510,7 @@ def _reduce_inactive_tracks(self):
495510 track .qparameter = False
496511 track .amplitude = False
497512 track .Uavg = False
513+ track .teke = False
498514 track .radius_s = False
499515 track .radius_e = False
500516 track .bounds = False
@@ -549,6 +565,7 @@ def write2chelton_nc(self, savedir, rtime):
549565 nc .variables ['lat' ][self .ncind :tend ] = np .array ([self .tracklist [i ].lat ])
550566 nc .variables ['A' ][self .ncind :tend ] = np .array ([self .tracklist [i ].amplitude ])
551567 nc .variables ['U' ][self .ncind :tend ] = np .array ([self .tracklist [i ].Uavg ]) * 100. # to cm/s
568+ nc .variables ['Teke' ][self .ncind :tend ] = np .array ([self .tracklist [i ].teke ])
552569 nc .variables ['L' ][self .ncind :tend ] = np .array ([self .tracklist [i ].radius_s ]) * np .array (1e-3 )
553570 nc .variables ['radius_e' ][self .ncind :tend ] = np .array ([self .tracklist [i ].radius_e ]) * np .array (1e-3 )
554571 if 'ROMS' in self .datatype :
@@ -594,6 +611,7 @@ def write2chelton_nc(self, savedir, rtime):
594611 self .old_radii_e = self .new_radii_e [lasti :]
595612 self .old_amp = self .new_amp [lasti :]
596613 self .old_Uavg = self .new_Uavg [lasti :]
614+ self .old_teke = self .new_teke [lasti :]
597615 if 'ROMS' in self .datatype :
598616 self .old_temp = self .new_temp [lasti :]
599617 self .old_salt = self .new_salt [lasti :]
@@ -604,6 +622,7 @@ def write2chelton_nc(self, savedir, rtime):
604622 self .new_radii_e = np .array ([])
605623 self .new_amp = np .array ([])
606624 self .new_Uavg = np .array ([])
625+ self .new_teke = np .array ([])
607626 self .new_time = np .array ([])
608627 if 'ROMS' in self .datatype :
609628 self .new_temp = np .array ([])
@@ -669,6 +688,14 @@ def insert_at_index(self, xarr, ind, x):
669688 self .new_amp = np .zeros ((newsize ))
670689 self .new_amp [:tmp .size ] = tmp
671690 self .new_amp [ind ] = x
691+ elif 'new_Uavg' in xarr :
692+ self .new_Uavg = np .zeros ((newsize ))
693+ self .new_Uavg [:tmp .size ] = tmp
694+ self .new_Uavg [ind ] = x
695+ elif 'new_teke' in xarr :
696+ self .new_teke = np .zeros ((newsize ))
697+ self .new_teke [:tmp .size ] = tmp
698+ self .new_teke [ind ] = x
672699 elif 'new_temp' in xarr :
673700 self .new_temp = np .zeros ((newsize ))
674701 self .new_temp [:tmp .size ] = tmp
@@ -683,7 +710,7 @@ def insert_at_index(self, xarr, ind, x):
683710
684711
685712 def update_eddy_properties (self , centlon , centlat , eddy_radius_s , eddy_radius_e ,
686- amplitude , Uavg , rtime , bounds , cent_temp = None , cent_salt = None ):
713+ amplitude , Uavg , teke , rtime , bounds , cent_temp = None , cent_salt = None ):
687714 '''
688715 Append new variable values to track arrays
689716 '''
@@ -693,6 +720,7 @@ def update_eddy_properties(self, centlon, centlat, eddy_radius_s, eddy_radius_e,
693720 self .new_radii_tmp_e = np .r_ [self .new_radii_tmp_e , eddy_radius_e ]
694721 self .new_amp_tmp = np .r_ [self .new_amp_tmp , amplitude ]
695722 self .new_Uavg_tmp = np .r_ [self .new_Uavg_tmp , Uavg ]
723+ self .new_teke_tmp = np .r_ [self .new_teke_tmp , teke ]
696724 self .new_time_tmp = np .r_ [self .new_time_tmp , rtime ]
697725 if 'ROMS' in self .datatype :
698726 self .new_temp_tmp = np .r_ [self .new_temp_tmp , cent_temp ]
0 commit comments