Skip to content

Commit fa4833f

Browse files
committed
Minor optimisation modifications
1 parent 340d184 commit fa4833f

File tree

3 files changed

+111
-65
lines changed

3 files changed

+111
-65
lines changed

make_eddy_track_AVISO.py

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -404,23 +404,29 @@ def make_gridmask(self, with_pad=True, use_maskoceans=False):
404404
self.Mx, self.My = x, y
405405
return self
406406

407+
407408
def get_geostrophic_velocity(self, zeta):
408409
'''
409410
Returns u and v geostrophic velocity at
410411
surface from variables f, zeta, pm, pn...
411412
Note: output at rho points
412413
'''
413414
gof = self.gof().view()
414-
vmask = self.v2rho_2d(self.vmask().view()
415+
416+
vmask = self.vmask().view()
415417
zeta1, zeta2 = zeta.data[1:].view(), zeta.data[:-1].view()
416418
pn1, pn2 = self.pn()[1:].view(), self.pn()[:-1].view()
417-
self.upad[:] = ne.evaluate('-gof * vmask * (zeta1 - zeta2) * 0.5 * (pn1 + pn2)')
419+
self.upad[:] = self.v2rho_2d(ne.evaluate('vmask * (zeta1 - zeta2) * 0.5 * (pn1 + pn2)'))
420+
self.upad *= -gof
418421
#self.upad[:] = -self.gof() * self.v2rho_2d(self.vmask() * (zeta.data[1:] - zeta.data[:-1]) \
419422
#* 0.5 * (self.pn()[1:] + self.pn()[:-1]))
420-
umask = self.u2rho_2d(self.umask().view()
423+
424+
umask = self.umask().view()
421425
zeta1, zeta2 = zeta.data[:,1:].view(), zeta.data[:,:-1].view()
422426
pm1, pm2 = self.pm()[:,1:].view(), self.pm()[:,:-1].view()
423-
self.vpad[:] = ne.evaluate('gof * umask * (zeta1 - zeta2) * 0.5 * (pm1 + pm2)')
427+
#self.vpad[:] = ne.evaluate('gof * (umask * (zeta1 - zeta2) * 0.5 * (pm1 + pm2))')
428+
self.vpad[:] = self.u2rho_2d(ne.evaluate('umask * (zeta1 - zeta2) * 0.5 * (pm1 + pm2)'))
429+
self.vpad *= gof
424430
#self.vpad[:] = self.gof() * self.u2rho_2d(self.umask() * (zeta.data[:, 1:] - zeta.data[:, :-1]) \
425431
#* 0.5 * (self.pm()[:, 1:] + self.pm()[:, :-1]))
426432
return self
@@ -656,8 +662,8 @@ def pn(self): # Reciprocal of dy
656662

657663

658664
def get_resolution(self):
659-
return np.mean(np.sqrt(np.diff(self.lon()[1:], axis=1) *
660-
np.diff(self.lat()[:,1:], axis=0)))
665+
return np.sqrt(np.diff(self.lon()[1:], axis=1) *
666+
np.diff(self.lat()[:,1:], axis=0)).mean()
661667

662668

663669

@@ -731,12 +737,12 @@ def pcol_2dxy(self, x, y):
731737
#the_domain = 'MedSea' # not yet implemented
732738

733739
# Specify use of new AVISO 2014 data
734-
new_AVISO = False
740+
new_AVISO = True
735741

736742
# Specify subsampling new AVISO 2014 data; i.e. you may
737743
# prefer to use every second day rather than every day
738744
if new_AVISO:
739-
new_AVISO_SUBSAMP = True
745+
new_AVISO_SUBSAMP = False
740746
if new_AVISO_SUBSAMP:
741747
days_btwn_recs = 3. # put sampling rate (days) here
742748
else:
@@ -780,7 +786,8 @@ def pcol_2dxy(self, x, y):
780786
# Set date range (YYYYMMDD)
781787
#date_str, date_end = 19980107, 19991110 #
782788
#date_str, date_end = 20081107, 20100110 #
783-
date_str, date_end = 19921014, 20120718 #
789+
#date_str, date_end = 19921014, 20120718 #
790+
date_str, date_end = 20020101, 20021231 #
784791

785792
# Choose type of diagnostic: either q-parameter ('Q') or sea level anomaly ('sla')
786793
#diag_type = 'Q' #<<< not implemented in 1.2.0
@@ -794,7 +801,8 @@ def pcol_2dxy(self, x, y):
794801
#savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_SUBSAMP-3days/'
795802
#savedir = '/marula/emason/aviso_eddy_tracking/junk/'
796803
#savedir = '/marula/emason/aviso_eddy_tracking/new_AVISO_test/BlackSea/'
797-
savedir = '/marula/emason/aviso_eddy_tracking/Corridor_V3_Dec2014/'
804+
#savedir = '/marula/emason/aviso_eddy_tracking/Corridor_V3_Dec2014/'
805+
savedir = '/marula/emason/aviso_eddy_tracking/CLS_test_1_acd66ba338a9/'
798806
#savedir = '/path/to/save/your/outputs/'
799807

800808

@@ -809,7 +817,7 @@ def pcol_2dxy(self, x, y):
809817
jday_ref = 2448623
810818

811819
# Min and max permitted eddy radii [degrees]
812-
radmin = 0.4 # degrees (Chelton recommends ~50 km minimum)
820+
radmin = 0.35 # degrees (Chelton recommends ~50 km minimum)
813821
radmax = 4.461 # degrees
814822

815823
if 'Q' in diag_type:
@@ -837,8 +845,8 @@ def pcol_2dxy(self, x, y):
837845

838846
# Set SLA contour spacing
839847
elif 'sla' in diag_type:
840-
slaparameter = np.arange(-100., 101., 1.0) # cm
841-
#slaparameter = np.arange(-100., 100.25, 0.25) # cm
848+
#slaparameter = np.arange(-100., 101., 1.0) # cm
849+
slaparameter = np.arange(-100., 100.25, 0.25) # cm
842850

843851

844852

@@ -861,10 +869,10 @@ def pcol_2dxy(self, x, y):
861869
subdomain = True
862870
if the_domain in 'Global':
863871

864-
lonmin = -40. # Canary
865-
lonmax = -5.5
866-
latmin = 16.
867-
latmax = 36.5
872+
#lonmin = -40. # Canary
873+
#lonmax = -5.5
874+
#latmin = 16.
875+
#latmax = 36.5
868876

869877
#lonmin = -30. # BENCS
870878
#lonmax = 22.
@@ -1177,6 +1185,7 @@ def pcol_2dxy(self, x, y):
11771185
if isinstance(smoothing, str):
11781186

11791187
if 'Gaussian' in smoothing:
1188+
11801189
if 'first_record' not in locals():
11811190
print '------ applying Gaussian high-pass filter'
11821191
# Set landpoints to zero
@@ -1185,7 +1194,9 @@ def pcol_2dxy(self, x, y):
11851194
# High pass filter, see
11861195
# http://stackoverflow.com/questions/6094957/high-pass-filter-for-image-processing-in-python-by-using-scipy-numpy
11871196
sla -= ndimage.gaussian_filter(sla, [mres, zres])
1197+
11881198
elif 'Hanning' in smoothing:
1199+
11891200
print '------ applying %s passes of Hanning filter' %smooth_fac
11901201
# Do smooth_fac passes of 2d Hanning filter
11911202
sla = func_hann2d_fast(sla, smooth_fac)

make_eddy_tracker_list_obj.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ def update_eddy_properties(self, centlon, centlat, eddy_radius_s, eddy_radius_e,
914914

915915

916916

917-
def get_bounds(self, centlon, centlat, radius, i, j, grd):
917+
def set_bounds(self, centlon, centlat, radius, i, j, grd):
918918
'''
919919
Get indices to a bounding box around the eddy
920920
'''

0 commit comments

Comments
 (0)