Skip to content

Commit 915785e

Browse files
committed
Version 1.1.0
Improved AVISO file iteration Chosen start and end dates no longer have to correspond exactly to AVISO file dates; this sometimes causes problems with weekly files.
1 parent d726d84 commit 915785e

File tree

5 files changed

+69
-50
lines changed

5 files changed

+69
-50
lines changed

haversine_distmat.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
! f2py -m haversine_distmat -h haversine_distmat.pyf haversine_distmat.f90 --overwrite-signature
2525
! f2py -c --fcompiler=gfortran haversine_distmat.pyf haversine_distmat.f90
2626
!
27-
! Version 1.0.1
27+
! Version 1.1.0
2828
!
2929
!===========================================================================
3030

make_eddy_track_AVISO.py

Lines changed: 52 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
2525
make_eddy_track_AVISO.py
2626
27-
Version 1.0.1
27+
Version 1.1.0
2828
2929
3030
Scroll down to line ~630 to get started
@@ -33,7 +33,9 @@
3333

3434

3535
import glob as glob
36+
#import matplotlib.pyplot as plt
3637
from py_eddy_tracker_classes import *
38+
from make_eddy_tracker_list_obj import *
3739

3840

3941
class py_eddy_tracker (object):
@@ -634,7 +636,6 @@ def pcol_2dxy(self, x, y):
634636
#diag_type = 'Q' <<< not implemented in 1.0.1
635637
diag_type = 'sla'
636638

637-
days_btwn_recs = 7.
638639

639640
# Path to directory where outputs are to be saved...
640641
#savedir = directory
@@ -646,20 +647,16 @@ def pcol_2dxy(self, x, y):
646647

647648
print '\nOutputs saved to', savedir
648649

650+
days_btwn_recs = 7.
649651

650-
651-
652-
653-
654-
655-
656652

657653

658654
# Reference Julian day (Julian date at Jan 1, 1992)
659655
jday_ref = 2448623
660656

661657
# Min and max permitted eddy radii [m]
662658
if 'Q' in diag_type:
659+
Exception # Not implemented
663660
radmin = 15000.
664661
radmax = 250000.
665662
ampmin = 0.02
@@ -673,25 +670,22 @@ def pcol_2dxy(self, x, y):
673670

674671

675672
# Obtain this file from:
676-
# http://www-po.coas.oregonstate.edu/research/po/research/rossby_radius/
673+
# http://www-po.coas.oregonstate.edu/research/po/research/rossby_radius/
677674
rw_path = '/home/emason/data_tmp/chelton_eddies/rossrad.dat'
678-
679-
# Option to track using speed-based radius or effective radius
680-
#track_with_speed = True
675+
681676

682677
# Make figures for animations
683678
anim_figs = True
684679

685680

686681
# Define contours
687682
if 'Q' in diag_type:
688-
# Set Q contours
683+
# Set Q contour spacing
689684
qparameter = np.linspace(0, 5*10**-11, 25)
690685
elif 'sla' in diag_type:
691-
# Units, cm; for anticyclones use -50 to 50
692-
#slaparameter = np.arange(-100., 100.5, 0.5)
693-
slaparameter = np.arange(-100., 101., 1.0)
694-
#slaparameter = np.arange(-50., 51., 1.)
686+
# Set SLA contour spacing
687+
slaparameter = np.arange(-100., 101., 1.0) # cm
688+
695689

696690

697691
# Apply a filter to the Q parameter
@@ -737,7 +731,7 @@ def pcol_2dxy(self, x, y):
737731

738732

739733
# Typical parameters
740-
dist0 = 25000. # m separation distance after ~7 days (see Chelton2011 fig 22)
734+
dist0 = 25000. # m separation distance after ~7 days (see CSS11 fig 22)
741735
if 'Q' in diag_type:
742736
amp0 = 0.02 # vort/f
743737
elif 'sla' in diag_type:
@@ -754,22 +748,20 @@ def pcol_2dxy(self, x, y):
754748
evolve_armax = 5 # max change in area
755749

756750

757-
separation_method = 'ellipse' # see Chelton etal (2011)
751+
separation_method = 'ellipse' # see CSS11
758752
#separation_method = 'sum_radii' # see Kurian etal (2011)
759753

760-
if 'sum_radii' in separation_method:
761-
# Separation distance factor. Adjust according to number of days between records
762-
# For 7 days, Chelton uses 150 km search ellipse
763-
# So, given typical eddy radius of r=50 km, 1.5 * (r1 + r2) = 150 km.
764-
#sep_dist_fac = 1.0
765-
sep_dist_fac = 1.15 # Seems ok for AVISO 7-day
766-
#sep_dist_fac = 1.5 # Causes tracks to jump for AVISO 7-day
754+
#if 'sum_radii' in separation_method:
755+
## Separation distance factor. Adjust according to number of days between records
756+
## For 7 days, Chelton uses 150 km search ellipse
757+
## So, given typical eddy radius of r=50 km, 1.5 * (r1 + r2) = 150 km.
758+
##sep_dist_fac = 1.0
759+
#sep_dist_fac = 1.15 # Seems ok for AVISO 7-day
760+
##sep_dist_fac = 1.5 # Causes tracks to jump for AVISO 7-day
767761

768762

769-
#cmap = plt.cm.Spectral_r
770-
#cmap = plt.cm.jet
771-
cmap = plt.cm.RdBu
772763

764+
cmap = plt.cm.RdBu
773765

774766
verbose = False
775767

@@ -780,6 +772,9 @@ def pcol_2dxy(self, x, y):
780772
assert date_str < date_end, 'date_end must be larger than date_str'
781773
assert diag_type in ('Q','sla'), 'diag_type not properly defined'
782774

775+
thestartdate = dt.date2num(datestr2datetime(str(date_str)))
776+
theenddate = dt.date2num(datestr2datetime(str(date_end)))
777+
783778
# Get complete AVISO file list
784779
AVISO_files = sorted(glob.glob(directory + AVISO_files))
785780

@@ -793,10 +788,8 @@ def pcol_2dxy(self, x, y):
793788
qparameter.size), 2)[::-1]
794789

795790
# The shape error can maybe be played with...
796-
#shape_err = np.power(np.linspace(200., 40, qparameter.size), 2) / 100.
797791
shape_err = np.power(np.linspace(85., 40, qparameter.size), 2) / 100.
798792
shape_err[shape_err < 35.] = 35.
799-
#shape_err = 35. * np.ones(qparameter.size)
800793

801794
elif 'sla' in diag_type:
802795
shape_err = 55. * np.ones(slaparameter.size)
@@ -808,7 +801,7 @@ def pcol_2dxy(self, x, y):
808801

809802
Mx, My = sla_grd.Mx[sla_grd.jup0:sla_grd.jup1, sla_grd.iup0:sla_grd.iup1], \
810803
sla_grd.My[sla_grd.jup0:sla_grd.jup1, sla_grd.iup0:sla_grd.iup1]
811-
pMx, pMy = sla_grd.pcol_2dxy(Mx, My)
804+
#pMx, pMy = sla_grd.pcol_2dxy(Mx, My)
812805

813806

814807
# Get Rossby wave speed data
@@ -932,8 +925,6 @@ def pcol_2dxy(self, x, y):
932925
A_eddy.dist0 = np.float(dist0)
933926
C_eddy.dist0 = np.float(dist0)
934927

935-
start = 0
936-
start_time = time.time()
937928
A_eddy.days_btwn_recs = days_btwn_recs
938929
C_eddy.days_btwn_recs = days_btwn_recs
939930

@@ -943,15 +934,32 @@ def pcol_2dxy(self, x, y):
943934

944935

945936
# Loop through the AVISO files...
946-
active = False
937+
#active = False
938+
start = True
939+
start_time = time.time()
947940
print '\nStart tracking'
948941
for AVISO_file in AVISO_files:
949-
950-
if str(date_str) in AVISO_file:
942+
943+
944+
with netcdf.Dataset(AVISO_file) as nc:
945+
946+
try:
947+
thedate = nc.OriginalName
948+
thedate = thedate.partition('qd_')[2].partition('_')[0]
949+
thedate = datestr2datetime(thedate)
950+
thedate = dt.date2num(thedate)
951+
except Exception:
952+
thedate = nc.variables['time']
953+
raise Exception # 2014 AVISO not yet implemented
954+
955+
956+
if np.logical_and(thedate >= thestartdate,
957+
thedate <= theenddate):
951958
active = True
952-
file_time = time.time()
953-
954-
959+
else:
960+
active = False
961+
962+
955963
if active:
956964

957965
#rec_start_time = time.time()
@@ -1161,13 +1169,14 @@ def pcol_2dxy(self, x, y):
11611169
plt.close(250)
11621170

11631171

1164-
if str(date_str) not in AVISO_file:
1165-
first_record = False
1166-
else:
1172+
if start:
11671173
first_record = True
11681174
# Set old variables equal to new variables
11691175
A_eddy.set_old_variables()
11701176
C_eddy.set_old_variables()
1177+
start = False
1178+
else:
1179+
first_record = False
11711180

11721181

11731182
# Track the eddies

make_eddy_track_ROMS.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
2525
make_eddy_track_ROMS.py
2626
27-
Version 1.0.1
27+
Version 1.1.0
2828
2929
3030
@@ -281,7 +281,7 @@
281281

282282
Mx, My = M(grd.lon()[jstr:jend,istr:iend],
283283
grd.lat()[jstr:jend,istr:iend])
284-
pMx, pMy = pcol_2dxy(Mx, My)
284+
#pMx, pMy = pcol_2dxy(Mx, My)
285285

286286
# Get Rossby wave speed data
287287
rwv = eddy_tracker.rossby_wave_speeds(rw_path)

make_eddy_tracker_list_obj.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
2626
make_eddy_tracker_list_obj.py
2727
28-
Version 1.0.1
28+
Version 1.1.0
2929
3030
3131
===========================================================================
@@ -34,8 +34,8 @@
3434
"""
3535

3636
import haversine_distmat as hav # needs compiling with f2py
37-
from make_eddy_track import *
38-
37+
#from make_eddy_track import *
38+
from py_eddy_tracker_classes import *
3939

4040
def haversine_distance_vector(lon1, lat1, lon2, lat2):
4141
'''

py_eddy_tracker_classes.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
2525
py_eddy_tracker_classes.py
2626
27-
Version 1.0.1
27+
Version 1.1.0
2828
===========================================================================
2929
3030
@@ -52,6 +52,16 @@
5252
import haversine_distmat as hav # needs compiling with f2py
5353

5454

55+
def datestr2datetime(datestr):
56+
'''
57+
Take strings with format YYYYMMDD and convert to datetime instance
58+
'''
59+
assert len(datestr) == 8, "'datestr' must have length 8"
60+
assert datestr[0] in ('1', '2'), "first character of 'datestr' should be '1' or '2'"
61+
return dt.datetime.datetime(np.int(datestr[:4]),
62+
np.int(datestr[4:6]),
63+
np.int(datestr[6:]))
64+
5565

5666
def gaussian_resolution(res, zwl, mwl):
5767
'''

0 commit comments

Comments
 (0)